jquery.dataTables.js 429 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951
  1. /*! DataTables 1.10.7
  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.7
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd (www.sprymedia.co.uk)
  10. * @contact www.sprymedia.co.uk/contact
  11. * @copyright Copyright 2008-2014 SpryMedia Ltd.
  12. *
  13. * This source file is free software, available under the following license:
  14. * MIT license - http://datatables.net/license
  15. *
  16. * This source file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  19. *
  20. * For details please refer to: http://www.datatables.net
  21. */
  22. /*jslint evil: true, undef: true, browser: true */
  23. /*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnScrollBarWidth,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  24. (/** @lends <global> */function( window, document, undefined ) {
  25. (function( factory ) {
  26. "use strict";
  27. if ( typeof define === 'function' && define.amd ) {
  28. // Define as an AMD module if possible
  29. define( 'datatables', ['jquery'], factory );
  30. }
  31. else if ( typeof exports === 'object' ) {
  32. // Node/CommonJS
  33. module.exports = factory( require( 'jquery' ) );
  34. }
  35. else if ( jQuery && !jQuery.fn.dataTable ) {
  36. // Define using browser globals otherwise
  37. // Prevent multiple instantiations if the script is loaded twice
  38. factory( jQuery );
  39. }
  40. }
  41. (/** @lends <global> */function( $ ) {
  42. "use strict";
  43. /**
  44. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  45. * flexible tool, based upon the foundations of progressive enhancement,
  46. * which will add advanced interaction controls to any HTML table. For a
  47. * full list of features please refer to
  48. * [DataTables.net](href="http://datatables.net).
  49. *
  50. * Note that the `DataTable` object is not a global variable but is aliased
  51. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  52. * be accessed.
  53. *
  54. * @class
  55. * @param {object} [init={}] Configuration object for DataTables. Options
  56. * are defined by {@link DataTable.defaults}
  57. * @requires jQuery 1.7+
  58. *
  59. * @example
  60. * // Basic initialisation
  61. * $(document).ready( function {
  62. * $('#example').dataTable();
  63. * } );
  64. *
  65. * @example
  66. * // Initialisation with configuration options - in this case, disable
  67. * // pagination and sorting.
  68. * $(document).ready( function {
  69. * $('#example').dataTable( {
  70. * "paginate": false,
  71. * "sort": false
  72. * } );
  73. * } );
  74. */
  75. var DataTable;
  76. /*
  77. * It is useful to have variables which are scoped locally so only the
  78. * DataTables functions can access them and they don't leak into global space.
  79. * At the same time these functions are often useful over multiple files in the
  80. * core and API, so we list, or at least document, all variables which are used
  81. * by DataTables as private variables here. This also ensures that there is no
  82. * clashing of variable names and that they can easily referenced for reuse.
  83. */
  84. // Defined else where
  85. // _selector_run
  86. // _selector_opts
  87. // _selector_first
  88. // _selector_row_indexes
  89. var _ext; // DataTable.ext
  90. var _Api; // DataTable.Api
  91. var _api_register; // DataTable.Api.register
  92. var _api_registerPlural; // DataTable.Api.registerPlural
  93. var _re_dic = {};
  94. var _re_new_lines = /[\r\n]/g;
  95. var _re_html = /<.*?>/g;
  96. var _re_date_start = /^[\w\+\-]/;
  97. var _re_date_end = /[\w\+\-]$/;
  98. // Escape regular expression special characters
  99. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  100. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  101. // - \u20BD - Russian ruble.
  102. // - \u20a9 - South Korean Won
  103. // - \u20BA - Turkish Lira
  104. // - \u20B9 - Indian Rupee
  105. // - R - Brazil (R$) and South Africa
  106. // - fr - Swiss Franc
  107. // - kr - Swedish krona, Norwegian krone and Danish krone
  108. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  109. // standards as thousands separators.
  110. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi;
  111. var _empty = function ( d ) {
  112. return !d || d === true || d === '-' ? true : false;
  113. };
  114. var _intVal = function ( s ) {
  115. var integer = parseInt( s, 10 );
  116. return !isNaN(integer) && isFinite(s) ? integer : null;
  117. };
  118. // Convert from a formatted number with characters other than `.` as the
  119. // decimal place, to a Javascript number
  120. var _numToDecimal = function ( num, decimalPoint ) {
  121. // Cache created regular expressions for speed as this function is called often
  122. if ( ! _re_dic[ decimalPoint ] ) {
  123. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  124. }
  125. return typeof num === 'string' && decimalPoint !== '.' ?
  126. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  127. num;
  128. };
  129. var _isNumber = function ( d, decimalPoint, formatted ) {
  130. var strType = typeof d === 'string';
  131. // If empty return immediately so there must be a number if it is a
  132. // formatted string (this stops the string "k", or "kr", etc being detected
  133. // as a formatted number for currency
  134. if ( _empty( d ) ) {
  135. return true;
  136. }
  137. if ( decimalPoint && strType ) {
  138. d = _numToDecimal( d, decimalPoint );
  139. }
  140. if ( formatted && strType ) {
  141. d = d.replace( _re_formatted_numeric, '' );
  142. }
  143. return !isNaN( parseFloat(d) ) && isFinite( d );
  144. };
  145. // A string without HTML in it can be considered to be HTML still
  146. var _isHtml = function ( d ) {
  147. return _empty( d ) || typeof d === 'string';
  148. };
  149. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  150. if ( _empty( d ) ) {
  151. return true;
  152. }
  153. var html = _isHtml( d );
  154. return ! html ?
  155. null :
  156. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  157. true :
  158. null;
  159. };
  160. var _pluck = function ( a, prop, prop2 ) {
  161. var out = [];
  162. var i=0, ien=a.length;
  163. // Could have the test in the loop for slightly smaller code, but speed
  164. // is essential here
  165. if ( prop2 !== undefined ) {
  166. for ( ; i<ien ; i++ ) {
  167. if ( a[i] && a[i][ prop ] ) {
  168. out.push( a[i][ prop ][ prop2 ] );
  169. }
  170. }
  171. }
  172. else {
  173. for ( ; i<ien ; i++ ) {
  174. if ( a[i] ) {
  175. out.push( a[i][ prop ] );
  176. }
  177. }
  178. }
  179. return out;
  180. };
  181. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  182. // as the indexes to pick from `a`
  183. var _pluck_order = function ( a, order, prop, prop2 )
  184. {
  185. var out = [];
  186. var i=0, ien=order.length;
  187. // Could have the test in the loop for slightly smaller code, but speed
  188. // is essential here
  189. if ( prop2 !== undefined ) {
  190. for ( ; i<ien ; i++ ) {
  191. if ( a[ order[i] ][ prop ] ) {
  192. out.push( a[ order[i] ][ prop ][ prop2 ] );
  193. }
  194. }
  195. }
  196. else {
  197. for ( ; i<ien ; i++ ) {
  198. out.push( a[ order[i] ][ prop ] );
  199. }
  200. }
  201. return out;
  202. };
  203. var _range = function ( len, start )
  204. {
  205. var out = [];
  206. var end;
  207. if ( start === undefined ) {
  208. start = 0;
  209. end = len;
  210. }
  211. else {
  212. end = start;
  213. start = len;
  214. }
  215. for ( var i=start ; i<end ; i++ ) {
  216. out.push( i );
  217. }
  218. return out;
  219. };
  220. var _removeEmpty = function ( a )
  221. {
  222. var out = [];
  223. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  224. if ( a[i] ) { // careful - will remove all falsy values!
  225. out.push( a[i] );
  226. }
  227. }
  228. return out;
  229. };
  230. var _stripHtml = function ( d ) {
  231. return d.replace( _re_html, '' );
  232. };
  233. /**
  234. * Find the unique elements in a source array.
  235. *
  236. * @param {array} src Source array
  237. * @return {array} Array of unique items
  238. * @ignore
  239. */
  240. var _unique = function ( src )
  241. {
  242. // A faster unique method is to use object keys to identify used values,
  243. // but this doesn't work with arrays or objects, which we must also
  244. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  245. // information.
  246. var
  247. out = [],
  248. val,
  249. i, ien=src.length,
  250. j, k=0;
  251. again: for ( i=0 ; i<ien ; i++ ) {
  252. val = src[i];
  253. for ( j=0 ; j<k ; j++ ) {
  254. if ( out[j] === val ) {
  255. continue again;
  256. }
  257. }
  258. out.push( val );
  259. k++;
  260. }
  261. return out;
  262. };
  263. /**
  264. * Create a mapping object that allows camel case parameters to be looked up
  265. * for their Hungarian counterparts. The mapping is stored in a private
  266. * parameter called `_hungarianMap` which can be accessed on the source object.
  267. * @param {object} o
  268. * @memberof DataTable#oApi
  269. */
  270. function _fnHungarianMap ( o )
  271. {
  272. var
  273. hungarian = 'a aa ai ao as b fn i m o s ',
  274. match,
  275. newKey,
  276. map = {};
  277. $.each( o, function (key, val) {
  278. match = key.match(/^([^A-Z]+?)([A-Z])/);
  279. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  280. {
  281. newKey = key.replace( match[0], match[2].toLowerCase() );
  282. map[ newKey ] = key;
  283. if ( match[1] === 'o' )
  284. {
  285. _fnHungarianMap( o[key] );
  286. }
  287. }
  288. } );
  289. o._hungarianMap = map;
  290. }
  291. /**
  292. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  293. * created by _fnHungarianMap.
  294. * @param {object} src The model object which holds all parameters that can be
  295. * mapped.
  296. * @param {object} user The object to convert from camel case to Hungarian.
  297. * @param {boolean} force When set to `true`, properties which already have a
  298. * Hungarian value in the `user` object will be overwritten. Otherwise they
  299. * won't be.
  300. * @memberof DataTable#oApi
  301. */
  302. function _fnCamelToHungarian ( src, user, force )
  303. {
  304. if ( ! src._hungarianMap ) {
  305. _fnHungarianMap( src );
  306. }
  307. var hungarianKey;
  308. $.each( user, function (key, val) {
  309. hungarianKey = src._hungarianMap[ key ];
  310. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  311. {
  312. // For objects, we need to buzz down into the object to copy parameters
  313. if ( hungarianKey.charAt(0) === 'o' )
  314. {
  315. // Copy the camelCase options over to the hungarian
  316. if ( ! user[ hungarianKey ] ) {
  317. user[ hungarianKey ] = {};
  318. }
  319. $.extend( true, user[hungarianKey], user[key] );
  320. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  321. }
  322. else {
  323. user[hungarianKey] = user[ key ];
  324. }
  325. }
  326. } );
  327. }
  328. /**
  329. * Language compatibility - when certain options are given, and others aren't, we
  330. * need to duplicate the values over, in order to provide backwards compatibility
  331. * with older language files.
  332. * @param {object} oSettings dataTables settings object
  333. * @memberof DataTable#oApi
  334. */
  335. function _fnLanguageCompat( lang )
  336. {
  337. var defaults = DataTable.defaults.oLanguage;
  338. var zeroRecords = lang.sZeroRecords;
  339. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  340. * sZeroRecords - assuming that is given.
  341. */
  342. if ( ! lang.sEmptyTable && zeroRecords &&
  343. defaults.sEmptyTable === "No data available in table" )
  344. {
  345. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  346. }
  347. /* Likewise with loading records */
  348. if ( ! lang.sLoadingRecords && zeroRecords &&
  349. defaults.sLoadingRecords === "Loading..." )
  350. {
  351. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  352. }
  353. // Old parameter name of the thousands separator mapped onto the new
  354. if ( lang.sInfoThousands ) {
  355. lang.sThousands = lang.sInfoThousands;
  356. }
  357. var decimal = lang.sDecimal;
  358. if ( decimal ) {
  359. _addNumericSort( decimal );
  360. }
  361. }
  362. /**
  363. * Map one parameter onto another
  364. * @param {object} o Object to map
  365. * @param {*} knew The new parameter name
  366. * @param {*} old The old parameter name
  367. */
  368. var _fnCompatMap = function ( o, knew, old ) {
  369. if ( o[ knew ] !== undefined ) {
  370. o[ old ] = o[ knew ];
  371. }
  372. };
  373. /**
  374. * Provide backwards compatibility for the main DT options. Note that the new
  375. * options are mapped onto the old parameters, so this is an external interface
  376. * change only.
  377. * @param {object} init Object to map
  378. */
  379. function _fnCompatOpts ( init )
  380. {
  381. _fnCompatMap( init, 'ordering', 'bSort' );
  382. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  383. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  384. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  385. _fnCompatMap( init, 'order', 'aaSorting' );
  386. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  387. _fnCompatMap( init, 'paging', 'bPaginate' );
  388. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  389. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  390. _fnCompatMap( init, 'searching', 'bFilter' );
  391. // Column search objects are in an array, so it needs to be converted
  392. // element by element
  393. var searchCols = init.aoSearchCols;
  394. if ( searchCols ) {
  395. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  396. if ( searchCols[i] ) {
  397. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  398. }
  399. }
  400. }
  401. }
  402. /**
  403. * Provide backwards compatibility for column options. Note that the new options
  404. * are mapped onto the old parameters, so this is an external interface change
  405. * only.
  406. * @param {object} init Object to map
  407. */
  408. function _fnCompatCols ( init )
  409. {
  410. _fnCompatMap( init, 'orderable', 'bSortable' );
  411. _fnCompatMap( init, 'orderData', 'aDataSort' );
  412. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  413. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  414. // orderData can be given as an integer
  415. var dataSort = init.aDataSort;
  416. if ( dataSort && ! $.isArray( dataSort ) ) {
  417. init.aDataSort = [ dataSort ];
  418. }
  419. }
  420. /**
  421. * Browser feature detection for capabilities, quirks
  422. * @param {object} settings dataTables settings object
  423. * @memberof DataTable#oApi
  424. */
  425. function _fnBrowserDetect( settings )
  426. {
  427. var browser = settings.oBrowser;
  428. // Scrolling feature / quirks detection
  429. var n = $('<div/>')
  430. .css( {
  431. position: 'absolute',
  432. top: 0,
  433. left: 0,
  434. height: 1,
  435. width: 1,
  436. overflow: 'hidden'
  437. } )
  438. .append(
  439. $('<div/>')
  440. .css( {
  441. position: 'absolute',
  442. top: 1,
  443. left: 1,
  444. width: 100,
  445. overflow: 'scroll'
  446. } )
  447. .append(
  448. $('<div class="test"/>')
  449. .css( {
  450. width: '100%',
  451. height: 10
  452. } )
  453. )
  454. )
  455. .appendTo( 'body' );
  456. var test = n.find('.test');
  457. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  458. // include the width of the scrollbar, while other browsers ensure the inner
  459. // element is contained without forcing scrolling
  460. browser.bScrollOversize = test[0].offsetWidth === 100;
  461. // In rtl text layout, some browsers (most, but not all) will place the
  462. // scrollbar on the left, rather than the right.
  463. browser.bScrollbarLeft = Math.round( test.offset().left ) !== 1;
  464. n.remove();
  465. }
  466. /**
  467. * Array.prototype reduce[Right] method, used for browsers which don't support
  468. * JS 1.6. Done this way to reduce code size, since we iterate either way
  469. * @param {object} settings dataTables settings object
  470. * @memberof DataTable#oApi
  471. */
  472. function _fnReduce ( that, fn, init, start, end, inc )
  473. {
  474. var
  475. i = start,
  476. value,
  477. isSet = false;
  478. if ( init !== undefined ) {
  479. value = init;
  480. isSet = true;
  481. }
  482. while ( i !== end ) {
  483. if ( ! that.hasOwnProperty(i) ) {
  484. continue;
  485. }
  486. value = isSet ?
  487. fn( value, that[i], i, that ) :
  488. that[i];
  489. isSet = true;
  490. i += inc;
  491. }
  492. return value;
  493. }
  494. /**
  495. * Add a column to the list used for the table with default values
  496. * @param {object} oSettings dataTables settings object
  497. * @param {node} nTh The th element for this column
  498. * @memberof DataTable#oApi
  499. */
  500. function _fnAddColumn( oSettings, nTh )
  501. {
  502. // Add column to aoColumns array
  503. var oDefaults = DataTable.defaults.column;
  504. var iCol = oSettings.aoColumns.length;
  505. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  506. "nTh": nTh ? nTh : document.createElement('th'),
  507. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  508. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  509. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  510. idx: iCol
  511. } );
  512. oSettings.aoColumns.push( oCol );
  513. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  514. // passed into extend can be undefined. This allows the user to give a default
  515. // with only some of the parameters defined, and also not give a default
  516. var searchCols = oSettings.aoPreSearchCols;
  517. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  518. // Use the default column options function to initialise classes etc
  519. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  520. }
  521. /**
  522. * Apply options for a column
  523. * @param {object} oSettings dataTables settings object
  524. * @param {int} iCol column index to consider
  525. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  526. * @memberof DataTable#oApi
  527. */
  528. function _fnColumnOptions( oSettings, iCol, oOptions )
  529. {
  530. var oCol = oSettings.aoColumns[ iCol ];
  531. var oClasses = oSettings.oClasses;
  532. var th = $(oCol.nTh);
  533. // Try to get width information from the DOM. We can't get it from CSS
  534. // as we'd need to parse the CSS stylesheet. `width` option can override
  535. if ( ! oCol.sWidthOrig ) {
  536. // Width attribute
  537. oCol.sWidthOrig = th.attr('width') || null;
  538. // Style attribute
  539. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  540. if ( t ) {
  541. oCol.sWidthOrig = t[1];
  542. }
  543. }
  544. /* User specified column options */
  545. if ( oOptions !== undefined && oOptions !== null )
  546. {
  547. // Backwards compatibility
  548. _fnCompatCols( oOptions );
  549. // Map camel case parameters to their Hungarian counterparts
  550. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  551. /* Backwards compatibility for mDataProp */
  552. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  553. {
  554. oOptions.mData = oOptions.mDataProp;
  555. }
  556. if ( oOptions.sType )
  557. {
  558. oCol._sManualType = oOptions.sType;
  559. }
  560. // `class` is a reserved word in Javascript, so we need to provide
  561. // the ability to use a valid name for the camel case input
  562. if ( oOptions.className && ! oOptions.sClass )
  563. {
  564. oOptions.sClass = oOptions.className;
  565. }
  566. $.extend( oCol, oOptions );
  567. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  568. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  569. * priority if defined
  570. */
  571. if ( oOptions.iDataSort !== undefined )
  572. {
  573. oCol.aDataSort = [ oOptions.iDataSort ];
  574. }
  575. _fnMap( oCol, oOptions, "aDataSort" );
  576. }
  577. /* Cache the data get and set functions for speed */
  578. var mDataSrc = oCol.mData;
  579. var mData = _fnGetObjectDataFn( mDataSrc );
  580. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  581. var attrTest = function( src ) {
  582. return typeof src === 'string' && src.indexOf('@') !== -1;
  583. };
  584. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  585. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  586. );
  587. oCol.fnGetData = function (rowData, type, meta) {
  588. var innerData = mData( rowData, type, undefined, meta );
  589. return mRender && type ?
  590. mRender( innerData, type, rowData, meta ) :
  591. innerData;
  592. };
  593. oCol.fnSetData = function ( rowData, val, meta ) {
  594. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  595. };
  596. // Indicate if DataTables should read DOM data as an object or array
  597. // Used in _fnGetRowElements
  598. if ( typeof mDataSrc !== 'number' ) {
  599. oSettings._rowReadObject = true;
  600. }
  601. /* Feature sorting overrides column specific when off */
  602. if ( !oSettings.oFeatures.bSort )
  603. {
  604. oCol.bSortable = false;
  605. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  606. }
  607. /* Check that the class assignment is correct for sorting */
  608. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  609. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  610. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  611. {
  612. oCol.sSortingClass = oClasses.sSortableNone;
  613. oCol.sSortingClassJUI = "";
  614. }
  615. else if ( bAsc && !bDesc )
  616. {
  617. oCol.sSortingClass = oClasses.sSortableAsc;
  618. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  619. }
  620. else if ( !bAsc && bDesc )
  621. {
  622. oCol.sSortingClass = oClasses.sSortableDesc;
  623. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  624. }
  625. else
  626. {
  627. oCol.sSortingClass = oClasses.sSortable;
  628. oCol.sSortingClassJUI = oClasses.sSortJUI;
  629. }
  630. }
  631. /**
  632. * Adjust the table column widths for new data. Note: you would probably want to
  633. * do a redraw after calling this function!
  634. * @param {object} settings dataTables settings object
  635. * @memberof DataTable#oApi
  636. */
  637. function _fnAdjustColumnSizing ( settings )
  638. {
  639. /* Not interested in doing column width calculation if auto-width is disabled */
  640. if ( settings.oFeatures.bAutoWidth !== false )
  641. {
  642. var columns = settings.aoColumns;
  643. _fnCalculateColumnWidths( settings );
  644. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  645. {
  646. columns[i].nTh.style.width = columns[i].sWidth;
  647. }
  648. }
  649. var scroll = settings.oScroll;
  650. if ( scroll.sY !== '' || scroll.sX !== '')
  651. {
  652. _fnScrollDraw( settings );
  653. }
  654. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  655. }
  656. /**
  657. * Covert the index of a visible column to the index in the data array (take account
  658. * of hidden columns)
  659. * @param {object} oSettings dataTables settings object
  660. * @param {int} iMatch Visible column index to lookup
  661. * @returns {int} i the data index
  662. * @memberof DataTable#oApi
  663. */
  664. function _fnVisibleToColumnIndex( oSettings, iMatch )
  665. {
  666. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  667. return typeof aiVis[iMatch] === 'number' ?
  668. aiVis[iMatch] :
  669. null;
  670. }
  671. /**
  672. * Covert the index of an index in the data array and convert it to the visible
  673. * column index (take account of hidden columns)
  674. * @param {int} iMatch Column index to lookup
  675. * @param {object} oSettings dataTables settings object
  676. * @returns {int} i the data index
  677. * @memberof DataTable#oApi
  678. */
  679. function _fnColumnIndexToVisible( oSettings, iMatch )
  680. {
  681. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  682. var iPos = $.inArray( iMatch, aiVis );
  683. return iPos !== -1 ? iPos : null;
  684. }
  685. /**
  686. * Get the number of visible columns
  687. * @param {object} oSettings dataTables settings object
  688. * @returns {int} i the number of visible columns
  689. * @memberof DataTable#oApi
  690. */
  691. function _fnVisbleColumns( oSettings )
  692. {
  693. return _fnGetColumns( oSettings, 'bVisible' ).length;
  694. }
  695. /**
  696. * Get an array of column indexes that match a given property
  697. * @param {object} oSettings dataTables settings object
  698. * @param {string} sParam Parameter in aoColumns to look for - typically
  699. * bVisible or bSearchable
  700. * @returns {array} Array of indexes with matched properties
  701. * @memberof DataTable#oApi
  702. */
  703. function _fnGetColumns( oSettings, sParam )
  704. {
  705. var a = [];
  706. $.map( oSettings.aoColumns, function(val, i) {
  707. if ( val[sParam] ) {
  708. a.push( i );
  709. }
  710. } );
  711. return a;
  712. }
  713. /**
  714. * Calculate the 'type' of a column
  715. * @param {object} settings dataTables settings object
  716. * @memberof DataTable#oApi
  717. */
  718. function _fnColumnTypes ( settings )
  719. {
  720. var columns = settings.aoColumns;
  721. var data = settings.aoData;
  722. var types = DataTable.ext.type.detect;
  723. var i, ien, j, jen, k, ken;
  724. var col, cell, detectedType, cache;
  725. // For each column, spin over the
  726. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  727. col = columns[i];
  728. cache = [];
  729. if ( ! col.sType && col._sManualType ) {
  730. col.sType = col._sManualType;
  731. }
  732. else if ( ! col.sType ) {
  733. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  734. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  735. // Use a cache array so we only need to get the type data
  736. // from the formatter once (when using multiple detectors)
  737. if ( cache[k] === undefined ) {
  738. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  739. }
  740. detectedType = types[j]( cache[k], settings );
  741. // If null, then this type can't apply to this column, so
  742. // rather than testing all cells, break out. There is an
  743. // exception for the last type which is `html`. We need to
  744. // scan all rows since it is possible to mix string and HTML
  745. // types
  746. if ( ! detectedType && j !== types.length-1 ) {
  747. break;
  748. }
  749. // Only a single match is needed for html type since it is
  750. // bottom of the pile and very similar to string
  751. if ( detectedType === 'html' ) {
  752. break;
  753. }
  754. }
  755. // Type is valid for all data points in the column - use this
  756. // type
  757. if ( detectedType ) {
  758. col.sType = detectedType;
  759. break;
  760. }
  761. }
  762. // Fall back - if no type was detected, always use string
  763. if ( ! col.sType ) {
  764. col.sType = 'string';
  765. }
  766. }
  767. }
  768. }
  769. /**
  770. * Take the column definitions and static columns arrays and calculate how
  771. * they relate to column indexes. The callback function will then apply the
  772. * definition found for a column to a suitable configuration object.
  773. * @param {object} oSettings dataTables settings object
  774. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  775. * @param {array} aoCols The aoColumns array that defines columns individually
  776. * @param {function} fn Callback function - takes two parameters, the calculated
  777. * column index and the definition for that column.
  778. * @memberof DataTable#oApi
  779. */
  780. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  781. {
  782. var i, iLen, j, jLen, k, kLen, def;
  783. var columns = oSettings.aoColumns;
  784. // Column definitions with aTargets
  785. if ( aoColDefs )
  786. {
  787. /* Loop over the definitions array - loop in reverse so first instance has priority */
  788. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  789. {
  790. def = aoColDefs[i];
  791. /* Each definition can target multiple columns, as it is an array */
  792. var aTargets = def.targets !== undefined ?
  793. def.targets :
  794. def.aTargets;
  795. if ( ! $.isArray( aTargets ) )
  796. {
  797. aTargets = [ aTargets ];
  798. }
  799. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  800. {
  801. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  802. {
  803. /* Add columns that we don't yet know about */
  804. while( columns.length <= aTargets[j] )
  805. {
  806. _fnAddColumn( oSettings );
  807. }
  808. /* Integer, basic index */
  809. fn( aTargets[j], def );
  810. }
  811. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  812. {
  813. /* Negative integer, right to left column counting */
  814. fn( columns.length+aTargets[j], def );
  815. }
  816. else if ( typeof aTargets[j] === 'string' )
  817. {
  818. /* Class name matching on TH element */
  819. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  820. {
  821. if ( aTargets[j] == "_all" ||
  822. $(columns[k].nTh).hasClass( aTargets[j] ) )
  823. {
  824. fn( k, def );
  825. }
  826. }
  827. }
  828. }
  829. }
  830. }
  831. // Statically defined columns array
  832. if ( aoCols )
  833. {
  834. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  835. {
  836. fn( i, aoCols[i] );
  837. }
  838. }
  839. }
  840. /**
  841. * Add a data array to the table, creating DOM node etc. This is the parallel to
  842. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  843. * DOM source.
  844. * @param {object} oSettings dataTables settings object
  845. * @param {array} aData data array to be added
  846. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  847. * DataTables will create a row automatically
  848. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  849. * if nTr is.
  850. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  851. * @memberof DataTable#oApi
  852. */
  853. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  854. {
  855. /* Create the object for storing information about this new row */
  856. var iRow = oSettings.aoData.length;
  857. var oData = $.extend( true, {}, DataTable.models.oRow, {
  858. src: nTr ? 'dom' : 'data'
  859. } );
  860. oData._aData = aDataIn;
  861. oSettings.aoData.push( oData );
  862. /* Create the cells */
  863. var nTd, sThisType;
  864. var columns = oSettings.aoColumns;
  865. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  866. {
  867. // When working with a row, the data source object must be populated. In
  868. // all other cases, the data source object is already populated, so we
  869. // don't overwrite it, which might break bindings etc
  870. if ( nTr ) {
  871. _fnSetCellData( oSettings, iRow, i, _fnGetCellData( oSettings, iRow, i ) );
  872. }
  873. columns[i].sType = null;
  874. }
  875. /* Add to the display array */
  876. oSettings.aiDisplayMaster.push( iRow );
  877. /* Create the DOM information, or register it if already present */
  878. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  879. {
  880. _fnCreateTr( oSettings, iRow, nTr, anTds );
  881. }
  882. return iRow;
  883. }
  884. /**
  885. * Add one or more TR elements to the table. Generally we'd expect to
  886. * use this for reading data from a DOM sourced table, but it could be
  887. * used for an TR element. Note that if a TR is given, it is used (i.e.
  888. * it is not cloned).
  889. * @param {object} settings dataTables settings object
  890. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  891. * @returns {array} Array of indexes for the added rows
  892. * @memberof DataTable#oApi
  893. */
  894. function _fnAddTr( settings, trs )
  895. {
  896. var row;
  897. // Allow an individual node to be passed in
  898. if ( ! (trs instanceof $) ) {
  899. trs = $(trs);
  900. }
  901. return trs.map( function (i, el) {
  902. row = _fnGetRowElements( settings, el );
  903. return _fnAddData( settings, row.data, el, row.cells );
  904. } );
  905. }
  906. /**
  907. * Take a TR element and convert it to an index in aoData
  908. * @param {object} oSettings dataTables settings object
  909. * @param {node} n the TR element to find
  910. * @returns {int} index if the node is found, null if not
  911. * @memberof DataTable#oApi
  912. */
  913. function _fnNodeToDataIndex( oSettings, n )
  914. {
  915. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  916. }
  917. /**
  918. * Take a TD element and convert it into a column data index (not the visible index)
  919. * @param {object} oSettings dataTables settings object
  920. * @param {int} iRow The row number the TD/TH can be found in
  921. * @param {node} n The TD/TH element to find
  922. * @returns {int} index if the node is found, -1 if not
  923. * @memberof DataTable#oApi
  924. */
  925. function _fnNodeToColumnIndex( oSettings, iRow, n )
  926. {
  927. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  928. }
  929. /**
  930. * Get the data for a given cell from the internal cache, taking into account data mapping
  931. * @param {object} settings dataTables settings object
  932. * @param {int} rowIdx aoData row id
  933. * @param {int} colIdx Column index
  934. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  935. * @returns {*} Cell data
  936. * @memberof DataTable#oApi
  937. */
  938. function _fnGetCellData( settings, rowIdx, colIdx, type )
  939. {
  940. var draw = settings.iDraw;
  941. var col = settings.aoColumns[colIdx];
  942. var rowData = settings.aoData[rowIdx]._aData;
  943. var defaultContent = col.sDefaultContent;
  944. var cellData = col.fnGetData( rowData, type, {
  945. settings: settings,
  946. row: rowIdx,
  947. col: colIdx
  948. } );
  949. if ( cellData === undefined ) {
  950. if ( settings.iDrawError != draw && defaultContent === null ) {
  951. _fnLog( settings, 0, "Requested unknown parameter "+
  952. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  953. " for row "+rowIdx, 4 );
  954. settings.iDrawError = draw;
  955. }
  956. return defaultContent;
  957. }
  958. /* When the data source is null, we can use default column data */
  959. if ( (cellData === rowData || cellData === null) && defaultContent !== null ) {
  960. cellData = defaultContent;
  961. }
  962. else if ( typeof cellData === 'function' ) {
  963. // If the data source is a function, then we run it and use the return,
  964. // executing in the scope of the data object (for instances)
  965. return cellData.call( rowData );
  966. }
  967. if ( cellData === null && type == 'display' ) {
  968. return '';
  969. }
  970. return cellData;
  971. }
  972. /**
  973. * Set the value for a specific cell, into the internal data cache
  974. * @param {object} settings dataTables settings object
  975. * @param {int} rowIdx aoData row id
  976. * @param {int} colIdx Column index
  977. * @param {*} val Value to set
  978. * @memberof DataTable#oApi
  979. */
  980. function _fnSetCellData( settings, rowIdx, colIdx, val )
  981. {
  982. var col = settings.aoColumns[colIdx];
  983. var rowData = settings.aoData[rowIdx]._aData;
  984. col.fnSetData( rowData, val, {
  985. settings: settings,
  986. row: rowIdx,
  987. col: colIdx
  988. } );
  989. }
  990. // Private variable that is used to match action syntax in the data property object
  991. var __reArray = /\[.*?\]$/;
  992. var __reFn = /\(\)$/;
  993. /**
  994. * Split string on periods, taking into account escaped periods
  995. * @param {string} str String to split
  996. * @return {array} Split string
  997. */
  998. function _fnSplitObjNotation( str )
  999. {
  1000. return $.map( str.match(/(\\.|[^\.])+/g), function ( s ) {
  1001. return s.replace(/\\./g, '.');
  1002. } );
  1003. }
  1004. /**
  1005. * Return a function that can be used to get data from a source object, taking
  1006. * into account the ability to use nested objects as a source
  1007. * @param {string|int|function} mSource The data source for the object
  1008. * @returns {function} Data get function
  1009. * @memberof DataTable#oApi
  1010. */
  1011. function _fnGetObjectDataFn( mSource )
  1012. {
  1013. if ( $.isPlainObject( mSource ) )
  1014. {
  1015. /* Build an object of get functions, and wrap them in a single call */
  1016. var o = {};
  1017. $.each( mSource, function (key, val) {
  1018. if ( val ) {
  1019. o[key] = _fnGetObjectDataFn( val );
  1020. }
  1021. } );
  1022. return function (data, type, row, meta) {
  1023. var t = o[type] || o._;
  1024. return t !== undefined ?
  1025. t(data, type, row, meta) :
  1026. data;
  1027. };
  1028. }
  1029. else if ( mSource === null )
  1030. {
  1031. /* Give an empty string for rendering / sorting etc */
  1032. return function (data) { // type, row and meta also passed, but not used
  1033. return data;
  1034. };
  1035. }
  1036. else if ( typeof mSource === 'function' )
  1037. {
  1038. return function (data, type, row, meta) {
  1039. return mSource( data, type, row, meta );
  1040. };
  1041. }
  1042. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1043. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1044. {
  1045. /* If there is a . in the source string then the data source is in a
  1046. * nested object so we loop over the data for each level to get the next
  1047. * level down. On each loop we test for undefined, and if found immediately
  1048. * return. This allows entire objects to be missing and sDefaultContent to
  1049. * be used if defined, rather than throwing an error
  1050. */
  1051. var fetchData = function (data, type, src) {
  1052. var arrayNotation, funcNotation, out, innerSrc;
  1053. if ( src !== "" )
  1054. {
  1055. var a = _fnSplitObjNotation( src );
  1056. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1057. {
  1058. // Check if we are dealing with special notation
  1059. arrayNotation = a[i].match(__reArray);
  1060. funcNotation = a[i].match(__reFn);
  1061. if ( arrayNotation )
  1062. {
  1063. // Array notation
  1064. a[i] = a[i].replace(__reArray, '');
  1065. // Condition allows simply [] to be passed in
  1066. if ( a[i] !== "" ) {
  1067. data = data[ a[i] ];
  1068. }
  1069. out = [];
  1070. // Get the remainder of the nested object to get
  1071. a.splice( 0, i+1 );
  1072. innerSrc = a.join('.');
  1073. // Traverse each entry in the array getting the properties requested
  1074. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  1075. out.push( fetchData( data[j], type, innerSrc ) );
  1076. }
  1077. // If a string is given in between the array notation indicators, that
  1078. // is used to join the strings together, otherwise an array is returned
  1079. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  1080. data = (join==="") ? out : out.join(join);
  1081. // The inner call to fetchData has already traversed through the remainder
  1082. // of the source requested, so we exit from the loop
  1083. break;
  1084. }
  1085. else if ( funcNotation )
  1086. {
  1087. // Function call
  1088. a[i] = a[i].replace(__reFn, '');
  1089. data = data[ a[i] ]();
  1090. continue;
  1091. }
  1092. if ( data === null || data[ a[i] ] === undefined )
  1093. {
  1094. return undefined;
  1095. }
  1096. data = data[ a[i] ];
  1097. }
  1098. }
  1099. return data;
  1100. };
  1101. return function (data, type) { // row and meta also passed, but not used
  1102. return fetchData( data, type, mSource );
  1103. };
  1104. }
  1105. else
  1106. {
  1107. /* Array or flat object mapping */
  1108. return function (data, type) { // row and meta also passed, but not used
  1109. return data[mSource];
  1110. };
  1111. }
  1112. }
  1113. /**
  1114. * Return a function that can be used to set data from a source object, taking
  1115. * into account the ability to use nested objects as a source
  1116. * @param {string|int|function} mSource The data source for the object
  1117. * @returns {function} Data set function
  1118. * @memberof DataTable#oApi
  1119. */
  1120. function _fnSetObjectDataFn( mSource )
  1121. {
  1122. if ( $.isPlainObject( mSource ) )
  1123. {
  1124. /* Unlike get, only the underscore (global) option is used for for
  1125. * setting data since we don't know the type here. This is why an object
  1126. * option is not documented for `mData` (which is read/write), but it is
  1127. * for `mRender` which is read only.
  1128. */
  1129. return _fnSetObjectDataFn( mSource._ );
  1130. }
  1131. else if ( mSource === null )
  1132. {
  1133. /* Nothing to do when the data source is null */
  1134. return function () {};
  1135. }
  1136. else if ( typeof mSource === 'function' )
  1137. {
  1138. return function (data, val, meta) {
  1139. mSource( data, 'set', val, meta );
  1140. };
  1141. }
  1142. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1143. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1144. {
  1145. /* Like the get, we need to get data from a nested object */
  1146. var setData = function (data, val, src) {
  1147. var a = _fnSplitObjNotation( src ), b;
  1148. var aLast = a[a.length-1];
  1149. var arrayNotation, funcNotation, o, innerSrc;
  1150. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  1151. {
  1152. // Check if we are dealing with an array notation request
  1153. arrayNotation = a[i].match(__reArray);
  1154. funcNotation = a[i].match(__reFn);
  1155. if ( arrayNotation )
  1156. {
  1157. a[i] = a[i].replace(__reArray, '');
  1158. data[ a[i] ] = [];
  1159. // Get the remainder of the nested object to set so we can recurse
  1160. b = a.slice();
  1161. b.splice( 0, i+1 );
  1162. innerSrc = b.join('.');
  1163. // Traverse each entry in the array setting the properties requested
  1164. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  1165. {
  1166. o = {};
  1167. setData( o, val[j], innerSrc );
  1168. data[ a[i] ].push( o );
  1169. }
  1170. // The inner call to setData has already traversed through the remainder
  1171. // of the source and has set the data, thus we can exit here
  1172. return;
  1173. }
  1174. else if ( funcNotation )
  1175. {
  1176. // Function call
  1177. a[i] = a[i].replace(__reFn, '');
  1178. data = data[ a[i] ]( val );
  1179. }
  1180. // If the nested object doesn't currently exist - since we are
  1181. // trying to set the value - create it
  1182. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  1183. {
  1184. data[ a[i] ] = {};
  1185. }
  1186. data = data[ a[i] ];
  1187. }
  1188. // Last item in the input - i.e, the actual set
  1189. if ( aLast.match(__reFn ) )
  1190. {
  1191. // Function call
  1192. data = data[ aLast.replace(__reFn, '') ]( val );
  1193. }
  1194. else
  1195. {
  1196. // If array notation is used, we just want to strip it and use the property name
  1197. // and assign the value. If it isn't used, then we get the result we want anyway
  1198. data[ aLast.replace(__reArray, '') ] = val;
  1199. }
  1200. };
  1201. return function (data, val) { // meta is also passed in, but not used
  1202. return setData( data, val, mSource );
  1203. };
  1204. }
  1205. else
  1206. {
  1207. /* Array or flat object mapping */
  1208. return function (data, val) { // meta is also passed in, but not used
  1209. data[mSource] = val;
  1210. };
  1211. }
  1212. }
  1213. /**
  1214. * Return an array with the full table data
  1215. * @param {object} oSettings dataTables settings object
  1216. * @returns array {array} aData Master data array
  1217. * @memberof DataTable#oApi
  1218. */
  1219. function _fnGetDataMaster ( settings )
  1220. {
  1221. return _pluck( settings.aoData, '_aData' );
  1222. }
  1223. /**
  1224. * Nuke the table
  1225. * @param {object} oSettings dataTables settings object
  1226. * @memberof DataTable#oApi
  1227. */
  1228. function _fnClearTable( settings )
  1229. {
  1230. settings.aoData.length = 0;
  1231. settings.aiDisplayMaster.length = 0;
  1232. settings.aiDisplay.length = 0;
  1233. }
  1234. /**
  1235. * Take an array of integers (index array) and remove a target integer (value - not
  1236. * the key!)
  1237. * @param {array} a Index array to target
  1238. * @param {int} iTarget value to find
  1239. * @memberof DataTable#oApi
  1240. */
  1241. function _fnDeleteIndex( a, iTarget, splice )
  1242. {
  1243. var iTargetIndex = -1;
  1244. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1245. {
  1246. if ( a[i] == iTarget )
  1247. {
  1248. iTargetIndex = i;
  1249. }
  1250. else if ( a[i] > iTarget )
  1251. {
  1252. a[i]--;
  1253. }
  1254. }
  1255. if ( iTargetIndex != -1 && splice === undefined )
  1256. {
  1257. a.splice( iTargetIndex, 1 );
  1258. }
  1259. }
  1260. /**
  1261. * Mark cached data as invalid such that a re-read of the data will occur when
  1262. * the cached data is next requested. Also update from the data source object.
  1263. *
  1264. * @param {object} settings DataTables settings object
  1265. * @param {int} rowIdx Row index to invalidate
  1266. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  1267. * or 'data'
  1268. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  1269. * row will be invalidated
  1270. * @memberof DataTable#oApi
  1271. *
  1272. * @todo For the modularisation of v1.11 this will need to become a callback, so
  1273. * the sort and filter methods can subscribe to it. That will required
  1274. * initialisation options for sorting, which is why it is not already baked in
  1275. */
  1276. function _fnInvalidate( settings, rowIdx, src, colIdx )
  1277. {
  1278. var row = settings.aoData[ rowIdx ];
  1279. var i, ien;
  1280. var cellWrite = function ( cell, col ) {
  1281. // This is very frustrating, but in IE if you just write directly
  1282. // to innerHTML, and elements that are overwritten are GC'ed,
  1283. // even if there is a reference to them elsewhere
  1284. while ( cell.childNodes.length ) {
  1285. cell.removeChild( cell.firstChild );
  1286. }
  1287. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  1288. };
  1289. // Are we reading last data from DOM or the data object?
  1290. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  1291. // Read the data from the DOM
  1292. row._aData = _fnGetRowElements(
  1293. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  1294. )
  1295. .data;
  1296. }
  1297. else {
  1298. // Reading from data object, update the DOM
  1299. var cells = row.anCells;
  1300. if ( cells ) {
  1301. if ( colIdx !== undefined ) {
  1302. cellWrite( cells[colIdx], colIdx );
  1303. }
  1304. else {
  1305. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1306. cellWrite( cells[i], i );
  1307. }
  1308. }
  1309. }
  1310. }
  1311. // For both row and cell invalidation, the cached data for sorting and
  1312. // filtering is nulled out
  1313. row._aSortData = null;
  1314. row._aFilterData = null;
  1315. // Invalidate the type for a specific column (if given) or all columns since
  1316. // the data might have changed
  1317. var cols = settings.aoColumns;
  1318. if ( colIdx !== undefined ) {
  1319. cols[ colIdx ].sType = null;
  1320. }
  1321. else {
  1322. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  1323. cols[i].sType = null;
  1324. }
  1325. // Update DataTables special `DT_*` attributes for the row
  1326. _fnRowAttributes( row );
  1327. }
  1328. }
  1329. /**
  1330. * Build a data source object from an HTML row, reading the contents of the
  1331. * cells that are in the row.
  1332. *
  1333. * @param {object} settings DataTables settings object
  1334. * @param {node|object} TR element from which to read data or existing row
  1335. * object from which to re-read the data from the cells
  1336. * @param {int} [colIdx] Optional column index
  1337. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  1338. * parameter should also be given and will be used to write the data into.
  1339. * Only the column in question will be written
  1340. * @returns {object} Object with two parameters: `data` the data read, in
  1341. * document order, and `cells` and array of nodes (they can be useful to the
  1342. * caller, so rather than needing a second traversal to get them, just return
  1343. * them from here).
  1344. * @memberof DataTable#oApi
  1345. */
  1346. function _fnGetRowElements( settings, row, colIdx, d )
  1347. {
  1348. var
  1349. tds = [],
  1350. td = row.firstChild,
  1351. name, col, o, i=0, contents,
  1352. columns = settings.aoColumns,
  1353. objectRead = settings._rowReadObject;
  1354. // Allow the data object to be passed in, or construct
  1355. d = d || objectRead ? {} : [];
  1356. var attr = function ( str, td ) {
  1357. if ( typeof str === 'string' ) {
  1358. var idx = str.indexOf('@');
  1359. if ( idx !== -1 ) {
  1360. var attr = str.substring( idx+1 );
  1361. var setter = _fnSetObjectDataFn( str );
  1362. setter( d, td.getAttribute( attr ) );
  1363. }
  1364. }
  1365. };
  1366. // Read data from a cell and store into the data object
  1367. var cellProcess = function ( cell ) {
  1368. if ( colIdx === undefined || colIdx === i ) {
  1369. col = columns[i];
  1370. contents = $.trim(cell.innerHTML);
  1371. if ( col && col._bAttrSrc ) {
  1372. var setter = _fnSetObjectDataFn( col.mData._ );
  1373. setter( d, contents );
  1374. attr( col.mData.sort, cell );
  1375. attr( col.mData.type, cell );
  1376. attr( col.mData.filter, cell );
  1377. }
  1378. else {
  1379. // Depending on the `data` option for the columns the data can
  1380. // be read to either an object or an array.
  1381. if ( objectRead ) {
  1382. if ( ! col._setter ) {
  1383. // Cache the setter function
  1384. col._setter = _fnSetObjectDataFn( col.mData );
  1385. }
  1386. col._setter( d, contents );
  1387. }
  1388. else {
  1389. d[i] = contents;
  1390. }
  1391. }
  1392. }
  1393. i++;
  1394. };
  1395. if ( td ) {
  1396. // `tr` element was passed in
  1397. while ( td ) {
  1398. name = td.nodeName.toUpperCase();
  1399. if ( name == "TD" || name == "TH" ) {
  1400. cellProcess( td );
  1401. tds.push( td );
  1402. }
  1403. td = td.nextSibling;
  1404. }
  1405. }
  1406. else {
  1407. // Existing row object passed in
  1408. tds = row.anCells;
  1409. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  1410. cellProcess( tds[j] );
  1411. }
  1412. }
  1413. return {
  1414. data: d,
  1415. cells: tds
  1416. };
  1417. }
  1418. /**
  1419. * Create a new TR element (and it's TD children) for a row
  1420. * @param {object} oSettings dataTables settings object
  1421. * @param {int} iRow Row to consider
  1422. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  1423. * DataTables will create a row automatically
  1424. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  1425. * if nTr is.
  1426. * @memberof DataTable#oApi
  1427. */
  1428. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  1429. {
  1430. var
  1431. row = oSettings.aoData[iRow],
  1432. rowData = row._aData,
  1433. cells = [],
  1434. nTr, nTd, oCol,
  1435. i, iLen;
  1436. if ( row.nTr === null )
  1437. {
  1438. nTr = nTrIn || document.createElement('tr');
  1439. row.nTr = nTr;
  1440. row.anCells = cells;
  1441. /* Use a private property on the node to allow reserve mapping from the node
  1442. * to the aoData array for fast look up
  1443. */
  1444. nTr._DT_RowIndex = iRow;
  1445. /* Special parameters can be given by the data source to be used on the row */
  1446. _fnRowAttributes( row );
  1447. /* Process each column */
  1448. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  1449. {
  1450. oCol = oSettings.aoColumns[i];
  1451. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  1452. cells.push( nTd );
  1453. // Need to create the HTML if new, or if a rendering function is defined
  1454. if ( !nTrIn || oCol.mRender || oCol.mData !== i )
  1455. {
  1456. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  1457. }
  1458. /* Add user defined class */
  1459. if ( oCol.sClass )
  1460. {
  1461. nTd.className += ' '+oCol.sClass;
  1462. }
  1463. // Visibility - add or remove as required
  1464. if ( oCol.bVisible && ! nTrIn )
  1465. {
  1466. nTr.appendChild( nTd );
  1467. }
  1468. else if ( ! oCol.bVisible && nTrIn )
  1469. {
  1470. nTd.parentNode.removeChild( nTd );
  1471. }
  1472. if ( oCol.fnCreatedCell )
  1473. {
  1474. oCol.fnCreatedCell.call( oSettings.oInstance,
  1475. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  1476. );
  1477. }
  1478. }
  1479. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  1480. }
  1481. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  1482. // and deployed
  1483. row.nTr.setAttribute( 'role', 'row' );
  1484. }
  1485. /**
  1486. * Add attributes to a row based on the special `DT_*` parameters in a data
  1487. * source object.
  1488. * @param {object} DataTables row object for the row to be modified
  1489. * @memberof DataTable#oApi
  1490. */
  1491. function _fnRowAttributes( row )
  1492. {
  1493. var tr = row.nTr;
  1494. var data = row._aData;
  1495. if ( tr ) {
  1496. if ( data.DT_RowId ) {
  1497. tr.id = data.DT_RowId;
  1498. }
  1499. if ( data.DT_RowClass ) {
  1500. // Remove any classes added by DT_RowClass before
  1501. var a = data.DT_RowClass.split(' ');
  1502. row.__rowc = row.__rowc ?
  1503. _unique( row.__rowc.concat( a ) ) :
  1504. a;
  1505. $(tr)
  1506. .removeClass( row.__rowc.join(' ') )
  1507. .addClass( data.DT_RowClass );
  1508. }
  1509. if ( data.DT_RowAttr ) {
  1510. $(tr).attr( data.DT_RowAttr );
  1511. }
  1512. if ( data.DT_RowData ) {
  1513. $(tr).data( data.DT_RowData );
  1514. }
  1515. }
  1516. }
  1517. /**
  1518. * Create the HTML header for the table
  1519. * @param {object} oSettings dataTables settings object
  1520. * @memberof DataTable#oApi
  1521. */
  1522. function _fnBuildHead( oSettings )
  1523. {
  1524. var i, ien, cell, row, column;
  1525. var thead = oSettings.nTHead;
  1526. var tfoot = oSettings.nTFoot;
  1527. var createHeader = $('th, td', thead).length === 0;
  1528. var classes = oSettings.oClasses;
  1529. var columns = oSettings.aoColumns;
  1530. if ( createHeader ) {
  1531. row = $('<tr/>').appendTo( thead );
  1532. }
  1533. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1534. column = columns[i];
  1535. cell = $( column.nTh ).addClass( column.sClass );
  1536. if ( createHeader ) {
  1537. cell.appendTo( row );
  1538. }
  1539. // 1.11 move into sorting
  1540. if ( oSettings.oFeatures.bSort ) {
  1541. cell.addClass( column.sSortingClass );
  1542. if ( column.bSortable !== false ) {
  1543. cell
  1544. .attr( 'tabindex', oSettings.iTabIndex )
  1545. .attr( 'aria-controls', oSettings.sTableId );
  1546. _fnSortAttachListener( oSettings, column.nTh, i );
  1547. }
  1548. }
  1549. if ( column.sTitle != cell.html() ) {
  1550. cell.html( column.sTitle );
  1551. }
  1552. _fnRenderer( oSettings, 'header' )(
  1553. oSettings, cell, column, classes
  1554. );
  1555. }
  1556. if ( createHeader ) {
  1557. _fnDetectHeader( oSettings.aoHeader, thead );
  1558. }
  1559. /* ARIA role for the rows */
  1560. $(thead).find('>tr').attr('role', 'row');
  1561. /* Deal with the footer - add classes if required */
  1562. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  1563. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  1564. // Cache the footer cells. Note that we only take the cells from the first
  1565. // row in the footer. If there is more than one row the user wants to
  1566. // interact with, they need to use the table().foot() method. Note also this
  1567. // allows cells to be used for multiple columns using colspan
  1568. if ( tfoot !== null ) {
  1569. var cells = oSettings.aoFooter[0];
  1570. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1571. column = columns[i];
  1572. column.nTf = cells[i].cell;
  1573. if ( column.sClass ) {
  1574. $(column.nTf).addClass( column.sClass );
  1575. }
  1576. }
  1577. }
  1578. }
  1579. /**
  1580. * Draw the header (or footer) element based on the column visibility states. The
  1581. * methodology here is to use the layout array from _fnDetectHeader, modified for
  1582. * the instantaneous column visibility, to construct the new layout. The grid is
  1583. * traversed over cell at a time in a rows x columns grid fashion, although each
  1584. * cell insert can cover multiple elements in the grid - which is tracks using the
  1585. * aApplied array. Cell inserts in the grid will only occur where there isn't
  1586. * already a cell in that position.
  1587. * @param {object} oSettings dataTables settings object
  1588. * @param array {objects} aoSource Layout array from _fnDetectHeader
  1589. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  1590. * @memberof DataTable#oApi
  1591. */
  1592. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  1593. {
  1594. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  1595. var aoLocal = [];
  1596. var aApplied = [];
  1597. var iColumns = oSettings.aoColumns.length;
  1598. var iRowspan, iColspan;
  1599. if ( ! aoSource )
  1600. {
  1601. return;
  1602. }
  1603. if ( bIncludeHidden === undefined )
  1604. {
  1605. bIncludeHidden = false;
  1606. }
  1607. /* Make a copy of the master layout array, but without the visible columns in it */
  1608. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  1609. {
  1610. aoLocal[i] = aoSource[i].slice();
  1611. aoLocal[i].nTr = aoSource[i].nTr;
  1612. /* Remove any columns which are currently hidden */
  1613. for ( j=iColumns-1 ; j>=0 ; j-- )
  1614. {
  1615. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  1616. {
  1617. aoLocal[i].splice( j, 1 );
  1618. }
  1619. }
  1620. /* Prep the applied array - it needs an element for each row */
  1621. aApplied.push( [] );
  1622. }
  1623. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  1624. {
  1625. nLocalTr = aoLocal[i].nTr;
  1626. /* All cells are going to be replaced, so empty out the row */
  1627. if ( nLocalTr )
  1628. {
  1629. while( (n = nLocalTr.firstChild) )
  1630. {
  1631. nLocalTr.removeChild( n );
  1632. }
  1633. }
  1634. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  1635. {
  1636. iRowspan = 1;
  1637. iColspan = 1;
  1638. /* Check to see if there is already a cell (row/colspan) covering our target
  1639. * insert point. If there is, then there is nothing to do.
  1640. */
  1641. if ( aApplied[i][j] === undefined )
  1642. {
  1643. nLocalTr.appendChild( aoLocal[i][j].cell );
  1644. aApplied[i][j] = 1;
  1645. /* Expand the cell to cover as many rows as needed */
  1646. while ( aoLocal[i+iRowspan] !== undefined &&
  1647. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  1648. {
  1649. aApplied[i+iRowspan][j] = 1;
  1650. iRowspan++;
  1651. }
  1652. /* Expand the cell to cover as many columns as needed */
  1653. while ( aoLocal[i][j+iColspan] !== undefined &&
  1654. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  1655. {
  1656. /* Must update the applied array over the rows for the columns */
  1657. for ( k=0 ; k<iRowspan ; k++ )
  1658. {
  1659. aApplied[i+k][j+iColspan] = 1;
  1660. }
  1661. iColspan++;
  1662. }
  1663. /* Do the actual expansion in the DOM */
  1664. $(aoLocal[i][j].cell)
  1665. .attr('rowspan', iRowspan)
  1666. .attr('colspan', iColspan);
  1667. }
  1668. }
  1669. }
  1670. }
  1671. /**
  1672. * Insert the required TR nodes into the table for display
  1673. * @param {object} oSettings dataTables settings object
  1674. * @memberof DataTable#oApi
  1675. */
  1676. function _fnDraw( oSettings )
  1677. {
  1678. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  1679. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  1680. if ( $.inArray( false, aPreDraw ) !== -1 )
  1681. {
  1682. _fnProcessingDisplay( oSettings, false );
  1683. return;
  1684. }
  1685. var i, iLen, n;
  1686. var anRows = [];
  1687. var iRowCount = 0;
  1688. var asStripeClasses = oSettings.asStripeClasses;
  1689. var iStripes = asStripeClasses.length;
  1690. var iOpenRows = oSettings.aoOpenRows.length;
  1691. var oLang = oSettings.oLanguage;
  1692. var iInitDisplayStart = oSettings.iInitDisplayStart;
  1693. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  1694. var aiDisplay = oSettings.aiDisplay;
  1695. oSettings.bDrawing = true;
  1696. /* Check and see if we have an initial draw position from state saving */
  1697. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  1698. {
  1699. oSettings._iDisplayStart = bServerSide ?
  1700. iInitDisplayStart :
  1701. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  1702. 0 :
  1703. iInitDisplayStart;
  1704. oSettings.iInitDisplayStart = -1;
  1705. }
  1706. var iDisplayStart = oSettings._iDisplayStart;
  1707. var iDisplayEnd = oSettings.fnDisplayEnd();
  1708. /* Server-side processing draw intercept */
  1709. if ( oSettings.bDeferLoading )
  1710. {
  1711. oSettings.bDeferLoading = false;
  1712. oSettings.iDraw++;
  1713. _fnProcessingDisplay( oSettings, false );
  1714. }
  1715. else if ( !bServerSide )
  1716. {
  1717. oSettings.iDraw++;
  1718. }
  1719. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  1720. {
  1721. return;
  1722. }
  1723. if ( aiDisplay.length !== 0 )
  1724. {
  1725. var iStart = bServerSide ? 0 : iDisplayStart;
  1726. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  1727. for ( var j=iStart ; j<iEnd ; j++ )
  1728. {
  1729. var iDataIndex = aiDisplay[j];
  1730. var aoData = oSettings.aoData[ iDataIndex ];
  1731. if ( aoData.nTr === null )
  1732. {
  1733. _fnCreateTr( oSettings, iDataIndex );
  1734. }
  1735. var nRow = aoData.nTr;
  1736. /* Remove the old striping classes and then add the new one */
  1737. if ( iStripes !== 0 )
  1738. {
  1739. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  1740. if ( aoData._sRowStripe != sStripe )
  1741. {
  1742. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  1743. aoData._sRowStripe = sStripe;
  1744. }
  1745. }
  1746. // Row callback functions - might want to manipulate the row
  1747. // iRowCount and j are not currently documented. Are they at all
  1748. // useful?
  1749. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  1750. [nRow, aoData._aData, iRowCount, j] );
  1751. anRows.push( nRow );
  1752. iRowCount++;
  1753. }
  1754. }
  1755. else
  1756. {
  1757. /* Table is empty - create a row with an empty message in it */
  1758. var sZero = oLang.sZeroRecords;
  1759. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  1760. {
  1761. sZero = oLang.sLoadingRecords;
  1762. }
  1763. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  1764. {
  1765. sZero = oLang.sEmptyTable;
  1766. }
  1767. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  1768. .append( $('<td />', {
  1769. 'valign': 'top',
  1770. 'colSpan': _fnVisbleColumns( oSettings ),
  1771. 'class': oSettings.oClasses.sRowEmpty
  1772. } ).html( sZero ) )[0];
  1773. }
  1774. /* Header and footer callbacks */
  1775. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  1776. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1777. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  1778. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1779. var body = $(oSettings.nTBody);
  1780. body.children().detach();
  1781. body.append( $(anRows) );
  1782. /* Call all required callback functions for the end of a draw */
  1783. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  1784. /* Draw is complete, sorting and filtering must be as well */
  1785. oSettings.bSorted = false;
  1786. oSettings.bFiltered = false;
  1787. oSettings.bDrawing = false;
  1788. }
  1789. /**
  1790. * Redraw the table - taking account of the various features which are enabled
  1791. * @param {object} oSettings dataTables settings object
  1792. * @param {boolean} [holdPosition] Keep the current paging position. By default
  1793. * the paging is reset to the first page
  1794. * @memberof DataTable#oApi
  1795. */
  1796. function _fnReDraw( settings, holdPosition )
  1797. {
  1798. var
  1799. features = settings.oFeatures,
  1800. sort = features.bSort,
  1801. filter = features.bFilter;
  1802. if ( sort ) {
  1803. _fnSort( settings );
  1804. }
  1805. if ( filter ) {
  1806. _fnFilterComplete( settings, settings.oPreviousSearch );
  1807. }
  1808. else {
  1809. // No filtering, so we want to just use the display master
  1810. settings.aiDisplay = settings.aiDisplayMaster.slice();
  1811. }
  1812. if ( holdPosition !== true ) {
  1813. settings._iDisplayStart = 0;
  1814. }
  1815. // Let any modules know about the draw hold position state (used by
  1816. // scrolling internally)
  1817. settings._drawHold = holdPosition;
  1818. _fnDraw( settings );
  1819. settings._drawHold = false;
  1820. }
  1821. /**
  1822. * Add the options to the page HTML for the table
  1823. * @param {object} oSettings dataTables settings object
  1824. * @memberof DataTable#oApi
  1825. */
  1826. function _fnAddOptionsHtml ( oSettings )
  1827. {
  1828. var classes = oSettings.oClasses;
  1829. var table = $(oSettings.nTable);
  1830. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  1831. var features = oSettings.oFeatures;
  1832. // All DataTables are wrapped in a div
  1833. var insert = $('<div/>', {
  1834. id: oSettings.sTableId+'_wrapper',
  1835. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  1836. } );
  1837. oSettings.nHolding = holding[0];
  1838. oSettings.nTableWrapper = insert[0];
  1839. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  1840. /* Loop over the user set positioning and place the elements as needed */
  1841. var aDom = oSettings.sDom.split('');
  1842. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  1843. for ( var i=0 ; i<aDom.length ; i++ )
  1844. {
  1845. featureNode = null;
  1846. cOption = aDom[i];
  1847. if ( cOption == '<' )
  1848. {
  1849. /* New container div */
  1850. nNewNode = $('<div/>')[0];
  1851. /* Check to see if we should append an id and/or a class name to the container */
  1852. cNext = aDom[i+1];
  1853. if ( cNext == "'" || cNext == '"' )
  1854. {
  1855. sAttr = "";
  1856. j = 2;
  1857. while ( aDom[i+j] != cNext )
  1858. {
  1859. sAttr += aDom[i+j];
  1860. j++;
  1861. }
  1862. /* Replace jQuery UI constants @todo depreciated */
  1863. if ( sAttr == "H" )
  1864. {
  1865. sAttr = classes.sJUIHeader;
  1866. }
  1867. else if ( sAttr == "F" )
  1868. {
  1869. sAttr = classes.sJUIFooter;
  1870. }
  1871. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  1872. * breaks the string into parts and applies them as needed
  1873. */
  1874. if ( sAttr.indexOf('.') != -1 )
  1875. {
  1876. var aSplit = sAttr.split('.');
  1877. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  1878. nNewNode.className = aSplit[1];
  1879. }
  1880. else if ( sAttr.charAt(0) == "#" )
  1881. {
  1882. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  1883. }
  1884. else
  1885. {
  1886. nNewNode.className = sAttr;
  1887. }
  1888. i += j; /* Move along the position array */
  1889. }
  1890. insert.append( nNewNode );
  1891. insert = $(nNewNode);
  1892. }
  1893. else if ( cOption == '>' )
  1894. {
  1895. /* End container div */
  1896. insert = insert.parent();
  1897. }
  1898. // @todo Move options into their own plugins?
  1899. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  1900. {
  1901. /* Length */
  1902. featureNode = _fnFeatureHtmlLength( oSettings );
  1903. }
  1904. else if ( cOption == 'f' && features.bFilter )
  1905. {
  1906. /* Filter */
  1907. featureNode = _fnFeatureHtmlFilter( oSettings );
  1908. }
  1909. else if ( cOption == 'r' && features.bProcessing )
  1910. {
  1911. /* pRocessing */
  1912. featureNode = _fnFeatureHtmlProcessing( oSettings );
  1913. }
  1914. else if ( cOption == 't' )
  1915. {
  1916. /* Table */
  1917. featureNode = _fnFeatureHtmlTable( oSettings );
  1918. }
  1919. else if ( cOption == 'i' && features.bInfo )
  1920. {
  1921. /* Info */
  1922. featureNode = _fnFeatureHtmlInfo( oSettings );
  1923. }
  1924. else if ( cOption == 'p' && features.bPaginate )
  1925. {
  1926. /* Pagination */
  1927. featureNode = _fnFeatureHtmlPaginate( oSettings );
  1928. }
  1929. else if ( DataTable.ext.feature.length !== 0 )
  1930. {
  1931. /* Plug-in features */
  1932. var aoFeatures = DataTable.ext.feature;
  1933. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  1934. {
  1935. if ( cOption == aoFeatures[k].cFeature )
  1936. {
  1937. featureNode = aoFeatures[k].fnInit( oSettings );
  1938. break;
  1939. }
  1940. }
  1941. }
  1942. /* Add to the 2D features array */
  1943. if ( featureNode )
  1944. {
  1945. var aanFeatures = oSettings.aanFeatures;
  1946. if ( ! aanFeatures[cOption] )
  1947. {
  1948. aanFeatures[cOption] = [];
  1949. }
  1950. aanFeatures[cOption].push( featureNode );
  1951. insert.append( featureNode );
  1952. }
  1953. }
  1954. /* Built our DOM structure - replace the holding div with what we want */
  1955. holding.replaceWith( insert );
  1956. }
  1957. /**
  1958. * Use the DOM source to create up an array of header cells. The idea here is to
  1959. * create a layout grid (array) of rows x columns, which contains a reference
  1960. * to the cell that that point in the grid (regardless of col/rowspan), such that
  1961. * any column / row could be removed and the new grid constructed
  1962. * @param array {object} aLayout Array to store the calculated layout in
  1963. * @param {node} nThead The header/footer element for the table
  1964. * @memberof DataTable#oApi
  1965. */
  1966. function _fnDetectHeader ( aLayout, nThead )
  1967. {
  1968. var nTrs = $(nThead).children('tr');
  1969. var nTr, nCell;
  1970. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  1971. var bUnique;
  1972. var fnShiftCol = function ( a, i, j ) {
  1973. var k = a[i];
  1974. while ( k[j] ) {
  1975. j++;
  1976. }
  1977. return j;
  1978. };
  1979. aLayout.splice( 0, aLayout.length );
  1980. /* We know how many rows there are in the layout - so prep it */
  1981. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1982. {
  1983. aLayout.push( [] );
  1984. }
  1985. /* Calculate a layout array */
  1986. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1987. {
  1988. nTr = nTrs[i];
  1989. iColumn = 0;
  1990. /* For every cell in the row... */
  1991. nCell = nTr.firstChild;
  1992. while ( nCell ) {
  1993. if ( nCell.nodeName.toUpperCase() == "TD" ||
  1994. nCell.nodeName.toUpperCase() == "TH" )
  1995. {
  1996. /* Get the col and rowspan attributes from the DOM and sanitise them */
  1997. iColspan = nCell.getAttribute('colspan') * 1;
  1998. iRowspan = nCell.getAttribute('rowspan') * 1;
  1999. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  2000. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  2001. /* There might be colspan cells already in this row, so shift our target
  2002. * accordingly
  2003. */
  2004. iColShifted = fnShiftCol( aLayout, i, iColumn );
  2005. /* Cache calculation for unique columns */
  2006. bUnique = iColspan === 1 ? true : false;
  2007. /* If there is col / rowspan, copy the information into the layout grid */
  2008. for ( l=0 ; l<iColspan ; l++ )
  2009. {
  2010. for ( k=0 ; k<iRowspan ; k++ )
  2011. {
  2012. aLayout[i+k][iColShifted+l] = {
  2013. "cell": nCell,
  2014. "unique": bUnique
  2015. };
  2016. aLayout[i+k].nTr = nTr;
  2017. }
  2018. }
  2019. }
  2020. nCell = nCell.nextSibling;
  2021. }
  2022. }
  2023. }
  2024. /**
  2025. * Get an array of unique th elements, one for each column
  2026. * @param {object} oSettings dataTables settings object
  2027. * @param {node} nHeader automatically detect the layout from this node - optional
  2028. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  2029. * @returns array {node} aReturn list of unique th's
  2030. * @memberof DataTable#oApi
  2031. */
  2032. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  2033. {
  2034. var aReturn = [];
  2035. if ( !aLayout )
  2036. {
  2037. aLayout = oSettings.aoHeader;
  2038. if ( nHeader )
  2039. {
  2040. aLayout = [];
  2041. _fnDetectHeader( aLayout, nHeader );
  2042. }
  2043. }
  2044. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  2045. {
  2046. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  2047. {
  2048. if ( aLayout[i][j].unique &&
  2049. (!aReturn[j] || !oSettings.bSortCellsTop) )
  2050. {
  2051. aReturn[j] = aLayout[i][j].cell;
  2052. }
  2053. }
  2054. }
  2055. return aReturn;
  2056. }
  2057. /**
  2058. * Create an Ajax call based on the table's settings, taking into account that
  2059. * parameters can have multiple forms, and backwards compatibility.
  2060. *
  2061. * @param {object} oSettings dataTables settings object
  2062. * @param {array} data Data to send to the server, required by
  2063. * DataTables - may be augmented by developer callbacks
  2064. * @param {function} fn Callback function to run when data is obtained
  2065. */
  2066. function _fnBuildAjax( oSettings, data, fn )
  2067. {
  2068. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  2069. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  2070. // Convert to object based for 1.10+ if using the old array scheme which can
  2071. // come from server-side processing or serverParams
  2072. if ( data && $.isArray(data) ) {
  2073. var tmp = {};
  2074. var rbracket = /(.*?)\[\]$/;
  2075. $.each( data, function (key, val) {
  2076. var match = val.name.match(rbracket);
  2077. if ( match ) {
  2078. // Support for arrays
  2079. var name = match[0];
  2080. if ( ! tmp[ name ] ) {
  2081. tmp[ name ] = [];
  2082. }
  2083. tmp[ name ].push( val.value );
  2084. }
  2085. else {
  2086. tmp[val.name] = val.value;
  2087. }
  2088. } );
  2089. data = tmp;
  2090. }
  2091. var ajaxData;
  2092. var ajax = oSettings.ajax;
  2093. var instance = oSettings.oInstance;
  2094. var callback = function ( json ) {
  2095. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  2096. fn( json );
  2097. };
  2098. if ( $.isPlainObject( ajax ) && ajax.data )
  2099. {
  2100. ajaxData = ajax.data;
  2101. var newData = $.isFunction( ajaxData ) ?
  2102. ajaxData( data, oSettings ) : // fn can manipulate data or return
  2103. ajaxData; // an object object or array to merge
  2104. // If the function returned something, use that alone
  2105. data = $.isFunction( ajaxData ) && newData ?
  2106. newData :
  2107. $.extend( true, data, newData );
  2108. // Remove the data property as we've resolved it already and don't want
  2109. // jQuery to do it again (it is restored at the end of the function)
  2110. delete ajax.data;
  2111. }
  2112. var baseAjax = {
  2113. "data": data,
  2114. "success": function (json) {
  2115. var error = json.error || json.sError;
  2116. if ( error ) {
  2117. _fnLog( oSettings, 0, error );
  2118. }
  2119. oSettings.json = json;
  2120. callback( json );
  2121. },
  2122. "dataType": "json",
  2123. "cache": false,
  2124. "type": oSettings.sServerMethod,
  2125. "error": function (xhr, error, thrown) {
  2126. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  2127. if ( $.inArray( true, ret ) === -1 ) {
  2128. if ( error == "parsererror" ) {
  2129. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  2130. }
  2131. else if ( xhr.readyState === 4 ) {
  2132. _fnLog( oSettings, 0, 'Ajax error', 7 );
  2133. }
  2134. }
  2135. _fnProcessingDisplay( oSettings, false );
  2136. }
  2137. };
  2138. // Store the data submitted for the API
  2139. oSettings.oAjaxData = data;
  2140. // Allow plug-ins and external processes to modify the data
  2141. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  2142. if ( oSettings.fnServerData )
  2143. {
  2144. // DataTables 1.9- compatibility
  2145. oSettings.fnServerData.call( instance,
  2146. oSettings.sAjaxSource,
  2147. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  2148. return { name: key, value: val };
  2149. } ),
  2150. callback,
  2151. oSettings
  2152. );
  2153. }
  2154. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  2155. {
  2156. // DataTables 1.9- compatibility
  2157. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  2158. url: ajax || oSettings.sAjaxSource
  2159. } ) );
  2160. }
  2161. else if ( $.isFunction( ajax ) )
  2162. {
  2163. // Is a function - let the caller define what needs to be done
  2164. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  2165. }
  2166. else
  2167. {
  2168. // Object to extend the base settings
  2169. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  2170. // Restore for next time around
  2171. ajax.data = ajaxData;
  2172. }
  2173. }
  2174. /**
  2175. * Update the table using an Ajax call
  2176. * @param {object} settings dataTables settings object
  2177. * @returns {boolean} Block the table drawing or not
  2178. * @memberof DataTable#oApi
  2179. */
  2180. function _fnAjaxUpdate( settings )
  2181. {
  2182. if ( settings.bAjaxDataGet ) {
  2183. settings.iDraw++;
  2184. _fnProcessingDisplay( settings, true );
  2185. _fnBuildAjax(
  2186. settings,
  2187. _fnAjaxParameters( settings ),
  2188. function(json) {
  2189. _fnAjaxUpdateDraw( settings, json );
  2190. }
  2191. );
  2192. return false;
  2193. }
  2194. return true;
  2195. }
  2196. /**
  2197. * Build up the parameters in an object needed for a server-side processing
  2198. * request. Note that this is basically done twice, is different ways - a modern
  2199. * method which is used by default in DataTables 1.10 which uses objects and
  2200. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  2201. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  2202. * option is set.
  2203. * @param {object} oSettings dataTables settings object
  2204. * @returns {bool} block the table drawing or not
  2205. * @memberof DataTable#oApi
  2206. */
  2207. function _fnAjaxParameters( settings )
  2208. {
  2209. var
  2210. columns = settings.aoColumns,
  2211. columnCount = columns.length,
  2212. features = settings.oFeatures,
  2213. preSearch = settings.oPreviousSearch,
  2214. preColSearch = settings.aoPreSearchCols,
  2215. i, data = [], dataProp, column, columnSearch,
  2216. sort = _fnSortFlatten( settings ),
  2217. displayStart = settings._iDisplayStart,
  2218. displayLength = features.bPaginate !== false ?
  2219. settings._iDisplayLength :
  2220. -1;
  2221. var param = function ( name, value ) {
  2222. data.push( { 'name': name, 'value': value } );
  2223. };
  2224. // DataTables 1.9- compatible method
  2225. param( 'sEcho', settings.iDraw );
  2226. param( 'iColumns', columnCount );
  2227. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  2228. param( 'iDisplayStart', displayStart );
  2229. param( 'iDisplayLength', displayLength );
  2230. // DataTables 1.10+ method
  2231. var d = {
  2232. draw: settings.iDraw,
  2233. columns: [],
  2234. order: [],
  2235. start: displayStart,
  2236. length: displayLength,
  2237. search: {
  2238. value: preSearch.sSearch,
  2239. regex: preSearch.bRegex
  2240. }
  2241. };
  2242. for ( i=0 ; i<columnCount ; i++ ) {
  2243. column = columns[i];
  2244. columnSearch = preColSearch[i];
  2245. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  2246. d.columns.push( {
  2247. data: dataProp,
  2248. name: column.sName,
  2249. searchable: column.bSearchable,
  2250. orderable: column.bSortable,
  2251. search: {
  2252. value: columnSearch.sSearch,
  2253. regex: columnSearch.bRegex
  2254. }
  2255. } );
  2256. param( "mDataProp_"+i, dataProp );
  2257. if ( features.bFilter ) {
  2258. param( 'sSearch_'+i, columnSearch.sSearch );
  2259. param( 'bRegex_'+i, columnSearch.bRegex );
  2260. param( 'bSearchable_'+i, column.bSearchable );
  2261. }
  2262. if ( features.bSort ) {
  2263. param( 'bSortable_'+i, column.bSortable );
  2264. }
  2265. }
  2266. if ( features.bFilter ) {
  2267. param( 'sSearch', preSearch.sSearch );
  2268. param( 'bRegex', preSearch.bRegex );
  2269. }
  2270. if ( features.bSort ) {
  2271. $.each( sort, function ( i, val ) {
  2272. d.order.push( { column: val.col, dir: val.dir } );
  2273. param( 'iSortCol_'+i, val.col );
  2274. param( 'sSortDir_'+i, val.dir );
  2275. } );
  2276. param( 'iSortingCols', sort.length );
  2277. }
  2278. // If the legacy.ajax parameter is null, then we automatically decide which
  2279. // form to use, based on sAjaxSource
  2280. var legacy = DataTable.ext.legacy.ajax;
  2281. if ( legacy === null ) {
  2282. return settings.sAjaxSource ? data : d;
  2283. }
  2284. // Otherwise, if legacy has been specified then we use that to decide on the
  2285. // form
  2286. return legacy ? data : d;
  2287. }
  2288. /**
  2289. * Data the data from the server (nuking the old) and redraw the table
  2290. * @param {object} oSettings dataTables settings object
  2291. * @param {object} json json data return from the server.
  2292. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  2293. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  2294. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  2295. * @param {array} json.aaData The data to display on this page
  2296. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  2297. * @memberof DataTable#oApi
  2298. */
  2299. function _fnAjaxUpdateDraw ( settings, json )
  2300. {
  2301. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  2302. // Support both
  2303. var compat = function ( old, modern ) {
  2304. return json[old] !== undefined ? json[old] : json[modern];
  2305. };
  2306. var data = _fnAjaxDataSrc( settings, json );
  2307. var draw = compat( 'sEcho', 'draw' );
  2308. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  2309. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  2310. if ( draw ) {
  2311. // Protect against out of sequence returns
  2312. if ( draw*1 < settings.iDraw ) {
  2313. return;
  2314. }
  2315. settings.iDraw = draw * 1;
  2316. }
  2317. _fnClearTable( settings );
  2318. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  2319. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  2320. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  2321. _fnAddData( settings, data[i] );
  2322. }
  2323. settings.aiDisplay = settings.aiDisplayMaster.slice();
  2324. settings.bAjaxDataGet = false;
  2325. _fnDraw( settings );
  2326. if ( ! settings._bInitComplete ) {
  2327. _fnInitComplete( settings, json );
  2328. }
  2329. settings.bAjaxDataGet = true;
  2330. _fnProcessingDisplay( settings, false );
  2331. }
  2332. /**
  2333. * Get the data from the JSON data source to use for drawing a table. Using
  2334. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  2335. * source object, or from a processing function.
  2336. * @param {object} oSettings dataTables settings object
  2337. * @param {object} json Data source object / array from the server
  2338. * @return {array} Array of data to use
  2339. */
  2340. function _fnAjaxDataSrc ( oSettings, json )
  2341. {
  2342. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  2343. oSettings.ajax.dataSrc :
  2344. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  2345. // Compatibility with 1.9-. In order to read from aaData, check if the
  2346. // default has been changed, if not, check for aaData
  2347. if ( dataSrc === 'data' ) {
  2348. return json.aaData || json[dataSrc];
  2349. }
  2350. return dataSrc !== "" ?
  2351. _fnGetObjectDataFn( dataSrc )( json ) :
  2352. json;
  2353. }
  2354. /**
  2355. * Generate the node required for filtering text
  2356. * @returns {node} Filter control element
  2357. * @param {object} oSettings dataTables settings object
  2358. * @memberof DataTable#oApi
  2359. */
  2360. function _fnFeatureHtmlFilter ( settings )
  2361. {
  2362. var classes = settings.oClasses;
  2363. var tableId = settings.sTableId;
  2364. var language = settings.oLanguage;
  2365. var previousSearch = settings.oPreviousSearch;
  2366. var features = settings.aanFeatures;
  2367. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  2368. var str = language.sSearch;
  2369. str = str.match(/_INPUT_/) ?
  2370. str.replace('_INPUT_', input) :
  2371. str+input;
  2372. var filter = $('<div/>', {
  2373. 'id': ! features.f ? tableId+'_filter' : null,
  2374. 'class': classes.sFilter
  2375. } )
  2376. .append( $('<label/>' ).append( str ) );
  2377. var searchFn = function() {
  2378. /* Update all other filter input elements for the new display */
  2379. var n = features.f;
  2380. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  2381. /* Now do the filter */
  2382. if ( val != previousSearch.sSearch ) {
  2383. _fnFilterComplete( settings, {
  2384. "sSearch": val,
  2385. "bRegex": previousSearch.bRegex,
  2386. "bSmart": previousSearch.bSmart ,
  2387. "bCaseInsensitive": previousSearch.bCaseInsensitive
  2388. } );
  2389. // Need to redraw, without resorting
  2390. settings._iDisplayStart = 0;
  2391. _fnDraw( settings );
  2392. }
  2393. };
  2394. var searchDelay = settings.searchDelay !== null ?
  2395. settings.searchDelay :
  2396. _fnDataSource( settings ) === 'ssp' ?
  2397. 400 :
  2398. 0;
  2399. var jqFilter = $('input', filter)
  2400. .val( previousSearch.sSearch )
  2401. .attr( 'placeholder', language.sSearchPlaceholder )
  2402. .bind(
  2403. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  2404. searchDelay ?
  2405. _fnThrottle( searchFn, searchDelay ) :
  2406. searchFn
  2407. )
  2408. .bind( 'keypress.DT', function(e) {
  2409. /* Prevent form submission */
  2410. if ( e.keyCode == 13 ) {
  2411. return false;
  2412. }
  2413. } )
  2414. .attr('aria-controls', tableId);
  2415. // Update the input elements whenever the table is filtered
  2416. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  2417. if ( settings === s ) {
  2418. // IE9 throws an 'unknown error' if document.activeElement is used
  2419. // inside an iframe or frame...
  2420. try {
  2421. if ( jqFilter[0] !== document.activeElement ) {
  2422. jqFilter.val( previousSearch.sSearch );
  2423. }
  2424. }
  2425. catch ( e ) {}
  2426. }
  2427. } );
  2428. return filter[0];
  2429. }
  2430. /**
  2431. * Filter the table using both the global filter and column based filtering
  2432. * @param {object} oSettings dataTables settings object
  2433. * @param {object} oSearch search information
  2434. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  2435. * @memberof DataTable#oApi
  2436. */
  2437. function _fnFilterComplete ( oSettings, oInput, iForce )
  2438. {
  2439. var oPrevSearch = oSettings.oPreviousSearch;
  2440. var aoPrevSearch = oSettings.aoPreSearchCols;
  2441. var fnSaveFilter = function ( oFilter ) {
  2442. /* Save the filtering values */
  2443. oPrevSearch.sSearch = oFilter.sSearch;
  2444. oPrevSearch.bRegex = oFilter.bRegex;
  2445. oPrevSearch.bSmart = oFilter.bSmart;
  2446. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  2447. };
  2448. var fnRegex = function ( o ) {
  2449. // Backwards compatibility with the bEscapeRegex option
  2450. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  2451. };
  2452. // Resolve any column types that are unknown due to addition or invalidation
  2453. // @todo As per sort - can this be moved into an event handler?
  2454. _fnColumnTypes( oSettings );
  2455. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  2456. if ( _fnDataSource( oSettings ) != 'ssp' )
  2457. {
  2458. /* Global filter */
  2459. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  2460. fnSaveFilter( oInput );
  2461. /* Now do the individual column filter */
  2462. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  2463. {
  2464. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  2465. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  2466. }
  2467. /* Custom filtering */
  2468. _fnFilterCustom( oSettings );
  2469. }
  2470. else
  2471. {
  2472. fnSaveFilter( oInput );
  2473. }
  2474. /* Tell the draw function we have been filtering */
  2475. oSettings.bFiltered = true;
  2476. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  2477. }
  2478. /**
  2479. * Apply custom filtering functions
  2480. * @param {object} oSettings dataTables settings object
  2481. * @memberof DataTable#oApi
  2482. */
  2483. function _fnFilterCustom( settings )
  2484. {
  2485. var filters = DataTable.ext.search;
  2486. var displayRows = settings.aiDisplay;
  2487. var row, rowIdx;
  2488. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  2489. var rows = [];
  2490. // Loop over each row and see if it should be included
  2491. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  2492. rowIdx = displayRows[ j ];
  2493. row = settings.aoData[ rowIdx ];
  2494. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  2495. rows.push( rowIdx );
  2496. }
  2497. }
  2498. // So the array reference doesn't break set the results into the
  2499. // existing array
  2500. displayRows.length = 0;
  2501. displayRows.push.apply( displayRows, rows );
  2502. }
  2503. }
  2504. /**
  2505. * Filter the table on a per-column basis
  2506. * @param {object} oSettings dataTables settings object
  2507. * @param {string} sInput string to filter on
  2508. * @param {int} iColumn column to filter
  2509. * @param {bool} bRegex treat search string as a regular expression or not
  2510. * @param {bool} bSmart use smart filtering or not
  2511. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  2512. * @memberof DataTable#oApi
  2513. */
  2514. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  2515. {
  2516. if ( searchStr === '' ) {
  2517. return;
  2518. }
  2519. var data;
  2520. var display = settings.aiDisplay;
  2521. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  2522. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  2523. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  2524. if ( ! rpSearch.test( data ) ) {
  2525. display.splice( i, 1 );
  2526. }
  2527. }
  2528. }
  2529. /**
  2530. * Filter the data table based on user input and draw the table
  2531. * @param {object} settings dataTables settings object
  2532. * @param {string} input string to filter on
  2533. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  2534. * @param {bool} regex treat as a regular expression or not
  2535. * @param {bool} smart perform smart filtering or not
  2536. * @param {bool} caseInsensitive Do case insenstive matching or not
  2537. * @memberof DataTable#oApi
  2538. */
  2539. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  2540. {
  2541. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  2542. var prevSearch = settings.oPreviousSearch.sSearch;
  2543. var displayMaster = settings.aiDisplayMaster;
  2544. var display, invalidated, i;
  2545. // Need to take account of custom filtering functions - always filter
  2546. if ( DataTable.ext.search.length !== 0 ) {
  2547. force = true;
  2548. }
  2549. // Check if any of the rows were invalidated
  2550. invalidated = _fnFilterData( settings );
  2551. // If the input is blank - we just want the full data set
  2552. if ( input.length <= 0 ) {
  2553. settings.aiDisplay = displayMaster.slice();
  2554. }
  2555. else {
  2556. // New search - start from the master array
  2557. if ( invalidated ||
  2558. force ||
  2559. prevSearch.length > input.length ||
  2560. input.indexOf(prevSearch) !== 0 ||
  2561. settings.bSorted // On resort, the display master needs to be
  2562. // re-filtered since indexes will have changed
  2563. ) {
  2564. settings.aiDisplay = displayMaster.slice();
  2565. }
  2566. // Search the display array
  2567. display = settings.aiDisplay;
  2568. for ( i=display.length-1 ; i>=0 ; i-- ) {
  2569. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  2570. display.splice( i, 1 );
  2571. }
  2572. }
  2573. }
  2574. }
  2575. /**
  2576. * Build a regular expression object suitable for searching a table
  2577. * @param {string} sSearch string to search for
  2578. * @param {bool} bRegex treat as a regular expression or not
  2579. * @param {bool} bSmart perform smart filtering or not
  2580. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  2581. * @returns {RegExp} constructed object
  2582. * @memberof DataTable#oApi
  2583. */
  2584. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  2585. {
  2586. search = regex ?
  2587. search :
  2588. _fnEscapeRegex( search );
  2589. if ( smart ) {
  2590. /* For smart filtering we want to allow the search to work regardless of
  2591. * word order. We also want double quoted text to be preserved, so word
  2592. * order is important - a la google. So this is what we want to
  2593. * generate:
  2594. *
  2595. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  2596. */
  2597. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  2598. if ( word.charAt(0) === '"' ) {
  2599. var m = word.match( /^"(.*)"$/ );
  2600. word = m ? m[1] : word;
  2601. }
  2602. return word.replace('"', '');
  2603. } );
  2604. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  2605. }
  2606. return new RegExp( search, caseInsensitive ? 'i' : '' );
  2607. }
  2608. /**
  2609. * Escape a string such that it can be used in a regular expression
  2610. * @param {string} sVal string to escape
  2611. * @returns {string} escaped string
  2612. * @memberof DataTable#oApi
  2613. */
  2614. function _fnEscapeRegex ( sVal )
  2615. {
  2616. return sVal.replace( _re_escape_regex, '\\$1' );
  2617. }
  2618. var __filter_div = $('<div>')[0];
  2619. var __filter_div_textContent = __filter_div.textContent !== undefined;
  2620. // Update the filtering data for each row if needed (by invalidation or first run)
  2621. function _fnFilterData ( settings )
  2622. {
  2623. var columns = settings.aoColumns;
  2624. var column;
  2625. var i, j, ien, jen, filterData, cellData, row;
  2626. var fomatters = DataTable.ext.type.search;
  2627. var wasInvalidated = false;
  2628. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  2629. row = settings.aoData[i];
  2630. if ( ! row._aFilterData ) {
  2631. filterData = [];
  2632. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  2633. column = columns[j];
  2634. if ( column.bSearchable ) {
  2635. cellData = _fnGetCellData( settings, i, j, 'filter' );
  2636. if ( fomatters[ column.sType ] ) {
  2637. cellData = fomatters[ column.sType ]( cellData );
  2638. }
  2639. // Search in DataTables 1.10 is string based. In 1.11 this
  2640. // should be altered to also allow strict type checking.
  2641. if ( cellData === null ) {
  2642. cellData = '';
  2643. }
  2644. if ( typeof cellData !== 'string' && cellData.toString ) {
  2645. cellData = cellData.toString();
  2646. }
  2647. }
  2648. else {
  2649. cellData = '';
  2650. }
  2651. // If it looks like there is an HTML entity in the string,
  2652. // attempt to decode it so sorting works as expected. Note that
  2653. // we could use a single line of jQuery to do this, but the DOM
  2654. // method used here is much faster http://jsperf.com/html-decode
  2655. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  2656. __filter_div.innerHTML = cellData;
  2657. cellData = __filter_div_textContent ?
  2658. __filter_div.textContent :
  2659. __filter_div.innerText;
  2660. }
  2661. if ( cellData.replace ) {
  2662. cellData = cellData.replace(/[\r\n]/g, '');
  2663. }
  2664. filterData.push( cellData );
  2665. }
  2666. row._aFilterData = filterData;
  2667. row._sFilterRow = filterData.join(' ');
  2668. wasInvalidated = true;
  2669. }
  2670. }
  2671. return wasInvalidated;
  2672. }
  2673. /**
  2674. * Convert from the internal Hungarian notation to camelCase for external
  2675. * interaction
  2676. * @param {object} obj Object to convert
  2677. * @returns {object} Inverted object
  2678. * @memberof DataTable#oApi
  2679. */
  2680. function _fnSearchToCamel ( obj )
  2681. {
  2682. return {
  2683. search: obj.sSearch,
  2684. smart: obj.bSmart,
  2685. regex: obj.bRegex,
  2686. caseInsensitive: obj.bCaseInsensitive
  2687. };
  2688. }
  2689. /**
  2690. * Convert from camelCase notation to the internal Hungarian. We could use the
  2691. * Hungarian convert function here, but this is cleaner
  2692. * @param {object} obj Object to convert
  2693. * @returns {object} Inverted object
  2694. * @memberof DataTable#oApi
  2695. */
  2696. function _fnSearchToHung ( obj )
  2697. {
  2698. return {
  2699. sSearch: obj.search,
  2700. bSmart: obj.smart,
  2701. bRegex: obj.regex,
  2702. bCaseInsensitive: obj.caseInsensitive
  2703. };
  2704. }
  2705. /**
  2706. * Generate the node required for the info display
  2707. * @param {object} oSettings dataTables settings object
  2708. * @returns {node} Information element
  2709. * @memberof DataTable#oApi
  2710. */
  2711. function _fnFeatureHtmlInfo ( settings )
  2712. {
  2713. var
  2714. tid = settings.sTableId,
  2715. nodes = settings.aanFeatures.i,
  2716. n = $('<div/>', {
  2717. 'class': settings.oClasses.sInfo,
  2718. 'id': ! nodes ? tid+'_info' : null
  2719. } );
  2720. if ( ! nodes ) {
  2721. // Update display on each draw
  2722. settings.aoDrawCallback.push( {
  2723. "fn": _fnUpdateInfo,
  2724. "sName": "information"
  2725. } );
  2726. n
  2727. .attr( 'role', 'status' )
  2728. .attr( 'aria-live', 'polite' );
  2729. // Table is described by our info div
  2730. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  2731. }
  2732. return n[0];
  2733. }
  2734. /**
  2735. * Update the information elements in the display
  2736. * @param {object} settings dataTables settings object
  2737. * @memberof DataTable#oApi
  2738. */
  2739. function _fnUpdateInfo ( settings )
  2740. {
  2741. /* Show information about the table */
  2742. var nodes = settings.aanFeatures.i;
  2743. if ( nodes.length === 0 ) {
  2744. return;
  2745. }
  2746. var
  2747. lang = settings.oLanguage,
  2748. start = settings._iDisplayStart+1,
  2749. end = settings.fnDisplayEnd(),
  2750. max = settings.fnRecordsTotal(),
  2751. total = settings.fnRecordsDisplay(),
  2752. out = total ?
  2753. lang.sInfo :
  2754. lang.sInfoEmpty;
  2755. if ( total !== max ) {
  2756. /* Record set after filtering */
  2757. out += ' ' + lang.sInfoFiltered;
  2758. }
  2759. // Convert the macros
  2760. out += lang.sInfoPostFix;
  2761. out = _fnInfoMacros( settings, out );
  2762. var callback = lang.fnInfoCallback;
  2763. if ( callback !== null ) {
  2764. out = callback.call( settings.oInstance,
  2765. settings, start, end, max, total, out
  2766. );
  2767. }
  2768. $(nodes).html( out );
  2769. }
  2770. function _fnInfoMacros ( settings, str )
  2771. {
  2772. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  2773. // internally
  2774. var
  2775. formatter = settings.fnFormatNumber,
  2776. start = settings._iDisplayStart+1,
  2777. len = settings._iDisplayLength,
  2778. vis = settings.fnRecordsDisplay(),
  2779. all = len === -1;
  2780. return str.
  2781. replace(/_START_/g, formatter.call( settings, start ) ).
  2782. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  2783. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  2784. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  2785. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  2786. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  2787. }
  2788. /**
  2789. * Draw the table for the first time, adding all required features
  2790. * @param {object} settings dataTables settings object
  2791. * @memberof DataTable#oApi
  2792. */
  2793. function _fnInitialise ( settings )
  2794. {
  2795. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  2796. var columns = settings.aoColumns, column;
  2797. var features = settings.oFeatures;
  2798. /* Ensure that the table data is fully initialised */
  2799. if ( ! settings.bInitialised ) {
  2800. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  2801. return;
  2802. }
  2803. /* Show the display HTML options */
  2804. _fnAddOptionsHtml( settings );
  2805. /* Build and draw the header / footer for the table */
  2806. _fnBuildHead( settings );
  2807. _fnDrawHead( settings, settings.aoHeader );
  2808. _fnDrawHead( settings, settings.aoFooter );
  2809. /* Okay to show that something is going on now */
  2810. _fnProcessingDisplay( settings, true );
  2811. /* Calculate sizes for columns */
  2812. if ( features.bAutoWidth ) {
  2813. _fnCalculateColumnWidths( settings );
  2814. }
  2815. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  2816. column = columns[i];
  2817. if ( column.sWidth ) {
  2818. column.nTh.style.width = _fnStringToCss( column.sWidth );
  2819. }
  2820. }
  2821. // If there is default sorting required - let's do it. The sort function
  2822. // will do the drawing for us. Otherwise we draw the table regardless of the
  2823. // Ajax source - this allows the table to look initialised for Ajax sourcing
  2824. // data (show 'loading' message possibly)
  2825. _fnReDraw( settings );
  2826. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  2827. var dataSrc = _fnDataSource( settings );
  2828. if ( dataSrc != 'ssp' ) {
  2829. // if there is an ajax source load the data
  2830. if ( dataSrc == 'ajax' ) {
  2831. _fnBuildAjax( settings, [], function(json) {
  2832. var aData = _fnAjaxDataSrc( settings, json );
  2833. // Got the data - add it to the table
  2834. for ( i=0 ; i<aData.length ; i++ ) {
  2835. _fnAddData( settings, aData[i] );
  2836. }
  2837. // Reset the init display for cookie saving. We've already done
  2838. // a filter, and therefore cleared it before. So we need to make
  2839. // it appear 'fresh'
  2840. settings.iInitDisplayStart = iAjaxStart;
  2841. _fnReDraw( settings );
  2842. _fnProcessingDisplay( settings, false );
  2843. _fnInitComplete( settings, json );
  2844. }, settings );
  2845. }
  2846. else {
  2847. _fnProcessingDisplay( settings, false );
  2848. _fnInitComplete( settings );
  2849. }
  2850. }
  2851. }
  2852. /**
  2853. * Draw the table for the first time, adding all required features
  2854. * @param {object} oSettings dataTables settings object
  2855. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  2856. * with client-side processing (optional)
  2857. * @memberof DataTable#oApi
  2858. */
  2859. function _fnInitComplete ( settings, json )
  2860. {
  2861. settings._bInitComplete = true;
  2862. // On an Ajax load we now have data and therefore want to apply the column
  2863. // sizing
  2864. if ( json ) {
  2865. _fnAdjustColumnSizing( settings );
  2866. }
  2867. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  2868. }
  2869. function _fnLengthChange ( settings, val )
  2870. {
  2871. var len = parseInt( val, 10 );
  2872. settings._iDisplayLength = len;
  2873. _fnLengthOverflow( settings );
  2874. // Fire length change event
  2875. _fnCallbackFire( settings, null, 'length', [settings, len] );
  2876. }
  2877. /**
  2878. * Generate the node required for user display length changing
  2879. * @param {object} settings dataTables settings object
  2880. * @returns {node} Display length feature node
  2881. * @memberof DataTable#oApi
  2882. */
  2883. function _fnFeatureHtmlLength ( settings )
  2884. {
  2885. var
  2886. classes = settings.oClasses,
  2887. tableId = settings.sTableId,
  2888. menu = settings.aLengthMenu,
  2889. d2 = $.isArray( menu[0] ),
  2890. lengths = d2 ? menu[0] : menu,
  2891. language = d2 ? menu[1] : menu;
  2892. var select = $('<select/>', {
  2893. 'name': tableId+'_length',
  2894. 'aria-controls': tableId,
  2895. 'class': classes.sLengthSelect
  2896. } );
  2897. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  2898. select[0][ i ] = new Option( language[i], lengths[i] );
  2899. }
  2900. var div = $('<div><label/></div>').addClass( classes.sLength );
  2901. if ( ! settings.aanFeatures.l ) {
  2902. div[0].id = tableId+'_length';
  2903. }
  2904. div.children().append(
  2905. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  2906. );
  2907. // Can't use `select` variable as user might provide their own and the
  2908. // reference is broken by the use of outerHTML
  2909. $('select', div)
  2910. .val( settings._iDisplayLength )
  2911. .bind( 'change.DT', function(e) {
  2912. _fnLengthChange( settings, $(this).val() );
  2913. _fnDraw( settings );
  2914. } );
  2915. // Update node value whenever anything changes the table's length
  2916. $(settings.nTable).bind( 'length.dt.DT', function (e, s, len) {
  2917. if ( settings === s ) {
  2918. $('select', div).val( len );
  2919. }
  2920. } );
  2921. return div[0];
  2922. }
  2923. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2924. * Note that most of the paging logic is done in
  2925. * DataTable.ext.pager
  2926. */
  2927. /**
  2928. * Generate the node required for default pagination
  2929. * @param {object} oSettings dataTables settings object
  2930. * @returns {node} Pagination feature node
  2931. * @memberof DataTable#oApi
  2932. */
  2933. function _fnFeatureHtmlPaginate ( settings )
  2934. {
  2935. var
  2936. type = settings.sPaginationType,
  2937. plugin = DataTable.ext.pager[ type ],
  2938. modern = typeof plugin === 'function',
  2939. redraw = function( settings ) {
  2940. _fnDraw( settings );
  2941. },
  2942. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  2943. features = settings.aanFeatures;
  2944. if ( ! modern ) {
  2945. plugin.fnInit( settings, node, redraw );
  2946. }
  2947. /* Add a draw callback for the pagination on first instance, to update the paging display */
  2948. if ( ! features.p )
  2949. {
  2950. node.id = settings.sTableId+'_paginate';
  2951. settings.aoDrawCallback.push( {
  2952. "fn": function( settings ) {
  2953. if ( modern ) {
  2954. var
  2955. start = settings._iDisplayStart,
  2956. len = settings._iDisplayLength,
  2957. visRecords = settings.fnRecordsDisplay(),
  2958. all = len === -1,
  2959. page = all ? 0 : Math.ceil( start / len ),
  2960. pages = all ? 1 : Math.ceil( visRecords / len ),
  2961. buttons = plugin(page, pages),
  2962. i, ien;
  2963. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  2964. _fnRenderer( settings, 'pageButton' )(
  2965. settings, features.p[i], i, buttons, page, pages
  2966. );
  2967. }
  2968. }
  2969. else {
  2970. plugin.fnUpdate( settings, redraw );
  2971. }
  2972. },
  2973. "sName": "pagination"
  2974. } );
  2975. }
  2976. return node;
  2977. }
  2978. /**
  2979. * Alter the display settings to change the page
  2980. * @param {object} settings DataTables settings object
  2981. * @param {string|int} action Paging action to take: "first", "previous",
  2982. * "next" or "last" or page number to jump to (integer)
  2983. * @param [bool] redraw Automatically draw the update or not
  2984. * @returns {bool} true page has changed, false - no change
  2985. * @memberof DataTable#oApi
  2986. */
  2987. function _fnPageChange ( settings, action, redraw )
  2988. {
  2989. var
  2990. start = settings._iDisplayStart,
  2991. len = settings._iDisplayLength,
  2992. records = settings.fnRecordsDisplay();
  2993. if ( records === 0 || len === -1 )
  2994. {
  2995. start = 0;
  2996. }
  2997. else if ( typeof action === "number" )
  2998. {
  2999. start = action * len;
  3000. if ( start > records )
  3001. {
  3002. start = 0;
  3003. }
  3004. }
  3005. else if ( action == "first" )
  3006. {
  3007. start = 0;
  3008. }
  3009. else if ( action == "previous" )
  3010. {
  3011. start = len >= 0 ?
  3012. start - len :
  3013. 0;
  3014. if ( start < 0 )
  3015. {
  3016. start = 0;
  3017. }
  3018. }
  3019. else if ( action == "next" )
  3020. {
  3021. if ( start + len < records )
  3022. {
  3023. start += len;
  3024. }
  3025. }
  3026. else if ( action == "last" )
  3027. {
  3028. start = Math.floor( (records-1) / len) * len;
  3029. }
  3030. else
  3031. {
  3032. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  3033. }
  3034. var changed = settings._iDisplayStart !== start;
  3035. settings._iDisplayStart = start;
  3036. if ( changed ) {
  3037. _fnCallbackFire( settings, null, 'page', [settings] );
  3038. if ( redraw ) {
  3039. _fnDraw( settings );
  3040. }
  3041. }
  3042. return changed;
  3043. }
  3044. /**
  3045. * Generate the node required for the processing node
  3046. * @param {object} settings dataTables settings object
  3047. * @returns {node} Processing element
  3048. * @memberof DataTable#oApi
  3049. */
  3050. function _fnFeatureHtmlProcessing ( settings )
  3051. {
  3052. return $('<div/>', {
  3053. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  3054. 'class': settings.oClasses.sProcessing
  3055. } )
  3056. .html( settings.oLanguage.sProcessing )
  3057. .insertBefore( settings.nTable )[0];
  3058. }
  3059. /**
  3060. * Display or hide the processing indicator
  3061. * @param {object} settings dataTables settings object
  3062. * @param {bool} show Show the processing indicator (true) or not (false)
  3063. * @memberof DataTable#oApi
  3064. */
  3065. function _fnProcessingDisplay ( settings, show )
  3066. {
  3067. if ( settings.oFeatures.bProcessing ) {
  3068. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  3069. }
  3070. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  3071. }
  3072. /**
  3073. * Add any control elements for the table - specifically scrolling
  3074. * @param {object} settings dataTables settings object
  3075. * @returns {node} Node to add to the DOM
  3076. * @memberof DataTable#oApi
  3077. */
  3078. function _fnFeatureHtmlTable ( settings )
  3079. {
  3080. var table = $(settings.nTable);
  3081. // Add the ARIA grid role to the table
  3082. table.attr( 'role', 'grid' );
  3083. // Scrolling from here on in
  3084. var scroll = settings.oScroll;
  3085. if ( scroll.sX === '' && scroll.sY === '' ) {
  3086. return settings.nTable;
  3087. }
  3088. var scrollX = scroll.sX;
  3089. var scrollY = scroll.sY;
  3090. var classes = settings.oClasses;
  3091. var caption = table.children('caption');
  3092. var captionSide = caption.length ? caption[0]._captionSide : null;
  3093. var headerClone = $( table[0].cloneNode(false) );
  3094. var footerClone = $( table[0].cloneNode(false) );
  3095. var footer = table.children('tfoot');
  3096. var _div = '<div/>';
  3097. var size = function ( s ) {
  3098. return !s ? null : _fnStringToCss( s );
  3099. };
  3100. // This is fairly messy, but with x scrolling enabled, if the table has a
  3101. // width attribute, regardless of any width applied using the column width
  3102. // options, the browser will shrink or grow the table as needed to fit into
  3103. // that 100%. That would make the width options useless. So we remove it.
  3104. // This is okay, under the assumption that width:100% is applied to the
  3105. // table in CSS (it is in the default stylesheet) which will set the table
  3106. // width as appropriate (the attribute and css behave differently...)
  3107. if ( scroll.sX && table.attr('width') === '100%' ) {
  3108. table.removeAttr('width');
  3109. }
  3110. if ( ! footer.length ) {
  3111. footer = null;
  3112. }
  3113. /*
  3114. * The HTML structure that we want to generate in this function is:
  3115. * div - scroller
  3116. * div - scroll head
  3117. * div - scroll head inner
  3118. * table - scroll head table
  3119. * thead - thead
  3120. * div - scroll body
  3121. * table - table (master table)
  3122. * thead - thead clone for sizing
  3123. * tbody - tbody
  3124. * div - scroll foot
  3125. * div - scroll foot inner
  3126. * table - scroll foot table
  3127. * tfoot - tfoot
  3128. */
  3129. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  3130. .append(
  3131. $(_div, { 'class': classes.sScrollHead } )
  3132. .css( {
  3133. overflow: 'hidden',
  3134. position: 'relative',
  3135. border: 0,
  3136. width: scrollX ? size(scrollX) : '100%'
  3137. } )
  3138. .append(
  3139. $(_div, { 'class': classes.sScrollHeadInner } )
  3140. .css( {
  3141. 'box-sizing': 'content-box',
  3142. width: scroll.sXInner || '100%'
  3143. } )
  3144. .append(
  3145. headerClone
  3146. .removeAttr('id')
  3147. .css( 'margin-left', 0 )
  3148. .append( captionSide === 'top' ? caption : null )
  3149. .append(
  3150. table.children('thead')
  3151. )
  3152. )
  3153. )
  3154. )
  3155. .append(
  3156. $(_div, { 'class': classes.sScrollBody } )
  3157. .css( {
  3158. overflow: 'auto',
  3159. height: size( scrollY ),
  3160. width: size( scrollX )
  3161. } )
  3162. .append( table )
  3163. );
  3164. if ( footer ) {
  3165. scroller.append(
  3166. $(_div, { 'class': classes.sScrollFoot } )
  3167. .css( {
  3168. overflow: 'hidden',
  3169. border: 0,
  3170. width: scrollX ? size(scrollX) : '100%'
  3171. } )
  3172. .append(
  3173. $(_div, { 'class': classes.sScrollFootInner } )
  3174. .append(
  3175. footerClone
  3176. .removeAttr('id')
  3177. .css( 'margin-left', 0 )
  3178. .append( captionSide === 'bottom' ? caption : null )
  3179. .append(
  3180. table.children('tfoot')
  3181. )
  3182. )
  3183. )
  3184. );
  3185. }
  3186. var children = scroller.children();
  3187. var scrollHead = children[0];
  3188. var scrollBody = children[1];
  3189. var scrollFoot = footer ? children[2] : null;
  3190. // When the body is scrolled, then we also want to scroll the headers
  3191. if ( scrollX ) {
  3192. $(scrollBody).on( 'scroll.DT', function (e) {
  3193. var scrollLeft = this.scrollLeft;
  3194. scrollHead.scrollLeft = scrollLeft;
  3195. if ( footer ) {
  3196. scrollFoot.scrollLeft = scrollLeft;
  3197. }
  3198. } );
  3199. }
  3200. settings.nScrollHead = scrollHead;
  3201. settings.nScrollBody = scrollBody;
  3202. settings.nScrollFoot = scrollFoot;
  3203. // On redraw - align columns
  3204. settings.aoDrawCallback.push( {
  3205. "fn": _fnScrollDraw,
  3206. "sName": "scrolling"
  3207. } );
  3208. return scroller[0];
  3209. }
  3210. /**
  3211. * Update the header, footer and body tables for resizing - i.e. column
  3212. * alignment.
  3213. *
  3214. * Welcome to the most horrible function DataTables. The process that this
  3215. * function follows is basically:
  3216. * 1. Re-create the table inside the scrolling div
  3217. * 2. Take live measurements from the DOM
  3218. * 3. Apply the measurements to align the columns
  3219. * 4. Clean up
  3220. *
  3221. * @param {object} settings dataTables settings object
  3222. * @memberof DataTable#oApi
  3223. */
  3224. function _fnScrollDraw ( settings )
  3225. {
  3226. // Given that this is such a monster function, a lot of variables are use
  3227. // to try and keep the minimised size as small as possible
  3228. var
  3229. scroll = settings.oScroll,
  3230. scrollX = scroll.sX,
  3231. scrollXInner = scroll.sXInner,
  3232. scrollY = scroll.sY,
  3233. barWidth = scroll.iBarWidth,
  3234. divHeader = $(settings.nScrollHead),
  3235. divHeaderStyle = divHeader[0].style,
  3236. divHeaderInner = divHeader.children('div'),
  3237. divHeaderInnerStyle = divHeaderInner[0].style,
  3238. divHeaderTable = divHeaderInner.children('table'),
  3239. divBodyEl = settings.nScrollBody,
  3240. divBody = $(divBodyEl),
  3241. divBodyStyle = divBodyEl.style,
  3242. divFooter = $(settings.nScrollFoot),
  3243. divFooterInner = divFooter.children('div'),
  3244. divFooterTable = divFooterInner.children('table'),
  3245. header = $(settings.nTHead),
  3246. table = $(settings.nTable),
  3247. tableEl = table[0],
  3248. tableStyle = tableEl.style,
  3249. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  3250. browser = settings.oBrowser,
  3251. ie67 = browser.bScrollOversize,
  3252. headerTrgEls, footerTrgEls,
  3253. headerSrcEls, footerSrcEls,
  3254. headerCopy, footerCopy,
  3255. headerWidths=[], footerWidths=[],
  3256. headerContent=[],
  3257. idx, correction, sanityWidth,
  3258. zeroOut = function(nSizer) {
  3259. var style = nSizer.style;
  3260. style.paddingTop = "0";
  3261. style.paddingBottom = "0";
  3262. style.borderTopWidth = "0";
  3263. style.borderBottomWidth = "0";
  3264. style.height = 0;
  3265. };
  3266. /*
  3267. * 1. Re-create the table inside the scrolling div
  3268. */
  3269. // Remove the old minimised thead and tfoot elements in the inner table
  3270. table.children('thead, tfoot').remove();
  3271. // Clone the current header and footer elements and then place it into the inner table
  3272. headerCopy = header.clone().prependTo( table );
  3273. headerTrgEls = header.find('tr'); // original header is in its own table
  3274. headerSrcEls = headerCopy.find('tr');
  3275. headerCopy.find('th, td').removeAttr('tabindex');
  3276. if ( footer ) {
  3277. footerCopy = footer.clone().prependTo( table );
  3278. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  3279. footerSrcEls = footerCopy.find('tr');
  3280. }
  3281. /*
  3282. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  3283. */
  3284. // Remove old sizing and apply the calculated column widths
  3285. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  3286. // calculated sizes to this header
  3287. if ( ! scrollX )
  3288. {
  3289. divBodyStyle.width = '100%';
  3290. divHeader[0].style.width = '100%';
  3291. }
  3292. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  3293. idx = _fnVisibleToColumnIndex( settings, i );
  3294. el.style.width = settings.aoColumns[idx].sWidth;
  3295. } );
  3296. if ( footer ) {
  3297. _fnApplyToChildren( function(n) {
  3298. n.style.width = "";
  3299. }, footerSrcEls );
  3300. }
  3301. // If scroll collapse is enabled, when we put the headers back into the body for sizing, we
  3302. // will end up forcing the scrollbar to appear, making our measurements wrong for when we
  3303. // then hide it (end of this function), so add the header height to the body scroller.
  3304. if ( scroll.bCollapse && scrollY !== "" ) {
  3305. divBodyStyle.height = (divBody[0].offsetHeight + header[0].offsetHeight)+"px";
  3306. }
  3307. // Size the table as a whole
  3308. sanityWidth = table.outerWidth();
  3309. if ( scrollX === "" ) {
  3310. // No x scrolling
  3311. tableStyle.width = "100%";
  3312. // IE7 will make the width of the table when 100% include the scrollbar
  3313. // - which is shouldn't. When there is a scrollbar we need to take this
  3314. // into account.
  3315. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  3316. divBody.css('overflow-y') == "scroll")
  3317. ) {
  3318. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  3319. }
  3320. }
  3321. else
  3322. {
  3323. // x scrolling
  3324. if ( scrollXInner !== "" ) {
  3325. // x scroll inner has been given - use it
  3326. tableStyle.width = _fnStringToCss(scrollXInner);
  3327. }
  3328. else if ( sanityWidth == divBody.width() && divBody.height() < table.height() ) {
  3329. // There is y-scrolling - try to take account of the y scroll bar
  3330. tableStyle.width = _fnStringToCss( sanityWidth-barWidth );
  3331. if ( table.outerWidth() > sanityWidth-barWidth ) {
  3332. // Not possible to take account of it
  3333. tableStyle.width = _fnStringToCss( sanityWidth );
  3334. }
  3335. }
  3336. else {
  3337. // When all else fails
  3338. tableStyle.width = _fnStringToCss( sanityWidth );
  3339. }
  3340. }
  3341. // Recalculate the sanity width - now that we've applied the required width,
  3342. // before it was a temporary variable. This is required because the column
  3343. // width calculation is done before this table DOM is created.
  3344. sanityWidth = table.outerWidth();
  3345. // Hidden header should have zero height, so remove padding and borders. Then
  3346. // set the width based on the real headers
  3347. // Apply all styles in one pass
  3348. _fnApplyToChildren( zeroOut, headerSrcEls );
  3349. // Read all widths in next pass
  3350. _fnApplyToChildren( function(nSizer) {
  3351. headerContent.push( nSizer.innerHTML );
  3352. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3353. }, headerSrcEls );
  3354. // Apply all widths in final pass
  3355. _fnApplyToChildren( function(nToSize, i) {
  3356. nToSize.style.width = headerWidths[i];
  3357. }, headerTrgEls );
  3358. $(headerSrcEls).height(0);
  3359. /* Same again with the footer if we have one */
  3360. if ( footer )
  3361. {
  3362. _fnApplyToChildren( zeroOut, footerSrcEls );
  3363. _fnApplyToChildren( function(nSizer) {
  3364. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3365. }, footerSrcEls );
  3366. _fnApplyToChildren( function(nToSize, i) {
  3367. nToSize.style.width = footerWidths[i];
  3368. }, footerTrgEls );
  3369. $(footerSrcEls).height(0);
  3370. }
  3371. /*
  3372. * 3. Apply the measurements
  3373. */
  3374. // "Hide" the header and footer that we used for the sizing. We need to keep
  3375. // the content of the cell so that the width applied to the header and body
  3376. // both match, but we want to hide it completely. We want to also fix their
  3377. // width to what they currently are
  3378. _fnApplyToChildren( function(nSizer, i) {
  3379. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  3380. nSizer.style.width = headerWidths[i];
  3381. }, headerSrcEls );
  3382. if ( footer )
  3383. {
  3384. _fnApplyToChildren( function(nSizer, i) {
  3385. nSizer.innerHTML = "";
  3386. nSizer.style.width = footerWidths[i];
  3387. }, footerSrcEls );
  3388. }
  3389. // Sanity check that the table is of a sensible width. If not then we are going to get
  3390. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  3391. if ( table.outerWidth() < sanityWidth )
  3392. {
  3393. // The min width depends upon if we have a vertical scrollbar visible or not */
  3394. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  3395. divBody.css('overflow-y') == "scroll")) ?
  3396. sanityWidth+barWidth :
  3397. sanityWidth;
  3398. // IE6/7 are a law unto themselves...
  3399. if ( ie67 && (divBodyEl.scrollHeight >
  3400. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  3401. ) {
  3402. tableStyle.width = _fnStringToCss( correction-barWidth );
  3403. }
  3404. // And give the user a warning that we've stopped the table getting too small
  3405. if ( scrollX === "" || scrollXInner !== "" ) {
  3406. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  3407. }
  3408. }
  3409. else
  3410. {
  3411. correction = '100%';
  3412. }
  3413. // Apply to the container elements
  3414. divBodyStyle.width = _fnStringToCss( correction );
  3415. divHeaderStyle.width = _fnStringToCss( correction );
  3416. if ( footer ) {
  3417. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  3418. }
  3419. /*
  3420. * 4. Clean up
  3421. */
  3422. if ( ! scrollY ) {
  3423. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  3424. * the scrollbar height from the visible display, rather than adding it on. We need to
  3425. * set the height in order to sort this. Don't want to do it in any other browsers.
  3426. */
  3427. if ( ie67 ) {
  3428. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  3429. }
  3430. }
  3431. if ( scrollY && scroll.bCollapse ) {
  3432. divBodyStyle.height = _fnStringToCss( scrollY );
  3433. var iExtra = (scrollX && tableEl.offsetWidth > divBodyEl.offsetWidth) ?
  3434. barWidth :
  3435. 0;
  3436. if ( tableEl.offsetHeight < divBodyEl.offsetHeight ) {
  3437. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+iExtra );
  3438. }
  3439. }
  3440. /* Finally set the width's of the header and footer tables */
  3441. var iOuterWidth = table.outerWidth();
  3442. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  3443. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  3444. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  3445. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  3446. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  3447. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  3448. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  3449. if ( footer ) {
  3450. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  3451. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  3452. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  3453. }
  3454. /* Adjust the position of the header in case we loose the y-scrollbar */
  3455. divBody.scroll();
  3456. // If sorting or filtering has occurred, jump the scrolling back to the top
  3457. // only if we aren't holding the position
  3458. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  3459. divBodyEl.scrollTop = 0;
  3460. }
  3461. }
  3462. /**
  3463. * Apply a given function to the display child nodes of an element array (typically
  3464. * TD children of TR rows
  3465. * @param {function} fn Method to apply to the objects
  3466. * @param array {nodes} an1 List of elements to look through for display children
  3467. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  3468. * @memberof DataTable#oApi
  3469. */
  3470. function _fnApplyToChildren( fn, an1, an2 )
  3471. {
  3472. var index=0, i=0, iLen=an1.length;
  3473. var nNode1, nNode2;
  3474. while ( i < iLen ) {
  3475. nNode1 = an1[i].firstChild;
  3476. nNode2 = an2 ? an2[i].firstChild : null;
  3477. while ( nNode1 ) {
  3478. if ( nNode1.nodeType === 1 ) {
  3479. if ( an2 ) {
  3480. fn( nNode1, nNode2, index );
  3481. }
  3482. else {
  3483. fn( nNode1, index );
  3484. }
  3485. index++;
  3486. }
  3487. nNode1 = nNode1.nextSibling;
  3488. nNode2 = an2 ? nNode2.nextSibling : null;
  3489. }
  3490. i++;
  3491. }
  3492. }
  3493. var __re_html_remove = /<.*?>/g;
  3494. /**
  3495. * Calculate the width of columns for the table
  3496. * @param {object} oSettings dataTables settings object
  3497. * @memberof DataTable#oApi
  3498. */
  3499. function _fnCalculateColumnWidths ( oSettings )
  3500. {
  3501. var
  3502. table = oSettings.nTable,
  3503. columns = oSettings.aoColumns,
  3504. scroll = oSettings.oScroll,
  3505. scrollY = scroll.sY,
  3506. scrollX = scroll.sX,
  3507. scrollXInner = scroll.sXInner,
  3508. columnCount = columns.length,
  3509. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  3510. headerCells = $('th', oSettings.nTHead),
  3511. tableWidthAttr = table.getAttribute('width'), // from DOM element
  3512. tableContainer = table.parentNode,
  3513. userInputs = false,
  3514. i, column, columnIdx, width, outerWidth;
  3515. var styleWidth = table.style.width;
  3516. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  3517. tableWidthAttr = styleWidth;
  3518. }
  3519. /* Convert any user input sizes into pixel sizes */
  3520. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3521. column = columns[ visibleColumns[i] ];
  3522. if ( column.sWidth !== null ) {
  3523. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  3524. userInputs = true;
  3525. }
  3526. }
  3527. /* If the number of columns in the DOM equals the number that we have to
  3528. * process in DataTables, then we can use the offsets that are created by
  3529. * the web- browser. No custom sizes can be set in order for this to happen,
  3530. * nor scrolling used
  3531. */
  3532. if ( ! userInputs && ! scrollX && ! scrollY &&
  3533. columnCount == _fnVisbleColumns( oSettings ) &&
  3534. columnCount == headerCells.length
  3535. ) {
  3536. for ( i=0 ; i<columnCount ; i++ ) {
  3537. columns[i].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  3538. }
  3539. }
  3540. else
  3541. {
  3542. // Otherwise construct a single row, worst case, table with the widest
  3543. // node in the data, assign any user defined widths, then insert it into
  3544. // the DOM and allow the browser to do all the hard work of calculating
  3545. // table widths
  3546. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  3547. .css( 'visibility', 'hidden' )
  3548. .removeAttr( 'id' );
  3549. // Clean up the table body
  3550. tmpTable.find('tbody tr').remove();
  3551. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  3552. // Remove any assigned widths from the footer (from scrolling)
  3553. tmpTable.find('tfoot th, tfoot td').css('width', '');
  3554. // Apply custom sizing to the cloned header
  3555. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  3556. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3557. column = columns[ visibleColumns[i] ];
  3558. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  3559. _fnStringToCss( column.sWidthOrig ) :
  3560. '';
  3561. }
  3562. // Find the widest cell for each column and put it into the table
  3563. if ( oSettings.aoData.length ) {
  3564. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3565. columnIdx = visibleColumns[i];
  3566. column = columns[ columnIdx ];
  3567. $( _fnGetWidestNode( oSettings, columnIdx ) )
  3568. .clone( false )
  3569. .append( column.sContentPadding )
  3570. .appendTo( tr );
  3571. }
  3572. }
  3573. // Table has been built, attach to the document so we can work with it
  3574. tmpTable.appendTo( tableContainer );
  3575. // When scrolling (X or Y) we want to set the width of the table as
  3576. // appropriate. However, when not scrolling leave the table width as it
  3577. // is. This results in slightly different, but I think correct behaviour
  3578. if ( scrollX && scrollXInner ) {
  3579. tmpTable.width( scrollXInner );
  3580. }
  3581. else if ( scrollX ) {
  3582. tmpTable.css( 'width', 'auto' );
  3583. if ( tmpTable.width() < tableContainer.offsetWidth ) {
  3584. tmpTable.width( tableContainer.offsetWidth );
  3585. }
  3586. }
  3587. else if ( scrollY ) {
  3588. tmpTable.width( tableContainer.offsetWidth );
  3589. }
  3590. else if ( tableWidthAttr ) {
  3591. tmpTable.width( tableWidthAttr );
  3592. }
  3593. // Take into account the y scrollbar
  3594. _fnScrollingWidthAdjust( oSettings, tmpTable[0] );
  3595. // Browsers need a bit of a hand when a width is assigned to any columns
  3596. // when x-scrolling as they tend to collapse the table to the min-width,
  3597. // even if we sent the column widths. So we need to keep track of what
  3598. // the table width should be by summing the user given values, and the
  3599. // automatic values
  3600. if ( scrollX )
  3601. {
  3602. var total = 0;
  3603. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3604. column = columns[ visibleColumns[i] ];
  3605. outerWidth = $(headerCells[i]).outerWidth();
  3606. total += column.sWidthOrig === null ?
  3607. outerWidth :
  3608. parseInt( column.sWidth, 10 ) + outerWidth - $(headerCells[i]).width();
  3609. }
  3610. tmpTable.width( _fnStringToCss( total ) );
  3611. table.style.width = _fnStringToCss( total );
  3612. }
  3613. // Get the width of each column in the constructed table
  3614. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3615. column = columns[ visibleColumns[i] ];
  3616. width = $(headerCells[i]).width();
  3617. if ( width ) {
  3618. column.sWidth = _fnStringToCss( width );
  3619. }
  3620. }
  3621. table.style.width = _fnStringToCss( tmpTable.css('width') );
  3622. // Finished with the table - ditch it
  3623. tmpTable.remove();
  3624. }
  3625. // If there is a width attr, we want to attach an event listener which
  3626. // allows the table sizing to automatically adjust when the window is
  3627. // resized. Use the width attr rather than CSS, since we can't know if the
  3628. // CSS is a relative value or absolute - DOM read is always px.
  3629. if ( tableWidthAttr ) {
  3630. table.style.width = _fnStringToCss( tableWidthAttr );
  3631. }
  3632. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  3633. var bindResize = function () {
  3634. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  3635. _fnAdjustColumnSizing( oSettings );
  3636. } ) );
  3637. };
  3638. // IE6/7 will crash if we bind a resize event handler on page load.
  3639. // To be removed in 1.11 which drops IE6/7 support
  3640. if ( oSettings.oBrowser.bScrollOversize ) {
  3641. setTimeout( bindResize, 1000 );
  3642. }
  3643. else {
  3644. bindResize();
  3645. }
  3646. oSettings._reszEvt = true;
  3647. }
  3648. }
  3649. /**
  3650. * Throttle the calls to a function. Arguments and context are maintained for
  3651. * the throttled function
  3652. * @param {function} fn Function to be called
  3653. * @param {int} [freq=200] call frequency in mS
  3654. * @returns {function} wrapped function
  3655. * @memberof DataTable#oApi
  3656. */
  3657. function _fnThrottle( fn, freq ) {
  3658. var
  3659. frequency = freq !== undefined ? freq : 200,
  3660. last,
  3661. timer;
  3662. return function () {
  3663. var
  3664. that = this,
  3665. now = +new Date(),
  3666. args = arguments;
  3667. if ( last && now < last + frequency ) {
  3668. clearTimeout( timer );
  3669. timer = setTimeout( function () {
  3670. last = undefined;
  3671. fn.apply( that, args );
  3672. }, frequency );
  3673. }
  3674. else {
  3675. last = now;
  3676. fn.apply( that, args );
  3677. }
  3678. };
  3679. }
  3680. /**
  3681. * Convert a CSS unit width to pixels (e.g. 2em)
  3682. * @param {string} width width to be converted
  3683. * @param {node} parent parent to get the with for (required for relative widths) - optional
  3684. * @returns {int} width in pixels
  3685. * @memberof DataTable#oApi
  3686. */
  3687. function _fnConvertToWidth ( width, parent )
  3688. {
  3689. if ( ! width ) {
  3690. return 0;
  3691. }
  3692. var n = $('<div/>')
  3693. .css( 'width', _fnStringToCss( width ) )
  3694. .appendTo( parent || document.body );
  3695. var val = n[0].offsetWidth;
  3696. n.remove();
  3697. return val;
  3698. }
  3699. /**
  3700. * Adjust a table's width to take account of vertical scroll bar
  3701. * @param {object} oSettings dataTables settings object
  3702. * @param {node} n table node
  3703. * @memberof DataTable#oApi
  3704. */
  3705. function _fnScrollingWidthAdjust ( settings, n )
  3706. {
  3707. var scroll = settings.oScroll;
  3708. if ( scroll.sX || scroll.sY ) {
  3709. // When y-scrolling only, we want to remove the width of the scroll bar
  3710. // so the table + scroll bar will fit into the area available, otherwise
  3711. // we fix the table at its current size with no adjustment
  3712. var correction = ! scroll.sX ? scroll.iBarWidth : 0;
  3713. n.style.width = _fnStringToCss( $(n).outerWidth() - correction );
  3714. }
  3715. }
  3716. /**
  3717. * Get the widest node
  3718. * @param {object} settings dataTables settings object
  3719. * @param {int} colIdx column of interest
  3720. * @returns {node} widest table node
  3721. * @memberof DataTable#oApi
  3722. */
  3723. function _fnGetWidestNode( settings, colIdx )
  3724. {
  3725. var idx = _fnGetMaxLenString( settings, colIdx );
  3726. if ( idx < 0 ) {
  3727. return null;
  3728. }
  3729. var data = settings.aoData[ idx ];
  3730. return ! data.nTr ? // Might not have been created when deferred rendering
  3731. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  3732. data.anCells[ colIdx ];
  3733. }
  3734. /**
  3735. * Get the maximum strlen for each data column
  3736. * @param {object} settings dataTables settings object
  3737. * @param {int} colIdx column of interest
  3738. * @returns {string} max string length for each column
  3739. * @memberof DataTable#oApi
  3740. */
  3741. function _fnGetMaxLenString( settings, colIdx )
  3742. {
  3743. var s, max=-1, maxIdx = -1;
  3744. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3745. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  3746. s = s.replace( __re_html_remove, '' );
  3747. if ( s.length > max ) {
  3748. max = s.length;
  3749. maxIdx = i;
  3750. }
  3751. }
  3752. return maxIdx;
  3753. }
  3754. /**
  3755. * Append a CSS unit (only if required) to a string
  3756. * @param {string} value to css-ify
  3757. * @returns {string} value with css unit
  3758. * @memberof DataTable#oApi
  3759. */
  3760. function _fnStringToCss( s )
  3761. {
  3762. if ( s === null ) {
  3763. return '0px';
  3764. }
  3765. if ( typeof s == 'number' ) {
  3766. return s < 0 ?
  3767. '0px' :
  3768. s+'px';
  3769. }
  3770. // Check it has a unit character already
  3771. return s.match(/\d$/) ?
  3772. s+'px' :
  3773. s;
  3774. }
  3775. /**
  3776. * Get the width of a scroll bar in this browser being used
  3777. * @returns {int} width in pixels
  3778. * @memberof DataTable#oApi
  3779. */
  3780. function _fnScrollBarWidth ()
  3781. {
  3782. // On first run a static variable is set, since this is only needed once.
  3783. // Subsequent runs will just use the previously calculated value
  3784. var width = DataTable.__scrollbarWidth;
  3785. if ( width === undefined ) {
  3786. var sizer = $('<p/>').css( {
  3787. position: 'absolute',
  3788. top: 0,
  3789. left: 0,
  3790. width: '100%',
  3791. height: 150,
  3792. padding: 0,
  3793. overflow: 'scroll',
  3794. visibility: 'hidden'
  3795. } )
  3796. .appendTo('body');
  3797. width = sizer[0].offsetWidth - sizer[0].clientWidth;
  3798. DataTable.__scrollbarWidth = width;
  3799. sizer.remove();
  3800. }
  3801. return width;
  3802. }
  3803. function _fnSortFlatten ( settings )
  3804. {
  3805. var
  3806. i, iLen, k, kLen,
  3807. aSort = [],
  3808. aiOrig = [],
  3809. aoColumns = settings.aoColumns,
  3810. aDataSort, iCol, sType, srcCol,
  3811. fixed = settings.aaSortingFixed,
  3812. fixedObj = $.isPlainObject( fixed ),
  3813. nestedSort = [],
  3814. add = function ( a ) {
  3815. if ( a.length && ! $.isArray( a[0] ) ) {
  3816. // 1D array
  3817. nestedSort.push( a );
  3818. }
  3819. else {
  3820. // 2D array
  3821. nestedSort.push.apply( nestedSort, a );
  3822. }
  3823. };
  3824. // Build the sort array, with pre-fix and post-fix options if they have been
  3825. // specified
  3826. if ( $.isArray( fixed ) ) {
  3827. add( fixed );
  3828. }
  3829. if ( fixedObj && fixed.pre ) {
  3830. add( fixed.pre );
  3831. }
  3832. add( settings.aaSorting );
  3833. if (fixedObj && fixed.post ) {
  3834. add( fixed.post );
  3835. }
  3836. for ( i=0 ; i<nestedSort.length ; i++ )
  3837. {
  3838. srcCol = nestedSort[i][0];
  3839. aDataSort = aoColumns[ srcCol ].aDataSort;
  3840. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  3841. {
  3842. iCol = aDataSort[k];
  3843. sType = aoColumns[ iCol ].sType || 'string';
  3844. if ( nestedSort[i]._idx === undefined ) {
  3845. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  3846. }
  3847. aSort.push( {
  3848. src: srcCol,
  3849. col: iCol,
  3850. dir: nestedSort[i][1],
  3851. index: nestedSort[i]._idx,
  3852. type: sType,
  3853. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  3854. } );
  3855. }
  3856. }
  3857. return aSort;
  3858. }
  3859. /**
  3860. * Change the order of the table
  3861. * @param {object} oSettings dataTables settings object
  3862. * @memberof DataTable#oApi
  3863. * @todo This really needs split up!
  3864. */
  3865. function _fnSort ( oSettings )
  3866. {
  3867. var
  3868. i, ien, iLen, j, jLen, k, kLen,
  3869. sDataType, nTh,
  3870. aiOrig = [],
  3871. oExtSort = DataTable.ext.type.order,
  3872. aoData = oSettings.aoData,
  3873. aoColumns = oSettings.aoColumns,
  3874. aDataSort, data, iCol, sType, oSort,
  3875. formatters = 0,
  3876. sortCol,
  3877. displayMaster = oSettings.aiDisplayMaster,
  3878. aSort;
  3879. // Resolve any column types that are unknown due to addition or invalidation
  3880. // @todo Can this be moved into a 'data-ready' handler which is called when
  3881. // data is going to be used in the table?
  3882. _fnColumnTypes( oSettings );
  3883. aSort = _fnSortFlatten( oSettings );
  3884. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  3885. sortCol = aSort[i];
  3886. // Track if we can use the fast sort algorithm
  3887. if ( sortCol.formatter ) {
  3888. formatters++;
  3889. }
  3890. // Load the data needed for the sort, for each cell
  3891. _fnSortData( oSettings, sortCol.col );
  3892. }
  3893. /* No sorting required if server-side or no sorting array */
  3894. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  3895. {
  3896. // Create a value - key array of the current row positions such that we can use their
  3897. // current position during the sort, if values match, in order to perform stable sorting
  3898. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  3899. aiOrig[ displayMaster[i] ] = i;
  3900. }
  3901. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  3902. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  3903. * follow on it's own, but this is what we want (example two column sorting):
  3904. * fnLocalSorting = function(a,b){
  3905. * var iTest;
  3906. * iTest = oSort['string-asc']('data11', 'data12');
  3907. * if (iTest !== 0)
  3908. * return iTest;
  3909. * iTest = oSort['numeric-desc']('data21', 'data22');
  3910. * if (iTest !== 0)
  3911. * return iTest;
  3912. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  3913. * }
  3914. * Basically we have a test for each sorting column, if the data in that column is equal,
  3915. * test the next column. If all columns match, then we use a numeric sort on the row
  3916. * positions in the original data array to provide a stable sort.
  3917. *
  3918. * Note - I know it seems excessive to have two sorting methods, but the first is around
  3919. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  3920. * methods which do not have a pre-sort formatting function.
  3921. */
  3922. if ( formatters === aSort.length ) {
  3923. // All sort types have formatting functions
  3924. displayMaster.sort( function ( a, b ) {
  3925. var
  3926. x, y, k, test, sort,
  3927. len=aSort.length,
  3928. dataA = aoData[a]._aSortData,
  3929. dataB = aoData[b]._aSortData;
  3930. for ( k=0 ; k<len ; k++ ) {
  3931. sort = aSort[k];
  3932. x = dataA[ sort.col ];
  3933. y = dataB[ sort.col ];
  3934. test = x<y ? -1 : x>y ? 1 : 0;
  3935. if ( test !== 0 ) {
  3936. return sort.dir === 'asc' ? test : -test;
  3937. }
  3938. }
  3939. x = aiOrig[a];
  3940. y = aiOrig[b];
  3941. return x<y ? -1 : x>y ? 1 : 0;
  3942. } );
  3943. }
  3944. else {
  3945. // Depreciated - remove in 1.11 (providing a plug-in option)
  3946. // Not all sort types have formatting methods, so we have to call their sorting
  3947. // methods.
  3948. displayMaster.sort( function ( a, b ) {
  3949. var
  3950. x, y, k, l, test, sort, fn,
  3951. len=aSort.length,
  3952. dataA = aoData[a]._aSortData,
  3953. dataB = aoData[b]._aSortData;
  3954. for ( k=0 ; k<len ; k++ ) {
  3955. sort = aSort[k];
  3956. x = dataA[ sort.col ];
  3957. y = dataB[ sort.col ];
  3958. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  3959. test = fn( x, y );
  3960. if ( test !== 0 ) {
  3961. return test;
  3962. }
  3963. }
  3964. x = aiOrig[a];
  3965. y = aiOrig[b];
  3966. return x<y ? -1 : x>y ? 1 : 0;
  3967. } );
  3968. }
  3969. }
  3970. /* Tell the draw function that we have sorted the data */
  3971. oSettings.bSorted = true;
  3972. }
  3973. function _fnSortAria ( settings )
  3974. {
  3975. var label;
  3976. var nextSort;
  3977. var columns = settings.aoColumns;
  3978. var aSort = _fnSortFlatten( settings );
  3979. var oAria = settings.oLanguage.oAria;
  3980. // ARIA attributes - need to loop all columns, to update all (removing old
  3981. // attributes as needed)
  3982. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  3983. {
  3984. var col = columns[i];
  3985. var asSorting = col.asSorting;
  3986. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  3987. var th = col.nTh;
  3988. // IE7 is throwing an error when setting these properties with jQuery's
  3989. // attr() and removeAttr() methods...
  3990. th.removeAttribute('aria-sort');
  3991. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  3992. if ( col.bSortable ) {
  3993. if ( aSort.length > 0 && aSort[0].col == i ) {
  3994. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  3995. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  3996. }
  3997. else {
  3998. nextSort = asSorting[0];
  3999. }
  4000. label = sTitle + ( nextSort === "asc" ?
  4001. oAria.sSortAscending :
  4002. oAria.sSortDescending
  4003. );
  4004. }
  4005. else {
  4006. label = sTitle;
  4007. }
  4008. th.setAttribute('aria-label', label);
  4009. }
  4010. }
  4011. /**
  4012. * Function to run on user sort request
  4013. * @param {object} settings dataTables settings object
  4014. * @param {node} attachTo node to attach the handler to
  4015. * @param {int} colIdx column sorting index
  4016. * @param {boolean} [append=false] Append the requested sort to the existing
  4017. * sort if true (i.e. multi-column sort)
  4018. * @param {function} [callback] callback function
  4019. * @memberof DataTable#oApi
  4020. */
  4021. function _fnSortListener ( settings, colIdx, append, callback )
  4022. {
  4023. var col = settings.aoColumns[ colIdx ];
  4024. var sorting = settings.aaSorting;
  4025. var asSorting = col.asSorting;
  4026. var nextSortIdx;
  4027. var next = function ( a, overflow ) {
  4028. var idx = a._idx;
  4029. if ( idx === undefined ) {
  4030. idx = $.inArray( a[1], asSorting );
  4031. }
  4032. return idx+1 < asSorting.length ?
  4033. idx+1 :
  4034. overflow ?
  4035. null :
  4036. 0;
  4037. };
  4038. // Convert to 2D array if needed
  4039. if ( typeof sorting[0] === 'number' ) {
  4040. sorting = settings.aaSorting = [ sorting ];
  4041. }
  4042. // If appending the sort then we are multi-column sorting
  4043. if ( append && settings.oFeatures.bSortMulti ) {
  4044. // Are we already doing some kind of sort on this column?
  4045. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  4046. if ( sortIdx !== -1 ) {
  4047. // Yes, modify the sort
  4048. nextSortIdx = next( sorting[sortIdx], true );
  4049. if ( nextSortIdx === null && sorting.length === 1 ) {
  4050. nextSortIdx = 0; // can't remove sorting completely
  4051. }
  4052. if ( nextSortIdx === null ) {
  4053. sorting.splice( sortIdx, 1 );
  4054. }
  4055. else {
  4056. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  4057. sorting[sortIdx]._idx = nextSortIdx;
  4058. }
  4059. }
  4060. else {
  4061. // No sort on this column yet
  4062. sorting.push( [ colIdx, asSorting[0], 0 ] );
  4063. sorting[sorting.length-1]._idx = 0;
  4064. }
  4065. }
  4066. else if ( sorting.length && sorting[0][0] == colIdx ) {
  4067. // Single column - already sorting on this column, modify the sort
  4068. nextSortIdx = next( sorting[0] );
  4069. sorting.length = 1;
  4070. sorting[0][1] = asSorting[ nextSortIdx ];
  4071. sorting[0]._idx = nextSortIdx;
  4072. }
  4073. else {
  4074. // Single column - sort only on this column
  4075. sorting.length = 0;
  4076. sorting.push( [ colIdx, asSorting[0] ] );
  4077. sorting[0]._idx = 0;
  4078. }
  4079. // Run the sort by calling a full redraw
  4080. _fnReDraw( settings );
  4081. // callback used for async user interaction
  4082. if ( typeof callback == 'function' ) {
  4083. callback( settings );
  4084. }
  4085. }
  4086. /**
  4087. * Attach a sort handler (click) to a node
  4088. * @param {object} settings dataTables settings object
  4089. * @param {node} attachTo node to attach the handler to
  4090. * @param {int} colIdx column sorting index
  4091. * @param {function} [callback] callback function
  4092. * @memberof DataTable#oApi
  4093. */
  4094. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  4095. {
  4096. var col = settings.aoColumns[ colIdx ];
  4097. _fnBindAction( attachTo, {}, function (e) {
  4098. /* If the column is not sortable - don't to anything */
  4099. if ( col.bSortable === false ) {
  4100. return;
  4101. }
  4102. // If processing is enabled use a timeout to allow the processing
  4103. // display to be shown - otherwise to it synchronously
  4104. if ( settings.oFeatures.bProcessing ) {
  4105. _fnProcessingDisplay( settings, true );
  4106. setTimeout( function() {
  4107. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4108. // In server-side processing, the draw callback will remove the
  4109. // processing display
  4110. if ( _fnDataSource( settings ) !== 'ssp' ) {
  4111. _fnProcessingDisplay( settings, false );
  4112. }
  4113. }, 0 );
  4114. }
  4115. else {
  4116. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4117. }
  4118. } );
  4119. }
  4120. /**
  4121. * Set the sorting classes on table's body, Note: it is safe to call this function
  4122. * when bSort and bSortClasses are false
  4123. * @param {object} oSettings dataTables settings object
  4124. * @memberof DataTable#oApi
  4125. */
  4126. function _fnSortingClasses( settings )
  4127. {
  4128. var oldSort = settings.aLastSort;
  4129. var sortClass = settings.oClasses.sSortColumn;
  4130. var sort = _fnSortFlatten( settings );
  4131. var features = settings.oFeatures;
  4132. var i, ien, colIdx;
  4133. if ( features.bSort && features.bSortClasses ) {
  4134. // Remove old sorting classes
  4135. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  4136. colIdx = oldSort[i].src;
  4137. // Remove column sorting
  4138. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4139. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  4140. }
  4141. // Add new column sorting
  4142. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  4143. colIdx = sort[i].src;
  4144. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4145. .addClass( sortClass + (i<2 ? i+1 : 3) );
  4146. }
  4147. }
  4148. settings.aLastSort = sort;
  4149. }
  4150. // Get the data to sort a column, be it from cache, fresh (populating the
  4151. // cache), or from a sort formatter
  4152. function _fnSortData( settings, idx )
  4153. {
  4154. // Custom sorting function - provided by the sort data type
  4155. var column = settings.aoColumns[ idx ];
  4156. var customSort = DataTable.ext.order[ column.sSortDataType ];
  4157. var customData;
  4158. if ( customSort ) {
  4159. customData = customSort.call( settings.oInstance, settings, idx,
  4160. _fnColumnIndexToVisible( settings, idx )
  4161. );
  4162. }
  4163. // Use / populate cache
  4164. var row, cellData;
  4165. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  4166. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4167. row = settings.aoData[i];
  4168. if ( ! row._aSortData ) {
  4169. row._aSortData = [];
  4170. }
  4171. if ( ! row._aSortData[idx] || customSort ) {
  4172. cellData = customSort ?
  4173. customData[i] : // If there was a custom sort function, use data from there
  4174. _fnGetCellData( settings, i, idx, 'sort' );
  4175. row._aSortData[ idx ] = formatter ?
  4176. formatter( cellData ) :
  4177. cellData;
  4178. }
  4179. }
  4180. }
  4181. /**
  4182. * Save the state of a table
  4183. * @param {object} oSettings dataTables settings object
  4184. * @memberof DataTable#oApi
  4185. */
  4186. function _fnSaveState ( settings )
  4187. {
  4188. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  4189. {
  4190. return;
  4191. }
  4192. /* Store the interesting variables */
  4193. var state = {
  4194. time: +new Date(),
  4195. start: settings._iDisplayStart,
  4196. length: settings._iDisplayLength,
  4197. order: $.extend( true, [], settings.aaSorting ),
  4198. search: _fnSearchToCamel( settings.oPreviousSearch ),
  4199. columns: $.map( settings.aoColumns, function ( col, i ) {
  4200. return {
  4201. visible: col.bVisible,
  4202. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  4203. };
  4204. } )
  4205. };
  4206. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  4207. settings.oSavedState = state;
  4208. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  4209. }
  4210. /**
  4211. * Attempt to load a saved table state
  4212. * @param {object} oSettings dataTables settings object
  4213. * @param {object} oInit DataTables init object so we can override settings
  4214. * @memberof DataTable#oApi
  4215. */
  4216. function _fnLoadState ( settings, oInit )
  4217. {
  4218. var i, ien;
  4219. var columns = settings.aoColumns;
  4220. if ( ! settings.oFeatures.bStateSave ) {
  4221. return;
  4222. }
  4223. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings );
  4224. if ( ! state || ! state.time ) {
  4225. return;
  4226. }
  4227. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  4228. * cancelling of loading by returning false
  4229. */
  4230. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state] );
  4231. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  4232. return;
  4233. }
  4234. /* Reject old data */
  4235. var duration = settings.iStateDuration;
  4236. if ( duration > 0 && state.time < +new Date() - (duration*1000) ) {
  4237. return;
  4238. }
  4239. // Number of columns have changed - all bets are off, no restore of settings
  4240. if ( columns.length !== state.columns.length ) {
  4241. return;
  4242. }
  4243. // Store the saved state so it might be accessed at any time
  4244. settings.oLoadedState = $.extend( true, {}, state );
  4245. // Restore key features - todo - for 1.11 this needs to be done by
  4246. // subscribed events
  4247. if ( state.start !== undefined ) {
  4248. settings._iDisplayStart = state.start;
  4249. settings.iInitDisplayStart = state.start;
  4250. }
  4251. if ( state.length !== undefined ) {
  4252. settings._iDisplayLength = state.length;
  4253. }
  4254. // Order
  4255. if ( state.order !== undefined ) {
  4256. settings.aaSorting = [];
  4257. $.each( state.order, function ( i, col ) {
  4258. settings.aaSorting.push( col[0] >= columns.length ?
  4259. [ 0, col[1] ] :
  4260. col
  4261. );
  4262. } );
  4263. }
  4264. // Search
  4265. if ( state.search !== undefined ) {
  4266. $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) );
  4267. }
  4268. // Columns
  4269. for ( i=0, ien=state.columns.length ; i<ien ; i++ ) {
  4270. var col = state.columns[i];
  4271. // Visibility
  4272. if ( col.visible !== undefined ) {
  4273. columns[i].bVisible = col.visible;
  4274. }
  4275. // Search
  4276. if ( col.search !== undefined ) {
  4277. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  4278. }
  4279. }
  4280. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, state] );
  4281. }
  4282. /**
  4283. * Return the settings object for a particular table
  4284. * @param {node} table table we are using as a dataTable
  4285. * @returns {object} Settings object - or null if not found
  4286. * @memberof DataTable#oApi
  4287. */
  4288. function _fnSettingsFromNode ( table )
  4289. {
  4290. var settings = DataTable.settings;
  4291. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  4292. return idx !== -1 ?
  4293. settings[ idx ] :
  4294. null;
  4295. }
  4296. /**
  4297. * Log an error message
  4298. * @param {object} settings dataTables settings object
  4299. * @param {int} level log error messages, or display them to the user
  4300. * @param {string} msg error message
  4301. * @param {int} tn Technical note id to get more information about the error.
  4302. * @memberof DataTable#oApi
  4303. */
  4304. function _fnLog( settings, level, msg, tn )
  4305. {
  4306. msg = 'DataTables warning: '+
  4307. (settings!==null ? 'table id='+settings.sTableId+' - ' : '')+msg;
  4308. if ( tn ) {
  4309. msg += '. For more information about this error, please see '+
  4310. 'http://datatables.net/tn/'+tn;
  4311. }
  4312. if ( ! level ) {
  4313. // Backwards compatibility pre 1.10
  4314. var ext = DataTable.ext;
  4315. var type = ext.sErrMode || ext.errMode;
  4316. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  4317. if ( type == 'alert' ) {
  4318. alert( msg );
  4319. }
  4320. else if ( type == 'throw' ) {
  4321. throw new Error(msg);
  4322. }
  4323. else if ( typeof type == 'function' ) {
  4324. type( settings, tn, msg );
  4325. }
  4326. }
  4327. else if ( window.console && console.log ) {
  4328. console.log( msg );
  4329. }
  4330. }
  4331. /**
  4332. * See if a property is defined on one object, if so assign it to the other object
  4333. * @param {object} ret target object
  4334. * @param {object} src source object
  4335. * @param {string} name property
  4336. * @param {string} [mappedName] name to map too - optional, name used if not given
  4337. * @memberof DataTable#oApi
  4338. */
  4339. function _fnMap( ret, src, name, mappedName )
  4340. {
  4341. if ( $.isArray( name ) ) {
  4342. $.each( name, function (i, val) {
  4343. if ( $.isArray( val ) ) {
  4344. _fnMap( ret, src, val[0], val[1] );
  4345. }
  4346. else {
  4347. _fnMap( ret, src, val );
  4348. }
  4349. } );
  4350. return;
  4351. }
  4352. if ( mappedName === undefined ) {
  4353. mappedName = name;
  4354. }
  4355. if ( src[name] !== undefined ) {
  4356. ret[mappedName] = src[name];
  4357. }
  4358. }
  4359. /**
  4360. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  4361. * shallow copy arrays. The reason we need to do this, is that we don't want to
  4362. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  4363. * able to override them, but we do want to deep copy arrays.
  4364. * @param {object} out Object to extend
  4365. * @param {object} extender Object from which the properties will be applied to
  4366. * out
  4367. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  4368. * independent copy with the exception of the `data` or `aaData` parameters
  4369. * if they are present. This is so you can pass in a collection to
  4370. * DataTables and have that used as your data source without breaking the
  4371. * references
  4372. * @returns {object} out Reference, just for convenience - out === the return.
  4373. * @memberof DataTable#oApi
  4374. * @todo This doesn't take account of arrays inside the deep copied objects.
  4375. */
  4376. function _fnExtend( out, extender, breakRefs )
  4377. {
  4378. var val;
  4379. for ( var prop in extender ) {
  4380. if ( extender.hasOwnProperty(prop) ) {
  4381. val = extender[prop];
  4382. if ( $.isPlainObject( val ) ) {
  4383. if ( ! $.isPlainObject( out[prop] ) ) {
  4384. out[prop] = {};
  4385. }
  4386. $.extend( true, out[prop], val );
  4387. }
  4388. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  4389. out[prop] = val.slice();
  4390. }
  4391. else {
  4392. out[prop] = val;
  4393. }
  4394. }
  4395. }
  4396. return out;
  4397. }
  4398. /**
  4399. * Bind an event handers to allow a click or return key to activate the callback.
  4400. * This is good for accessibility since a return on the keyboard will have the
  4401. * same effect as a click, if the element has focus.
  4402. * @param {element} n Element to bind the action to
  4403. * @param {object} oData Data object to pass to the triggered function
  4404. * @param {function} fn Callback function for when the event is triggered
  4405. * @memberof DataTable#oApi
  4406. */
  4407. function _fnBindAction( n, oData, fn )
  4408. {
  4409. $(n)
  4410. .bind( 'click.DT', oData, function (e) {
  4411. n.blur(); // Remove focus outline for mouse users
  4412. fn(e);
  4413. } )
  4414. .bind( 'keypress.DT', oData, function (e){
  4415. if ( e.which === 13 ) {
  4416. e.preventDefault();
  4417. fn(e);
  4418. }
  4419. } )
  4420. .bind( 'selectstart.DT', function () {
  4421. /* Take the brutal approach to cancelling text selection */
  4422. return false;
  4423. } );
  4424. }
  4425. /**
  4426. * Register a callback function. Easily allows a callback function to be added to
  4427. * an array store of callback functions that can then all be called together.
  4428. * @param {object} oSettings dataTables settings object
  4429. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  4430. * @param {function} fn Function to be called back
  4431. * @param {string} sName Identifying name for the callback (i.e. a label)
  4432. * @memberof DataTable#oApi
  4433. */
  4434. function _fnCallbackReg( oSettings, sStore, fn, sName )
  4435. {
  4436. if ( fn )
  4437. {
  4438. oSettings[sStore].push( {
  4439. "fn": fn,
  4440. "sName": sName
  4441. } );
  4442. }
  4443. }
  4444. /**
  4445. * Fire callback functions and trigger events. Note that the loop over the
  4446. * callback array store is done backwards! Further note that you do not want to
  4447. * fire off triggers in time sensitive applications (for example cell creation)
  4448. * as its slow.
  4449. * @param {object} settings dataTables settings object
  4450. * @param {string} callbackArr Name of the array storage for the callbacks in
  4451. * oSettings
  4452. * @param {string} eventName Name of the jQuery custom event to trigger. If
  4453. * null no trigger is fired
  4454. * @param {array} args Array of arguments to pass to the callback function /
  4455. * trigger
  4456. * @memberof DataTable#oApi
  4457. */
  4458. function _fnCallbackFire( settings, callbackArr, eventName, args )
  4459. {
  4460. var ret = [];
  4461. if ( callbackArr ) {
  4462. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  4463. return val.fn.apply( settings.oInstance, args );
  4464. } );
  4465. }
  4466. if ( eventName !== null ) {
  4467. var e = $.Event( eventName+'.dt' );
  4468. $(settings.nTable).trigger( e, args );
  4469. ret.push( e.result );
  4470. }
  4471. return ret;
  4472. }
  4473. function _fnLengthOverflow ( settings )
  4474. {
  4475. var
  4476. start = settings._iDisplayStart,
  4477. end = settings.fnDisplayEnd(),
  4478. len = settings._iDisplayLength;
  4479. /* If we have space to show extra rows (backing up from the end point - then do so */
  4480. if ( start >= end )
  4481. {
  4482. start = end - len;
  4483. }
  4484. // Keep the start record on the current page
  4485. start -= (start % len);
  4486. if ( len === -1 || start < 0 )
  4487. {
  4488. start = 0;
  4489. }
  4490. settings._iDisplayStart = start;
  4491. }
  4492. function _fnRenderer( settings, type )
  4493. {
  4494. var renderer = settings.renderer;
  4495. var host = DataTable.ext.renderer[type];
  4496. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  4497. // Specific renderer for this type. If available use it, otherwise use
  4498. // the default.
  4499. return host[renderer[type]] || host._;
  4500. }
  4501. else if ( typeof renderer === 'string' ) {
  4502. // Common renderer - if there is one available for this type use it,
  4503. // otherwise use the default
  4504. return host[renderer] || host._;
  4505. }
  4506. // Use the default
  4507. return host._;
  4508. }
  4509. /**
  4510. * Detect the data source being used for the table. Used to simplify the code
  4511. * a little (ajax) and to make it compress a little smaller.
  4512. *
  4513. * @param {object} settings dataTables settings object
  4514. * @returns {string} Data source
  4515. * @memberof DataTable#oApi
  4516. */
  4517. function _fnDataSource ( settings )
  4518. {
  4519. if ( settings.oFeatures.bServerSide ) {
  4520. return 'ssp';
  4521. }
  4522. else if ( settings.ajax || settings.sAjaxSource ) {
  4523. return 'ajax';
  4524. }
  4525. return 'dom';
  4526. }
  4527. DataTable = function( options )
  4528. {
  4529. /**
  4530. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  4531. * return the resulting jQuery object.
  4532. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4533. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4534. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  4535. * criterion ("applied") or all TR elements (i.e. no filter).
  4536. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  4537. * Can be either 'current', whereby the current sorting of the table is used, or
  4538. * 'original' whereby the original order the data was read into the table is used.
  4539. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4540. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4541. * 'current' and filter is 'applied', regardless of what they might be given as.
  4542. * @returns {object} jQuery object, filtered by the given selector.
  4543. * @dtopt API
  4544. * @deprecated Since v1.10
  4545. *
  4546. * @example
  4547. * $(document).ready(function() {
  4548. * var oTable = $('#example').dataTable();
  4549. *
  4550. * // Highlight every second row
  4551. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  4552. * } );
  4553. *
  4554. * @example
  4555. * $(document).ready(function() {
  4556. * var oTable = $('#example').dataTable();
  4557. *
  4558. * // Filter to rows with 'Webkit' in them, add a background colour and then
  4559. * // remove the filter, thus highlighting the 'Webkit' rows only.
  4560. * oTable.fnFilter('Webkit');
  4561. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  4562. * oTable.fnFilter('');
  4563. * } );
  4564. */
  4565. this.$ = function ( sSelector, oOpts )
  4566. {
  4567. return this.api(true).$( sSelector, oOpts );
  4568. };
  4569. /**
  4570. * Almost identical to $ in operation, but in this case returns the data for the matched
  4571. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  4572. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  4573. * rows are found, the data returned is the original data array/object that was used to
  4574. * create the row (or a generated array if from a DOM source).
  4575. *
  4576. * This method is often useful in-combination with $ where both functions are given the
  4577. * same parameters and the array indexes will match identically.
  4578. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4579. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4580. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  4581. * criterion ("applied") or all elements (i.e. no filter).
  4582. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  4583. * Can be either 'current', whereby the current sorting of the table is used, or
  4584. * 'original' whereby the original order the data was read into the table is used.
  4585. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4586. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4587. * 'current' and filter is 'applied', regardless of what they might be given as.
  4588. * @returns {array} Data for the matched elements. If any elements, as a result of the
  4589. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  4590. * entry in the array.
  4591. * @dtopt API
  4592. * @deprecated Since v1.10
  4593. *
  4594. * @example
  4595. * $(document).ready(function() {
  4596. * var oTable = $('#example').dataTable();
  4597. *
  4598. * // Get the data from the first row in the table
  4599. * var data = oTable._('tr:first');
  4600. *
  4601. * // Do something useful with the data
  4602. * alert( "First cell is: "+data[0] );
  4603. * } );
  4604. *
  4605. * @example
  4606. * $(document).ready(function() {
  4607. * var oTable = $('#example').dataTable();
  4608. *
  4609. * // Filter to 'Webkit' and get all data for
  4610. * oTable.fnFilter('Webkit');
  4611. * var data = oTable._('tr', {"search": "applied"});
  4612. *
  4613. * // Do something with the data
  4614. * alert( data.length+" rows matched the search" );
  4615. * } );
  4616. */
  4617. this._ = function ( sSelector, oOpts )
  4618. {
  4619. return this.api(true).rows( sSelector, oOpts ).data();
  4620. };
  4621. /**
  4622. * Create a DataTables Api instance, with the currently selected tables for
  4623. * the Api's context.
  4624. * @param {boolean} [traditional=false] Set the API instance's context to be
  4625. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  4626. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  4627. * or if all tables captured in the jQuery object should be used.
  4628. * @return {DataTables.Api}
  4629. */
  4630. this.api = function ( traditional )
  4631. {
  4632. return traditional ?
  4633. new _Api(
  4634. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  4635. ) :
  4636. new _Api( this );
  4637. };
  4638. /**
  4639. * Add a single new row or multiple rows of data to the table. Please note
  4640. * that this is suitable for client-side processing only - if you are using
  4641. * server-side processing (i.e. "bServerSide": true), then to add data, you
  4642. * must add it to the data source, i.e. the server-side, through an Ajax call.
  4643. * @param {array|object} data The data to be added to the table. This can be:
  4644. * <ul>
  4645. * <li>1D array of data - add a single row with the data provided</li>
  4646. * <li>2D array of arrays - add multiple rows in a single call</li>
  4647. * <li>object - data object when using <i>mData</i></li>
  4648. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  4649. * </ul>
  4650. * @param {bool} [redraw=true] redraw the table or not
  4651. * @returns {array} An array of integers, representing the list of indexes in
  4652. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  4653. * the table.
  4654. * @dtopt API
  4655. * @deprecated Since v1.10
  4656. *
  4657. * @example
  4658. * // Global var for counter
  4659. * var giCount = 2;
  4660. *
  4661. * $(document).ready(function() {
  4662. * $('#example').dataTable();
  4663. * } );
  4664. *
  4665. * function fnClickAddRow() {
  4666. * $('#example').dataTable().fnAddData( [
  4667. * giCount+".1",
  4668. * giCount+".2",
  4669. * giCount+".3",
  4670. * giCount+".4" ]
  4671. * );
  4672. *
  4673. * giCount++;
  4674. * }
  4675. */
  4676. this.fnAddData = function( data, redraw )
  4677. {
  4678. var api = this.api( true );
  4679. /* Check if we want to add multiple rows or not */
  4680. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  4681. api.rows.add( data ) :
  4682. api.row.add( data );
  4683. if ( redraw === undefined || redraw ) {
  4684. api.draw();
  4685. }
  4686. return rows.flatten().toArray();
  4687. };
  4688. /**
  4689. * This function will make DataTables recalculate the column sizes, based on the data
  4690. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  4691. * through the sWidth parameter). This can be useful when the width of the table's
  4692. * parent element changes (for example a window resize).
  4693. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  4694. * @dtopt API
  4695. * @deprecated Since v1.10
  4696. *
  4697. * @example
  4698. * $(document).ready(function() {
  4699. * var oTable = $('#example').dataTable( {
  4700. * "sScrollY": "200px",
  4701. * "bPaginate": false
  4702. * } );
  4703. *
  4704. * $(window).bind('resize', function () {
  4705. * oTable.fnAdjustColumnSizing();
  4706. * } );
  4707. * } );
  4708. */
  4709. this.fnAdjustColumnSizing = function ( bRedraw )
  4710. {
  4711. var api = this.api( true ).columns.adjust();
  4712. var settings = api.settings()[0];
  4713. var scroll = settings.oScroll;
  4714. if ( bRedraw === undefined || bRedraw ) {
  4715. api.draw( false );
  4716. }
  4717. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  4718. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  4719. _fnScrollDraw( settings );
  4720. }
  4721. };
  4722. /**
  4723. * Quickly and simply clear a table
  4724. * @param {bool} [bRedraw=true] redraw the table or not
  4725. * @dtopt API
  4726. * @deprecated Since v1.10
  4727. *
  4728. * @example
  4729. * $(document).ready(function() {
  4730. * var oTable = $('#example').dataTable();
  4731. *
  4732. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  4733. * oTable.fnClearTable();
  4734. * } );
  4735. */
  4736. this.fnClearTable = function( bRedraw )
  4737. {
  4738. var api = this.api( true ).clear();
  4739. if ( bRedraw === undefined || bRedraw ) {
  4740. api.draw();
  4741. }
  4742. };
  4743. /**
  4744. * The exact opposite of 'opening' a row, this function will close any rows which
  4745. * are currently 'open'.
  4746. * @param {node} nTr the table row to 'close'
  4747. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  4748. * @dtopt API
  4749. * @deprecated Since v1.10
  4750. *
  4751. * @example
  4752. * $(document).ready(function() {
  4753. * var oTable;
  4754. *
  4755. * // 'open' an information row when a row is clicked on
  4756. * $('#example tbody tr').click( function () {
  4757. * if ( oTable.fnIsOpen(this) ) {
  4758. * oTable.fnClose( this );
  4759. * } else {
  4760. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4761. * }
  4762. * } );
  4763. *
  4764. * oTable = $('#example').dataTable();
  4765. * } );
  4766. */
  4767. this.fnClose = function( nTr )
  4768. {
  4769. this.api( true ).row( nTr ).child.hide();
  4770. };
  4771. /**
  4772. * Remove a row for the table
  4773. * @param {mixed} target The index of the row from aoData to be deleted, or
  4774. * the TR element you want to delete
  4775. * @param {function|null} [callBack] Callback function
  4776. * @param {bool} [redraw=true] Redraw the table or not
  4777. * @returns {array} The row that was deleted
  4778. * @dtopt API
  4779. * @deprecated Since v1.10
  4780. *
  4781. * @example
  4782. * $(document).ready(function() {
  4783. * var oTable = $('#example').dataTable();
  4784. *
  4785. * // Immediately remove the first row
  4786. * oTable.fnDeleteRow( 0 );
  4787. * } );
  4788. */
  4789. this.fnDeleteRow = function( target, callback, redraw )
  4790. {
  4791. var api = this.api( true );
  4792. var rows = api.rows( target );
  4793. var settings = rows.settings()[0];
  4794. var data = settings.aoData[ rows[0][0] ];
  4795. rows.remove();
  4796. if ( callback ) {
  4797. callback.call( this, settings, data );
  4798. }
  4799. if ( redraw === undefined || redraw ) {
  4800. api.draw();
  4801. }
  4802. return data;
  4803. };
  4804. /**
  4805. * Restore the table to it's original state in the DOM by removing all of DataTables
  4806. * enhancements, alterations to the DOM structure of the table and event listeners.
  4807. * @param {boolean} [remove=false] Completely remove the table from the DOM
  4808. * @dtopt API
  4809. * @deprecated Since v1.10
  4810. *
  4811. * @example
  4812. * $(document).ready(function() {
  4813. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  4814. * var oTable = $('#example').dataTable();
  4815. * oTable.fnDestroy();
  4816. * } );
  4817. */
  4818. this.fnDestroy = function ( remove )
  4819. {
  4820. this.api( true ).destroy( remove );
  4821. };
  4822. /**
  4823. * Redraw the table
  4824. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  4825. * @dtopt API
  4826. * @deprecated Since v1.10
  4827. *
  4828. * @example
  4829. * $(document).ready(function() {
  4830. * var oTable = $('#example').dataTable();
  4831. *
  4832. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  4833. * oTable.fnDraw();
  4834. * } );
  4835. */
  4836. this.fnDraw = function( complete )
  4837. {
  4838. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  4839. // into account the new data, but can hold position.
  4840. this.api( true ).draw( complete );
  4841. };
  4842. /**
  4843. * Filter the input based on data
  4844. * @param {string} sInput String to filter the table on
  4845. * @param {int|null} [iColumn] Column to limit filtering to
  4846. * @param {bool} [bRegex=false] Treat as regular expression or not
  4847. * @param {bool} [bSmart=true] Perform smart filtering or not
  4848. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  4849. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  4850. * @dtopt API
  4851. * @deprecated Since v1.10
  4852. *
  4853. * @example
  4854. * $(document).ready(function() {
  4855. * var oTable = $('#example').dataTable();
  4856. *
  4857. * // Sometime later - filter...
  4858. * oTable.fnFilter( 'test string' );
  4859. * } );
  4860. */
  4861. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  4862. {
  4863. var api = this.api( true );
  4864. if ( iColumn === null || iColumn === undefined ) {
  4865. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  4866. }
  4867. else {
  4868. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  4869. }
  4870. api.draw();
  4871. };
  4872. /**
  4873. * Get the data for the whole table, an individual row or an individual cell based on the
  4874. * provided parameters.
  4875. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  4876. * a TR node then the data source for the whole row will be returned. If given as a
  4877. * TD/TH cell node then iCol will be automatically calculated and the data for the
  4878. * cell returned. If given as an integer, then this is treated as the aoData internal
  4879. * data index for the row (see fnGetPosition) and the data for that row used.
  4880. * @param {int} [col] Optional column index that you want the data of.
  4881. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  4882. * returned. If mRow is defined, just data for that row, and is iCol is
  4883. * defined, only data for the designated cell is returned.
  4884. * @dtopt API
  4885. * @deprecated Since v1.10
  4886. *
  4887. * @example
  4888. * // Row data
  4889. * $(document).ready(function() {
  4890. * oTable = $('#example').dataTable();
  4891. *
  4892. * oTable.$('tr').click( function () {
  4893. * var data = oTable.fnGetData( this );
  4894. * // ... do something with the array / object of data for the row
  4895. * } );
  4896. * } );
  4897. *
  4898. * @example
  4899. * // Individual cell data
  4900. * $(document).ready(function() {
  4901. * oTable = $('#example').dataTable();
  4902. *
  4903. * oTable.$('td').click( function () {
  4904. * var sData = oTable.fnGetData( this );
  4905. * alert( 'The cell clicked on had the value of '+sData );
  4906. * } );
  4907. * } );
  4908. */
  4909. this.fnGetData = function( src, col )
  4910. {
  4911. var api = this.api( true );
  4912. if ( src !== undefined ) {
  4913. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  4914. return col !== undefined || type == 'td' || type == 'th' ?
  4915. api.cell( src, col ).data() :
  4916. api.row( src ).data() || null;
  4917. }
  4918. return api.data().toArray();
  4919. };
  4920. /**
  4921. * Get an array of the TR nodes that are used in the table's body. Note that you will
  4922. * typically want to use the '$' API method in preference to this as it is more
  4923. * flexible.
  4924. * @param {int} [iRow] Optional row index for the TR element you want
  4925. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  4926. * in the table's body, or iRow is defined, just the TR element requested.
  4927. * @dtopt API
  4928. * @deprecated Since v1.10
  4929. *
  4930. * @example
  4931. * $(document).ready(function() {
  4932. * var oTable = $('#example').dataTable();
  4933. *
  4934. * // Get the nodes from the table
  4935. * var nNodes = oTable.fnGetNodes( );
  4936. * } );
  4937. */
  4938. this.fnGetNodes = function( iRow )
  4939. {
  4940. var api = this.api( true );
  4941. return iRow !== undefined ?
  4942. api.row( iRow ).node() :
  4943. api.rows().nodes().flatten().toArray();
  4944. };
  4945. /**
  4946. * Get the array indexes of a particular cell from it's DOM element
  4947. * and column index including hidden columns
  4948. * @param {node} node this can either be a TR, TD or TH in the table's body
  4949. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  4950. * if given as a cell, an array of [row index, column index (visible),
  4951. * column index (all)] is given.
  4952. * @dtopt API
  4953. * @deprecated Since v1.10
  4954. *
  4955. * @example
  4956. * $(document).ready(function() {
  4957. * $('#example tbody td').click( function () {
  4958. * // Get the position of the current data from the node
  4959. * var aPos = oTable.fnGetPosition( this );
  4960. *
  4961. * // Get the data array for this row
  4962. * var aData = oTable.fnGetData( aPos[0] );
  4963. *
  4964. * // Update the data array and return the value
  4965. * aData[ aPos[1] ] = 'clicked';
  4966. * this.innerHTML = 'clicked';
  4967. * } );
  4968. *
  4969. * // Init DataTables
  4970. * oTable = $('#example').dataTable();
  4971. * } );
  4972. */
  4973. this.fnGetPosition = function( node )
  4974. {
  4975. var api = this.api( true );
  4976. var nodeName = node.nodeName.toUpperCase();
  4977. if ( nodeName == 'TR' ) {
  4978. return api.row( node ).index();
  4979. }
  4980. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  4981. var cell = api.cell( node ).index();
  4982. return [
  4983. cell.row,
  4984. cell.columnVisible,
  4985. cell.column
  4986. ];
  4987. }
  4988. return null;
  4989. };
  4990. /**
  4991. * Check to see if a row is 'open' or not.
  4992. * @param {node} nTr the table row to check
  4993. * @returns {boolean} true if the row is currently open, false otherwise
  4994. * @dtopt API
  4995. * @deprecated Since v1.10
  4996. *
  4997. * @example
  4998. * $(document).ready(function() {
  4999. * var oTable;
  5000. *
  5001. * // 'open' an information row when a row is clicked on
  5002. * $('#example tbody tr').click( function () {
  5003. * if ( oTable.fnIsOpen(this) ) {
  5004. * oTable.fnClose( this );
  5005. * } else {
  5006. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  5007. * }
  5008. * } );
  5009. *
  5010. * oTable = $('#example').dataTable();
  5011. * } );
  5012. */
  5013. this.fnIsOpen = function( nTr )
  5014. {
  5015. return this.api( true ).row( nTr ).child.isShown();
  5016. };
  5017. /**
  5018. * This function will place a new row directly after a row which is currently
  5019. * on display on the page, with the HTML contents that is passed into the
  5020. * function. This can be used, for example, to ask for confirmation that a
  5021. * particular record should be deleted.
  5022. * @param {node} nTr The table row to 'open'
  5023. * @param {string|node|jQuery} mHtml The HTML to put into the row
  5024. * @param {string} sClass Class to give the new TD cell
  5025. * @returns {node} The row opened. Note that if the table row passed in as the
  5026. * first parameter, is not found in the table, this method will silently
  5027. * return.
  5028. * @dtopt API
  5029. * @deprecated Since v1.10
  5030. *
  5031. * @example
  5032. * $(document).ready(function() {
  5033. * var oTable;
  5034. *
  5035. * // 'open' an information row when a row is clicked on
  5036. * $('#example tbody tr').click( function () {
  5037. * if ( oTable.fnIsOpen(this) ) {
  5038. * oTable.fnClose( this );
  5039. * } else {
  5040. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  5041. * }
  5042. * } );
  5043. *
  5044. * oTable = $('#example').dataTable();
  5045. * } );
  5046. */
  5047. this.fnOpen = function( nTr, mHtml, sClass )
  5048. {
  5049. return this.api( true )
  5050. .row( nTr )
  5051. .child( mHtml, sClass )
  5052. .show()
  5053. .child()[0];
  5054. };
  5055. /**
  5056. * Change the pagination - provides the internal logic for pagination in a simple API
  5057. * function. With this function you can have a DataTables table go to the next,
  5058. * previous, first or last pages.
  5059. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  5060. * or page number to jump to (integer), note that page 0 is the first page.
  5061. * @param {bool} [bRedraw=true] Redraw the table or not
  5062. * @dtopt API
  5063. * @deprecated Since v1.10
  5064. *
  5065. * @example
  5066. * $(document).ready(function() {
  5067. * var oTable = $('#example').dataTable();
  5068. * oTable.fnPageChange( 'next' );
  5069. * } );
  5070. */
  5071. this.fnPageChange = function ( mAction, bRedraw )
  5072. {
  5073. var api = this.api( true ).page( mAction );
  5074. if ( bRedraw === undefined || bRedraw ) {
  5075. api.draw(false);
  5076. }
  5077. };
  5078. /**
  5079. * Show a particular column
  5080. * @param {int} iCol The column whose display should be changed
  5081. * @param {bool} bShow Show (true) or hide (false) the column
  5082. * @param {bool} [bRedraw=true] Redraw the table or not
  5083. * @dtopt API
  5084. * @deprecated Since v1.10
  5085. *
  5086. * @example
  5087. * $(document).ready(function() {
  5088. * var oTable = $('#example').dataTable();
  5089. *
  5090. * // Hide the second column after initialisation
  5091. * oTable.fnSetColumnVis( 1, false );
  5092. * } );
  5093. */
  5094. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  5095. {
  5096. var api = this.api( true ).column( iCol ).visible( bShow );
  5097. if ( bRedraw === undefined || bRedraw ) {
  5098. api.columns.adjust().draw();
  5099. }
  5100. };
  5101. /**
  5102. * Get the settings for a particular table for external manipulation
  5103. * @returns {object} DataTables settings object. See
  5104. * {@link DataTable.models.oSettings}
  5105. * @dtopt API
  5106. * @deprecated Since v1.10
  5107. *
  5108. * @example
  5109. * $(document).ready(function() {
  5110. * var oTable = $('#example').dataTable();
  5111. * var oSettings = oTable.fnSettings();
  5112. *
  5113. * // Show an example parameter from the settings
  5114. * alert( oSettings._iDisplayStart );
  5115. * } );
  5116. */
  5117. this.fnSettings = function()
  5118. {
  5119. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  5120. };
  5121. /**
  5122. * Sort the table by a particular column
  5123. * @param {int} iCol the data index to sort on. Note that this will not match the
  5124. * 'display index' if you have hidden data entries
  5125. * @dtopt API
  5126. * @deprecated Since v1.10
  5127. *
  5128. * @example
  5129. * $(document).ready(function() {
  5130. * var oTable = $('#example').dataTable();
  5131. *
  5132. * // Sort immediately with columns 0 and 1
  5133. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  5134. * } );
  5135. */
  5136. this.fnSort = function( aaSort )
  5137. {
  5138. this.api( true ).order( aaSort ).draw();
  5139. };
  5140. /**
  5141. * Attach a sort listener to an element for a given column
  5142. * @param {node} nNode the element to attach the sort listener to
  5143. * @param {int} iColumn the column that a click on this node will sort on
  5144. * @param {function} [fnCallback] callback function when sort is run
  5145. * @dtopt API
  5146. * @deprecated Since v1.10
  5147. *
  5148. * @example
  5149. * $(document).ready(function() {
  5150. * var oTable = $('#example').dataTable();
  5151. *
  5152. * // Sort on column 1, when 'sorter' is clicked on
  5153. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  5154. * } );
  5155. */
  5156. this.fnSortListener = function( nNode, iColumn, fnCallback )
  5157. {
  5158. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  5159. };
  5160. /**
  5161. * Update a table cell or row - this method will accept either a single value to
  5162. * update the cell with, an array of values with one element for each column or
  5163. * an object in the same format as the original data source. The function is
  5164. * self-referencing in order to make the multi column updates easier.
  5165. * @param {object|array|string} mData Data to update the cell/row with
  5166. * @param {node|int} mRow TR element you want to update or the aoData index
  5167. * @param {int} [iColumn] The column to update, give as null or undefined to
  5168. * update a whole row.
  5169. * @param {bool} [bRedraw=true] Redraw the table or not
  5170. * @param {bool} [bAction=true] Perform pre-draw actions or not
  5171. * @returns {int} 0 on success, 1 on error
  5172. * @dtopt API
  5173. * @deprecated Since v1.10
  5174. *
  5175. * @example
  5176. * $(document).ready(function() {
  5177. * var oTable = $('#example').dataTable();
  5178. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  5179. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  5180. * } );
  5181. */
  5182. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  5183. {
  5184. var api = this.api( true );
  5185. if ( iColumn === undefined || iColumn === null ) {
  5186. api.row( mRow ).data( mData );
  5187. }
  5188. else {
  5189. api.cell( mRow, iColumn ).data( mData );
  5190. }
  5191. if ( bAction === undefined || bAction ) {
  5192. api.columns.adjust();
  5193. }
  5194. if ( bRedraw === undefined || bRedraw ) {
  5195. api.draw();
  5196. }
  5197. return 0;
  5198. };
  5199. /**
  5200. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  5201. * to ensure compatibility.
  5202. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  5203. * formats "X" and "X.Y" are also acceptable.
  5204. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  5205. * version, or false if this version of DataTales is not suitable
  5206. * @method
  5207. * @dtopt API
  5208. * @deprecated Since v1.10
  5209. *
  5210. * @example
  5211. * $(document).ready(function() {
  5212. * var oTable = $('#example').dataTable();
  5213. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  5214. * } );
  5215. */
  5216. this.fnVersionCheck = _ext.fnVersionCheck;
  5217. var _that = this;
  5218. var emptyInit = options === undefined;
  5219. var len = this.length;
  5220. if ( emptyInit ) {
  5221. options = {};
  5222. }
  5223. this.oApi = this.internal = _ext.internal;
  5224. // Extend with old style plug-in API methods
  5225. for ( var fn in DataTable.ext.internal ) {
  5226. if ( fn ) {
  5227. this[fn] = _fnExternApiFunc(fn);
  5228. }
  5229. }
  5230. this.each(function() {
  5231. // For each initialisation we want to give it a clean initialisation
  5232. // object that can be bashed around
  5233. var o = {};
  5234. var oInit = len > 1 ? // optimisation for single table case
  5235. _fnExtend( o, options, true ) :
  5236. options;
  5237. /*global oInit,_that,emptyInit*/
  5238. var i=0, iLen, j, jLen, k, kLen;
  5239. var sId = this.getAttribute( 'id' );
  5240. var bInitHandedOff = false;
  5241. var defaults = DataTable.defaults;
  5242. var $this = $(this);
  5243. /* Sanity check */
  5244. if ( this.nodeName.toLowerCase() != 'table' )
  5245. {
  5246. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  5247. return;
  5248. }
  5249. /* Backwards compatibility for the defaults */
  5250. _fnCompatOpts( defaults );
  5251. _fnCompatCols( defaults.column );
  5252. /* Convert the camel-case defaults to Hungarian */
  5253. _fnCamelToHungarian( defaults, defaults, true );
  5254. _fnCamelToHungarian( defaults.column, defaults.column, true );
  5255. /* Setting up the initialisation object */
  5256. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ) );
  5257. /* Check to see if we are re-initialising a table */
  5258. var allSettings = DataTable.settings;
  5259. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  5260. {
  5261. var s = allSettings[i];
  5262. /* Base check on table node */
  5263. if ( s.nTable == this || s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this) )
  5264. {
  5265. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  5266. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  5267. if ( emptyInit || bRetrieve )
  5268. {
  5269. return s.oInstance;
  5270. }
  5271. else if ( bDestroy )
  5272. {
  5273. s.oInstance.fnDestroy();
  5274. break;
  5275. }
  5276. else
  5277. {
  5278. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  5279. return;
  5280. }
  5281. }
  5282. /* If the element we are initialising has the same ID as a table which was previously
  5283. * initialised, but the table nodes don't match (from before) then we destroy the old
  5284. * instance by simply deleting it. This is under the assumption that the table has been
  5285. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  5286. */
  5287. if ( s.sTableId == this.id )
  5288. {
  5289. allSettings.splice( i, 1 );
  5290. break;
  5291. }
  5292. }
  5293. /* Ensure the table has an ID - required for accessibility */
  5294. if ( sId === null || sId === "" )
  5295. {
  5296. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  5297. this.id = sId;
  5298. }
  5299. /* Create the settings object for this table and set some of the default parameters */
  5300. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  5301. "sDestroyWidth": $this[0].style.width,
  5302. "sInstance": sId,
  5303. "sTableId": sId
  5304. } );
  5305. oSettings.nTable = this;
  5306. oSettings.oApi = _that.internal;
  5307. oSettings.oInit = oInit;
  5308. allSettings.push( oSettings );
  5309. // Need to add the instance after the instance after the settings object has been added
  5310. // to the settings array, so we can self reference the table instance if more than one
  5311. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  5312. // Backwards compatibility, before we apply all the defaults
  5313. _fnCompatOpts( oInit );
  5314. if ( oInit.oLanguage )
  5315. {
  5316. _fnLanguageCompat( oInit.oLanguage );
  5317. }
  5318. // If the length menu is given, but the init display length is not, use the length menu
  5319. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  5320. {
  5321. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  5322. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  5323. }
  5324. // Apply the defaults and init options to make a single init object will all
  5325. // options defined from defaults and instance options.
  5326. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  5327. // Map the initialisation options onto the settings object
  5328. _fnMap( oSettings.oFeatures, oInit, [
  5329. "bPaginate",
  5330. "bLengthChange",
  5331. "bFilter",
  5332. "bSort",
  5333. "bSortMulti",
  5334. "bInfo",
  5335. "bProcessing",
  5336. "bAutoWidth",
  5337. "bSortClasses",
  5338. "bServerSide",
  5339. "bDeferRender"
  5340. ] );
  5341. _fnMap( oSettings, oInit, [
  5342. "asStripeClasses",
  5343. "ajax",
  5344. "fnServerData",
  5345. "fnFormatNumber",
  5346. "sServerMethod",
  5347. "aaSorting",
  5348. "aaSortingFixed",
  5349. "aLengthMenu",
  5350. "sPaginationType",
  5351. "sAjaxSource",
  5352. "sAjaxDataProp",
  5353. "iStateDuration",
  5354. "sDom",
  5355. "bSortCellsTop",
  5356. "iTabIndex",
  5357. "fnStateLoadCallback",
  5358. "fnStateSaveCallback",
  5359. "renderer",
  5360. "searchDelay",
  5361. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  5362. [ "oSearch", "oPreviousSearch" ],
  5363. [ "aoSearchCols", "aoPreSearchCols" ],
  5364. [ "iDisplayLength", "_iDisplayLength" ],
  5365. [ "bJQueryUI", "bJUI" ]
  5366. ] );
  5367. _fnMap( oSettings.oScroll, oInit, [
  5368. [ "sScrollX", "sX" ],
  5369. [ "sScrollXInner", "sXInner" ],
  5370. [ "sScrollY", "sY" ],
  5371. [ "bScrollCollapse", "bCollapse" ]
  5372. ] );
  5373. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  5374. /* Callback functions which are array driven */
  5375. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  5376. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  5377. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  5378. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  5379. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  5380. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  5381. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  5382. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  5383. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  5384. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  5385. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  5386. var oClasses = oSettings.oClasses;
  5387. // @todo Remove in 1.11
  5388. if ( oInit.bJQueryUI )
  5389. {
  5390. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  5391. * you want to have multiple tables with multiple independent classes
  5392. */
  5393. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  5394. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  5395. {
  5396. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  5397. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  5398. }
  5399. if ( ! oSettings.renderer ) {
  5400. oSettings.renderer = 'jqueryui';
  5401. }
  5402. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  5403. oSettings.renderer.header = 'jqueryui';
  5404. }
  5405. }
  5406. else
  5407. {
  5408. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  5409. }
  5410. $this.addClass( oClasses.sTable );
  5411. /* Calculate the scroll bar width and cache it for use later on */
  5412. if ( oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "" )
  5413. {
  5414. oSettings.oScroll.iBarWidth = _fnScrollBarWidth();
  5415. }
  5416. if ( oSettings.oScroll.sX === true ) { // Easy initialisation of x-scrolling
  5417. oSettings.oScroll.sX = '100%';
  5418. }
  5419. if ( oSettings.iInitDisplayStart === undefined )
  5420. {
  5421. /* Display start point, taking into account the save saving */
  5422. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  5423. oSettings._iDisplayStart = oInit.iDisplayStart;
  5424. }
  5425. if ( oInit.iDeferLoading !== null )
  5426. {
  5427. oSettings.bDeferLoading = true;
  5428. var tmp = $.isArray( oInit.iDeferLoading );
  5429. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  5430. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  5431. }
  5432. /* Language definitions */
  5433. var oLanguage = oSettings.oLanguage;
  5434. $.extend( true, oLanguage, oInit.oLanguage );
  5435. if ( oLanguage.sUrl !== "" )
  5436. {
  5437. /* Get the language definitions from a file - because this Ajax call makes the language
  5438. * get async to the remainder of this function we use bInitHandedOff to indicate that
  5439. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  5440. */
  5441. $.ajax( {
  5442. dataType: 'json',
  5443. url: oLanguage.sUrl,
  5444. success: function ( json ) {
  5445. _fnLanguageCompat( json );
  5446. _fnCamelToHungarian( defaults.oLanguage, json );
  5447. $.extend( true, oLanguage, json );
  5448. _fnInitialise( oSettings );
  5449. },
  5450. error: function () {
  5451. // Error occurred loading language file, continue on as best we can
  5452. _fnInitialise( oSettings );
  5453. }
  5454. } );
  5455. bInitHandedOff = true;
  5456. }
  5457. /*
  5458. * Stripes
  5459. */
  5460. if ( oInit.asStripeClasses === null )
  5461. {
  5462. oSettings.asStripeClasses =[
  5463. oClasses.sStripeOdd,
  5464. oClasses.sStripeEven
  5465. ];
  5466. }
  5467. /* Remove row stripe classes if they are already on the table row */
  5468. var stripeClasses = oSettings.asStripeClasses;
  5469. var rowOne = $this.children('tbody').find('tr').eq(0);
  5470. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  5471. return rowOne.hasClass(el);
  5472. } ) ) !== -1 ) {
  5473. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  5474. oSettings.asDestroyStripes = stripeClasses.slice();
  5475. }
  5476. /*
  5477. * Columns
  5478. * See if we should load columns automatically or use defined ones
  5479. */
  5480. var anThs = [];
  5481. var aoColumnsInit;
  5482. var nThead = this.getElementsByTagName('thead');
  5483. if ( nThead.length !== 0 )
  5484. {
  5485. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  5486. anThs = _fnGetUniqueThs( oSettings );
  5487. }
  5488. /* If not given a column array, generate one with nulls */
  5489. if ( oInit.aoColumns === null )
  5490. {
  5491. aoColumnsInit = [];
  5492. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  5493. {
  5494. aoColumnsInit.push( null );
  5495. }
  5496. }
  5497. else
  5498. {
  5499. aoColumnsInit = oInit.aoColumns;
  5500. }
  5501. /* Add the columns */
  5502. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  5503. {
  5504. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  5505. }
  5506. /* Apply the column definitions */
  5507. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  5508. _fnColumnOptions( oSettings, iCol, oDef );
  5509. } );
  5510. /* HTML5 attribute detection - build an mData object automatically if the
  5511. * attributes are found
  5512. */
  5513. if ( rowOne.length ) {
  5514. var a = function ( cell, name ) {
  5515. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  5516. };
  5517. $.each( _fnGetRowElements( oSettings, rowOne[0] ).cells, function (i, cell) {
  5518. var col = oSettings.aoColumns[i];
  5519. if ( col.mData === i ) {
  5520. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  5521. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  5522. if ( sort !== null || filter !== null ) {
  5523. col.mData = {
  5524. _: i+'.display',
  5525. sort: sort !== null ? i+'.@data-'+sort : undefined,
  5526. type: sort !== null ? i+'.@data-'+sort : undefined,
  5527. filter: filter !== null ? i+'.@data-'+filter : undefined
  5528. };
  5529. _fnColumnOptions( oSettings, i );
  5530. }
  5531. }
  5532. } );
  5533. }
  5534. var features = oSettings.oFeatures;
  5535. /* Must be done after everything which can be overridden by the state saving! */
  5536. if ( oInit.bStateSave )
  5537. {
  5538. features.bStateSave = true;
  5539. _fnLoadState( oSettings, oInit );
  5540. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  5541. }
  5542. /*
  5543. * Sorting
  5544. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  5545. */
  5546. // If aaSorting is not defined, then we use the first indicator in asSorting
  5547. // in case that has been altered, so the default sort reflects that option
  5548. if ( oInit.aaSorting === undefined )
  5549. {
  5550. var sorting = oSettings.aaSorting;
  5551. for ( i=0, iLen=sorting.length ; i<iLen ; i++ )
  5552. {
  5553. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  5554. }
  5555. }
  5556. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  5557. * account, and also will apply sorting disabled classes if disabled
  5558. */
  5559. _fnSortingClasses( oSettings );
  5560. if ( features.bSort )
  5561. {
  5562. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5563. if ( oSettings.bSorted ) {
  5564. var aSort = _fnSortFlatten( oSettings );
  5565. var sortedColumns = {};
  5566. $.each( aSort, function (i, val) {
  5567. sortedColumns[ val.src ] = val.dir;
  5568. } );
  5569. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  5570. _fnSortAria( oSettings );
  5571. }
  5572. } );
  5573. }
  5574. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5575. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  5576. _fnSortingClasses( oSettings );
  5577. }
  5578. }, 'sc' );
  5579. /*
  5580. * Final init
  5581. * Cache the header, body and footer as required, creating them if needed
  5582. */
  5583. /* Browser support detection */
  5584. _fnBrowserDetect( oSettings );
  5585. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  5586. var captions = $this.children('caption').each( function () {
  5587. this._captionSide = $this.css('caption-side');
  5588. } );
  5589. var thead = $this.children('thead');
  5590. if ( thead.length === 0 )
  5591. {
  5592. thead = $('<thead/>').appendTo(this);
  5593. }
  5594. oSettings.nTHead = thead[0];
  5595. var tbody = $this.children('tbody');
  5596. if ( tbody.length === 0 )
  5597. {
  5598. tbody = $('<tbody/>').appendTo(this);
  5599. }
  5600. oSettings.nTBody = tbody[0];
  5601. var tfoot = $this.children('tfoot');
  5602. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  5603. {
  5604. // If we are a scrolling table, and no footer has been given, then we need to create
  5605. // a tfoot element for the caption element to be appended to
  5606. tfoot = $('<tfoot/>').appendTo(this);
  5607. }
  5608. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  5609. $this.addClass( oClasses.sNoFooter );
  5610. }
  5611. else if ( tfoot.length > 0 ) {
  5612. oSettings.nTFoot = tfoot[0];
  5613. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  5614. }
  5615. /* Check if there is data passing into the constructor */
  5616. if ( oInit.aaData )
  5617. {
  5618. for ( i=0 ; i<oInit.aaData.length ; i++ )
  5619. {
  5620. _fnAddData( oSettings, oInit.aaData[ i ] );
  5621. }
  5622. }
  5623. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  5624. {
  5625. /* Grab the data from the page - only do this when deferred loading or no Ajax
  5626. * source since there is no point in reading the DOM data if we are then going
  5627. * to replace it with Ajax data
  5628. */
  5629. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  5630. }
  5631. /* Copy the data index array */
  5632. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  5633. /* Initialisation complete - table can be drawn */
  5634. oSettings.bInitialised = true;
  5635. /* Check if we need to initialise the table (it might not have been handed off to the
  5636. * language processor)
  5637. */
  5638. if ( bInitHandedOff === false )
  5639. {
  5640. _fnInitialise( oSettings );
  5641. }
  5642. } );
  5643. _that = null;
  5644. return this;
  5645. };
  5646. /**
  5647. * Computed structure of the DataTables API, defined by the options passed to
  5648. * `DataTable.Api.register()` when building the API.
  5649. *
  5650. * The structure is built in order to speed creation and extension of the Api
  5651. * objects since the extensions are effectively pre-parsed.
  5652. *
  5653. * The array is an array of objects with the following structure, where this
  5654. * base array represents the Api prototype base:
  5655. *
  5656. * [
  5657. * {
  5658. * name: 'data' -- string - Property name
  5659. * val: function () {}, -- function - Api method (or undefined if just an object
  5660. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5661. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5662. * },
  5663. * {
  5664. * name: 'row'
  5665. * val: {},
  5666. * methodExt: [ ... ],
  5667. * propExt: [
  5668. * {
  5669. * name: 'data'
  5670. * val: function () {},
  5671. * methodExt: [ ... ],
  5672. * propExt: [ ... ]
  5673. * },
  5674. * ...
  5675. * ]
  5676. * }
  5677. * ]
  5678. *
  5679. * @type {Array}
  5680. * @ignore
  5681. */
  5682. var __apiStruct = [];
  5683. /**
  5684. * `Array.prototype` reference.
  5685. *
  5686. * @type object
  5687. * @ignore
  5688. */
  5689. var __arrayProto = Array.prototype;
  5690. /**
  5691. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5692. * take several different forms for ease of use.
  5693. *
  5694. * Each of the input parameter types will be converted to a DataTables settings
  5695. * object where possible.
  5696. *
  5697. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5698. * of:
  5699. *
  5700. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5701. * with be found and used.
  5702. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5703. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5704. * * `object` - DataTables settings object
  5705. * * `DataTables.Api` - API instance
  5706. * @return {array|null} Matching DataTables settings objects. `null` or
  5707. * `undefined` is returned if no matching DataTable is found.
  5708. * @ignore
  5709. */
  5710. var _toSettings = function ( mixed )
  5711. {
  5712. var idx, jq;
  5713. var settings = DataTable.settings;
  5714. var tables = $.map( settings, function (el, i) {
  5715. return el.nTable;
  5716. } );
  5717. if ( ! mixed ) {
  5718. return [];
  5719. }
  5720. else if ( mixed.nTable && mixed.oApi ) {
  5721. // DataTables settings object
  5722. return [ mixed ];
  5723. }
  5724. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5725. // Table node
  5726. idx = $.inArray( mixed, tables );
  5727. return idx !== -1 ? [ settings[idx] ] : null;
  5728. }
  5729. else if ( mixed && typeof mixed.settings === 'function' ) {
  5730. return mixed.settings().toArray();
  5731. }
  5732. else if ( typeof mixed === 'string' ) {
  5733. // jQuery selector
  5734. jq = $(mixed);
  5735. }
  5736. else if ( mixed instanceof $ ) {
  5737. // jQuery object (also DataTables instance)
  5738. jq = mixed;
  5739. }
  5740. if ( jq ) {
  5741. return jq.map( function(i) {
  5742. idx = $.inArray( this, tables );
  5743. return idx !== -1 ? settings[idx] : null;
  5744. } ).toArray();
  5745. }
  5746. };
  5747. /**
  5748. * DataTables API class - used to control and interface with one or more
  5749. * DataTables enhanced tables.
  5750. *
  5751. * The API class is heavily based on jQuery, presenting a chainable interface
  5752. * that you can use to interact with tables. Each instance of the API class has
  5753. * a "context" - i.e. the tables that it will operate on. This could be a single
  5754. * table, all tables on a page or a sub-set thereof.
  5755. *
  5756. * Additionally the API is designed to allow you to easily work with the data in
  5757. * the tables, retrieving and manipulating it as required. This is done by
  5758. * presenting the API class as an array like interface. The contents of the
  5759. * array depend upon the actions requested by each method (for example
  5760. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5761. * return an array of objects or arrays depending upon your table's
  5762. * configuration). The API object has a number of array like methods (`push`,
  5763. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5764. * `unique` etc) to assist your working with the data held in a table.
  5765. *
  5766. * Most methods (those which return an Api instance) are chainable, which means
  5767. * the return from a method call also has all of the methods available that the
  5768. * top level object had. For example, these two calls are equivalent:
  5769. *
  5770. * // Not chained
  5771. * api.row.add( {...} );
  5772. * api.draw();
  5773. *
  5774. * // Chained
  5775. * api.row.add( {...} ).draw();
  5776. *
  5777. * @class DataTable.Api
  5778. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5779. * used to define which DataTables enhanced tables this API will operate on.
  5780. * Can be one of:
  5781. *
  5782. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5783. * with be found and used.
  5784. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5785. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5786. * * `object` - DataTables settings object
  5787. * @param {array} [data] Data to initialise the Api instance with.
  5788. *
  5789. * @example
  5790. * // Direct initialisation during DataTables construction
  5791. * var api = $('#example').DataTable();
  5792. *
  5793. * @example
  5794. * // Initialisation using a DataTables jQuery object
  5795. * var api = $('#example').dataTable().api();
  5796. *
  5797. * @example
  5798. * // Initialisation as a constructor
  5799. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5800. */
  5801. _Api = function ( context, data )
  5802. {
  5803. if ( ! (this instanceof _Api) ) {
  5804. return new _Api( context, data );
  5805. }
  5806. var settings = [];
  5807. var ctxSettings = function ( o ) {
  5808. var a = _toSettings( o );
  5809. if ( a ) {
  5810. settings.push.apply( settings, a );
  5811. }
  5812. };
  5813. if ( $.isArray( context ) ) {
  5814. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5815. ctxSettings( context[i] );
  5816. }
  5817. }
  5818. else {
  5819. ctxSettings( context );
  5820. }
  5821. // Remove duplicates
  5822. this.context = _unique( settings );
  5823. // Initial data
  5824. if ( data ) {
  5825. this.push.apply( this, data.toArray ? data.toArray() : data );
  5826. }
  5827. // selector
  5828. this.selector = {
  5829. rows: null,
  5830. cols: null,
  5831. opts: null
  5832. };
  5833. _Api.extend( this, this, __apiStruct );
  5834. };
  5835. DataTable.Api = _Api;
  5836. _Api.prototype = /** @lends DataTables.Api */{
  5837. any: function ()
  5838. {
  5839. return this.flatten().length !== 0;
  5840. },
  5841. concat: __arrayProto.concat,
  5842. context: [], // array of table settings objects
  5843. each: function ( fn )
  5844. {
  5845. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5846. fn.call( this, this[i], i, this );
  5847. }
  5848. return this;
  5849. },
  5850. eq: function ( idx )
  5851. {
  5852. var ctx = this.context;
  5853. return ctx.length > idx ?
  5854. new _Api( ctx[idx], this[idx] ) :
  5855. null;
  5856. },
  5857. filter: function ( fn )
  5858. {
  5859. var a = [];
  5860. if ( __arrayProto.filter ) {
  5861. a = __arrayProto.filter.call( this, fn, this );
  5862. }
  5863. else {
  5864. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5865. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5866. if ( fn.call( this, this[i], i, this ) ) {
  5867. a.push( this[i] );
  5868. }
  5869. }
  5870. }
  5871. return new _Api( this.context, a );
  5872. },
  5873. flatten: function ()
  5874. {
  5875. var a = [];
  5876. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  5877. },
  5878. join: __arrayProto.join,
  5879. indexOf: __arrayProto.indexOf || function (obj, start)
  5880. {
  5881. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  5882. if ( this[i] === obj ) {
  5883. return i;
  5884. }
  5885. }
  5886. return -1;
  5887. },
  5888. iterator: function ( flatten, type, fn, alwaysNew ) {
  5889. var
  5890. a = [], ret,
  5891. i, ien, j, jen,
  5892. context = this.context,
  5893. rows, items, item,
  5894. selector = this.selector;
  5895. // Argument shifting
  5896. if ( typeof flatten === 'string' ) {
  5897. alwaysNew = fn;
  5898. fn = type;
  5899. type = flatten;
  5900. flatten = false;
  5901. }
  5902. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  5903. var apiInst = new _Api( context[i] );
  5904. if ( type === 'table' ) {
  5905. ret = fn.call( apiInst, context[i], i );
  5906. if ( ret !== undefined ) {
  5907. a.push( ret );
  5908. }
  5909. }
  5910. else if ( type === 'columns' || type === 'rows' ) {
  5911. // this has same length as context - one entry for each table
  5912. ret = fn.call( apiInst, context[i], this[i], i );
  5913. if ( ret !== undefined ) {
  5914. a.push( ret );
  5915. }
  5916. }
  5917. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  5918. // columns and rows share the same structure.
  5919. // 'this' is an array of column indexes for each context
  5920. items = this[i];
  5921. if ( type === 'column-rows' ) {
  5922. rows = _selector_row_indexes( context[i], selector.opts );
  5923. }
  5924. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  5925. item = items[j];
  5926. if ( type === 'cell' ) {
  5927. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  5928. }
  5929. else {
  5930. ret = fn.call( apiInst, context[i], item, i, j, rows );
  5931. }
  5932. if ( ret !== undefined ) {
  5933. a.push( ret );
  5934. }
  5935. }
  5936. }
  5937. }
  5938. if ( a.length || alwaysNew ) {
  5939. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  5940. var apiSelector = api.selector;
  5941. apiSelector.rows = selector.rows;
  5942. apiSelector.cols = selector.cols;
  5943. apiSelector.opts = selector.opts;
  5944. return api;
  5945. }
  5946. return this;
  5947. },
  5948. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  5949. {
  5950. // Bit cheeky...
  5951. return this.indexOf.apply( this.toArray.reverse(), arguments );
  5952. },
  5953. length: 0,
  5954. map: function ( fn )
  5955. {
  5956. var a = [];
  5957. if ( __arrayProto.map ) {
  5958. a = __arrayProto.map.call( this, fn, this );
  5959. }
  5960. else {
  5961. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5962. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5963. a.push( fn.call( this, this[i], i ) );
  5964. }
  5965. }
  5966. return new _Api( this.context, a );
  5967. },
  5968. pluck: function ( prop )
  5969. {
  5970. return this.map( function ( el ) {
  5971. return el[ prop ];
  5972. } );
  5973. },
  5974. pop: __arrayProto.pop,
  5975. push: __arrayProto.push,
  5976. // Does not return an API instance
  5977. reduce: __arrayProto.reduce || function ( fn, init )
  5978. {
  5979. return _fnReduce( this, fn, init, 0, this.length, 1 );
  5980. },
  5981. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  5982. {
  5983. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  5984. },
  5985. reverse: __arrayProto.reverse,
  5986. // Object with rows, columns and opts
  5987. selector: null,
  5988. shift: __arrayProto.shift,
  5989. sort: __arrayProto.sort, // ? name - order?
  5990. splice: __arrayProto.splice,
  5991. toArray: function ()
  5992. {
  5993. return __arrayProto.slice.call( this );
  5994. },
  5995. to$: function ()
  5996. {
  5997. return $( this );
  5998. },
  5999. toJQuery: function ()
  6000. {
  6001. return $( this );
  6002. },
  6003. unique: function ()
  6004. {
  6005. return new _Api( this.context, _unique(this) );
  6006. },
  6007. unshift: __arrayProto.unshift
  6008. };
  6009. _Api.extend = function ( scope, obj, ext )
  6010. {
  6011. // Only extend API instances and static properties of the API
  6012. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6013. return;
  6014. }
  6015. var
  6016. i, ien,
  6017. j, jen,
  6018. struct, inner,
  6019. methodScoping = function ( scope, fn, struc ) {
  6020. return function () {
  6021. var ret = fn.apply( scope, arguments );
  6022. // Method extension
  6023. _Api.extend( ret, ret, struc.methodExt );
  6024. return ret;
  6025. };
  6026. };
  6027. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6028. struct = ext[i];
  6029. // Value
  6030. obj[ struct.name ] = typeof struct.val === 'function' ?
  6031. methodScoping( scope, struct.val, struct ) :
  6032. $.isPlainObject( struct.val ) ?
  6033. {} :
  6034. struct.val;
  6035. obj[ struct.name ].__dt_wrapper = true;
  6036. // Property extension
  6037. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6038. }
  6039. };
  6040. // @todo - Is there need for an augment function?
  6041. // _Api.augment = function ( inst, name )
  6042. // {
  6043. // // Find src object in the structure from the name
  6044. // var parts = name.split('.');
  6045. // _Api.extend( inst, obj );
  6046. // };
  6047. // [
  6048. // {
  6049. // name: 'data' -- string - Property name
  6050. // val: function () {}, -- function - Api method (or undefined if just an object
  6051. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6052. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6053. // },
  6054. // {
  6055. // name: 'row'
  6056. // val: {},
  6057. // methodExt: [ ... ],
  6058. // propExt: [
  6059. // {
  6060. // name: 'data'
  6061. // val: function () {},
  6062. // methodExt: [ ... ],
  6063. // propExt: [ ... ]
  6064. // },
  6065. // ...
  6066. // ]
  6067. // }
  6068. // ]
  6069. _Api.register = _api_register = function ( name, val )
  6070. {
  6071. if ( $.isArray( name ) ) {
  6072. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6073. _Api.register( name[j], val );
  6074. }
  6075. return;
  6076. }
  6077. var
  6078. i, ien,
  6079. heir = name.split('.'),
  6080. struct = __apiStruct,
  6081. key, method;
  6082. var find = function ( src, name ) {
  6083. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6084. if ( src[i].name === name ) {
  6085. return src[i];
  6086. }
  6087. }
  6088. return null;
  6089. };
  6090. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6091. method = heir[i].indexOf('()') !== -1;
  6092. key = method ?
  6093. heir[i].replace('()', '') :
  6094. heir[i];
  6095. var src = find( struct, key );
  6096. if ( ! src ) {
  6097. src = {
  6098. name: key,
  6099. val: {},
  6100. methodExt: [],
  6101. propExt: []
  6102. };
  6103. struct.push( src );
  6104. }
  6105. if ( i === ien-1 ) {
  6106. src.val = val;
  6107. }
  6108. else {
  6109. struct = method ?
  6110. src.methodExt :
  6111. src.propExt;
  6112. }
  6113. }
  6114. };
  6115. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6116. _Api.register( pluralName, val );
  6117. _Api.register( singularName, function () {
  6118. var ret = val.apply( this, arguments );
  6119. if ( ret === this ) {
  6120. // Returned item is the API instance that was passed in, return it
  6121. return this;
  6122. }
  6123. else if ( ret instanceof _Api ) {
  6124. // New API instance returned, want the value from the first item
  6125. // in the returned array for the singular result.
  6126. return ret.length ?
  6127. $.isArray( ret[0] ) ?
  6128. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6129. ret[0] :
  6130. undefined;
  6131. }
  6132. // Non-API return - just fire it back
  6133. return ret;
  6134. } );
  6135. };
  6136. /**
  6137. * Selector for HTML tables. Apply the given selector to the give array of
  6138. * DataTables settings objects.
  6139. *
  6140. * @param {string|integer} [selector] jQuery selector string or integer
  6141. * @param {array} Array of DataTables settings objects to be filtered
  6142. * @return {array}
  6143. * @ignore
  6144. */
  6145. var __table_selector = function ( selector, a )
  6146. {
  6147. // Integer is used to pick out a table by index
  6148. if ( typeof selector === 'number' ) {
  6149. return [ a[ selector ] ];
  6150. }
  6151. // Perform a jQuery selector on the table nodes
  6152. var nodes = $.map( a, function (el, i) {
  6153. return el.nTable;
  6154. } );
  6155. return $(nodes)
  6156. .filter( selector )
  6157. .map( function (i) {
  6158. // Need to translate back from the table node to the settings
  6159. var idx = $.inArray( this, nodes );
  6160. return a[ idx ];
  6161. } )
  6162. .toArray();
  6163. };
  6164. /**
  6165. * Context selector for the API's context (i.e. the tables the API instance
  6166. * refers to.
  6167. *
  6168. * @name DataTable.Api#tables
  6169. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6170. * should operate on. If not given, all tables in the current context are
  6171. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6172. * select multiple tables or as an integer to select a single table.
  6173. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6174. */
  6175. _api_register( 'tables()', function ( selector ) {
  6176. // A new instance is created if there was a selector specified
  6177. return selector ?
  6178. new _Api( __table_selector( selector, this.context ) ) :
  6179. this;
  6180. } );
  6181. _api_register( 'table()', function ( selector ) {
  6182. var tables = this.tables( selector );
  6183. var ctx = tables.context;
  6184. // Truncate to the first matched table
  6185. return ctx.length ?
  6186. new _Api( ctx[0] ) :
  6187. tables;
  6188. } );
  6189. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6190. return this.iterator( 'table', function ( ctx ) {
  6191. return ctx.nTable;
  6192. }, 1 );
  6193. } );
  6194. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6195. return this.iterator( 'table', function ( ctx ) {
  6196. return ctx.nTBody;
  6197. }, 1 );
  6198. } );
  6199. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6200. return this.iterator( 'table', function ( ctx ) {
  6201. return ctx.nTHead;
  6202. }, 1 );
  6203. } );
  6204. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6205. return this.iterator( 'table', function ( ctx ) {
  6206. return ctx.nTFoot;
  6207. }, 1 );
  6208. } );
  6209. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6210. return this.iterator( 'table', function ( ctx ) {
  6211. return ctx.nTableWrapper;
  6212. }, 1 );
  6213. } );
  6214. /**
  6215. * Redraw the tables in the current context.
  6216. *
  6217. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6218. * position. A full re-sort and re-filter is performed when this method is
  6219. * called, which is why the pagination reset is the default action.
  6220. * @returns {DataTables.Api} this
  6221. */
  6222. _api_register( 'draw()', function ( resetPaging ) {
  6223. return this.iterator( 'table', function ( settings ) {
  6224. _fnReDraw( settings, resetPaging===false );
  6225. } );
  6226. } );
  6227. /**
  6228. * Get the current page index.
  6229. *
  6230. * @return {integer} Current page index (zero based)
  6231. *//**
  6232. * Set the current page.
  6233. *
  6234. * Note that if you attempt to show a page which does not exist, DataTables will
  6235. * not throw an error, but rather reset the paging.
  6236. *
  6237. * @param {integer|string} action The paging action to take. This can be one of:
  6238. * * `integer` - The page index to jump to
  6239. * * `string` - An action to take:
  6240. * * `first` - Jump to first page.
  6241. * * `next` - Jump to the next page
  6242. * * `previous` - Jump to previous page
  6243. * * `last` - Jump to the last page.
  6244. * @returns {DataTables.Api} this
  6245. */
  6246. _api_register( 'page()', function ( action ) {
  6247. if ( action === undefined ) {
  6248. return this.page.info().page; // not an expensive call
  6249. }
  6250. // else, have an action to take on all tables
  6251. return this.iterator( 'table', function ( settings ) {
  6252. _fnPageChange( settings, action );
  6253. } );
  6254. } );
  6255. /**
  6256. * Paging information for the first table in the current context.
  6257. *
  6258. * If you require paging information for another table, use the `table()` method
  6259. * with a suitable selector.
  6260. *
  6261. * @return {object} Object with the following properties set:
  6262. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6263. * * `pages` - Total number of pages
  6264. * * `start` - Display index for the first record shown on the current page
  6265. * * `end` - Display index for the last record shown on the current page
  6266. * * `length` - Display length (number of records). Note that generally `start
  6267. * + length = end`, but this is not always true, for example if there are
  6268. * only 2 records to show on the final page, with a length of 10.
  6269. * * `recordsTotal` - Full data set length
  6270. * * `recordsDisplay` - Data set length once the current filtering criterion
  6271. * are applied.
  6272. */
  6273. _api_register( 'page.info()', function ( action ) {
  6274. if ( this.context.length === 0 ) {
  6275. return undefined;
  6276. }
  6277. var
  6278. settings = this.context[0],
  6279. start = settings._iDisplayStart,
  6280. len = settings._iDisplayLength,
  6281. visRecords = settings.fnRecordsDisplay(),
  6282. all = len === -1;
  6283. return {
  6284. "page": all ? 0 : Math.floor( start / len ),
  6285. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6286. "start": start,
  6287. "end": settings.fnDisplayEnd(),
  6288. "length": len,
  6289. "recordsTotal": settings.fnRecordsTotal(),
  6290. "recordsDisplay": visRecords
  6291. };
  6292. } );
  6293. /**
  6294. * Get the current page length.
  6295. *
  6296. * @return {integer} Current page length. Note `-1` indicates that all records
  6297. * are to be shown.
  6298. *//**
  6299. * Set the current page length.
  6300. *
  6301. * @param {integer} Page length to set. Use `-1` to show all records.
  6302. * @returns {DataTables.Api} this
  6303. */
  6304. _api_register( 'page.len()', function ( len ) {
  6305. // Note that we can't call this function 'length()' because `length`
  6306. // is a Javascript property of functions which defines how many arguments
  6307. // the function expects.
  6308. if ( len === undefined ) {
  6309. return this.context.length !== 0 ?
  6310. this.context[0]._iDisplayLength :
  6311. undefined;
  6312. }
  6313. // else, set the page length
  6314. return this.iterator( 'table', function ( settings ) {
  6315. _fnLengthChange( settings, len );
  6316. } );
  6317. } );
  6318. var __reload = function ( settings, holdPosition, callback ) {
  6319. // Use the draw event to trigger a callback
  6320. if ( callback ) {
  6321. var api = new _Api( settings );
  6322. api.one( 'draw', function () {
  6323. callback( api.ajax.json() );
  6324. } );
  6325. }
  6326. if ( _fnDataSource( settings ) == 'ssp' ) {
  6327. _fnReDraw( settings, holdPosition );
  6328. }
  6329. else {
  6330. // Trigger xhr
  6331. _fnProcessingDisplay( settings, true );
  6332. _fnBuildAjax( settings, [], function( json ) {
  6333. _fnClearTable( settings );
  6334. var data = _fnAjaxDataSrc( settings, json );
  6335. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6336. _fnAddData( settings, data[i] );
  6337. }
  6338. _fnReDraw( settings, holdPosition );
  6339. _fnProcessingDisplay( settings, false );
  6340. } );
  6341. }
  6342. };
  6343. /**
  6344. * Get the JSON response from the last Ajax request that DataTables made to the
  6345. * server. Note that this returns the JSON from the first table in the current
  6346. * context.
  6347. *
  6348. * @return {object} JSON received from the server.
  6349. */
  6350. _api_register( 'ajax.json()', function () {
  6351. var ctx = this.context;
  6352. if ( ctx.length > 0 ) {
  6353. return ctx[0].json;
  6354. }
  6355. // else return undefined;
  6356. } );
  6357. /**
  6358. * Get the data submitted in the last Ajax request
  6359. */
  6360. _api_register( 'ajax.params()', function () {
  6361. var ctx = this.context;
  6362. if ( ctx.length > 0 ) {
  6363. return ctx[0].oAjaxData;
  6364. }
  6365. // else return undefined;
  6366. } );
  6367. /**
  6368. * Reload tables from the Ajax data source. Note that this function will
  6369. * automatically re-draw the table when the remote data has been loaded.
  6370. *
  6371. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6372. * position. A full re-sort and re-filter is performed when this method is
  6373. * called, which is why the pagination reset is the default action.
  6374. * @returns {DataTables.Api} this
  6375. */
  6376. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6377. return this.iterator( 'table', function (settings) {
  6378. __reload( settings, resetPaging===false, callback );
  6379. } );
  6380. } );
  6381. /**
  6382. * Get the current Ajax URL. Note that this returns the URL from the first
  6383. * table in the current context.
  6384. *
  6385. * @return {string} Current Ajax source URL
  6386. *//**
  6387. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6388. * current context.
  6389. *
  6390. * @param {string} url URL to set.
  6391. * @returns {DataTables.Api} this
  6392. */
  6393. _api_register( 'ajax.url()', function ( url ) {
  6394. var ctx = this.context;
  6395. if ( url === undefined ) {
  6396. // get
  6397. if ( ctx.length === 0 ) {
  6398. return undefined;
  6399. }
  6400. ctx = ctx[0];
  6401. return ctx.ajax ?
  6402. $.isPlainObject( ctx.ajax ) ?
  6403. ctx.ajax.url :
  6404. ctx.ajax :
  6405. ctx.sAjaxSource;
  6406. }
  6407. // set
  6408. return this.iterator( 'table', function ( settings ) {
  6409. if ( $.isPlainObject( settings.ajax ) ) {
  6410. settings.ajax.url = url;
  6411. }
  6412. else {
  6413. settings.ajax = url;
  6414. }
  6415. // No need to consider sAjaxSource here since DataTables gives priority
  6416. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6417. // value of `sAjaxSource` redundant.
  6418. } );
  6419. } );
  6420. /**
  6421. * Load data from the newly set Ajax URL. Note that this method is only
  6422. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6423. * has the same effect as calling `ajax.reload()` but is provided for
  6424. * convenience when setting a new URL. Like `ajax.reload()` it will
  6425. * automatically redraw the table once the remote data has been loaded.
  6426. *
  6427. * @returns {DataTables.Api} this
  6428. */
  6429. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6430. // Same as a reload, but makes sense to present it for easy access after a
  6431. // url change
  6432. return this.iterator( 'table', function ( ctx ) {
  6433. __reload( ctx, resetPaging===false, callback );
  6434. } );
  6435. } );
  6436. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6437. {
  6438. var
  6439. out = [], res,
  6440. a, i, ien, j, jen,
  6441. selectorType = typeof selector;
  6442. // Can't just check for isArray here, as an API or jQuery instance might be
  6443. // given with their array like look
  6444. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6445. selector = [ selector ];
  6446. }
  6447. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6448. a = selector[i] && selector[i].split ?
  6449. selector[i].split(',') :
  6450. [ selector[i] ];
  6451. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6452. res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6453. if ( res && res.length ) {
  6454. out.push.apply( out, res );
  6455. }
  6456. }
  6457. }
  6458. // selector extensions
  6459. var ext = _ext.selector[ type ];
  6460. if ( ext.length ) {
  6461. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6462. out = ext[i]( settings, opts, out );
  6463. }
  6464. }
  6465. return out;
  6466. };
  6467. var _selector_opts = function ( opts )
  6468. {
  6469. if ( ! opts ) {
  6470. opts = {};
  6471. }
  6472. // Backwards compatibility for 1.9- which used the terminology filter rather
  6473. // than search
  6474. if ( opts.filter && opts.search === undefined ) {
  6475. opts.search = opts.filter;
  6476. }
  6477. return $.extend( {
  6478. search: 'none',
  6479. order: 'current',
  6480. page: 'all'
  6481. }, opts );
  6482. };
  6483. var _selector_first = function ( inst )
  6484. {
  6485. // Reduce the API instance to the first item found
  6486. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6487. if ( inst[i].length > 0 ) {
  6488. // Assign the first element to the first item in the instance
  6489. // and truncate the instance and context
  6490. inst[0] = inst[i];
  6491. inst[0].length = 1;
  6492. inst.length = 1;
  6493. inst.context = [ inst.context[i] ];
  6494. return inst;
  6495. }
  6496. }
  6497. // Not found - return an empty instance
  6498. inst.length = 0;
  6499. return inst;
  6500. };
  6501. var _selector_row_indexes = function ( settings, opts )
  6502. {
  6503. var
  6504. i, ien, tmp, a=[],
  6505. displayFiltered = settings.aiDisplay,
  6506. displayMaster = settings.aiDisplayMaster;
  6507. var
  6508. search = opts.search, // none, applied, removed
  6509. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6510. page = opts.page; // all, current
  6511. if ( _fnDataSource( settings ) == 'ssp' ) {
  6512. // In server-side processing mode, most options are irrelevant since
  6513. // rows not shown don't exist and the index order is the applied order
  6514. // Removed is a special case - for consistency just return an empty
  6515. // array
  6516. return search === 'removed' ?
  6517. [] :
  6518. _range( 0, displayMaster.length );
  6519. }
  6520. else if ( page == 'current' ) {
  6521. // Current page implies that order=current and fitler=applied, since it is
  6522. // fairly senseless otherwise, regardless of what order and search actually
  6523. // are
  6524. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6525. a.push( displayFiltered[i] );
  6526. }
  6527. }
  6528. else if ( order == 'current' || order == 'applied' ) {
  6529. a = search == 'none' ?
  6530. displayMaster.slice() : // no search
  6531. search == 'applied' ?
  6532. displayFiltered.slice() : // applied search
  6533. $.map( displayMaster, function (el, i) { // removed search
  6534. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6535. } );
  6536. }
  6537. else if ( order == 'index' || order == 'original' ) {
  6538. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6539. if ( search == 'none' ) {
  6540. a.push( i );
  6541. }
  6542. else { // applied | removed
  6543. tmp = $.inArray( i, displayFiltered );
  6544. if ((tmp === -1 && search == 'removed') ||
  6545. (tmp >= 0 && search == 'applied') )
  6546. {
  6547. a.push( i );
  6548. }
  6549. }
  6550. }
  6551. }
  6552. return a;
  6553. };
  6554. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6555. * Rows
  6556. *
  6557. * {} - no selector - use all available rows
  6558. * {integer} - row aoData index
  6559. * {node} - TR node
  6560. * {string} - jQuery selector to apply to the TR elements
  6561. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6562. *
  6563. */
  6564. var __row_selector = function ( settings, selector, opts )
  6565. {
  6566. var run = function ( sel ) {
  6567. var selInt = _intVal( sel );
  6568. var i, ien;
  6569. // Short cut - selector is a number and no options provided (default is
  6570. // all records, so no need to check if the index is in there, since it
  6571. // must be - dev error if the index doesn't exist).
  6572. if ( selInt !== null && ! opts ) {
  6573. return [ selInt ];
  6574. }
  6575. var rows = _selector_row_indexes( settings, opts );
  6576. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6577. // Selector - integer
  6578. return [ selInt ];
  6579. }
  6580. else if ( ! sel ) {
  6581. // Selector - none
  6582. return rows;
  6583. }
  6584. // Selector - function
  6585. if ( typeof sel === 'function' ) {
  6586. return $.map( rows, function (idx) {
  6587. var row = settings.aoData[ idx ];
  6588. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6589. } );
  6590. }
  6591. // Get nodes in the order from the `rows` array with null values removed
  6592. var nodes = _removeEmpty(
  6593. _pluck_order( settings.aoData, rows, 'nTr' )
  6594. );
  6595. // Selector - node
  6596. if ( sel.nodeName ) {
  6597. if ( $.inArray( sel, nodes ) !== -1 ) {
  6598. return [ sel._DT_RowIndex ]; // sel is a TR node that is in the table
  6599. // and DataTables adds a prop for fast lookup
  6600. }
  6601. }
  6602. // Selector - jQuery selector string, array of nodes or jQuery object/
  6603. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6604. // it also allows arrays, so this will cope with all three options
  6605. return $(nodes)
  6606. .filter( sel )
  6607. .map( function () {
  6608. return this._DT_RowIndex;
  6609. } )
  6610. .toArray();
  6611. };
  6612. return _selector_run( 'row', selector, run, settings, opts );
  6613. };
  6614. _api_register( 'rows()', function ( selector, opts ) {
  6615. // argument shifting
  6616. if ( selector === undefined ) {
  6617. selector = '';
  6618. }
  6619. else if ( $.isPlainObject( selector ) ) {
  6620. opts = selector;
  6621. selector = '';
  6622. }
  6623. opts = _selector_opts( opts );
  6624. var inst = this.iterator( 'table', function ( settings ) {
  6625. return __row_selector( settings, selector, opts );
  6626. }, 1 );
  6627. // Want argument shifting here and in __row_selector?
  6628. inst.selector.rows = selector;
  6629. inst.selector.opts = opts;
  6630. return inst;
  6631. } );
  6632. _api_register( 'rows().nodes()', function () {
  6633. return this.iterator( 'row', function ( settings, row ) {
  6634. return settings.aoData[ row ].nTr || undefined;
  6635. }, 1 );
  6636. } );
  6637. _api_register( 'rows().data()', function () {
  6638. return this.iterator( true, 'rows', function ( settings, rows ) {
  6639. return _pluck_order( settings.aoData, rows, '_aData' );
  6640. }, 1 );
  6641. } );
  6642. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6643. return this.iterator( 'row', function ( settings, row ) {
  6644. var r = settings.aoData[ row ];
  6645. return type === 'search' ? r._aFilterData : r._aSortData;
  6646. }, 1 );
  6647. } );
  6648. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6649. return this.iterator( 'row', function ( settings, row ) {
  6650. _fnInvalidate( settings, row, src );
  6651. } );
  6652. } );
  6653. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6654. return this.iterator( 'row', function ( settings, row ) {
  6655. return row;
  6656. }, 1 );
  6657. } );
  6658. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6659. var that = this;
  6660. return this.iterator( 'row', function ( settings, row, thatIdx ) {
  6661. var data = settings.aoData;
  6662. data.splice( row, 1 );
  6663. // Update the _DT_RowIndex parameter on all rows in the table
  6664. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6665. if ( data[i].nTr !== null ) {
  6666. data[i].nTr._DT_RowIndex = i;
  6667. }
  6668. }
  6669. // Remove the target row from the search array
  6670. var displayIndex = $.inArray( row, settings.aiDisplay );
  6671. // Delete from the display arrays
  6672. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6673. _fnDeleteIndex( settings.aiDisplay, row );
  6674. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6675. // Check for an 'overflow' they case for displaying the table
  6676. _fnLengthOverflow( settings );
  6677. } );
  6678. } );
  6679. _api_register( 'rows.add()', function ( rows ) {
  6680. var newRows = this.iterator( 'table', function ( settings ) {
  6681. var row, i, ien;
  6682. var out = [];
  6683. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6684. row = rows[i];
  6685. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6686. out.push( _fnAddTr( settings, row )[0] );
  6687. }
  6688. else {
  6689. out.push( _fnAddData( settings, row ) );
  6690. }
  6691. }
  6692. return out;
  6693. }, 1 );
  6694. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6695. var modRows = this.rows( -1 );
  6696. modRows.pop();
  6697. modRows.push.apply( modRows, newRows.toArray() );
  6698. return modRows;
  6699. } );
  6700. /**
  6701. *
  6702. */
  6703. _api_register( 'row()', function ( selector, opts ) {
  6704. return _selector_first( this.rows( selector, opts ) );
  6705. } );
  6706. _api_register( 'row().data()', function ( data ) {
  6707. var ctx = this.context;
  6708. if ( data === undefined ) {
  6709. // Get
  6710. return ctx.length && this.length ?
  6711. ctx[0].aoData[ this[0] ]._aData :
  6712. undefined;
  6713. }
  6714. // Set
  6715. ctx[0].aoData[ this[0] ]._aData = data;
  6716. // Automatically invalidate
  6717. _fnInvalidate( ctx[0], this[0], 'data' );
  6718. return this;
  6719. } );
  6720. _api_register( 'row().node()', function () {
  6721. var ctx = this.context;
  6722. return ctx.length && this.length ?
  6723. ctx[0].aoData[ this[0] ].nTr || null :
  6724. null;
  6725. } );
  6726. _api_register( 'row.add()', function ( row ) {
  6727. // Allow a jQuery object to be passed in - only a single row is added from
  6728. // it though - the first element in the set
  6729. if ( row instanceof $ && row.length ) {
  6730. row = row[0];
  6731. }
  6732. var rows = this.iterator( 'table', function ( settings ) {
  6733. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6734. return _fnAddTr( settings, row )[0];
  6735. }
  6736. return _fnAddData( settings, row );
  6737. } );
  6738. // Return an Api.rows() extended instance, with the newly added row selected
  6739. return this.row( rows[0] );
  6740. } );
  6741. var __details_add = function ( ctx, row, data, klass )
  6742. {
  6743. // Convert to array of TR elements
  6744. var rows = [];
  6745. var addRow = function ( r, k ) {
  6746. // Recursion to allow for arrays of jQuery objects
  6747. if ( $.isArray( r ) || r instanceof $ ) {
  6748. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  6749. addRow( r[i], k );
  6750. }
  6751. return;
  6752. }
  6753. // If we get a TR element, then just add it directly - up to the dev
  6754. // to add the correct number of columns etc
  6755. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  6756. rows.push( r );
  6757. }
  6758. else {
  6759. // Otherwise create a row with a wrapper
  6760. var created = $('<tr><td/></tr>').addClass( k );
  6761. $('td', created)
  6762. .addClass( k )
  6763. .html( r )
  6764. [0].colSpan = _fnVisbleColumns( ctx );
  6765. rows.push( created[0] );
  6766. }
  6767. };
  6768. addRow( data, klass );
  6769. if ( row._details ) {
  6770. row._details.remove();
  6771. }
  6772. row._details = $(rows);
  6773. // If the children were already shown, that state should be retained
  6774. if ( row._detailsShow ) {
  6775. row._details.insertAfter( row.nTr );
  6776. }
  6777. };
  6778. var __details_remove = function ( api, idx )
  6779. {
  6780. var ctx = api.context;
  6781. if ( ctx.length ) {
  6782. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  6783. if ( row._details ) {
  6784. row._details.remove();
  6785. row._detailsShow = undefined;
  6786. row._details = undefined;
  6787. }
  6788. }
  6789. };
  6790. var __details_display = function ( api, show ) {
  6791. var ctx = api.context;
  6792. if ( ctx.length && api.length ) {
  6793. var row = ctx[0].aoData[ api[0] ];
  6794. if ( row._details ) {
  6795. row._detailsShow = show;
  6796. if ( show ) {
  6797. row._details.insertAfter( row.nTr );
  6798. }
  6799. else {
  6800. row._details.detach();
  6801. }
  6802. __details_events( ctx[0] );
  6803. }
  6804. }
  6805. };
  6806. var __details_events = function ( settings )
  6807. {
  6808. var api = new _Api( settings );
  6809. var namespace = '.dt.DT_details';
  6810. var drawEvent = 'draw'+namespace;
  6811. var colvisEvent = 'column-visibility'+namespace;
  6812. var destroyEvent = 'destroy'+namespace;
  6813. var data = settings.aoData;
  6814. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  6815. if ( _pluck( data, '_details' ).length > 0 ) {
  6816. // On each draw, insert the required elements into the document
  6817. api.on( drawEvent, function ( e, ctx ) {
  6818. if ( settings !== ctx ) {
  6819. return;
  6820. }
  6821. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  6822. // Internal data grab
  6823. var row = data[ idx ];
  6824. if ( row._detailsShow ) {
  6825. row._details.insertAfter( row.nTr );
  6826. }
  6827. } );
  6828. } );
  6829. // Column visibility change - update the colspan
  6830. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  6831. if ( settings !== ctx ) {
  6832. return;
  6833. }
  6834. // Update the colspan for the details rows (note, only if it already has
  6835. // a colspan)
  6836. var row, visible = _fnVisbleColumns( ctx );
  6837. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6838. row = data[i];
  6839. if ( row._details ) {
  6840. row._details.children('td[colspan]').attr('colspan', visible );
  6841. }
  6842. }
  6843. } );
  6844. // Table destroyed - nuke any child rows
  6845. api.on( destroyEvent, function ( e, ctx ) {
  6846. if ( settings !== ctx ) {
  6847. return;
  6848. }
  6849. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6850. if ( data[i]._details ) {
  6851. __details_remove( api, i );
  6852. }
  6853. }
  6854. } );
  6855. }
  6856. };
  6857. // Strings for the method names to help minification
  6858. var _emp = '';
  6859. var _child_obj = _emp+'row().child';
  6860. var _child_mth = _child_obj+'()';
  6861. // data can be:
  6862. // tr
  6863. // string
  6864. // jQuery or array of any of the above
  6865. _api_register( _child_mth, function ( data, klass ) {
  6866. var ctx = this.context;
  6867. if ( data === undefined ) {
  6868. // get
  6869. return ctx.length && this.length ?
  6870. ctx[0].aoData[ this[0] ]._details :
  6871. undefined;
  6872. }
  6873. else if ( data === true ) {
  6874. // show
  6875. this.child.show();
  6876. }
  6877. else if ( data === false ) {
  6878. // remove
  6879. __details_remove( this );
  6880. }
  6881. else if ( ctx.length && this.length ) {
  6882. // set
  6883. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  6884. }
  6885. return this;
  6886. } );
  6887. _api_register( [
  6888. _child_obj+'.show()',
  6889. _child_mth+'.show()' // only when `child()` was called with parameters (without
  6890. ], function ( show ) { // it returns an object and this method is not executed)
  6891. __details_display( this, true );
  6892. return this;
  6893. } );
  6894. _api_register( [
  6895. _child_obj+'.hide()',
  6896. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  6897. ], function () { // it returns an object and this method is not executed)
  6898. __details_display( this, false );
  6899. return this;
  6900. } );
  6901. _api_register( [
  6902. _child_obj+'.remove()',
  6903. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  6904. ], function () { // it returns an object and this method is not executed)
  6905. __details_remove( this );
  6906. return this;
  6907. } );
  6908. _api_register( _child_obj+'.isShown()', function () {
  6909. var ctx = this.context;
  6910. if ( ctx.length && this.length ) {
  6911. // _detailsShown as false or undefined will fall through to return false
  6912. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  6913. }
  6914. return false;
  6915. } );
  6916. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6917. * Columns
  6918. *
  6919. * {integer} - column index (>=0 count from left, <0 count from right)
  6920. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  6921. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  6922. * "{string}:name" - column name
  6923. * "{string}" - jQuery selector on column header nodes
  6924. *
  6925. */
  6926. // can be an array of these items, comma separated list, or an array of comma
  6927. // separated lists
  6928. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  6929. // r1 and r2 are redundant - but it means that the parameters match for the
  6930. // iterator callback in columns().data()
  6931. var __columnData = function ( settings, column, r1, r2, rows ) {
  6932. var a = [];
  6933. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  6934. a.push( _fnGetCellData( settings, rows[row], column ) );
  6935. }
  6936. return a;
  6937. };
  6938. var __column_selector = function ( settings, selector, opts )
  6939. {
  6940. var
  6941. columns = settings.aoColumns,
  6942. names = _pluck( columns, 'sName' ),
  6943. nodes = _pluck( columns, 'nTh' );
  6944. var run = function ( s ) {
  6945. var selInt = _intVal( s );
  6946. // Selector - all
  6947. if ( s === '' ) {
  6948. return _range( columns.length );
  6949. }
  6950. // Selector - index
  6951. if ( selInt !== null ) {
  6952. return [ selInt >= 0 ?
  6953. selInt : // Count from left
  6954. columns.length + selInt // Count from right (+ because its a negative value)
  6955. ];
  6956. }
  6957. // Selector = function
  6958. if ( typeof s === 'function' ) {
  6959. var rows = _selector_row_indexes( settings, opts );
  6960. return $.map( columns, function (col, idx) {
  6961. return s(
  6962. idx,
  6963. __columnData( settings, idx, 0, 0, rows ),
  6964. nodes[ idx ]
  6965. ) ? idx : null;
  6966. } );
  6967. }
  6968. // jQuery or string selector
  6969. var match = typeof s === 'string' ?
  6970. s.match( __re_column_selector ) :
  6971. '';
  6972. if ( match ) {
  6973. switch( match[2] ) {
  6974. case 'visIdx':
  6975. case 'visible':
  6976. var idx = parseInt( match[1], 10 );
  6977. // Visible index given, convert to column index
  6978. if ( idx < 0 ) {
  6979. // Counting from the right
  6980. var visColumns = $.map( columns, function (col,i) {
  6981. return col.bVisible ? i : null;
  6982. } );
  6983. return [ visColumns[ visColumns.length + idx ] ];
  6984. }
  6985. // Counting from the left
  6986. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  6987. case 'name':
  6988. // match by name. `names` is column index complete and in order
  6989. return $.map( names, function (name, i) {
  6990. return name === match[1] ? i : null;
  6991. } );
  6992. }
  6993. }
  6994. else {
  6995. // jQuery selector on the TH elements for the columns
  6996. return $( nodes )
  6997. .filter( s )
  6998. .map( function () {
  6999. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7000. } )
  7001. .toArray();
  7002. }
  7003. };
  7004. return _selector_run( 'column', selector, run, settings, opts );
  7005. };
  7006. var __setColumnVis = function ( settings, column, vis, recalc ) {
  7007. var
  7008. cols = settings.aoColumns,
  7009. col = cols[ column ],
  7010. data = settings.aoData,
  7011. row, cells, i, ien, tr;
  7012. // Get
  7013. if ( vis === undefined ) {
  7014. return col.bVisible;
  7015. }
  7016. // Set
  7017. // No change
  7018. if ( col.bVisible === vis ) {
  7019. return;
  7020. }
  7021. if ( vis ) {
  7022. // Insert column
  7023. // Need to decide if we should use appendChild or insertBefore
  7024. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7025. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7026. tr = data[i].nTr;
  7027. cells = data[i].anCells;
  7028. if ( tr ) {
  7029. // insertBefore can act like appendChild if 2nd arg is null
  7030. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7031. }
  7032. }
  7033. }
  7034. else {
  7035. // Remove column
  7036. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7037. }
  7038. // Common actions
  7039. col.bVisible = vis;
  7040. _fnDrawHead( settings, settings.aoHeader );
  7041. _fnDrawHead( settings, settings.aoFooter );
  7042. if ( recalc === undefined || recalc ) {
  7043. // Automatically adjust column sizing
  7044. _fnAdjustColumnSizing( settings );
  7045. // Realign columns for scrolling
  7046. if ( settings.oScroll.sX || settings.oScroll.sY ) {
  7047. _fnScrollDraw( settings );
  7048. }
  7049. }
  7050. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis] );
  7051. _fnSaveState( settings );
  7052. };
  7053. _api_register( 'columns()', function ( selector, opts ) {
  7054. // argument shifting
  7055. if ( selector === undefined ) {
  7056. selector = '';
  7057. }
  7058. else if ( $.isPlainObject( selector ) ) {
  7059. opts = selector;
  7060. selector = '';
  7061. }
  7062. opts = _selector_opts( opts );
  7063. var inst = this.iterator( 'table', function ( settings ) {
  7064. return __column_selector( settings, selector, opts );
  7065. }, 1 );
  7066. // Want argument shifting here and in _row_selector?
  7067. inst.selector.cols = selector;
  7068. inst.selector.opts = opts;
  7069. return inst;
  7070. } );
  7071. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7072. return this.iterator( 'column', function ( settings, column ) {
  7073. return settings.aoColumns[column].nTh;
  7074. }, 1 );
  7075. } );
  7076. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7077. return this.iterator( 'column', function ( settings, column ) {
  7078. return settings.aoColumns[column].nTf;
  7079. }, 1 );
  7080. } );
  7081. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7082. return this.iterator( 'column-rows', __columnData, 1 );
  7083. } );
  7084. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7085. return this.iterator( 'column', function ( settings, column ) {
  7086. return settings.aoColumns[column].mData;
  7087. }, 1 );
  7088. } );
  7089. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7090. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7091. return _pluck_order( settings.aoData, rows,
  7092. type === 'search' ? '_aFilterData' : '_aSortData', column
  7093. );
  7094. }, 1 );
  7095. } );
  7096. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7097. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7098. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7099. }, 1 );
  7100. } );
  7101. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7102. return this.iterator( 'column', function ( settings, column ) {
  7103. if ( vis === undefined ) {
  7104. return settings.aoColumns[ column ].bVisible;
  7105. } // else
  7106. __setColumnVis( settings, column, vis, calc );
  7107. } );
  7108. } );
  7109. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7110. return this.iterator( 'column', function ( settings, column ) {
  7111. return type === 'visible' ?
  7112. _fnColumnIndexToVisible( settings, column ) :
  7113. column;
  7114. }, 1 );
  7115. } );
  7116. _api_register( 'columns.adjust()', function () {
  7117. return this.iterator( 'table', function ( settings ) {
  7118. _fnAdjustColumnSizing( settings );
  7119. }, 1 );
  7120. } );
  7121. _api_register( 'column.index()', function ( type, idx ) {
  7122. if ( this.context.length !== 0 ) {
  7123. var ctx = this.context[0];
  7124. if ( type === 'fromVisible' || type === 'toData' ) {
  7125. return _fnVisibleToColumnIndex( ctx, idx );
  7126. }
  7127. else if ( type === 'fromData' || type === 'toVisible' ) {
  7128. return _fnColumnIndexToVisible( ctx, idx );
  7129. }
  7130. }
  7131. } );
  7132. _api_register( 'column()', function ( selector, opts ) {
  7133. return _selector_first( this.columns( selector, opts ) );
  7134. } );
  7135. var __cell_selector = function ( settings, selector, opts )
  7136. {
  7137. var data = settings.aoData;
  7138. var rows = _selector_row_indexes( settings, opts );
  7139. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7140. var allCells = $( [].concat.apply([], cells) );
  7141. var row;
  7142. var columns = settings.aoColumns.length;
  7143. var a, i, ien, j, o, host;
  7144. var run = function ( s ) {
  7145. var fnSelector = typeof s === 'function';
  7146. if ( s === null || s === undefined || fnSelector ) {
  7147. // All cells and function selectors
  7148. a = [];
  7149. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7150. row = rows[i];
  7151. for ( j=0 ; j<columns ; j++ ) {
  7152. o = {
  7153. row: row,
  7154. column: j
  7155. };
  7156. if ( fnSelector ) {
  7157. // Selector - function
  7158. host = settings.aoData[ row ];
  7159. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7160. a.push( o );
  7161. }
  7162. }
  7163. else {
  7164. // Selector - all
  7165. a.push( o );
  7166. }
  7167. }
  7168. }
  7169. return a;
  7170. }
  7171. // Selector - index
  7172. if ( $.isPlainObject( s ) ) {
  7173. return [s];
  7174. }
  7175. // Selector - jQuery filtered cells
  7176. return allCells
  7177. .filter( s )
  7178. .map( function (i, el) {
  7179. row = el.parentNode._DT_RowIndex;
  7180. return {
  7181. row: row,
  7182. column: $.inArray( el, data[ row ].anCells )
  7183. };
  7184. } )
  7185. .toArray();
  7186. };
  7187. return _selector_run( 'cell', selector, run, settings, opts );
  7188. };
  7189. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7190. // Argument shifting
  7191. if ( $.isPlainObject( rowSelector ) ) {
  7192. // Indexes
  7193. if ( rowSelector.row === undefined ) {
  7194. // Selector options in first parameter
  7195. opts = rowSelector;
  7196. rowSelector = null;
  7197. }
  7198. else {
  7199. // Cell index objects in first parameter
  7200. opts = columnSelector;
  7201. columnSelector = null;
  7202. }
  7203. }
  7204. if ( $.isPlainObject( columnSelector ) ) {
  7205. opts = columnSelector;
  7206. columnSelector = null;
  7207. }
  7208. // Cell selector
  7209. if ( columnSelector === null || columnSelector === undefined ) {
  7210. return this.iterator( 'table', function ( settings ) {
  7211. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7212. } );
  7213. }
  7214. // Row + column selector
  7215. var columns = this.columns( columnSelector, opts );
  7216. var rows = this.rows( rowSelector, opts );
  7217. var a, i, ien, j, jen;
  7218. var cells = this.iterator( 'table', function ( settings, idx ) {
  7219. a = [];
  7220. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7221. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7222. a.push( {
  7223. row: rows[idx][i],
  7224. column: columns[idx][j]
  7225. } );
  7226. }
  7227. }
  7228. return a;
  7229. }, 1 );
  7230. $.extend( cells.selector, {
  7231. cols: columnSelector,
  7232. rows: rowSelector,
  7233. opts: opts
  7234. } );
  7235. return cells;
  7236. } );
  7237. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7238. return this.iterator( 'cell', function ( settings, row, column ) {
  7239. var cells = settings.aoData[ row ].anCells;
  7240. return cells ?
  7241. cells[ column ] :
  7242. undefined;
  7243. }, 1 );
  7244. } );
  7245. _api_register( 'cells().data()', function () {
  7246. return this.iterator( 'cell', function ( settings, row, column ) {
  7247. return _fnGetCellData( settings, row, column );
  7248. }, 1 );
  7249. } );
  7250. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7251. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7252. return this.iterator( 'cell', function ( settings, row, column ) {
  7253. return settings.aoData[ row ][ type ][ column ];
  7254. }, 1 );
  7255. } );
  7256. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7257. return this.iterator( 'cell', function ( settings, row, column ) {
  7258. return _fnGetCellData( settings, row, column, type );
  7259. }, 1 );
  7260. } );
  7261. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7262. return this.iterator( 'cell', function ( settings, row, column ) {
  7263. return {
  7264. row: row,
  7265. column: column,
  7266. columnVisible: _fnColumnIndexToVisible( settings, column )
  7267. };
  7268. }, 1 );
  7269. } );
  7270. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7271. return this.iterator( 'cell', function ( settings, row, column ) {
  7272. _fnInvalidate( settings, row, src, column );
  7273. } );
  7274. } );
  7275. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7276. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7277. } );
  7278. _api_register( 'cell().data()', function ( data ) {
  7279. var ctx = this.context;
  7280. var cell = this[0];
  7281. if ( data === undefined ) {
  7282. // Get
  7283. return ctx.length && cell.length ?
  7284. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7285. undefined;
  7286. }
  7287. // Set
  7288. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7289. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7290. return this;
  7291. } );
  7292. /**
  7293. * Get current ordering (sorting) that has been applied to the table.
  7294. *
  7295. * @returns {array} 2D array containing the sorting information for the first
  7296. * table in the current context. Each element in the parent array represents
  7297. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7298. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7299. * the column index that the sorting condition applies to, the second is the
  7300. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7301. * index of the sorting order from the `column.sorting` initialisation array.
  7302. *//**
  7303. * Set the ordering for the table.
  7304. *
  7305. * @param {integer} order Column index to sort upon.
  7306. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7307. * @returns {DataTables.Api} this
  7308. *//**
  7309. * Set the ordering for the table.
  7310. *
  7311. * @param {array} order 1D array of sorting information to be applied.
  7312. * @param {array} [...] Optional additional sorting conditions
  7313. * @returns {DataTables.Api} this
  7314. *//**
  7315. * Set the ordering for the table.
  7316. *
  7317. * @param {array} order 2D array of sorting information to be applied.
  7318. * @returns {DataTables.Api} this
  7319. */
  7320. _api_register( 'order()', function ( order, dir ) {
  7321. var ctx = this.context;
  7322. if ( order === undefined ) {
  7323. // get
  7324. return ctx.length !== 0 ?
  7325. ctx[0].aaSorting :
  7326. undefined;
  7327. }
  7328. // set
  7329. if ( typeof order === 'number' ) {
  7330. // Simple column / direction passed in
  7331. order = [ [ order, dir ] ];
  7332. }
  7333. else if ( ! $.isArray( order[0] ) ) {
  7334. // Arguments passed in (list of 1D arrays)
  7335. order = Array.prototype.slice.call( arguments );
  7336. }
  7337. // otherwise a 2D array was passed in
  7338. return this.iterator( 'table', function ( settings ) {
  7339. settings.aaSorting = order.slice();
  7340. } );
  7341. } );
  7342. /**
  7343. * Attach a sort listener to an element for a given column
  7344. *
  7345. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7346. * listener to. This can take the form of a single DOM node, a jQuery
  7347. * collection of nodes or a jQuery selector which will identify the node(s).
  7348. * @param {integer} column the column that a click on this node will sort on
  7349. * @param {function} [callback] callback function when sort is run
  7350. * @returns {DataTables.Api} this
  7351. */
  7352. _api_register( 'order.listener()', function ( node, column, callback ) {
  7353. return this.iterator( 'table', function ( settings ) {
  7354. _fnSortAttachListener( settings, node, column, callback );
  7355. } );
  7356. } );
  7357. // Order by the selected column(s)
  7358. _api_register( [
  7359. 'columns().order()',
  7360. 'column().order()'
  7361. ], function ( dir ) {
  7362. var that = this;
  7363. return this.iterator( 'table', function ( settings, i ) {
  7364. var sort = [];
  7365. $.each( that[i], function (j, col) {
  7366. sort.push( [ col, dir ] );
  7367. } );
  7368. settings.aaSorting = sort;
  7369. } );
  7370. } );
  7371. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7372. var ctx = this.context;
  7373. if ( input === undefined ) {
  7374. // get
  7375. return ctx.length !== 0 ?
  7376. ctx[0].oPreviousSearch.sSearch :
  7377. undefined;
  7378. }
  7379. // set
  7380. return this.iterator( 'table', function ( settings ) {
  7381. if ( ! settings.oFeatures.bFilter ) {
  7382. return;
  7383. }
  7384. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7385. "sSearch": input+"",
  7386. "bRegex": regex === null ? false : regex,
  7387. "bSmart": smart === null ? true : smart,
  7388. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7389. } ), 1 );
  7390. } );
  7391. } );
  7392. _api_registerPlural(
  7393. 'columns().search()',
  7394. 'column().search()',
  7395. function ( input, regex, smart, caseInsen ) {
  7396. return this.iterator( 'column', function ( settings, column ) {
  7397. var preSearch = settings.aoPreSearchCols;
  7398. if ( input === undefined ) {
  7399. // get
  7400. return preSearch[ column ].sSearch;
  7401. }
  7402. // set
  7403. if ( ! settings.oFeatures.bFilter ) {
  7404. return;
  7405. }
  7406. $.extend( preSearch[ column ], {
  7407. "sSearch": input+"",
  7408. "bRegex": regex === null ? false : regex,
  7409. "bSmart": smart === null ? true : smart,
  7410. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7411. } );
  7412. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7413. } );
  7414. }
  7415. );
  7416. /*
  7417. * State API methods
  7418. */
  7419. _api_register( 'state()', function () {
  7420. return this.context.length ?
  7421. this.context[0].oSavedState :
  7422. null;
  7423. } );
  7424. _api_register( 'state.clear()', function () {
  7425. return this.iterator( 'table', function ( settings ) {
  7426. // Save an empty object
  7427. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7428. } );
  7429. } );
  7430. _api_register( 'state.loaded()', function () {
  7431. return this.context.length ?
  7432. this.context[0].oLoadedState :
  7433. null;
  7434. } );
  7435. _api_register( 'state.save()', function () {
  7436. return this.iterator( 'table', function ( settings ) {
  7437. _fnSaveState( settings );
  7438. } );
  7439. } );
  7440. /**
  7441. * Provide a common method for plug-ins to check the version of DataTables being
  7442. * used, in order to ensure compatibility.
  7443. *
  7444. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7445. * Note that the formats "X" and "X.Y" are also acceptable.
  7446. * @returns {boolean} true if this version of DataTables is greater or equal to
  7447. * the required version, or false if this version of DataTales is not
  7448. * suitable
  7449. * @static
  7450. * @dtopt API-Static
  7451. *
  7452. * @example
  7453. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7454. */
  7455. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7456. {
  7457. var aThis = DataTable.version.split('.');
  7458. var aThat = version.split('.');
  7459. var iThis, iThat;
  7460. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7461. iThis = parseInt( aThis[i], 10 ) || 0;
  7462. iThat = parseInt( aThat[i], 10 ) || 0;
  7463. // Parts are the same, keep comparing
  7464. if (iThis === iThat) {
  7465. continue;
  7466. }
  7467. // Parts are different, return immediately
  7468. return iThis > iThat;
  7469. }
  7470. return true;
  7471. };
  7472. /**
  7473. * Check if a `<table>` node is a DataTable table already or not.
  7474. *
  7475. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7476. * selector for the table to test. Note that if more than more than one
  7477. * table is passed on, only the first will be checked
  7478. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7479. * @static
  7480. * @dtopt API-Static
  7481. *
  7482. * @example
  7483. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7484. * $('#example').dataTable();
  7485. * }
  7486. */
  7487. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7488. {
  7489. var t = $(table).get(0);
  7490. var is = false;
  7491. $.each( DataTable.settings, function (i, o) {
  7492. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7493. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7494. if ( o.nTable === t || head === t || foot === t ) {
  7495. is = true;
  7496. }
  7497. } );
  7498. return is;
  7499. };
  7500. /**
  7501. * Get all DataTable tables that have been initialised - optionally you can
  7502. * select to get only currently visible tables.
  7503. *
  7504. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7505. * or visible tables only.
  7506. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7507. * DataTables
  7508. * @static
  7509. * @dtopt API-Static
  7510. *
  7511. * @example
  7512. * $.each( $.fn.dataTable.tables(true), function () {
  7513. * $(table).DataTable().columns.adjust();
  7514. * } );
  7515. */
  7516. DataTable.tables = DataTable.fnTables = function ( visible )
  7517. {
  7518. return $.map( DataTable.settings, function (o) {
  7519. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7520. return o.nTable;
  7521. }
  7522. } );
  7523. };
  7524. /**
  7525. * DataTables utility methods
  7526. *
  7527. * This namespace provides helper methods that DataTables uses internally to
  7528. * create a DataTable, but which are not exclusively used only for DataTables.
  7529. * These methods can be used by extension authors to save the duplication of
  7530. * code.
  7531. *
  7532. * @namespace
  7533. */
  7534. DataTable.util = {
  7535. /**
  7536. * Throttle the calls to a function. Arguments and context are maintained
  7537. * for the throttled function.
  7538. *
  7539. * @param {function} fn Function to be called
  7540. * @param {integer} freq Call frequency in mS
  7541. * @return {function} Wrapped function
  7542. */
  7543. throttle: _fnThrottle,
  7544. /**
  7545. * Escape a string such that it can be used in a regular expression
  7546. *
  7547. * @param {string} sVal string to escape
  7548. * @returns {string} escaped string
  7549. */
  7550. escapeRegex: _fnEscapeRegex
  7551. };
  7552. /**
  7553. * Convert from camel case parameters to Hungarian notation. This is made public
  7554. * for the extensions to provide the same ability as DataTables core to accept
  7555. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7556. * parameters.
  7557. *
  7558. * @param {object} src The model object which holds all parameters that can be
  7559. * mapped.
  7560. * @param {object} user The object to convert from camel case to Hungarian.
  7561. * @param {boolean} force When set to `true`, properties which already have a
  7562. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7563. * won't be.
  7564. */
  7565. DataTable.camelToHungarian = _fnCamelToHungarian;
  7566. /**
  7567. *
  7568. */
  7569. _api_register( '$()', function ( selector, opts ) {
  7570. var
  7571. rows = this.rows( opts ).nodes(), // Get all rows
  7572. jqRows = $(rows);
  7573. return $( [].concat(
  7574. jqRows.filter( selector ).toArray(),
  7575. jqRows.find( selector ).toArray()
  7576. ) );
  7577. } );
  7578. // jQuery functions to operate on the tables
  7579. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7580. _api_register( key+'()', function ( /* event, handler */ ) {
  7581. var args = Array.prototype.slice.call(arguments);
  7582. // Add the `dt` namespace automatically if it isn't already present
  7583. if ( ! args[0].match(/\.dt\b/) ) {
  7584. args[0] += '.dt';
  7585. }
  7586. var inst = $( this.tables().nodes() );
  7587. inst[key].apply( inst, args );
  7588. return this;
  7589. } );
  7590. } );
  7591. _api_register( 'clear()', function () {
  7592. return this.iterator( 'table', function ( settings ) {
  7593. _fnClearTable( settings );
  7594. } );
  7595. } );
  7596. _api_register( 'settings()', function () {
  7597. return new _Api( this.context, this.context );
  7598. } );
  7599. _api_register( 'init()', function () {
  7600. var ctx = this.context;
  7601. return ctx.length ? ctx[0].oInit : null;
  7602. } );
  7603. _api_register( 'data()', function () {
  7604. return this.iterator( 'table', function ( settings ) {
  7605. return _pluck( settings.aoData, '_aData' );
  7606. } ).flatten();
  7607. } );
  7608. _api_register( 'destroy()', function ( remove ) {
  7609. remove = remove || false;
  7610. return this.iterator( 'table', function ( settings ) {
  7611. var orig = settings.nTableWrapper.parentNode;
  7612. var classes = settings.oClasses;
  7613. var table = settings.nTable;
  7614. var tbody = settings.nTBody;
  7615. var thead = settings.nTHead;
  7616. var tfoot = settings.nTFoot;
  7617. var jqTable = $(table);
  7618. var jqTbody = $(tbody);
  7619. var jqWrapper = $(settings.nTableWrapper);
  7620. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7621. var i, ien;
  7622. // Flag to note that the table is currently being destroyed - no action
  7623. // should be taken
  7624. settings.bDestroying = true;
  7625. // Fire off the destroy callbacks for plug-ins etc
  7626. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7627. // If not being removed from the document, make all columns visible
  7628. if ( ! remove ) {
  7629. new _Api( settings ).columns().visible( true );
  7630. }
  7631. // Blitz all `DT` namespaced events (these are internal events, the
  7632. // lowercase, `dt` events are user subscribed and they are responsible
  7633. // for removing them
  7634. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  7635. $(window).unbind('.DT-'+settings.sInstance);
  7636. // When scrolling we had to break the table up - restore it
  7637. if ( table != thead.parentNode ) {
  7638. jqTable.children('thead').detach();
  7639. jqTable.append( thead );
  7640. }
  7641. if ( tfoot && table != tfoot.parentNode ) {
  7642. jqTable.children('tfoot').detach();
  7643. jqTable.append( tfoot );
  7644. }
  7645. // Remove the DataTables generated nodes, events and classes
  7646. jqTable.detach();
  7647. jqWrapper.detach();
  7648. settings.aaSorting = [];
  7649. settings.aaSortingFixed = [];
  7650. _fnSortingClasses( settings );
  7651. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7652. $('th, td', thead).removeClass( classes.sSortable+' '+
  7653. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7654. );
  7655. if ( settings.bJUI ) {
  7656. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  7657. $('th, td', thead).each( function () {
  7658. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  7659. $(this).append( wrapper.contents() );
  7660. wrapper.detach();
  7661. } );
  7662. }
  7663. if ( ! remove && orig ) {
  7664. // insertBefore acts like appendChild if !arg[1]
  7665. orig.insertBefore( table, settings.nTableReinsertBefore );
  7666. }
  7667. // Add the TR elements back into the table in their original order
  7668. jqTbody.children().detach();
  7669. jqTbody.append( rows );
  7670. // Restore the width of the original table - was read from the style property,
  7671. // so we can restore directly to that
  7672. jqTable
  7673. .css( 'width', settings.sDestroyWidth )
  7674. .removeClass( classes.sTable );
  7675. // If the were originally stripe classes - then we add them back here.
  7676. // Note this is not fool proof (for example if not all rows had stripe
  7677. // classes - but it's a good effort without getting carried away
  7678. ien = settings.asDestroyStripes.length;
  7679. if ( ien ) {
  7680. jqTbody.children().each( function (i) {
  7681. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7682. } );
  7683. }
  7684. /* Remove the settings object from the settings array */
  7685. var idx = $.inArray( settings, DataTable.settings );
  7686. if ( idx !== -1 ) {
  7687. DataTable.settings.splice( idx, 1 );
  7688. }
  7689. } );
  7690. } );
  7691. // Add the `every()` method for rows, columns and cells in a compact form
  7692. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  7693. _api_register( type+'s().every()', function ( fn ) {
  7694. return this.iterator( type, function ( settings, idx, idx2 ) {
  7695. // idx2 is undefined for rows and columns.
  7696. fn.call( new _Api( settings )[ type ]( idx, idx2 ) );
  7697. } );
  7698. } );
  7699. } );
  7700. // i18n method for extensions to be able to use the language object from the
  7701. // DataTable
  7702. _api_register( 'i18n()', function ( token, def, plural ) {
  7703. var ctx = this.context[0];
  7704. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  7705. if ( resolved === undefined ) {
  7706. resolved = def;
  7707. }
  7708. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  7709. resolved = resolved[ plural ] !== undefined ?
  7710. resolved[ plural ] :
  7711. resolved._;
  7712. }
  7713. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  7714. } );
  7715. /**
  7716. * Version string for plug-ins to check compatibility. Allowed format is
  7717. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7718. * only for non-release builds. See http://semver.org/ for more information.
  7719. * @member
  7720. * @type string
  7721. * @default Version number
  7722. */
  7723. DataTable.version = "1.10.7";
  7724. /**
  7725. * Private data store, containing all of the settings objects that are
  7726. * created for the tables on a given page.
  7727. *
  7728. * Note that the `DataTable.settings` object is aliased to
  7729. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7730. * manipulated, or `jQuery.fn.dataTable.settings`.
  7731. * @member
  7732. * @type array
  7733. * @default []
  7734. * @private
  7735. */
  7736. DataTable.settings = [];
  7737. /**
  7738. * Object models container, for the various models that DataTables has
  7739. * available to it. These models define the objects that are used to hold
  7740. * the active state and configuration of the table.
  7741. * @namespace
  7742. */
  7743. DataTable.models = {};
  7744. /**
  7745. * Template object for the way in which DataTables holds information about
  7746. * search information for the global filter and individual column filters.
  7747. * @namespace
  7748. */
  7749. DataTable.models.oSearch = {
  7750. /**
  7751. * Flag to indicate if the filtering should be case insensitive or not
  7752. * @type boolean
  7753. * @default true
  7754. */
  7755. "bCaseInsensitive": true,
  7756. /**
  7757. * Applied search term
  7758. * @type string
  7759. * @default <i>Empty string</i>
  7760. */
  7761. "sSearch": "",
  7762. /**
  7763. * Flag to indicate if the search term should be interpreted as a
  7764. * regular expression (true) or not (false) and therefore and special
  7765. * regex characters escaped.
  7766. * @type boolean
  7767. * @default false
  7768. */
  7769. "bRegex": false,
  7770. /**
  7771. * Flag to indicate if DataTables is to use its smart filtering or not.
  7772. * @type boolean
  7773. * @default true
  7774. */
  7775. "bSmart": true
  7776. };
  7777. /**
  7778. * Template object for the way in which DataTables holds information about
  7779. * each individual row. This is the object format used for the settings
  7780. * aoData array.
  7781. * @namespace
  7782. */
  7783. DataTable.models.oRow = {
  7784. /**
  7785. * TR element for the row
  7786. * @type node
  7787. * @default null
  7788. */
  7789. "nTr": null,
  7790. /**
  7791. * Array of TD elements for each row. This is null until the row has been
  7792. * created.
  7793. * @type array nodes
  7794. * @default []
  7795. */
  7796. "anCells": null,
  7797. /**
  7798. * Data object from the original data source for the row. This is either
  7799. * an array if using the traditional form of DataTables, or an object if
  7800. * using mData options. The exact type will depend on the passed in
  7801. * data from the data source, or will be an array if using DOM a data
  7802. * source.
  7803. * @type array|object
  7804. * @default []
  7805. */
  7806. "_aData": [],
  7807. /**
  7808. * Sorting data cache - this array is ostensibly the same length as the
  7809. * number of columns (although each index is generated only as it is
  7810. * needed), and holds the data that is used for sorting each column in the
  7811. * row. We do this cache generation at the start of the sort in order that
  7812. * the formatting of the sort data need be done only once for each cell
  7813. * per sort. This array should not be read from or written to by anything
  7814. * other than the master sorting methods.
  7815. * @type array
  7816. * @default null
  7817. * @private
  7818. */
  7819. "_aSortData": null,
  7820. /**
  7821. * Per cell filtering data cache. As per the sort data cache, used to
  7822. * increase the performance of the filtering in DataTables
  7823. * @type array
  7824. * @default null
  7825. * @private
  7826. */
  7827. "_aFilterData": null,
  7828. /**
  7829. * Filtering data cache. This is the same as the cell filtering cache, but
  7830. * in this case a string rather than an array. This is easily computed with
  7831. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  7832. * needed on every search (memory traded for performance)
  7833. * @type array
  7834. * @default null
  7835. * @private
  7836. */
  7837. "_sFilterRow": null,
  7838. /**
  7839. * Cache of the class name that DataTables has applied to the row, so we
  7840. * can quickly look at this variable rather than needing to do a DOM check
  7841. * on className for the nTr property.
  7842. * @type string
  7843. * @default <i>Empty string</i>
  7844. * @private
  7845. */
  7846. "_sRowStripe": "",
  7847. /**
  7848. * Denote if the original data source was from the DOM, or the data source
  7849. * object. This is used for invalidating data, so DataTables can
  7850. * automatically read data from the original source, unless uninstructed
  7851. * otherwise.
  7852. * @type string
  7853. * @default null
  7854. * @private
  7855. */
  7856. "src": null
  7857. };
  7858. /**
  7859. * Template object for the column information object in DataTables. This object
  7860. * is held in the settings aoColumns array and contains all the information that
  7861. * DataTables needs about each individual column.
  7862. *
  7863. * Note that this object is related to {@link DataTable.defaults.column}
  7864. * but this one is the internal data store for DataTables's cache of columns.
  7865. * It should NOT be manipulated outside of DataTables. Any configuration should
  7866. * be done through the initialisation options.
  7867. * @namespace
  7868. */
  7869. DataTable.models.oColumn = {
  7870. /**
  7871. * Column index. This could be worked out on-the-fly with $.inArray, but it
  7872. * is faster to just hold it as a variable
  7873. * @type integer
  7874. * @default null
  7875. */
  7876. "idx": null,
  7877. /**
  7878. * A list of the columns that sorting should occur on when this column
  7879. * is sorted. That this property is an array allows multi-column sorting
  7880. * to be defined for a column (for example first name / last name columns
  7881. * would benefit from this). The values are integers pointing to the
  7882. * columns to be sorted on (typically it will be a single integer pointing
  7883. * at itself, but that doesn't need to be the case).
  7884. * @type array
  7885. */
  7886. "aDataSort": null,
  7887. /**
  7888. * Define the sorting directions that are applied to the column, in sequence
  7889. * as the column is repeatedly sorted upon - i.e. the first value is used
  7890. * as the sorting direction when the column if first sorted (clicked on).
  7891. * Sort it again (click again) and it will move on to the next index.
  7892. * Repeat until loop.
  7893. * @type array
  7894. */
  7895. "asSorting": null,
  7896. /**
  7897. * Flag to indicate if the column is searchable, and thus should be included
  7898. * in the filtering or not.
  7899. * @type boolean
  7900. */
  7901. "bSearchable": null,
  7902. /**
  7903. * Flag to indicate if the column is sortable or not.
  7904. * @type boolean
  7905. */
  7906. "bSortable": null,
  7907. /**
  7908. * Flag to indicate if the column is currently visible in the table or not
  7909. * @type boolean
  7910. */
  7911. "bVisible": null,
  7912. /**
  7913. * Store for manual type assignment using the `column.type` option. This
  7914. * is held in store so we can manipulate the column's `sType` property.
  7915. * @type string
  7916. * @default null
  7917. * @private
  7918. */
  7919. "_sManualType": null,
  7920. /**
  7921. * Flag to indicate if HTML5 data attributes should be used as the data
  7922. * source for filtering or sorting. True is either are.
  7923. * @type boolean
  7924. * @default false
  7925. * @private
  7926. */
  7927. "_bAttrSrc": false,
  7928. /**
  7929. * Developer definable function that is called whenever a cell is created (Ajax source,
  7930. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  7931. * allowing you to modify the DOM element (add background colour for example) when the
  7932. * element is available.
  7933. * @type function
  7934. * @param {element} nTd The TD node that has been created
  7935. * @param {*} sData The Data for the cell
  7936. * @param {array|object} oData The data for the whole row
  7937. * @param {int} iRow The row index for the aoData data store
  7938. * @default null
  7939. */
  7940. "fnCreatedCell": null,
  7941. /**
  7942. * Function to get data from a cell in a column. You should <b>never</b>
  7943. * access data directly through _aData internally in DataTables - always use
  7944. * the method attached to this property. It allows mData to function as
  7945. * required. This function is automatically assigned by the column
  7946. * initialisation method
  7947. * @type function
  7948. * @param {array|object} oData The data array/object for the array
  7949. * (i.e. aoData[]._aData)
  7950. * @param {string} sSpecific The specific data type you want to get -
  7951. * 'display', 'type' 'filter' 'sort'
  7952. * @returns {*} The data for the cell from the given row's data
  7953. * @default null
  7954. */
  7955. "fnGetData": null,
  7956. /**
  7957. * Function to set data for a cell in the column. You should <b>never</b>
  7958. * set the data directly to _aData internally in DataTables - always use
  7959. * this method. It allows mData to function as required. This function
  7960. * is automatically assigned by the column initialisation method
  7961. * @type function
  7962. * @param {array|object} oData The data array/object for the array
  7963. * (i.e. aoData[]._aData)
  7964. * @param {*} sValue Value to set
  7965. * @default null
  7966. */
  7967. "fnSetData": null,
  7968. /**
  7969. * Property to read the value for the cells in the column from the data
  7970. * source array / object. If null, then the default content is used, if a
  7971. * function is given then the return from the function is used.
  7972. * @type function|int|string|null
  7973. * @default null
  7974. */
  7975. "mData": null,
  7976. /**
  7977. * Partner property to mData which is used (only when defined) to get
  7978. * the data - i.e. it is basically the same as mData, but without the
  7979. * 'set' option, and also the data fed to it is the result from mData.
  7980. * This is the rendering method to match the data method of mData.
  7981. * @type function|int|string|null
  7982. * @default null
  7983. */
  7984. "mRender": null,
  7985. /**
  7986. * Unique header TH/TD element for this column - this is what the sorting
  7987. * listener is attached to (if sorting is enabled.)
  7988. * @type node
  7989. * @default null
  7990. */
  7991. "nTh": null,
  7992. /**
  7993. * Unique footer TH/TD element for this column (if there is one). Not used
  7994. * in DataTables as such, but can be used for plug-ins to reference the
  7995. * footer for each column.
  7996. * @type node
  7997. * @default null
  7998. */
  7999. "nTf": null,
  8000. /**
  8001. * The class to apply to all TD elements in the table's TBODY for the column
  8002. * @type string
  8003. * @default null
  8004. */
  8005. "sClass": null,
  8006. /**
  8007. * When DataTables calculates the column widths to assign to each column,
  8008. * it finds the longest string in each column and then constructs a
  8009. * temporary table and reads the widths from that. The problem with this
  8010. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8011. * string - thus the calculation can go wrong (doing it properly and putting
  8012. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8013. * a "work around" we provide this option. It will append its value to the
  8014. * text that is found to be the longest string for the column - i.e. padding.
  8015. * @type string
  8016. */
  8017. "sContentPadding": null,
  8018. /**
  8019. * Allows a default value to be given for a column's data, and will be used
  8020. * whenever a null data source is encountered (this can be because mData
  8021. * is set to null, or because the data source itself is null).
  8022. * @type string
  8023. * @default null
  8024. */
  8025. "sDefaultContent": null,
  8026. /**
  8027. * Name for the column, allowing reference to the column by name as well as
  8028. * by index (needs a lookup to work by name).
  8029. * @type string
  8030. */
  8031. "sName": null,
  8032. /**
  8033. * Custom sorting data type - defines which of the available plug-ins in
  8034. * afnSortData the custom sorting will use - if any is defined.
  8035. * @type string
  8036. * @default std
  8037. */
  8038. "sSortDataType": 'std',
  8039. /**
  8040. * Class to be applied to the header element when sorting on this column
  8041. * @type string
  8042. * @default null
  8043. */
  8044. "sSortingClass": null,
  8045. /**
  8046. * Class to be applied to the header element when sorting on this column -
  8047. * when jQuery UI theming is used.
  8048. * @type string
  8049. * @default null
  8050. */
  8051. "sSortingClassJUI": null,
  8052. /**
  8053. * Title of the column - what is seen in the TH element (nTh).
  8054. * @type string
  8055. */
  8056. "sTitle": null,
  8057. /**
  8058. * Column sorting and filtering type
  8059. * @type string
  8060. * @default null
  8061. */
  8062. "sType": null,
  8063. /**
  8064. * Width of the column
  8065. * @type string
  8066. * @default null
  8067. */
  8068. "sWidth": null,
  8069. /**
  8070. * Width of the column when it was first "encountered"
  8071. * @type string
  8072. * @default null
  8073. */
  8074. "sWidthOrig": null
  8075. };
  8076. /*
  8077. * Developer note: The properties of the object below are given in Hungarian
  8078. * notation, that was used as the interface for DataTables prior to v1.10, however
  8079. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8080. * breaking backwards compatibility utterly with this change, the Hungarian
  8081. * version is still, internally the primary interface, but is is not documented
  8082. * - hence the @name tags in each doc comment. This allows a Javascript function
  8083. * to create a map from Hungarian notation to camel case (going the other direction
  8084. * would require each property to be listed, which would at around 3K to the size
  8085. * of DataTables, while this method is about a 0.5K hit.
  8086. *
  8087. * Ultimately this does pave the way for Hungarian notation to be dropped
  8088. * completely, but that is a massive amount of work and will break current
  8089. * installs (therefore is on-hold until v2).
  8090. */
  8091. /**
  8092. * Initialisation options that can be given to DataTables at initialisation
  8093. * time.
  8094. * @namespace
  8095. */
  8096. DataTable.defaults = {
  8097. /**
  8098. * An array of data to use for the table, passed in at initialisation which
  8099. * will be used in preference to any data which is already in the DOM. This is
  8100. * particularly useful for constructing tables purely in Javascript, for
  8101. * example with a custom Ajax call.
  8102. * @type array
  8103. * @default null
  8104. *
  8105. * @dtopt Option
  8106. * @name DataTable.defaults.data
  8107. *
  8108. * @example
  8109. * // Using a 2D array data source
  8110. * $(document).ready( function () {
  8111. * $('#example').dataTable( {
  8112. * "data": [
  8113. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8114. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8115. * ],
  8116. * "columns": [
  8117. * { "title": "Engine" },
  8118. * { "title": "Browser" },
  8119. * { "title": "Platform" },
  8120. * { "title": "Version" },
  8121. * { "title": "Grade" }
  8122. * ]
  8123. * } );
  8124. * } );
  8125. *
  8126. * @example
  8127. * // Using an array of objects as a data source (`data`)
  8128. * $(document).ready( function () {
  8129. * $('#example').dataTable( {
  8130. * "data": [
  8131. * {
  8132. * "engine": "Trident",
  8133. * "browser": "Internet Explorer 4.0",
  8134. * "platform": "Win 95+",
  8135. * "version": 4,
  8136. * "grade": "X"
  8137. * },
  8138. * {
  8139. * "engine": "Trident",
  8140. * "browser": "Internet Explorer 5.0",
  8141. * "platform": "Win 95+",
  8142. * "version": 5,
  8143. * "grade": "C"
  8144. * }
  8145. * ],
  8146. * "columns": [
  8147. * { "title": "Engine", "data": "engine" },
  8148. * { "title": "Browser", "data": "browser" },
  8149. * { "title": "Platform", "data": "platform" },
  8150. * { "title": "Version", "data": "version" },
  8151. * { "title": "Grade", "data": "grade" }
  8152. * ]
  8153. * } );
  8154. * } );
  8155. */
  8156. "aaData": null,
  8157. /**
  8158. * If ordering is enabled, then DataTables will perform a first pass sort on
  8159. * initialisation. You can define which column(s) the sort is performed
  8160. * upon, and the sorting direction, with this variable. The `sorting` array
  8161. * should contain an array for each column to be sorted initially containing
  8162. * the column's index and a direction string ('asc' or 'desc').
  8163. * @type array
  8164. * @default [[0,'asc']]
  8165. *
  8166. * @dtopt Option
  8167. * @name DataTable.defaults.order
  8168. *
  8169. * @example
  8170. * // Sort by 3rd column first, and then 4th column
  8171. * $(document).ready( function() {
  8172. * $('#example').dataTable( {
  8173. * "order": [[2,'asc'], [3,'desc']]
  8174. * } );
  8175. * } );
  8176. *
  8177. * // No initial sorting
  8178. * $(document).ready( function() {
  8179. * $('#example').dataTable( {
  8180. * "order": []
  8181. * } );
  8182. * } );
  8183. */
  8184. "aaSorting": [[0,'asc']],
  8185. /**
  8186. * This parameter is basically identical to the `sorting` parameter, but
  8187. * cannot be overridden by user interaction with the table. What this means
  8188. * is that you could have a column (visible or hidden) which the sorting
  8189. * will always be forced on first - any sorting after that (from the user)
  8190. * will then be performed as required. This can be useful for grouping rows
  8191. * together.
  8192. * @type array
  8193. * @default null
  8194. *
  8195. * @dtopt Option
  8196. * @name DataTable.defaults.orderFixed
  8197. *
  8198. * @example
  8199. * $(document).ready( function() {
  8200. * $('#example').dataTable( {
  8201. * "orderFixed": [[0,'asc']]
  8202. * } );
  8203. * } )
  8204. */
  8205. "aaSortingFixed": [],
  8206. /**
  8207. * DataTables can be instructed to load data to display in the table from a
  8208. * Ajax source. This option defines how that Ajax call is made and where to.
  8209. *
  8210. * The `ajax` property has three different modes of operation, depending on
  8211. * how it is defined. These are:
  8212. *
  8213. * * `string` - Set the URL from where the data should be loaded from.
  8214. * * `object` - Define properties for `jQuery.ajax`.
  8215. * * `function` - Custom data get function
  8216. *
  8217. * `string`
  8218. * --------
  8219. *
  8220. * As a string, the `ajax` property simply defines the URL from which
  8221. * DataTables will load data.
  8222. *
  8223. * `object`
  8224. * --------
  8225. *
  8226. * As an object, the parameters in the object are passed to
  8227. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8228. * of the Ajax request. DataTables has a number of default parameters which
  8229. * you can override using this option. Please refer to the jQuery
  8230. * documentation for a full description of the options available, although
  8231. * the following parameters provide additional options in DataTables or
  8232. * require special consideration:
  8233. *
  8234. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8235. * can also be used as a function to manipulate the data DataTables sends
  8236. * to the server. The function takes a single parameter, an object of
  8237. * parameters with the values that DataTables has readied for sending. An
  8238. * object may be returned which will be merged into the DataTables
  8239. * defaults, or you can add the items to the object that was passed in and
  8240. * not return anything from the function. This supersedes `fnServerParams`
  8241. * from DataTables 1.9-.
  8242. *
  8243. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8244. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8245. * from an Ajax source or for server-side processing - this parameter
  8246. * allows that property to be changed. You can use Javascript dotted
  8247. * object notation to get a data source for multiple levels of nesting, or
  8248. * it my be used as a function. As a function it takes a single parameter,
  8249. * the JSON returned from the server, which can be manipulated as
  8250. * required, with the returned value being that used by DataTables as the
  8251. * data source for the table. This supersedes `sAjaxDataProp` from
  8252. * DataTables 1.9-.
  8253. *
  8254. * * `success` - Should not be overridden it is used internally in
  8255. * DataTables. To manipulate / transform the data returned by the server
  8256. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8257. *
  8258. * `function`
  8259. * ----------
  8260. *
  8261. * As a function, making the Ajax call is left up to yourself allowing
  8262. * complete control of the Ajax request. Indeed, if desired, a method other
  8263. * than Ajax could be used to obtain the required data, such as Web storage
  8264. * or an AIR database.
  8265. *
  8266. * The function is given four parameters and no return is required. The
  8267. * parameters are:
  8268. *
  8269. * 1. _object_ - Data to send to the server
  8270. * 2. _function_ - Callback function that must be executed when the required
  8271. * data has been obtained. That data should be passed into the callback
  8272. * as the only parameter
  8273. * 3. _object_ - DataTables settings object for the table
  8274. *
  8275. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8276. *
  8277. * @type string|object|function
  8278. * @default null
  8279. *
  8280. * @dtopt Option
  8281. * @name DataTable.defaults.ajax
  8282. * @since 1.10.0
  8283. *
  8284. * @example
  8285. * // Get JSON data from a file via Ajax.
  8286. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8287. * $('#example').dataTable( {
  8288. * "ajax": "data.json"
  8289. * } );
  8290. *
  8291. * @example
  8292. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8293. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8294. * $('#example').dataTable( {
  8295. * "ajax": {
  8296. * "url": "data.json",
  8297. * "dataSrc": "tableData"
  8298. * }
  8299. * } );
  8300. *
  8301. * @example
  8302. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8303. * // from a plain array rather than an array in an object
  8304. * $('#example').dataTable( {
  8305. * "ajax": {
  8306. * "url": "data.json",
  8307. * "dataSrc": ""
  8308. * }
  8309. * } );
  8310. *
  8311. * @example
  8312. * // Manipulate the data returned from the server - add a link to data
  8313. * // (note this can, should, be done using `render` for the column - this
  8314. * // is just a simple example of how the data can be manipulated).
  8315. * $('#example').dataTable( {
  8316. * "ajax": {
  8317. * "url": "data.json",
  8318. * "dataSrc": function ( json ) {
  8319. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8320. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8321. * }
  8322. * return json;
  8323. * }
  8324. * }
  8325. * } );
  8326. *
  8327. * @example
  8328. * // Add data to the request
  8329. * $('#example').dataTable( {
  8330. * "ajax": {
  8331. * "url": "data.json",
  8332. * "data": function ( d ) {
  8333. * return {
  8334. * "extra_search": $('#extra').val()
  8335. * };
  8336. * }
  8337. * }
  8338. * } );
  8339. *
  8340. * @example
  8341. * // Send request as POST
  8342. * $('#example').dataTable( {
  8343. * "ajax": {
  8344. * "url": "data.json",
  8345. * "type": "POST"
  8346. * }
  8347. * } );
  8348. *
  8349. * @example
  8350. * // Get the data from localStorage (could interface with a form for
  8351. * // adding, editing and removing rows).
  8352. * $('#example').dataTable( {
  8353. * "ajax": function (data, callback, settings) {
  8354. * callback(
  8355. * JSON.parse( localStorage.getItem('dataTablesData') )
  8356. * );
  8357. * }
  8358. * } );
  8359. */
  8360. "ajax": null,
  8361. /**
  8362. * This parameter allows you to readily specify the entries in the length drop
  8363. * down menu that DataTables shows when pagination is enabled. It can be
  8364. * either a 1D array of options which will be used for both the displayed
  8365. * option and the value, or a 2D array which will use the array in the first
  8366. * position as the value, and the array in the second position as the
  8367. * displayed options (useful for language strings such as 'All').
  8368. *
  8369. * Note that the `pageLength` property will be automatically set to the
  8370. * first value given in this array, unless `pageLength` is also provided.
  8371. * @type array
  8372. * @default [ 10, 25, 50, 100 ]
  8373. *
  8374. * @dtopt Option
  8375. * @name DataTable.defaults.lengthMenu
  8376. *
  8377. * @example
  8378. * $(document).ready( function() {
  8379. * $('#example').dataTable( {
  8380. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8381. * } );
  8382. * } );
  8383. */
  8384. "aLengthMenu": [ 10, 25, 50, 100 ],
  8385. /**
  8386. * The `columns` option in the initialisation parameter allows you to define
  8387. * details about the way individual columns behave. For a full list of
  8388. * column options that can be set, please see
  8389. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8390. * define your columns, you must have an entry in the array for every single
  8391. * column that you have in your table (these can be null if you don't which
  8392. * to specify any options).
  8393. * @member
  8394. *
  8395. * @name DataTable.defaults.column
  8396. */
  8397. "aoColumns": null,
  8398. /**
  8399. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8400. * column, multiple columns, or all columns, using the `targets` property of
  8401. * each object in the array. This allows great flexibility when creating
  8402. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8403. * columns you specifically want. `columnDefs` may use any of the column
  8404. * options available: {@link DataTable.defaults.column}, but it _must_
  8405. * have `targets` defined in each object in the array. Values in the `targets`
  8406. * array may be:
  8407. * <ul>
  8408. * <li>a string - class name will be matched on the TH for the column</li>
  8409. * <li>0 or a positive integer - column index counting from the left</li>
  8410. * <li>a negative integer - column index counting from the right</li>
  8411. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8412. * </ul>
  8413. * @member
  8414. *
  8415. * @name DataTable.defaults.columnDefs
  8416. */
  8417. "aoColumnDefs": null,
  8418. /**
  8419. * Basically the same as `search`, this parameter defines the individual column
  8420. * filtering state at initialisation time. The array must be of the same size
  8421. * as the number of columns, and each element be an object with the parameters
  8422. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8423. * accepted and the default will be used.
  8424. * @type array
  8425. * @default []
  8426. *
  8427. * @dtopt Option
  8428. * @name DataTable.defaults.searchCols
  8429. *
  8430. * @example
  8431. * $(document).ready( function() {
  8432. * $('#example').dataTable( {
  8433. * "searchCols": [
  8434. * null,
  8435. * { "search": "My filter" },
  8436. * null,
  8437. * { "search": "^[0-9]", "escapeRegex": false }
  8438. * ]
  8439. * } );
  8440. * } )
  8441. */
  8442. "aoSearchCols": [],
  8443. /**
  8444. * An array of CSS classes that should be applied to displayed rows. This
  8445. * array may be of any length, and DataTables will apply each class
  8446. * sequentially, looping when required.
  8447. * @type array
  8448. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8449. * options</i>
  8450. *
  8451. * @dtopt Option
  8452. * @name DataTable.defaults.stripeClasses
  8453. *
  8454. * @example
  8455. * $(document).ready( function() {
  8456. * $('#example').dataTable( {
  8457. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8458. * } );
  8459. * } )
  8460. */
  8461. "asStripeClasses": null,
  8462. /**
  8463. * Enable or disable automatic column width calculation. This can be disabled
  8464. * as an optimisation (it takes some time to calculate the widths) if the
  8465. * tables widths are passed in using `columns`.
  8466. * @type boolean
  8467. * @default true
  8468. *
  8469. * @dtopt Features
  8470. * @name DataTable.defaults.autoWidth
  8471. *
  8472. * @example
  8473. * $(document).ready( function () {
  8474. * $('#example').dataTable( {
  8475. * "autoWidth": false
  8476. * } );
  8477. * } );
  8478. */
  8479. "bAutoWidth": true,
  8480. /**
  8481. * Deferred rendering can provide DataTables with a huge speed boost when you
  8482. * are using an Ajax or JS data source for the table. This option, when set to
  8483. * true, will cause DataTables to defer the creation of the table elements for
  8484. * each row until they are needed for a draw - saving a significant amount of
  8485. * time.
  8486. * @type boolean
  8487. * @default false
  8488. *
  8489. * @dtopt Features
  8490. * @name DataTable.defaults.deferRender
  8491. *
  8492. * @example
  8493. * $(document).ready( function() {
  8494. * $('#example').dataTable( {
  8495. * "ajax": "sources/arrays.txt",
  8496. * "deferRender": true
  8497. * } );
  8498. * } );
  8499. */
  8500. "bDeferRender": false,
  8501. /**
  8502. * Replace a DataTable which matches the given selector and replace it with
  8503. * one which has the properties of the new initialisation object passed. If no
  8504. * table matches the selector, then the new DataTable will be constructed as
  8505. * per normal.
  8506. * @type boolean
  8507. * @default false
  8508. *
  8509. * @dtopt Options
  8510. * @name DataTable.defaults.destroy
  8511. *
  8512. * @example
  8513. * $(document).ready( function() {
  8514. * $('#example').dataTable( {
  8515. * "srollY": "200px",
  8516. * "paginate": false
  8517. * } );
  8518. *
  8519. * // Some time later....
  8520. * $('#example').dataTable( {
  8521. * "filter": false,
  8522. * "destroy": true
  8523. * } );
  8524. * } );
  8525. */
  8526. "bDestroy": false,
  8527. /**
  8528. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8529. * that it allows the end user to input multiple words (space separated) and
  8530. * will match a row containing those words, even if not in the order that was
  8531. * specified (this allow matching across multiple columns). Note that if you
  8532. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8533. * default filtering input box and retain filtering abilities, please use
  8534. * {@link DataTable.defaults.dom}.
  8535. * @type boolean
  8536. * @default true
  8537. *
  8538. * @dtopt Features
  8539. * @name DataTable.defaults.searching
  8540. *
  8541. * @example
  8542. * $(document).ready( function () {
  8543. * $('#example').dataTable( {
  8544. * "searching": false
  8545. * } );
  8546. * } );
  8547. */
  8548. "bFilter": true,
  8549. /**
  8550. * Enable or disable the table information display. This shows information
  8551. * about the data that is currently visible on the page, including information
  8552. * about filtered data if that action is being performed.
  8553. * @type boolean
  8554. * @default true
  8555. *
  8556. * @dtopt Features
  8557. * @name DataTable.defaults.info
  8558. *
  8559. * @example
  8560. * $(document).ready( function () {
  8561. * $('#example').dataTable( {
  8562. * "info": false
  8563. * } );
  8564. * } );
  8565. */
  8566. "bInfo": true,
  8567. /**
  8568. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8569. * slightly different and additional mark-up from what DataTables has
  8570. * traditionally used).
  8571. * @type boolean
  8572. * @default false
  8573. *
  8574. * @dtopt Features
  8575. * @name DataTable.defaults.jQueryUI
  8576. *
  8577. * @example
  8578. * $(document).ready( function() {
  8579. * $('#example').dataTable( {
  8580. * "jQueryUI": true
  8581. * } );
  8582. * } );
  8583. */
  8584. "bJQueryUI": false,
  8585. /**
  8586. * Allows the end user to select the size of a formatted page from a select
  8587. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8588. * @type boolean
  8589. * @default true
  8590. *
  8591. * @dtopt Features
  8592. * @name DataTable.defaults.lengthChange
  8593. *
  8594. * @example
  8595. * $(document).ready( function () {
  8596. * $('#example').dataTable( {
  8597. * "lengthChange": false
  8598. * } );
  8599. * } );
  8600. */
  8601. "bLengthChange": true,
  8602. /**
  8603. * Enable or disable pagination.
  8604. * @type boolean
  8605. * @default true
  8606. *
  8607. * @dtopt Features
  8608. * @name DataTable.defaults.paging
  8609. *
  8610. * @example
  8611. * $(document).ready( function () {
  8612. * $('#example').dataTable( {
  8613. * "paging": false
  8614. * } );
  8615. * } );
  8616. */
  8617. "bPaginate": true,
  8618. /**
  8619. * Enable or disable the display of a 'processing' indicator when the table is
  8620. * being processed (e.g. a sort). This is particularly useful for tables with
  8621. * large amounts of data where it can take a noticeable amount of time to sort
  8622. * the entries.
  8623. * @type boolean
  8624. * @default false
  8625. *
  8626. * @dtopt Features
  8627. * @name DataTable.defaults.processing
  8628. *
  8629. * @example
  8630. * $(document).ready( function () {
  8631. * $('#example').dataTable( {
  8632. * "processing": true
  8633. * } );
  8634. * } );
  8635. */
  8636. "bProcessing": false,
  8637. /**
  8638. * Retrieve the DataTables object for the given selector. Note that if the
  8639. * table has already been initialised, this parameter will cause DataTables
  8640. * to simply return the object that has already been set up - it will not take
  8641. * account of any changes you might have made to the initialisation object
  8642. * passed to DataTables (setting this parameter to true is an acknowledgement
  8643. * that you understand this). `destroy` can be used to reinitialise a table if
  8644. * you need.
  8645. * @type boolean
  8646. * @default false
  8647. *
  8648. * @dtopt Options
  8649. * @name DataTable.defaults.retrieve
  8650. *
  8651. * @example
  8652. * $(document).ready( function() {
  8653. * initTable();
  8654. * tableActions();
  8655. * } );
  8656. *
  8657. * function initTable ()
  8658. * {
  8659. * return $('#example').dataTable( {
  8660. * "scrollY": "200px",
  8661. * "paginate": false,
  8662. * "retrieve": true
  8663. * } );
  8664. * }
  8665. *
  8666. * function tableActions ()
  8667. * {
  8668. * var table = initTable();
  8669. * // perform API operations with oTable
  8670. * }
  8671. */
  8672. "bRetrieve": false,
  8673. /**
  8674. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8675. * the table's viewport to the given height at all times (useful for layout).
  8676. * However, this can look odd when filtering data down to a small data set,
  8677. * and the footer is left "floating" further down. This parameter (when
  8678. * enabled) will cause DataTables to collapse the table's viewport down when
  8679. * the result set will fit within the given Y height.
  8680. * @type boolean
  8681. * @default false
  8682. *
  8683. * @dtopt Options
  8684. * @name DataTable.defaults.scrollCollapse
  8685. *
  8686. * @example
  8687. * $(document).ready( function() {
  8688. * $('#example').dataTable( {
  8689. * "scrollY": "200",
  8690. * "scrollCollapse": true
  8691. * } );
  8692. * } );
  8693. */
  8694. "bScrollCollapse": false,
  8695. /**
  8696. * Configure DataTables to use server-side processing. Note that the
  8697. * `ajax` parameter must also be given in order to give DataTables a
  8698. * source to obtain the required data for each draw.
  8699. * @type boolean
  8700. * @default false
  8701. *
  8702. * @dtopt Features
  8703. * @dtopt Server-side
  8704. * @name DataTable.defaults.serverSide
  8705. *
  8706. * @example
  8707. * $(document).ready( function () {
  8708. * $('#example').dataTable( {
  8709. * "serverSide": true,
  8710. * "ajax": "xhr.php"
  8711. * } );
  8712. * } );
  8713. */
  8714. "bServerSide": false,
  8715. /**
  8716. * Enable or disable sorting of columns. Sorting of individual columns can be
  8717. * disabled by the `sortable` option for each column.
  8718. * @type boolean
  8719. * @default true
  8720. *
  8721. * @dtopt Features
  8722. * @name DataTable.defaults.ordering
  8723. *
  8724. * @example
  8725. * $(document).ready( function () {
  8726. * $('#example').dataTable( {
  8727. * "ordering": false
  8728. * } );
  8729. * } );
  8730. */
  8731. "bSort": true,
  8732. /**
  8733. * Enable or display DataTables' ability to sort multiple columns at the
  8734. * same time (activated by shift-click by the user).
  8735. * @type boolean
  8736. * @default true
  8737. *
  8738. * @dtopt Options
  8739. * @name DataTable.defaults.orderMulti
  8740. *
  8741. * @example
  8742. * // Disable multiple column sorting ability
  8743. * $(document).ready( function () {
  8744. * $('#example').dataTable( {
  8745. * "orderMulti": false
  8746. * } );
  8747. * } );
  8748. */
  8749. "bSortMulti": true,
  8750. /**
  8751. * Allows control over whether DataTables should use the top (true) unique
  8752. * cell that is found for a single column, or the bottom (false - default).
  8753. * This is useful when using complex headers.
  8754. * @type boolean
  8755. * @default false
  8756. *
  8757. * @dtopt Options
  8758. * @name DataTable.defaults.orderCellsTop
  8759. *
  8760. * @example
  8761. * $(document).ready( function() {
  8762. * $('#example').dataTable( {
  8763. * "orderCellsTop": true
  8764. * } );
  8765. * } );
  8766. */
  8767. "bSortCellsTop": false,
  8768. /**
  8769. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8770. * `sorting\_3` to the columns which are currently being sorted on. This is
  8771. * presented as a feature switch as it can increase processing time (while
  8772. * classes are removed and added) so for large data sets you might want to
  8773. * turn this off.
  8774. * @type boolean
  8775. * @default true
  8776. *
  8777. * @dtopt Features
  8778. * @name DataTable.defaults.orderClasses
  8779. *
  8780. * @example
  8781. * $(document).ready( function () {
  8782. * $('#example').dataTable( {
  8783. * "orderClasses": false
  8784. * } );
  8785. * } );
  8786. */
  8787. "bSortClasses": true,
  8788. /**
  8789. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  8790. * used to save table display information such as pagination information,
  8791. * display length, filtering and sorting. As such when the end user reloads
  8792. * the page the display display will match what thy had previously set up.
  8793. *
  8794. * Due to the use of `localStorage` the default state saving is not supported
  8795. * in IE6 or 7. If state saving is required in those browsers, use
  8796. * `stateSaveCallback` to provide a storage solution such as cookies.
  8797. * @type boolean
  8798. * @default false
  8799. *
  8800. * @dtopt Features
  8801. * @name DataTable.defaults.stateSave
  8802. *
  8803. * @example
  8804. * $(document).ready( function () {
  8805. * $('#example').dataTable( {
  8806. * "stateSave": true
  8807. * } );
  8808. * } );
  8809. */
  8810. "bStateSave": false,
  8811. /**
  8812. * This function is called when a TR element is created (and all TD child
  8813. * elements have been inserted), or registered if using a DOM source, allowing
  8814. * manipulation of the TR element (adding classes etc).
  8815. * @type function
  8816. * @param {node} row "TR" element for the current row
  8817. * @param {array} data Raw data array for this row
  8818. * @param {int} dataIndex The index of this row in the internal aoData array
  8819. *
  8820. * @dtopt Callbacks
  8821. * @name DataTable.defaults.createdRow
  8822. *
  8823. * @example
  8824. * $(document).ready( function() {
  8825. * $('#example').dataTable( {
  8826. * "createdRow": function( row, data, dataIndex ) {
  8827. * // Bold the grade for all 'A' grade browsers
  8828. * if ( data[4] == "A" )
  8829. * {
  8830. * $('td:eq(4)', row).html( '<b>A</b>' );
  8831. * }
  8832. * }
  8833. * } );
  8834. * } );
  8835. */
  8836. "fnCreatedRow": null,
  8837. /**
  8838. * This function is called on every 'draw' event, and allows you to
  8839. * dynamically modify any aspect you want about the created DOM.
  8840. * @type function
  8841. * @param {object} settings DataTables settings object
  8842. *
  8843. * @dtopt Callbacks
  8844. * @name DataTable.defaults.drawCallback
  8845. *
  8846. * @example
  8847. * $(document).ready( function() {
  8848. * $('#example').dataTable( {
  8849. * "drawCallback": function( settings ) {
  8850. * alert( 'DataTables has redrawn the table' );
  8851. * }
  8852. * } );
  8853. * } );
  8854. */
  8855. "fnDrawCallback": null,
  8856. /**
  8857. * Identical to fnHeaderCallback() but for the table footer this function
  8858. * allows you to modify the table footer on every 'draw' event.
  8859. * @type function
  8860. * @param {node} foot "TR" element for the footer
  8861. * @param {array} data Full table data (as derived from the original HTML)
  8862. * @param {int} start Index for the current display starting point in the
  8863. * display array
  8864. * @param {int} end Index for the current display ending point in the
  8865. * display array
  8866. * @param {array int} display Index array to translate the visual position
  8867. * to the full data array
  8868. *
  8869. * @dtopt Callbacks
  8870. * @name DataTable.defaults.footerCallback
  8871. *
  8872. * @example
  8873. * $(document).ready( function() {
  8874. * $('#example').dataTable( {
  8875. * "footerCallback": function( tfoot, data, start, end, display ) {
  8876. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  8877. * }
  8878. * } );
  8879. * } )
  8880. */
  8881. "fnFooterCallback": null,
  8882. /**
  8883. * When rendering large numbers in the information element for the table
  8884. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  8885. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  8886. * rendered as "1,000,000") to help readability for the end user. This
  8887. * function will override the default method DataTables uses.
  8888. * @type function
  8889. * @member
  8890. * @param {int} toFormat number to be formatted
  8891. * @returns {string} formatted string for DataTables to show the number
  8892. *
  8893. * @dtopt Callbacks
  8894. * @name DataTable.defaults.formatNumber
  8895. *
  8896. * @example
  8897. * // Format a number using a single quote for the separator (note that
  8898. * // this can also be done with the language.thousands option)
  8899. * $(document).ready( function() {
  8900. * $('#example').dataTable( {
  8901. * "formatNumber": function ( toFormat ) {
  8902. * return toFormat.toString().replace(
  8903. * /\B(?=(\d{3})+(?!\d))/g, "'"
  8904. * );
  8905. * };
  8906. * } );
  8907. * } );
  8908. */
  8909. "fnFormatNumber": function ( toFormat ) {
  8910. return toFormat.toString().replace(
  8911. /\B(?=(\d{3})+(?!\d))/g,
  8912. this.oLanguage.sThousands
  8913. );
  8914. },
  8915. /**
  8916. * This function is called on every 'draw' event, and allows you to
  8917. * dynamically modify the header row. This can be used to calculate and
  8918. * display useful information about the table.
  8919. * @type function
  8920. * @param {node} head "TR" element for the header
  8921. * @param {array} data Full table data (as derived from the original HTML)
  8922. * @param {int} start Index for the current display starting point in the
  8923. * display array
  8924. * @param {int} end Index for the current display ending point in the
  8925. * display array
  8926. * @param {array int} display Index array to translate the visual position
  8927. * to the full data array
  8928. *
  8929. * @dtopt Callbacks
  8930. * @name DataTable.defaults.headerCallback
  8931. *
  8932. * @example
  8933. * $(document).ready( function() {
  8934. * $('#example').dataTable( {
  8935. * "fheaderCallback": function( head, data, start, end, display ) {
  8936. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  8937. * }
  8938. * } );
  8939. * } )
  8940. */
  8941. "fnHeaderCallback": null,
  8942. /**
  8943. * The information element can be used to convey information about the current
  8944. * state of the table. Although the internationalisation options presented by
  8945. * DataTables are quite capable of dealing with most customisations, there may
  8946. * be times where you wish to customise the string further. This callback
  8947. * allows you to do exactly that.
  8948. * @type function
  8949. * @param {object} oSettings DataTables settings object
  8950. * @param {int} start Starting position in data for the draw
  8951. * @param {int} end End position in data for the draw
  8952. * @param {int} max Total number of rows in the table (regardless of
  8953. * filtering)
  8954. * @param {int} total Total number of rows in the data set, after filtering
  8955. * @param {string} pre The string that DataTables has formatted using it's
  8956. * own rules
  8957. * @returns {string} The string to be displayed in the information element.
  8958. *
  8959. * @dtopt Callbacks
  8960. * @name DataTable.defaults.infoCallback
  8961. *
  8962. * @example
  8963. * $('#example').dataTable( {
  8964. * "infoCallback": function( settings, start, end, max, total, pre ) {
  8965. * return start +" to "+ end;
  8966. * }
  8967. * } );
  8968. */
  8969. "fnInfoCallback": null,
  8970. /**
  8971. * Called when the table has been initialised. Normally DataTables will
  8972. * initialise sequentially and there will be no need for this function,
  8973. * however, this does not hold true when using external language information
  8974. * since that is obtained using an async XHR call.
  8975. * @type function
  8976. * @param {object} settings DataTables settings object
  8977. * @param {object} json The JSON object request from the server - only
  8978. * present if client-side Ajax sourced data is used
  8979. *
  8980. * @dtopt Callbacks
  8981. * @name DataTable.defaults.initComplete
  8982. *
  8983. * @example
  8984. * $(document).ready( function() {
  8985. * $('#example').dataTable( {
  8986. * "initComplete": function(settings, json) {
  8987. * alert( 'DataTables has finished its initialisation.' );
  8988. * }
  8989. * } );
  8990. * } )
  8991. */
  8992. "fnInitComplete": null,
  8993. /**
  8994. * Called at the very start of each table draw and can be used to cancel the
  8995. * draw by returning false, any other return (including undefined) results in
  8996. * the full draw occurring).
  8997. * @type function
  8998. * @param {object} settings DataTables settings object
  8999. * @returns {boolean} False will cancel the draw, anything else (including no
  9000. * return) will allow it to complete.
  9001. *
  9002. * @dtopt Callbacks
  9003. * @name DataTable.defaults.preDrawCallback
  9004. *
  9005. * @example
  9006. * $(document).ready( function() {
  9007. * $('#example').dataTable( {
  9008. * "preDrawCallback": function( settings ) {
  9009. * if ( $('#test').val() == 1 ) {
  9010. * return false;
  9011. * }
  9012. * }
  9013. * } );
  9014. * } );
  9015. */
  9016. "fnPreDrawCallback": null,
  9017. /**
  9018. * This function allows you to 'post process' each row after it have been
  9019. * generated for each table draw, but before it is rendered on screen. This
  9020. * function might be used for setting the row class name etc.
  9021. * @type function
  9022. * @param {node} row "TR" element for the current row
  9023. * @param {array} data Raw data array for this row
  9024. * @param {int} displayIndex The display index for the current table draw
  9025. * @param {int} displayIndexFull The index of the data in the full list of
  9026. * rows (after filtering)
  9027. *
  9028. * @dtopt Callbacks
  9029. * @name DataTable.defaults.rowCallback
  9030. *
  9031. * @example
  9032. * $(document).ready( function() {
  9033. * $('#example').dataTable( {
  9034. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9035. * // Bold the grade for all 'A' grade browsers
  9036. * if ( data[4] == "A" ) {
  9037. * $('td:eq(4)', row).html( '<b>A</b>' );
  9038. * }
  9039. * }
  9040. * } );
  9041. * } );
  9042. */
  9043. "fnRowCallback": null,
  9044. /**
  9045. * __Deprecated__ The functionality provided by this parameter has now been
  9046. * superseded by that provided through `ajax`, which should be used instead.
  9047. *
  9048. * This parameter allows you to override the default function which obtains
  9049. * the data from the server so something more suitable for your application.
  9050. * For example you could use POST data, or pull information from a Gears or
  9051. * AIR database.
  9052. * @type function
  9053. * @member
  9054. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9055. * @param {array} data A key/value pair object containing the data to send
  9056. * to the server
  9057. * @param {function} callback to be called on completion of the data get
  9058. * process that will draw the data on the page.
  9059. * @param {object} settings DataTables settings object
  9060. *
  9061. * @dtopt Callbacks
  9062. * @dtopt Server-side
  9063. * @name DataTable.defaults.serverData
  9064. *
  9065. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9066. */
  9067. "fnServerData": null,
  9068. /**
  9069. * __Deprecated__ The functionality provided by this parameter has now been
  9070. * superseded by that provided through `ajax`, which should be used instead.
  9071. *
  9072. * It is often useful to send extra data to the server when making an Ajax
  9073. * request - for example custom filtering information, and this callback
  9074. * function makes it trivial to send extra information to the server. The
  9075. * passed in parameter is the data set that has been constructed by
  9076. * DataTables, and you can add to this or modify it as you require.
  9077. * @type function
  9078. * @param {array} data Data array (array of objects which are name/value
  9079. * pairs) that has been constructed by DataTables and will be sent to the
  9080. * server. In the case of Ajax sourced data with server-side processing
  9081. * this will be an empty array, for server-side processing there will be a
  9082. * significant number of parameters!
  9083. * @returns {undefined} Ensure that you modify the data array passed in,
  9084. * as this is passed by reference.
  9085. *
  9086. * @dtopt Callbacks
  9087. * @dtopt Server-side
  9088. * @name DataTable.defaults.serverParams
  9089. *
  9090. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9091. */
  9092. "fnServerParams": null,
  9093. /**
  9094. * Load the table state. With this function you can define from where, and how, the
  9095. * state of a table is loaded. By default DataTables will load from `localStorage`
  9096. * but you might wish to use a server-side database or cookies.
  9097. * @type function
  9098. * @member
  9099. * @param {object} settings DataTables settings object
  9100. * @return {object} The DataTables state object to be loaded
  9101. *
  9102. * @dtopt Callbacks
  9103. * @name DataTable.defaults.stateLoadCallback
  9104. *
  9105. * @example
  9106. * $(document).ready( function() {
  9107. * $('#example').dataTable( {
  9108. * "stateSave": true,
  9109. * "stateLoadCallback": function (settings) {
  9110. * var o;
  9111. *
  9112. * // Send an Ajax request to the server to get the data. Note that
  9113. * // this is a synchronous request.
  9114. * $.ajax( {
  9115. * "url": "/state_load",
  9116. * "async": false,
  9117. * "dataType": "json",
  9118. * "success": function (json) {
  9119. * o = json;
  9120. * }
  9121. * } );
  9122. *
  9123. * return o;
  9124. * }
  9125. * } );
  9126. * } );
  9127. */
  9128. "fnStateLoadCallback": function ( settings ) {
  9129. try {
  9130. return JSON.parse(
  9131. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9132. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9133. )
  9134. );
  9135. } catch (e) {}
  9136. },
  9137. /**
  9138. * Callback which allows modification of the saved state prior to loading that state.
  9139. * This callback is called when the table is loading state from the stored data, but
  9140. * prior to the settings object being modified by the saved state. Note that for
  9141. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9142. * a plug-in.
  9143. * @type function
  9144. * @param {object} settings DataTables settings object
  9145. * @param {object} data The state object that is to be loaded
  9146. *
  9147. * @dtopt Callbacks
  9148. * @name DataTable.defaults.stateLoadParams
  9149. *
  9150. * @example
  9151. * // Remove a saved filter, so filtering is never loaded
  9152. * $(document).ready( function() {
  9153. * $('#example').dataTable( {
  9154. * "stateSave": true,
  9155. * "stateLoadParams": function (settings, data) {
  9156. * data.oSearch.sSearch = "";
  9157. * }
  9158. * } );
  9159. * } );
  9160. *
  9161. * @example
  9162. * // Disallow state loading by returning false
  9163. * $(document).ready( function() {
  9164. * $('#example').dataTable( {
  9165. * "stateSave": true,
  9166. * "stateLoadParams": function (settings, data) {
  9167. * return false;
  9168. * }
  9169. * } );
  9170. * } );
  9171. */
  9172. "fnStateLoadParams": null,
  9173. /**
  9174. * Callback that is called when the state has been loaded from the state saving method
  9175. * and the DataTables settings object has been modified as a result of the loaded state.
  9176. * @type function
  9177. * @param {object} settings DataTables settings object
  9178. * @param {object} data The state object that was loaded
  9179. *
  9180. * @dtopt Callbacks
  9181. * @name DataTable.defaults.stateLoaded
  9182. *
  9183. * @example
  9184. * // Show an alert with the filtering value that was saved
  9185. * $(document).ready( function() {
  9186. * $('#example').dataTable( {
  9187. * "stateSave": true,
  9188. * "stateLoaded": function (settings, data) {
  9189. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9190. * }
  9191. * } );
  9192. * } );
  9193. */
  9194. "fnStateLoaded": null,
  9195. /**
  9196. * Save the table state. This function allows you to define where and how the state
  9197. * information for the table is stored By default DataTables will use `localStorage`
  9198. * but you might wish to use a server-side database or cookies.
  9199. * @type function
  9200. * @member
  9201. * @param {object} settings DataTables settings object
  9202. * @param {object} data The state object to be saved
  9203. *
  9204. * @dtopt Callbacks
  9205. * @name DataTable.defaults.stateSaveCallback
  9206. *
  9207. * @example
  9208. * $(document).ready( function() {
  9209. * $('#example').dataTable( {
  9210. * "stateSave": true,
  9211. * "stateSaveCallback": function (settings, data) {
  9212. * // Send an Ajax request to the server with the state object
  9213. * $.ajax( {
  9214. * "url": "/state_save",
  9215. * "data": data,
  9216. * "dataType": "json",
  9217. * "method": "POST"
  9218. * "success": function () {}
  9219. * } );
  9220. * }
  9221. * } );
  9222. * } );
  9223. */
  9224. "fnStateSaveCallback": function ( settings, data ) {
  9225. try {
  9226. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9227. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9228. JSON.stringify( data )
  9229. );
  9230. } catch (e) {}
  9231. },
  9232. /**
  9233. * Callback which allows modification of the state to be saved. Called when the table
  9234. * has changed state a new state save is required. This method allows modification of
  9235. * the state saving object prior to actually doing the save, including addition or
  9236. * other state properties or modification. Note that for plug-in authors, you should
  9237. * use the `stateSaveParams` event to save parameters for a plug-in.
  9238. * @type function
  9239. * @param {object} settings DataTables settings object
  9240. * @param {object} data The state object to be saved
  9241. *
  9242. * @dtopt Callbacks
  9243. * @name DataTable.defaults.stateSaveParams
  9244. *
  9245. * @example
  9246. * // Remove a saved filter, so filtering is never saved
  9247. * $(document).ready( function() {
  9248. * $('#example').dataTable( {
  9249. * "stateSave": true,
  9250. * "stateSaveParams": function (settings, data) {
  9251. * data.oSearch.sSearch = "";
  9252. * }
  9253. * } );
  9254. * } );
  9255. */
  9256. "fnStateSaveParams": null,
  9257. /**
  9258. * Duration for which the saved state information is considered valid. After this period
  9259. * has elapsed the state will be returned to the default.
  9260. * Value is given in seconds.
  9261. * @type int
  9262. * @default 7200 <i>(2 hours)</i>
  9263. *
  9264. * @dtopt Options
  9265. * @name DataTable.defaults.stateDuration
  9266. *
  9267. * @example
  9268. * $(document).ready( function() {
  9269. * $('#example').dataTable( {
  9270. * "stateDuration": 60*60*24; // 1 day
  9271. * } );
  9272. * } )
  9273. */
  9274. "iStateDuration": 7200,
  9275. /**
  9276. * When enabled DataTables will not make a request to the server for the first
  9277. * page draw - rather it will use the data already on the page (no sorting etc
  9278. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9279. * is used to indicate that deferred loading is required, but it is also used
  9280. * to tell DataTables how many records there are in the full table (allowing
  9281. * the information element and pagination to be displayed correctly). In the case
  9282. * where a filtering is applied to the table on initial load, this can be
  9283. * indicated by giving the parameter as an array, where the first element is
  9284. * the number of records available after filtering and the second element is the
  9285. * number of records without filtering (allowing the table information element
  9286. * to be shown correctly).
  9287. * @type int | array
  9288. * @default null
  9289. *
  9290. * @dtopt Options
  9291. * @name DataTable.defaults.deferLoading
  9292. *
  9293. * @example
  9294. * // 57 records available in the table, no filtering applied
  9295. * $(document).ready( function() {
  9296. * $('#example').dataTable( {
  9297. * "serverSide": true,
  9298. * "ajax": "scripts/server_processing.php",
  9299. * "deferLoading": 57
  9300. * } );
  9301. * } );
  9302. *
  9303. * @example
  9304. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9305. * $(document).ready( function() {
  9306. * $('#example').dataTable( {
  9307. * "serverSide": true,
  9308. * "ajax": "scripts/server_processing.php",
  9309. * "deferLoading": [ 57, 100 ],
  9310. * "search": {
  9311. * "search": "my_filter"
  9312. * }
  9313. * } );
  9314. * } );
  9315. */
  9316. "iDeferLoading": null,
  9317. /**
  9318. * Number of rows to display on a single page when using pagination. If
  9319. * feature enabled (`lengthChange`) then the end user will be able to override
  9320. * this to a custom setting using a pop-up menu.
  9321. * @type int
  9322. * @default 10
  9323. *
  9324. * @dtopt Options
  9325. * @name DataTable.defaults.pageLength
  9326. *
  9327. * @example
  9328. * $(document).ready( function() {
  9329. * $('#example').dataTable( {
  9330. * "pageLength": 50
  9331. * } );
  9332. * } )
  9333. */
  9334. "iDisplayLength": 10,
  9335. /**
  9336. * Define the starting point for data display when using DataTables with
  9337. * pagination. Note that this parameter is the number of records, rather than
  9338. * the page number, so if you have 10 records per page and want to start on
  9339. * the third page, it should be "20".
  9340. * @type int
  9341. * @default 0
  9342. *
  9343. * @dtopt Options
  9344. * @name DataTable.defaults.displayStart
  9345. *
  9346. * @example
  9347. * $(document).ready( function() {
  9348. * $('#example').dataTable( {
  9349. * "displayStart": 20
  9350. * } );
  9351. * } )
  9352. */
  9353. "iDisplayStart": 0,
  9354. /**
  9355. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9356. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9357. * allows you to tab through the controls and press the enter key to activate them.
  9358. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9359. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9360. * disable built-in keyboard navigation.
  9361. * @type int
  9362. * @default 0
  9363. *
  9364. * @dtopt Options
  9365. * @name DataTable.defaults.tabIndex
  9366. *
  9367. * @example
  9368. * $(document).ready( function() {
  9369. * $('#example').dataTable( {
  9370. * "tabIndex": 1
  9371. * } );
  9372. * } );
  9373. */
  9374. "iTabIndex": 0,
  9375. /**
  9376. * Classes that DataTables assigns to the various components and features
  9377. * that it adds to the HTML table. This allows classes to be configured
  9378. * during initialisation in addition to through the static
  9379. * {@link DataTable.ext.oStdClasses} object).
  9380. * @namespace
  9381. * @name DataTable.defaults.classes
  9382. */
  9383. "oClasses": {},
  9384. /**
  9385. * All strings that DataTables uses in the user interface that it creates
  9386. * are defined in this object, allowing you to modified them individually or
  9387. * completely replace them all as required.
  9388. * @namespace
  9389. * @name DataTable.defaults.language
  9390. */
  9391. "oLanguage": {
  9392. /**
  9393. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9394. * actually visible on the page, but will be read by screenreaders, and thus
  9395. * must be internationalised as well).
  9396. * @namespace
  9397. * @name DataTable.defaults.language.aria
  9398. */
  9399. "oAria": {
  9400. /**
  9401. * ARIA label that is added to the table headers when the column may be
  9402. * sorted ascending by activing the column (click or return when focused).
  9403. * Note that the column header is prefixed to this string.
  9404. * @type string
  9405. * @default : activate to sort column ascending
  9406. *
  9407. * @dtopt Language
  9408. * @name DataTable.defaults.language.aria.sortAscending
  9409. *
  9410. * @example
  9411. * $(document).ready( function() {
  9412. * $('#example').dataTable( {
  9413. * "language": {
  9414. * "aria": {
  9415. * "sortAscending": " - click/return to sort ascending"
  9416. * }
  9417. * }
  9418. * } );
  9419. * } );
  9420. */
  9421. "sSortAscending": ": activate to sort column ascending",
  9422. /**
  9423. * ARIA label that is added to the table headers when the column may be
  9424. * sorted descending by activing the column (click or return when focused).
  9425. * Note that the column header is prefixed to this string.
  9426. * @type string
  9427. * @default : activate to sort column ascending
  9428. *
  9429. * @dtopt Language
  9430. * @name DataTable.defaults.language.aria.sortDescending
  9431. *
  9432. * @example
  9433. * $(document).ready( function() {
  9434. * $('#example').dataTable( {
  9435. * "language": {
  9436. * "aria": {
  9437. * "sortDescending": " - click/return to sort descending"
  9438. * }
  9439. * }
  9440. * } );
  9441. * } );
  9442. */
  9443. "sSortDescending": ": activate to sort column descending"
  9444. },
  9445. /**
  9446. * Pagination string used by DataTables for the built-in pagination
  9447. * control types.
  9448. * @namespace
  9449. * @name DataTable.defaults.language.paginate
  9450. */
  9451. "oPaginate": {
  9452. /**
  9453. * Text to use when using the 'full_numbers' type of pagination for the
  9454. * button to take the user to the first page.
  9455. * @type string
  9456. * @default First
  9457. *
  9458. * @dtopt Language
  9459. * @name DataTable.defaults.language.paginate.first
  9460. *
  9461. * @example
  9462. * $(document).ready( function() {
  9463. * $('#example').dataTable( {
  9464. * "language": {
  9465. * "paginate": {
  9466. * "first": "First page"
  9467. * }
  9468. * }
  9469. * } );
  9470. * } );
  9471. */
  9472. "sFirst": "First",
  9473. /**
  9474. * Text to use when using the 'full_numbers' type of pagination for the
  9475. * button to take the user to the last page.
  9476. * @type string
  9477. * @default Last
  9478. *
  9479. * @dtopt Language
  9480. * @name DataTable.defaults.language.paginate.last
  9481. *
  9482. * @example
  9483. * $(document).ready( function() {
  9484. * $('#example').dataTable( {
  9485. * "language": {
  9486. * "paginate": {
  9487. * "last": "Last page"
  9488. * }
  9489. * }
  9490. * } );
  9491. * } );
  9492. */
  9493. "sLast": "Last",
  9494. /**
  9495. * Text to use for the 'next' pagination button (to take the user to the
  9496. * next page).
  9497. * @type string
  9498. * @default Next
  9499. *
  9500. * @dtopt Language
  9501. * @name DataTable.defaults.language.paginate.next
  9502. *
  9503. * @example
  9504. * $(document).ready( function() {
  9505. * $('#example').dataTable( {
  9506. * "language": {
  9507. * "paginate": {
  9508. * "next": "Next page"
  9509. * }
  9510. * }
  9511. * } );
  9512. * } );
  9513. */
  9514. "sNext": "Next",
  9515. /**
  9516. * Text to use for the 'previous' pagination button (to take the user to
  9517. * the previous page).
  9518. * @type string
  9519. * @default Previous
  9520. *
  9521. * @dtopt Language
  9522. * @name DataTable.defaults.language.paginate.previous
  9523. *
  9524. * @example
  9525. * $(document).ready( function() {
  9526. * $('#example').dataTable( {
  9527. * "language": {
  9528. * "paginate": {
  9529. * "previous": "Previous page"
  9530. * }
  9531. * }
  9532. * } );
  9533. * } );
  9534. */
  9535. "sPrevious": "Previous"
  9536. },
  9537. /**
  9538. * This string is shown in preference to `zeroRecords` when the table is
  9539. * empty of data (regardless of filtering). Note that this is an optional
  9540. * parameter - if it is not given, the value of `zeroRecords` will be used
  9541. * instead (either the default or given value).
  9542. * @type string
  9543. * @default No data available in table
  9544. *
  9545. * @dtopt Language
  9546. * @name DataTable.defaults.language.emptyTable
  9547. *
  9548. * @example
  9549. * $(document).ready( function() {
  9550. * $('#example').dataTable( {
  9551. * "language": {
  9552. * "emptyTable": "No data available in table"
  9553. * }
  9554. * } );
  9555. * } );
  9556. */
  9557. "sEmptyTable": "No data available in table",
  9558. /**
  9559. * This string gives information to the end user about the information
  9560. * that is current on display on the page. The following tokens can be
  9561. * used in the string and will be dynamically replaced as the table
  9562. * display updates. This tokens can be placed anywhere in the string, or
  9563. * removed as needed by the language requires:
  9564. *
  9565. * * `\_START\_` - Display index of the first record on the current page
  9566. * * `\_END\_` - Display index of the last record on the current page
  9567. * * `\_TOTAL\_` - Number of records in the table after filtering
  9568. * * `\_MAX\_` - Number of records in the table without filtering
  9569. * * `\_PAGE\_` - Current page number
  9570. * * `\_PAGES\_` - Total number of pages of data in the table
  9571. *
  9572. * @type string
  9573. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9574. *
  9575. * @dtopt Language
  9576. * @name DataTable.defaults.language.info
  9577. *
  9578. * @example
  9579. * $(document).ready( function() {
  9580. * $('#example').dataTable( {
  9581. * "language": {
  9582. * "info": "Showing page _PAGE_ of _PAGES_"
  9583. * }
  9584. * } );
  9585. * } );
  9586. */
  9587. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9588. /**
  9589. * Display information string for when the table is empty. Typically the
  9590. * format of this string should match `info`.
  9591. * @type string
  9592. * @default Showing 0 to 0 of 0 entries
  9593. *
  9594. * @dtopt Language
  9595. * @name DataTable.defaults.language.infoEmpty
  9596. *
  9597. * @example
  9598. * $(document).ready( function() {
  9599. * $('#example').dataTable( {
  9600. * "language": {
  9601. * "infoEmpty": "No entries to show"
  9602. * }
  9603. * } );
  9604. * } );
  9605. */
  9606. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9607. /**
  9608. * When a user filters the information in a table, this string is appended
  9609. * to the information (`info`) to give an idea of how strong the filtering
  9610. * is. The variable _MAX_ is dynamically updated.
  9611. * @type string
  9612. * @default (filtered from _MAX_ total entries)
  9613. *
  9614. * @dtopt Language
  9615. * @name DataTable.defaults.language.infoFiltered
  9616. *
  9617. * @example
  9618. * $(document).ready( function() {
  9619. * $('#example').dataTable( {
  9620. * "language": {
  9621. * "infoFiltered": " - filtering from _MAX_ records"
  9622. * }
  9623. * } );
  9624. * } );
  9625. */
  9626. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9627. /**
  9628. * If can be useful to append extra information to the info string at times,
  9629. * and this variable does exactly that. This information will be appended to
  9630. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9631. * being used) at all times.
  9632. * @type string
  9633. * @default <i>Empty string</i>
  9634. *
  9635. * @dtopt Language
  9636. * @name DataTable.defaults.language.infoPostFix
  9637. *
  9638. * @example
  9639. * $(document).ready( function() {
  9640. * $('#example').dataTable( {
  9641. * "language": {
  9642. * "infoPostFix": "All records shown are derived from real information."
  9643. * }
  9644. * } );
  9645. * } );
  9646. */
  9647. "sInfoPostFix": "",
  9648. /**
  9649. * This decimal place operator is a little different from the other
  9650. * language options since DataTables doesn't output floating point
  9651. * numbers, so it won't ever use this for display of a number. Rather,
  9652. * what this parameter does is modify the sort methods of the table so
  9653. * that numbers which are in a format which has a character other than
  9654. * a period (`.`) as a decimal place will be sorted numerically.
  9655. *
  9656. * Note that numbers with different decimal places cannot be shown in
  9657. * the same table and still be sortable, the table must be consistent.
  9658. * However, multiple different tables on the page can use different
  9659. * decimal place characters.
  9660. * @type string
  9661. * @default
  9662. *
  9663. * @dtopt Language
  9664. * @name DataTable.defaults.language.decimal
  9665. *
  9666. * @example
  9667. * $(document).ready( function() {
  9668. * $('#example').dataTable( {
  9669. * "language": {
  9670. * "decimal": ","
  9671. * "thousands": "."
  9672. * }
  9673. * } );
  9674. * } );
  9675. */
  9676. "sDecimal": "",
  9677. /**
  9678. * DataTables has a build in number formatter (`formatNumber`) which is
  9679. * used to format large numbers that are used in the table information.
  9680. * By default a comma is used, but this can be trivially changed to any
  9681. * character you wish with this parameter.
  9682. * @type string
  9683. * @default ,
  9684. *
  9685. * @dtopt Language
  9686. * @name DataTable.defaults.language.thousands
  9687. *
  9688. * @example
  9689. * $(document).ready( function() {
  9690. * $('#example').dataTable( {
  9691. * "language": {
  9692. * "thousands": "'"
  9693. * }
  9694. * } );
  9695. * } );
  9696. */
  9697. "sThousands": ",",
  9698. /**
  9699. * Detail the action that will be taken when the drop down menu for the
  9700. * pagination length option is changed. The '_MENU_' variable is replaced
  9701. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9702. * with a custom select box if required.
  9703. * @type string
  9704. * @default Show _MENU_ entries
  9705. *
  9706. * @dtopt Language
  9707. * @name DataTable.defaults.language.lengthMenu
  9708. *
  9709. * @example
  9710. * // Language change only
  9711. * $(document).ready( function() {
  9712. * $('#example').dataTable( {
  9713. * "language": {
  9714. * "lengthMenu": "Display _MENU_ records"
  9715. * }
  9716. * } );
  9717. * } );
  9718. *
  9719. * @example
  9720. * // Language and options change
  9721. * $(document).ready( function() {
  9722. * $('#example').dataTable( {
  9723. * "language": {
  9724. * "lengthMenu": 'Display <select>'+
  9725. * '<option value="10">10</option>'+
  9726. * '<option value="20">20</option>'+
  9727. * '<option value="30">30</option>'+
  9728. * '<option value="40">40</option>'+
  9729. * '<option value="50">50</option>'+
  9730. * '<option value="-1">All</option>'+
  9731. * '</select> records'
  9732. * }
  9733. * } );
  9734. * } );
  9735. */
  9736. "sLengthMenu": "Show _MENU_ entries",
  9737. /**
  9738. * When using Ajax sourced data and during the first draw when DataTables is
  9739. * gathering the data, this message is shown in an empty row in the table to
  9740. * indicate to the end user the the data is being loaded. Note that this
  9741. * parameter is not used when loading data by server-side processing, just
  9742. * Ajax sourced data with client-side processing.
  9743. * @type string
  9744. * @default Loading...
  9745. *
  9746. * @dtopt Language
  9747. * @name DataTable.defaults.language.loadingRecords
  9748. *
  9749. * @example
  9750. * $(document).ready( function() {
  9751. * $('#example').dataTable( {
  9752. * "language": {
  9753. * "loadingRecords": "Please wait - loading..."
  9754. * }
  9755. * } );
  9756. * } );
  9757. */
  9758. "sLoadingRecords": "Loading...",
  9759. /**
  9760. * Text which is displayed when the table is processing a user action
  9761. * (usually a sort command or similar).
  9762. * @type string
  9763. * @default Processing...
  9764. *
  9765. * @dtopt Language
  9766. * @name DataTable.defaults.language.processing
  9767. *
  9768. * @example
  9769. * $(document).ready( function() {
  9770. * $('#example').dataTable( {
  9771. * "language": {
  9772. * "processing": "DataTables is currently busy"
  9773. * }
  9774. * } );
  9775. * } );
  9776. */
  9777. "sProcessing": "Processing...",
  9778. /**
  9779. * Details the actions that will be taken when the user types into the
  9780. * filtering input text box. The variable "_INPUT_", if used in the string,
  9781. * is replaced with the HTML text box for the filtering input allowing
  9782. * control over where it appears in the string. If "_INPUT_" is not given
  9783. * then the input box is appended to the string automatically.
  9784. * @type string
  9785. * @default Search:
  9786. *
  9787. * @dtopt Language
  9788. * @name DataTable.defaults.language.search
  9789. *
  9790. * @example
  9791. * // Input text box will be appended at the end automatically
  9792. * $(document).ready( function() {
  9793. * $('#example').dataTable( {
  9794. * "language": {
  9795. * "search": "Filter records:"
  9796. * }
  9797. * } );
  9798. * } );
  9799. *
  9800. * @example
  9801. * // Specify where the filter should appear
  9802. * $(document).ready( function() {
  9803. * $('#example').dataTable( {
  9804. * "language": {
  9805. * "search": "Apply filter _INPUT_ to table"
  9806. * }
  9807. * } );
  9808. * } );
  9809. */
  9810. "sSearch": "Search:",
  9811. /**
  9812. * Assign a `placeholder` attribute to the search `input` element
  9813. * @type string
  9814. * @default
  9815. *
  9816. * @dtopt Language
  9817. * @name DataTable.defaults.language.searchPlaceholder
  9818. */
  9819. "sSearchPlaceholder": "",
  9820. /**
  9821. * All of the language information can be stored in a file on the
  9822. * server-side, which DataTables will look up if this parameter is passed.
  9823. * It must store the URL of the language file, which is in a JSON format,
  9824. * and the object has the same properties as the oLanguage object in the
  9825. * initialiser object (i.e. the above parameters). Please refer to one of
  9826. * the example language files to see how this works in action.
  9827. * @type string
  9828. * @default <i>Empty string - i.e. disabled</i>
  9829. *
  9830. * @dtopt Language
  9831. * @name DataTable.defaults.language.url
  9832. *
  9833. * @example
  9834. * $(document).ready( function() {
  9835. * $('#example').dataTable( {
  9836. * "language": {
  9837. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  9838. * }
  9839. * } );
  9840. * } );
  9841. */
  9842. "sUrl": "",
  9843. /**
  9844. * Text shown inside the table records when the is no information to be
  9845. * displayed after filtering. `emptyTable` is shown when there is simply no
  9846. * information in the table at all (regardless of filtering).
  9847. * @type string
  9848. * @default No matching records found
  9849. *
  9850. * @dtopt Language
  9851. * @name DataTable.defaults.language.zeroRecords
  9852. *
  9853. * @example
  9854. * $(document).ready( function() {
  9855. * $('#example').dataTable( {
  9856. * "language": {
  9857. * "zeroRecords": "No records to display"
  9858. * }
  9859. * } );
  9860. * } );
  9861. */
  9862. "sZeroRecords": "No matching records found"
  9863. },
  9864. /**
  9865. * This parameter allows you to have define the global filtering state at
  9866. * initialisation time. As an object the `search` parameter must be
  9867. * defined, but all other parameters are optional. When `regex` is true,
  9868. * the search string will be treated as a regular expression, when false
  9869. * (default) it will be treated as a straight string. When `smart`
  9870. * DataTables will use it's smart filtering methods (to word match at
  9871. * any point in the data), when false this will not be done.
  9872. * @namespace
  9873. * @extends DataTable.models.oSearch
  9874. *
  9875. * @dtopt Options
  9876. * @name DataTable.defaults.search
  9877. *
  9878. * @example
  9879. * $(document).ready( function() {
  9880. * $('#example').dataTable( {
  9881. * "search": {"search": "Initial search"}
  9882. * } );
  9883. * } )
  9884. */
  9885. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  9886. /**
  9887. * __Deprecated__ The functionality provided by this parameter has now been
  9888. * superseded by that provided through `ajax`, which should be used instead.
  9889. *
  9890. * By default DataTables will look for the property `data` (or `aaData` for
  9891. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  9892. * source or for server-side processing - this parameter allows that
  9893. * property to be changed. You can use Javascript dotted object notation to
  9894. * get a data source for multiple levels of nesting.
  9895. * @type string
  9896. * @default data
  9897. *
  9898. * @dtopt Options
  9899. * @dtopt Server-side
  9900. * @name DataTable.defaults.ajaxDataProp
  9901. *
  9902. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9903. */
  9904. "sAjaxDataProp": "data",
  9905. /**
  9906. * __Deprecated__ The functionality provided by this parameter has now been
  9907. * superseded by that provided through `ajax`, which should be used instead.
  9908. *
  9909. * You can instruct DataTables to load data from an external
  9910. * source using this parameter (use aData if you want to pass data in you
  9911. * already have). Simply provide a url a JSON object can be obtained from.
  9912. * @type string
  9913. * @default null
  9914. *
  9915. * @dtopt Options
  9916. * @dtopt Server-side
  9917. * @name DataTable.defaults.ajaxSource
  9918. *
  9919. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9920. */
  9921. "sAjaxSource": null,
  9922. /**
  9923. * This initialisation variable allows you to specify exactly where in the
  9924. * DOM you want DataTables to inject the various controls it adds to the page
  9925. * (for example you might want the pagination controls at the top of the
  9926. * table). DIV elements (with or without a custom class) can also be added to
  9927. * aid styling. The follow syntax is used:
  9928. * <ul>
  9929. * <li>The following options are allowed:
  9930. * <ul>
  9931. * <li>'l' - Length changing</li>
  9932. * <li>'f' - Filtering input</li>
  9933. * <li>'t' - The table!</li>
  9934. * <li>'i' - Information</li>
  9935. * <li>'p' - Pagination</li>
  9936. * <li>'r' - pRocessing</li>
  9937. * </ul>
  9938. * </li>
  9939. * <li>The following constants are allowed:
  9940. * <ul>
  9941. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  9942. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  9943. * </ul>
  9944. * </li>
  9945. * <li>The following syntax is expected:
  9946. * <ul>
  9947. * <li>'&lt;' and '&gt;' - div elements</li>
  9948. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  9949. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  9950. * </ul>
  9951. * </li>
  9952. * <li>Examples:
  9953. * <ul>
  9954. * <li>'&lt;"wrapper"flipt&gt;'</li>
  9955. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  9956. * </ul>
  9957. * </li>
  9958. * </ul>
  9959. * @type string
  9960. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  9961. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  9962. *
  9963. * @dtopt Options
  9964. * @name DataTable.defaults.dom
  9965. *
  9966. * @example
  9967. * $(document).ready( function() {
  9968. * $('#example').dataTable( {
  9969. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  9970. * } );
  9971. * } );
  9972. */
  9973. "sDom": "lfrtip",
  9974. /**
  9975. * Search delay option. This will throttle full table searches that use the
  9976. * DataTables provided search input element (it does not effect calls to
  9977. * `dt-api search()`, providing a delay before the search is made.
  9978. * @type integer
  9979. * @default 0
  9980. *
  9981. * @dtopt Options
  9982. * @name DataTable.defaults.searchDelay
  9983. *
  9984. * @example
  9985. * $(document).ready( function() {
  9986. * $('#example').dataTable( {
  9987. * "searchDelay": 200
  9988. * } );
  9989. * } )
  9990. */
  9991. "searchDelay": null,
  9992. /**
  9993. * DataTables features four different built-in options for the buttons to
  9994. * display for pagination control:
  9995. *
  9996. * * `simple` - 'Previous' and 'Next' buttons only
  9997. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  9998. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  9999. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  10000. * page numbers
  10001. *
  10002. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10003. * @type string
  10004. * @default simple_numbers
  10005. *
  10006. * @dtopt Options
  10007. * @name DataTable.defaults.pagingType
  10008. *
  10009. * @example
  10010. * $(document).ready( function() {
  10011. * $('#example').dataTable( {
  10012. * "pagingType": "full_numbers"
  10013. * } );
  10014. * } )
  10015. */
  10016. "sPaginationType": "simple_numbers",
  10017. /**
  10018. * Enable horizontal scrolling. When a table is too wide to fit into a
  10019. * certain layout, or you have a large number of columns in the table, you
  10020. * can enable x-scrolling to show the table in a viewport, which can be
  10021. * scrolled. This property can be `true` which will allow the table to
  10022. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10023. * case it will be treated as a pixel measurement). Setting as simply `true`
  10024. * is recommended.
  10025. * @type boolean|string
  10026. * @default <i>blank string - i.e. disabled</i>
  10027. *
  10028. * @dtopt Features
  10029. * @name DataTable.defaults.scrollX
  10030. *
  10031. * @example
  10032. * $(document).ready( function() {
  10033. * $('#example').dataTable( {
  10034. * "scrollX": true,
  10035. * "scrollCollapse": true
  10036. * } );
  10037. * } );
  10038. */
  10039. "sScrollX": "",
  10040. /**
  10041. * This property can be used to force a DataTable to use more width than it
  10042. * might otherwise do when x-scrolling is enabled. For example if you have a
  10043. * table which requires to be well spaced, this parameter is useful for
  10044. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10045. * any CSS unit, or a number (in which case it will be treated as a pixel
  10046. * measurement).
  10047. * @type string
  10048. * @default <i>blank string - i.e. disabled</i>
  10049. *
  10050. * @dtopt Options
  10051. * @name DataTable.defaults.scrollXInner
  10052. *
  10053. * @example
  10054. * $(document).ready( function() {
  10055. * $('#example').dataTable( {
  10056. * "scrollX": "100%",
  10057. * "scrollXInner": "110%"
  10058. * } );
  10059. * } );
  10060. */
  10061. "sScrollXInner": "",
  10062. /**
  10063. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10064. * to the given height, and enable scrolling for any data which overflows the
  10065. * current viewport. This can be used as an alternative to paging to display
  10066. * a lot of data in a small area (although paging and scrolling can both be
  10067. * enabled at the same time). This property can be any CSS unit, or a number
  10068. * (in which case it will be treated as a pixel measurement).
  10069. * @type string
  10070. * @default <i>blank string - i.e. disabled</i>
  10071. *
  10072. * @dtopt Features
  10073. * @name DataTable.defaults.scrollY
  10074. *
  10075. * @example
  10076. * $(document).ready( function() {
  10077. * $('#example').dataTable( {
  10078. * "scrollY": "200px",
  10079. * "paginate": false
  10080. * } );
  10081. * } );
  10082. */
  10083. "sScrollY": "",
  10084. /**
  10085. * __Deprecated__ The functionality provided by this parameter has now been
  10086. * superseded by that provided through `ajax`, which should be used instead.
  10087. *
  10088. * Set the HTTP method that is used to make the Ajax call for server-side
  10089. * processing or Ajax sourced data.
  10090. * @type string
  10091. * @default GET
  10092. *
  10093. * @dtopt Options
  10094. * @dtopt Server-side
  10095. * @name DataTable.defaults.serverMethod
  10096. *
  10097. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10098. */
  10099. "sServerMethod": "GET",
  10100. /**
  10101. * DataTables makes use of renderers when displaying HTML elements for
  10102. * a table. These renderers can be added or modified by plug-ins to
  10103. * generate suitable mark-up for a site. For example the Bootstrap
  10104. * integration plug-in for DataTables uses a paging button renderer to
  10105. * display pagination buttons in the mark-up required by Bootstrap.
  10106. *
  10107. * For further information about the renderers available see
  10108. * DataTable.ext.renderer
  10109. * @type string|object
  10110. * @default null
  10111. *
  10112. * @name DataTable.defaults.renderer
  10113. *
  10114. */
  10115. "renderer": null
  10116. };
  10117. _fnHungarianMap( DataTable.defaults );
  10118. /*
  10119. * Developer note - See note in model.defaults.js about the use of Hungarian
  10120. * notation and camel case.
  10121. */
  10122. /**
  10123. * Column options that can be given to DataTables at initialisation time.
  10124. * @namespace
  10125. */
  10126. DataTable.defaults.column = {
  10127. /**
  10128. * Define which column(s) an order will occur on for this column. This
  10129. * allows a column's ordering to take multiple columns into account when
  10130. * doing a sort or use the data from a different column. For example first
  10131. * name / last name columns make sense to do a multi-column sort over the
  10132. * two columns.
  10133. * @type array|int
  10134. * @default null <i>Takes the value of the column index automatically</i>
  10135. *
  10136. * @name DataTable.defaults.column.orderData
  10137. * @dtopt Columns
  10138. *
  10139. * @example
  10140. * // Using `columnDefs`
  10141. * $(document).ready( function() {
  10142. * $('#example').dataTable( {
  10143. * "columnDefs": [
  10144. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10145. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10146. * { "orderData": 2, "targets": [ 2 ] }
  10147. * ]
  10148. * } );
  10149. * } );
  10150. *
  10151. * @example
  10152. * // Using `columns`
  10153. * $(document).ready( function() {
  10154. * $('#example').dataTable( {
  10155. * "columns": [
  10156. * { "orderData": [ 0, 1 ] },
  10157. * { "orderData": [ 1, 0 ] },
  10158. * { "orderData": 2 },
  10159. * null,
  10160. * null
  10161. * ]
  10162. * } );
  10163. * } );
  10164. */
  10165. "aDataSort": null,
  10166. "iDataSort": -1,
  10167. /**
  10168. * You can control the default ordering direction, and even alter the
  10169. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10170. * using this parameter.
  10171. * @type array
  10172. * @default [ 'asc', 'desc' ]
  10173. *
  10174. * @name DataTable.defaults.column.orderSequence
  10175. * @dtopt Columns
  10176. *
  10177. * @example
  10178. * // Using `columnDefs`
  10179. * $(document).ready( function() {
  10180. * $('#example').dataTable( {
  10181. * "columnDefs": [
  10182. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10183. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10184. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10185. * ]
  10186. * } );
  10187. * } );
  10188. *
  10189. * @example
  10190. * // Using `columns`
  10191. * $(document).ready( function() {
  10192. * $('#example').dataTable( {
  10193. * "columns": [
  10194. * null,
  10195. * { "orderSequence": [ "asc" ] },
  10196. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10197. * { "orderSequence": [ "desc" ] },
  10198. * null
  10199. * ]
  10200. * } );
  10201. * } );
  10202. */
  10203. "asSorting": [ 'asc', 'desc' ],
  10204. /**
  10205. * Enable or disable filtering on the data in this column.
  10206. * @type boolean
  10207. * @default true
  10208. *
  10209. * @name DataTable.defaults.column.searchable
  10210. * @dtopt Columns
  10211. *
  10212. * @example
  10213. * // Using `columnDefs`
  10214. * $(document).ready( function() {
  10215. * $('#example').dataTable( {
  10216. * "columnDefs": [
  10217. * { "searchable": false, "targets": [ 0 ] }
  10218. * ] } );
  10219. * } );
  10220. *
  10221. * @example
  10222. * // Using `columns`
  10223. * $(document).ready( function() {
  10224. * $('#example').dataTable( {
  10225. * "columns": [
  10226. * { "searchable": false },
  10227. * null,
  10228. * null,
  10229. * null,
  10230. * null
  10231. * ] } );
  10232. * } );
  10233. */
  10234. "bSearchable": true,
  10235. /**
  10236. * Enable or disable ordering on this column.
  10237. * @type boolean
  10238. * @default true
  10239. *
  10240. * @name DataTable.defaults.column.orderable
  10241. * @dtopt Columns
  10242. *
  10243. * @example
  10244. * // Using `columnDefs`
  10245. * $(document).ready( function() {
  10246. * $('#example').dataTable( {
  10247. * "columnDefs": [
  10248. * { "orderable": false, "targets": [ 0 ] }
  10249. * ] } );
  10250. * } );
  10251. *
  10252. * @example
  10253. * // Using `columns`
  10254. * $(document).ready( function() {
  10255. * $('#example').dataTable( {
  10256. * "columns": [
  10257. * { "orderable": false },
  10258. * null,
  10259. * null,
  10260. * null,
  10261. * null
  10262. * ] } );
  10263. * } );
  10264. */
  10265. "bSortable": true,
  10266. /**
  10267. * Enable or disable the display of this column.
  10268. * @type boolean
  10269. * @default true
  10270. *
  10271. * @name DataTable.defaults.column.visible
  10272. * @dtopt Columns
  10273. *
  10274. * @example
  10275. * // Using `columnDefs`
  10276. * $(document).ready( function() {
  10277. * $('#example').dataTable( {
  10278. * "columnDefs": [
  10279. * { "visible": false, "targets": [ 0 ] }
  10280. * ] } );
  10281. * } );
  10282. *
  10283. * @example
  10284. * // Using `columns`
  10285. * $(document).ready( function() {
  10286. * $('#example').dataTable( {
  10287. * "columns": [
  10288. * { "visible": false },
  10289. * null,
  10290. * null,
  10291. * null,
  10292. * null
  10293. * ] } );
  10294. * } );
  10295. */
  10296. "bVisible": true,
  10297. /**
  10298. * Developer definable function that is called whenever a cell is created (Ajax source,
  10299. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10300. * allowing you to modify the DOM element (add background colour for example) when the
  10301. * element is available.
  10302. * @type function
  10303. * @param {element} td The TD node that has been created
  10304. * @param {*} cellData The Data for the cell
  10305. * @param {array|object} rowData The data for the whole row
  10306. * @param {int} row The row index for the aoData data store
  10307. * @param {int} col The column index for aoColumns
  10308. *
  10309. * @name DataTable.defaults.column.createdCell
  10310. * @dtopt Columns
  10311. *
  10312. * @example
  10313. * $(document).ready( function() {
  10314. * $('#example').dataTable( {
  10315. * "columnDefs": [ {
  10316. * "targets": [3],
  10317. * "createdCell": function (td, cellData, rowData, row, col) {
  10318. * if ( cellData == "1.7" ) {
  10319. * $(td).css('color', 'blue')
  10320. * }
  10321. * }
  10322. * } ]
  10323. * });
  10324. * } );
  10325. */
  10326. "fnCreatedCell": null,
  10327. /**
  10328. * This parameter has been replaced by `data` in DataTables to ensure naming
  10329. * consistency. `dataProp` can still be used, as there is backwards
  10330. * compatibility in DataTables for this option, but it is strongly
  10331. * recommended that you use `data` in preference to `dataProp`.
  10332. * @name DataTable.defaults.column.dataProp
  10333. */
  10334. /**
  10335. * This property can be used to read data from any data source property,
  10336. * including deeply nested objects / properties. `data` can be given in a
  10337. * number of different ways which effect its behaviour:
  10338. *
  10339. * * `integer` - treated as an array index for the data source. This is the
  10340. * default that DataTables uses (incrementally increased for each column).
  10341. * * `string` - read an object property from the data source. There are
  10342. * three 'special' options that can be used in the string to alter how
  10343. * DataTables reads the data from the source object:
  10344. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10345. * Javascript to read from nested objects, so to can the options
  10346. * specified in `data`. For example: `browser.version` or
  10347. * `browser.name`. If your object parameter name contains a period, use
  10348. * `\\` to escape it - i.e. `first\\.name`.
  10349. * * `[]` - Array notation. DataTables can automatically combine data
  10350. * from and array source, joining the data with the characters provided
  10351. * between the two brackets. For example: `name[, ]` would provide a
  10352. * comma-space separated list from the source array. If no characters
  10353. * are provided between the brackets, the original array source is
  10354. * returned.
  10355. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10356. * execute a function of the name given. For example: `browser()` for a
  10357. * simple function on the data source, `browser.version()` for a
  10358. * function in a nested property or even `browser().version` to get an
  10359. * object property if the function called returns an object. Note that
  10360. * function notation is recommended for use in `render` rather than
  10361. * `data` as it is much simpler to use as a renderer.
  10362. * * `null` - use the original data source for the row rather than plucking
  10363. * data directly from it. This action has effects on two other
  10364. * initialisation options:
  10365. * * `defaultContent` - When null is given as the `data` option and
  10366. * `defaultContent` is specified for the column, the value defined by
  10367. * `defaultContent` will be used for the cell.
  10368. * * `render` - When null is used for the `data` option and the `render`
  10369. * option is specified for the column, the whole data source for the
  10370. * row is used for the renderer.
  10371. * * `function` - the function given will be executed whenever DataTables
  10372. * needs to set or get the data for a cell in the column. The function
  10373. * takes three parameters:
  10374. * * Parameters:
  10375. * * `{array|object}` The data source for the row
  10376. * * `{string}` The type call data requested - this will be 'set' when
  10377. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10378. * when gathering data. Note that when `undefined` is given for the
  10379. * type DataTables expects to get the raw data for the object back<
  10380. * * `{*}` Data to set when the second parameter is 'set'.
  10381. * * Return:
  10382. * * The return value from the function is not required when 'set' is
  10383. * the type of call, but otherwise the return is what will be used
  10384. * for the data requested.
  10385. *
  10386. * Note that `data` is a getter and setter option. If you just require
  10387. * formatting of data for output, you will likely want to use `render` which
  10388. * is simply a getter and thus simpler to use.
  10389. *
  10390. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10391. * name change reflects the flexibility of this property and is consistent
  10392. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10393. * be used by DataTables, as it automatically maps the old name to the new
  10394. * if required.
  10395. *
  10396. * @type string|int|function|null
  10397. * @default null <i>Use automatically calculated column index</i>
  10398. *
  10399. * @name DataTable.defaults.column.data
  10400. * @dtopt Columns
  10401. *
  10402. * @example
  10403. * // Read table data from objects
  10404. * // JSON structure for each row:
  10405. * // {
  10406. * // "engine": {value},
  10407. * // "browser": {value},
  10408. * // "platform": {value},
  10409. * // "version": {value},
  10410. * // "grade": {value}
  10411. * // }
  10412. * $(document).ready( function() {
  10413. * $('#example').dataTable( {
  10414. * "ajaxSource": "sources/objects.txt",
  10415. * "columns": [
  10416. * { "data": "engine" },
  10417. * { "data": "browser" },
  10418. * { "data": "platform" },
  10419. * { "data": "version" },
  10420. * { "data": "grade" }
  10421. * ]
  10422. * } );
  10423. * } );
  10424. *
  10425. * @example
  10426. * // Read information from deeply nested objects
  10427. * // JSON structure for each row:
  10428. * // {
  10429. * // "engine": {value},
  10430. * // "browser": {value},
  10431. * // "platform": {
  10432. * // "inner": {value}
  10433. * // },
  10434. * // "details": [
  10435. * // {value}, {value}
  10436. * // ]
  10437. * // }
  10438. * $(document).ready( function() {
  10439. * $('#example').dataTable( {
  10440. * "ajaxSource": "sources/deep.txt",
  10441. * "columns": [
  10442. * { "data": "engine" },
  10443. * { "data": "browser" },
  10444. * { "data": "platform.inner" },
  10445. * { "data": "platform.details.0" },
  10446. * { "data": "platform.details.1" }
  10447. * ]
  10448. * } );
  10449. * } );
  10450. *
  10451. * @example
  10452. * // Using `data` as a function to provide different information for
  10453. * // sorting, filtering and display. In this case, currency (price)
  10454. * $(document).ready( function() {
  10455. * $('#example').dataTable( {
  10456. * "columnDefs": [ {
  10457. * "targets": [ 0 ],
  10458. * "data": function ( source, type, val ) {
  10459. * if (type === 'set') {
  10460. * source.price = val;
  10461. * // Store the computed dislay and filter values for efficiency
  10462. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10463. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10464. * return;
  10465. * }
  10466. * else if (type === 'display') {
  10467. * return source.price_display;
  10468. * }
  10469. * else if (type === 'filter') {
  10470. * return source.price_filter;
  10471. * }
  10472. * // 'sort', 'type' and undefined all just use the integer
  10473. * return source.price;
  10474. * }
  10475. * } ]
  10476. * } );
  10477. * } );
  10478. *
  10479. * @example
  10480. * // Using default content
  10481. * $(document).ready( function() {
  10482. * $('#example').dataTable( {
  10483. * "columnDefs": [ {
  10484. * "targets": [ 0 ],
  10485. * "data": null,
  10486. * "defaultContent": "Click to edit"
  10487. * } ]
  10488. * } );
  10489. * } );
  10490. *
  10491. * @example
  10492. * // Using array notation - outputting a list from an array
  10493. * $(document).ready( function() {
  10494. * $('#example').dataTable( {
  10495. * "columnDefs": [ {
  10496. * "targets": [ 0 ],
  10497. * "data": "name[, ]"
  10498. * } ]
  10499. * } );
  10500. * } );
  10501. *
  10502. */
  10503. "mData": null,
  10504. /**
  10505. * This property is the rendering partner to `data` and it is suggested that
  10506. * when you want to manipulate data for display (including filtering,
  10507. * sorting etc) without altering the underlying data for the table, use this
  10508. * property. `render` can be considered to be the the read only companion to
  10509. * `data` which is read / write (then as such more complex). Like `data`
  10510. * this option can be given in a number of different ways to effect its
  10511. * behaviour:
  10512. *
  10513. * * `integer` - treated as an array index for the data source. This is the
  10514. * default that DataTables uses (incrementally increased for each column).
  10515. * * `string` - read an object property from the data source. There are
  10516. * three 'special' options that can be used in the string to alter how
  10517. * DataTables reads the data from the source object:
  10518. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10519. * Javascript to read from nested objects, so to can the options
  10520. * specified in `data`. For example: `browser.version` or
  10521. * `browser.name`. If your object parameter name contains a period, use
  10522. * `\\` to escape it - i.e. `first\\.name`.
  10523. * * `[]` - Array notation. DataTables can automatically combine data
  10524. * from and array source, joining the data with the characters provided
  10525. * between the two brackets. For example: `name[, ]` would provide a
  10526. * comma-space separated list from the source array. If no characters
  10527. * are provided between the brackets, the original array source is
  10528. * returned.
  10529. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10530. * execute a function of the name given. For example: `browser()` for a
  10531. * simple function on the data source, `browser.version()` for a
  10532. * function in a nested property or even `browser().version` to get an
  10533. * object property if the function called returns an object.
  10534. * * `object` - use different data for the different data types requested by
  10535. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10536. * of the object is the data type the property refers to and the value can
  10537. * defined using an integer, string or function using the same rules as
  10538. * `render` normally does. Note that an `_` option _must_ be specified.
  10539. * This is the default value to use if you haven't specified a value for
  10540. * the data type requested by DataTables.
  10541. * * `function` - the function given will be executed whenever DataTables
  10542. * needs to set or get the data for a cell in the column. The function
  10543. * takes three parameters:
  10544. * * Parameters:
  10545. * * {array|object} The data source for the row (based on `data`)
  10546. * * {string} The type call data requested - this will be 'filter',
  10547. * 'display', 'type' or 'sort'.
  10548. * * {array|object} The full data source for the row (not based on
  10549. * `data`)
  10550. * * Return:
  10551. * * The return value from the function is what will be used for the
  10552. * data requested.
  10553. *
  10554. * @type string|int|function|object|null
  10555. * @default null Use the data source value.
  10556. *
  10557. * @name DataTable.defaults.column.render
  10558. * @dtopt Columns
  10559. *
  10560. * @example
  10561. * // Create a comma separated list from an array of objects
  10562. * $(document).ready( function() {
  10563. * $('#example').dataTable( {
  10564. * "ajaxSource": "sources/deep.txt",
  10565. * "columns": [
  10566. * { "data": "engine" },
  10567. * { "data": "browser" },
  10568. * {
  10569. * "data": "platform",
  10570. * "render": "[, ].name"
  10571. * }
  10572. * ]
  10573. * } );
  10574. * } );
  10575. *
  10576. * @example
  10577. * // Execute a function to obtain data
  10578. * $(document).ready( function() {
  10579. * $('#example').dataTable( {
  10580. * "columnDefs": [ {
  10581. * "targets": [ 0 ],
  10582. * "data": null, // Use the full data source object for the renderer's source
  10583. * "render": "browserName()"
  10584. * } ]
  10585. * } );
  10586. * } );
  10587. *
  10588. * @example
  10589. * // As an object, extracting different data for the different types
  10590. * // This would be used with a data source such as:
  10591. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10592. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10593. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10594. * // the formatted phone number is the one that is shown in the table.
  10595. * $(document).ready( function() {
  10596. * $('#example').dataTable( {
  10597. * "columnDefs": [ {
  10598. * "targets": [ 0 ],
  10599. * "data": null, // Use the full data source object for the renderer's source
  10600. * "render": {
  10601. * "_": "phone",
  10602. * "filter": "phone_filter",
  10603. * "display": "phone_display"
  10604. * }
  10605. * } ]
  10606. * } );
  10607. * } );
  10608. *
  10609. * @example
  10610. * // Use as a function to create a link from the data source
  10611. * $(document).ready( function() {
  10612. * $('#example').dataTable( {
  10613. * "columnDefs": [ {
  10614. * "targets": [ 0 ],
  10615. * "data": "download_link",
  10616. * "render": function ( data, type, full ) {
  10617. * return '<a href="'+data+'">Download</a>';
  10618. * }
  10619. * } ]
  10620. * } );
  10621. * } );
  10622. */
  10623. "mRender": null,
  10624. /**
  10625. * Change the cell type created for the column - either TD cells or TH cells. This
  10626. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10627. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10628. * @type string
  10629. * @default td
  10630. *
  10631. * @name DataTable.defaults.column.cellType
  10632. * @dtopt Columns
  10633. *
  10634. * @example
  10635. * // Make the first column use TH cells
  10636. * $(document).ready( function() {
  10637. * $('#example').dataTable( {
  10638. * "columnDefs": [ {
  10639. * "targets": [ 0 ],
  10640. * "cellType": "th"
  10641. * } ]
  10642. * } );
  10643. * } );
  10644. */
  10645. "sCellType": "td",
  10646. /**
  10647. * Class to give to each cell in this column.
  10648. * @type string
  10649. * @default <i>Empty string</i>
  10650. *
  10651. * @name DataTable.defaults.column.class
  10652. * @dtopt Columns
  10653. *
  10654. * @example
  10655. * // Using `columnDefs`
  10656. * $(document).ready( function() {
  10657. * $('#example').dataTable( {
  10658. * "columnDefs": [
  10659. * { "class": "my_class", "targets": [ 0 ] }
  10660. * ]
  10661. * } );
  10662. * } );
  10663. *
  10664. * @example
  10665. * // Using `columns`
  10666. * $(document).ready( function() {
  10667. * $('#example').dataTable( {
  10668. * "columns": [
  10669. * { "class": "my_class" },
  10670. * null,
  10671. * null,
  10672. * null,
  10673. * null
  10674. * ]
  10675. * } );
  10676. * } );
  10677. */
  10678. "sClass": "",
  10679. /**
  10680. * When DataTables calculates the column widths to assign to each column,
  10681. * it finds the longest string in each column and then constructs a
  10682. * temporary table and reads the widths from that. The problem with this
  10683. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10684. * string - thus the calculation can go wrong (doing it properly and putting
  10685. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10686. * a "work around" we provide this option. It will append its value to the
  10687. * text that is found to be the longest string for the column - i.e. padding.
  10688. * Generally you shouldn't need this!
  10689. * @type string
  10690. * @default <i>Empty string<i>
  10691. *
  10692. * @name DataTable.defaults.column.contentPadding
  10693. * @dtopt Columns
  10694. *
  10695. * @example
  10696. * // Using `columns`
  10697. * $(document).ready( function() {
  10698. * $('#example').dataTable( {
  10699. * "columns": [
  10700. * null,
  10701. * null,
  10702. * null,
  10703. * {
  10704. * "contentPadding": "mmm"
  10705. * }
  10706. * ]
  10707. * } );
  10708. * } );
  10709. */
  10710. "sContentPadding": "",
  10711. /**
  10712. * Allows a default value to be given for a column's data, and will be used
  10713. * whenever a null data source is encountered (this can be because `data`
  10714. * is set to null, or because the data source itself is null).
  10715. * @type string
  10716. * @default null
  10717. *
  10718. * @name DataTable.defaults.column.defaultContent
  10719. * @dtopt Columns
  10720. *
  10721. * @example
  10722. * // Using `columnDefs`
  10723. * $(document).ready( function() {
  10724. * $('#example').dataTable( {
  10725. * "columnDefs": [
  10726. * {
  10727. * "data": null,
  10728. * "defaultContent": "Edit",
  10729. * "targets": [ -1 ]
  10730. * }
  10731. * ]
  10732. * } );
  10733. * } );
  10734. *
  10735. * @example
  10736. * // Using `columns`
  10737. * $(document).ready( function() {
  10738. * $('#example').dataTable( {
  10739. * "columns": [
  10740. * null,
  10741. * null,
  10742. * null,
  10743. * {
  10744. * "data": null,
  10745. * "defaultContent": "Edit"
  10746. * }
  10747. * ]
  10748. * } );
  10749. * } );
  10750. */
  10751. "sDefaultContent": null,
  10752. /**
  10753. * This parameter is only used in DataTables' server-side processing. It can
  10754. * be exceptionally useful to know what columns are being displayed on the
  10755. * client side, and to map these to database fields. When defined, the names
  10756. * also allow DataTables to reorder information from the server if it comes
  10757. * back in an unexpected order (i.e. if you switch your columns around on the
  10758. * client-side, your server-side code does not also need updating).
  10759. * @type string
  10760. * @default <i>Empty string</i>
  10761. *
  10762. * @name DataTable.defaults.column.name
  10763. * @dtopt Columns
  10764. *
  10765. * @example
  10766. * // Using `columnDefs`
  10767. * $(document).ready( function() {
  10768. * $('#example').dataTable( {
  10769. * "columnDefs": [
  10770. * { "name": "engine", "targets": [ 0 ] },
  10771. * { "name": "browser", "targets": [ 1 ] },
  10772. * { "name": "platform", "targets": [ 2 ] },
  10773. * { "name": "version", "targets": [ 3 ] },
  10774. * { "name": "grade", "targets": [ 4 ] }
  10775. * ]
  10776. * } );
  10777. * } );
  10778. *
  10779. * @example
  10780. * // Using `columns`
  10781. * $(document).ready( function() {
  10782. * $('#example').dataTable( {
  10783. * "columns": [
  10784. * { "name": "engine" },
  10785. * { "name": "browser" },
  10786. * { "name": "platform" },
  10787. * { "name": "version" },
  10788. * { "name": "grade" }
  10789. * ]
  10790. * } );
  10791. * } );
  10792. */
  10793. "sName": "",
  10794. /**
  10795. * Defines a data source type for the ordering which can be used to read
  10796. * real-time information from the table (updating the internally cached
  10797. * version) prior to ordering. This allows ordering to occur on user
  10798. * editable elements such as form inputs.
  10799. * @type string
  10800. * @default std
  10801. *
  10802. * @name DataTable.defaults.column.orderDataType
  10803. * @dtopt Columns
  10804. *
  10805. * @example
  10806. * // Using `columnDefs`
  10807. * $(document).ready( function() {
  10808. * $('#example').dataTable( {
  10809. * "columnDefs": [
  10810. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  10811. * { "type": "numeric", "targets": [ 3 ] },
  10812. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  10813. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  10814. * ]
  10815. * } );
  10816. * } );
  10817. *
  10818. * @example
  10819. * // Using `columns`
  10820. * $(document).ready( function() {
  10821. * $('#example').dataTable( {
  10822. * "columns": [
  10823. * null,
  10824. * null,
  10825. * { "orderDataType": "dom-text" },
  10826. * { "orderDataType": "dom-text", "type": "numeric" },
  10827. * { "orderDataType": "dom-select" },
  10828. * { "orderDataType": "dom-checkbox" }
  10829. * ]
  10830. * } );
  10831. * } );
  10832. */
  10833. "sSortDataType": "std",
  10834. /**
  10835. * The title of this column.
  10836. * @type string
  10837. * @default null <i>Derived from the 'TH' value for this column in the
  10838. * original HTML table.</i>
  10839. *
  10840. * @name DataTable.defaults.column.title
  10841. * @dtopt Columns
  10842. *
  10843. * @example
  10844. * // Using `columnDefs`
  10845. * $(document).ready( function() {
  10846. * $('#example').dataTable( {
  10847. * "columnDefs": [
  10848. * { "title": "My column title", "targets": [ 0 ] }
  10849. * ]
  10850. * } );
  10851. * } );
  10852. *
  10853. * @example
  10854. * // Using `columns`
  10855. * $(document).ready( function() {
  10856. * $('#example').dataTable( {
  10857. * "columns": [
  10858. * { "title": "My column title" },
  10859. * null,
  10860. * null,
  10861. * null,
  10862. * null
  10863. * ]
  10864. * } );
  10865. * } );
  10866. */
  10867. "sTitle": null,
  10868. /**
  10869. * The type allows you to specify how the data for this column will be
  10870. * ordered. Four types (string, numeric, date and html (which will strip
  10871. * HTML tags before ordering)) are currently available. Note that only date
  10872. * formats understood by Javascript's Date() object will be accepted as type
  10873. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  10874. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  10875. * through plug-ins.
  10876. * @type string
  10877. * @default null <i>Auto-detected from raw data</i>
  10878. *
  10879. * @name DataTable.defaults.column.type
  10880. * @dtopt Columns
  10881. *
  10882. * @example
  10883. * // Using `columnDefs`
  10884. * $(document).ready( function() {
  10885. * $('#example').dataTable( {
  10886. * "columnDefs": [
  10887. * { "type": "html", "targets": [ 0 ] }
  10888. * ]
  10889. * } );
  10890. * } );
  10891. *
  10892. * @example
  10893. * // Using `columns`
  10894. * $(document).ready( function() {
  10895. * $('#example').dataTable( {
  10896. * "columns": [
  10897. * { "type": "html" },
  10898. * null,
  10899. * null,
  10900. * null,
  10901. * null
  10902. * ]
  10903. * } );
  10904. * } );
  10905. */
  10906. "sType": null,
  10907. /**
  10908. * Defining the width of the column, this parameter may take any CSS value
  10909. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  10910. * been given a specific width through this interface ensuring that the table
  10911. * remains readable.
  10912. * @type string
  10913. * @default null <i>Automatic</i>
  10914. *
  10915. * @name DataTable.defaults.column.width
  10916. * @dtopt Columns
  10917. *
  10918. * @example
  10919. * // Using `columnDefs`
  10920. * $(document).ready( function() {
  10921. * $('#example').dataTable( {
  10922. * "columnDefs": [
  10923. * { "width": "20%", "targets": [ 0 ] }
  10924. * ]
  10925. * } );
  10926. * } );
  10927. *
  10928. * @example
  10929. * // Using `columns`
  10930. * $(document).ready( function() {
  10931. * $('#example').dataTable( {
  10932. * "columns": [
  10933. * { "width": "20%" },
  10934. * null,
  10935. * null,
  10936. * null,
  10937. * null
  10938. * ]
  10939. * } );
  10940. * } );
  10941. */
  10942. "sWidth": null
  10943. };
  10944. _fnHungarianMap( DataTable.defaults.column );
  10945. /**
  10946. * DataTables settings object - this holds all the information needed for a
  10947. * given table, including configuration, data and current application of the
  10948. * table options. DataTables does not have a single instance for each DataTable
  10949. * with the settings attached to that instance, but rather instances of the
  10950. * DataTable "class" are created on-the-fly as needed (typically by a
  10951. * $().dataTable() call) and the settings object is then applied to that
  10952. * instance.
  10953. *
  10954. * Note that this object is related to {@link DataTable.defaults} but this
  10955. * one is the internal data store for DataTables's cache of columns. It should
  10956. * NOT be manipulated outside of DataTables. Any configuration should be done
  10957. * through the initialisation options.
  10958. * @namespace
  10959. * @todo Really should attach the settings object to individual instances so we
  10960. * don't need to create new instances on each $().dataTable() call (if the
  10961. * table already exists). It would also save passing oSettings around and
  10962. * into every single function. However, this is a very significant
  10963. * architecture change for DataTables and will almost certainly break
  10964. * backwards compatibility with older installations. This is something that
  10965. * will be done in 2.0.
  10966. */
  10967. DataTable.models.oSettings = {
  10968. /**
  10969. * Primary features of DataTables and their enablement state.
  10970. * @namespace
  10971. */
  10972. "oFeatures": {
  10973. /**
  10974. * Flag to say if DataTables should automatically try to calculate the
  10975. * optimum table and columns widths (true) or not (false).
  10976. * Note that this parameter will be set by the initialisation routine. To
  10977. * set a default use {@link DataTable.defaults}.
  10978. * @type boolean
  10979. */
  10980. "bAutoWidth": null,
  10981. /**
  10982. * Delay the creation of TR and TD elements until they are actually
  10983. * needed by a driven page draw. This can give a significant speed
  10984. * increase for Ajax source and Javascript source data, but makes no
  10985. * difference at all fro DOM and server-side processing tables.
  10986. * Note that this parameter will be set by the initialisation routine. To
  10987. * set a default use {@link DataTable.defaults}.
  10988. * @type boolean
  10989. */
  10990. "bDeferRender": null,
  10991. /**
  10992. * Enable filtering on the table or not. Note that if this is disabled
  10993. * then there is no filtering at all on the table, including fnFilter.
  10994. * To just remove the filtering input use sDom and remove the 'f' option.
  10995. * Note that this parameter will be set by the initialisation routine. To
  10996. * set a default use {@link DataTable.defaults}.
  10997. * @type boolean
  10998. */
  10999. "bFilter": null,
  11000. /**
  11001. * Table information element (the 'Showing x of y records' div) enable
  11002. * flag.
  11003. * Note that this parameter will be set by the initialisation routine. To
  11004. * set a default use {@link DataTable.defaults}.
  11005. * @type boolean
  11006. */
  11007. "bInfo": null,
  11008. /**
  11009. * Present a user control allowing the end user to change the page size
  11010. * when pagination is enabled.
  11011. * Note that this parameter will be set by the initialisation routine. To
  11012. * set a default use {@link DataTable.defaults}.
  11013. * @type boolean
  11014. */
  11015. "bLengthChange": null,
  11016. /**
  11017. * Pagination enabled or not. Note that if this is disabled then length
  11018. * changing must also be disabled.
  11019. * Note that this parameter will be set by the initialisation routine. To
  11020. * set a default use {@link DataTable.defaults}.
  11021. * @type boolean
  11022. */
  11023. "bPaginate": null,
  11024. /**
  11025. * Processing indicator enable flag whenever DataTables is enacting a
  11026. * user request - typically an Ajax request for server-side processing.
  11027. * Note that this parameter will be set by the initialisation routine. To
  11028. * set a default use {@link DataTable.defaults}.
  11029. * @type boolean
  11030. */
  11031. "bProcessing": null,
  11032. /**
  11033. * Server-side processing enabled flag - when enabled DataTables will
  11034. * get all data from the server for every draw - there is no filtering,
  11035. * sorting or paging done on the client-side.
  11036. * Note that this parameter will be set by the initialisation routine. To
  11037. * set a default use {@link DataTable.defaults}.
  11038. * @type boolean
  11039. */
  11040. "bServerSide": null,
  11041. /**
  11042. * Sorting enablement flag.
  11043. * Note that this parameter will be set by the initialisation routine. To
  11044. * set a default use {@link DataTable.defaults}.
  11045. * @type boolean
  11046. */
  11047. "bSort": null,
  11048. /**
  11049. * Multi-column sorting
  11050. * Note that this parameter will be set by the initialisation routine. To
  11051. * set a default use {@link DataTable.defaults}.
  11052. * @type boolean
  11053. */
  11054. "bSortMulti": null,
  11055. /**
  11056. * Apply a class to the columns which are being sorted to provide a
  11057. * visual highlight or not. This can slow things down when enabled since
  11058. * there is a lot of DOM interaction.
  11059. * Note that this parameter will be set by the initialisation routine. To
  11060. * set a default use {@link DataTable.defaults}.
  11061. * @type boolean
  11062. */
  11063. "bSortClasses": null,
  11064. /**
  11065. * State saving enablement flag.
  11066. * Note that this parameter will be set by the initialisation routine. To
  11067. * set a default use {@link DataTable.defaults}.
  11068. * @type boolean
  11069. */
  11070. "bStateSave": null
  11071. },
  11072. /**
  11073. * Scrolling settings for a table.
  11074. * @namespace
  11075. */
  11076. "oScroll": {
  11077. /**
  11078. * When the table is shorter in height than sScrollY, collapse the
  11079. * table container down to the height of the table (when true).
  11080. * Note that this parameter will be set by the initialisation routine. To
  11081. * set a default use {@link DataTable.defaults}.
  11082. * @type boolean
  11083. */
  11084. "bCollapse": null,
  11085. /**
  11086. * Width of the scrollbar for the web-browser's platform. Calculated
  11087. * during table initialisation.
  11088. * @type int
  11089. * @default 0
  11090. */
  11091. "iBarWidth": 0,
  11092. /**
  11093. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11094. * disabled if an empty string.
  11095. * Note that this parameter will be set by the initialisation routine. To
  11096. * set a default use {@link DataTable.defaults}.
  11097. * @type string
  11098. */
  11099. "sX": null,
  11100. /**
  11101. * Width to expand the table to when using x-scrolling. Typically you
  11102. * should not need to use this.
  11103. * Note that this parameter will be set by the initialisation routine. To
  11104. * set a default use {@link DataTable.defaults}.
  11105. * @type string
  11106. * @deprecated
  11107. */
  11108. "sXInner": null,
  11109. /**
  11110. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11111. * if an empty string.
  11112. * Note that this parameter will be set by the initialisation routine. To
  11113. * set a default use {@link DataTable.defaults}.
  11114. * @type string
  11115. */
  11116. "sY": null
  11117. },
  11118. /**
  11119. * Language information for the table.
  11120. * @namespace
  11121. * @extends DataTable.defaults.oLanguage
  11122. */
  11123. "oLanguage": {
  11124. /**
  11125. * Information callback function. See
  11126. * {@link DataTable.defaults.fnInfoCallback}
  11127. * @type function
  11128. * @default null
  11129. */
  11130. "fnInfoCallback": null
  11131. },
  11132. /**
  11133. * Browser support parameters
  11134. * @namespace
  11135. */
  11136. "oBrowser": {
  11137. /**
  11138. * Indicate if the browser incorrectly calculates width:100% inside a
  11139. * scrolling element (IE6/7)
  11140. * @type boolean
  11141. * @default false
  11142. */
  11143. "bScrollOversize": false,
  11144. /**
  11145. * Determine if the vertical scrollbar is on the right or left of the
  11146. * scrolling container - needed for rtl language layout, although not
  11147. * all browsers move the scrollbar (Safari).
  11148. * @type boolean
  11149. * @default false
  11150. */
  11151. "bScrollbarLeft": false
  11152. },
  11153. "ajax": null,
  11154. /**
  11155. * Array referencing the nodes which are used for the features. The
  11156. * parameters of this object match what is allowed by sDom - i.e.
  11157. * <ul>
  11158. * <li>'l' - Length changing</li>
  11159. * <li>'f' - Filtering input</li>
  11160. * <li>'t' - The table!</li>
  11161. * <li>'i' - Information</li>
  11162. * <li>'p' - Pagination</li>
  11163. * <li>'r' - pRocessing</li>
  11164. * </ul>
  11165. * @type array
  11166. * @default []
  11167. */
  11168. "aanFeatures": [],
  11169. /**
  11170. * Store data information - see {@link DataTable.models.oRow} for detailed
  11171. * information.
  11172. * @type array
  11173. * @default []
  11174. */
  11175. "aoData": [],
  11176. /**
  11177. * Array of indexes which are in the current display (after filtering etc)
  11178. * @type array
  11179. * @default []
  11180. */
  11181. "aiDisplay": [],
  11182. /**
  11183. * Array of indexes for display - no filtering
  11184. * @type array
  11185. * @default []
  11186. */
  11187. "aiDisplayMaster": [],
  11188. /**
  11189. * Store information about each column that is in use
  11190. * @type array
  11191. * @default []
  11192. */
  11193. "aoColumns": [],
  11194. /**
  11195. * Store information about the table's header
  11196. * @type array
  11197. * @default []
  11198. */
  11199. "aoHeader": [],
  11200. /**
  11201. * Store information about the table's footer
  11202. * @type array
  11203. * @default []
  11204. */
  11205. "aoFooter": [],
  11206. /**
  11207. * Store the applied global search information in case we want to force a
  11208. * research or compare the old search to a new one.
  11209. * Note that this parameter will be set by the initialisation routine. To
  11210. * set a default use {@link DataTable.defaults}.
  11211. * @namespace
  11212. * @extends DataTable.models.oSearch
  11213. */
  11214. "oPreviousSearch": {},
  11215. /**
  11216. * Store the applied search for each column - see
  11217. * {@link DataTable.models.oSearch} for the format that is used for the
  11218. * filtering information for each column.
  11219. * @type array
  11220. * @default []
  11221. */
  11222. "aoPreSearchCols": [],
  11223. /**
  11224. * Sorting that is applied to the table. Note that the inner arrays are
  11225. * used in the following manner:
  11226. * <ul>
  11227. * <li>Index 0 - column number</li>
  11228. * <li>Index 1 - current sorting direction</li>
  11229. * </ul>
  11230. * Note that this parameter will be set by the initialisation routine. To
  11231. * set a default use {@link DataTable.defaults}.
  11232. * @type array
  11233. * @todo These inner arrays should really be objects
  11234. */
  11235. "aaSorting": null,
  11236. /**
  11237. * Sorting that is always applied to the table (i.e. prefixed in front of
  11238. * aaSorting).
  11239. * Note that this parameter will be set by the initialisation routine. To
  11240. * set a default use {@link DataTable.defaults}.
  11241. * @type array
  11242. * @default []
  11243. */
  11244. "aaSortingFixed": [],
  11245. /**
  11246. * Classes to use for the striping of a table.
  11247. * Note that this parameter will be set by the initialisation routine. To
  11248. * set a default use {@link DataTable.defaults}.
  11249. * @type array
  11250. * @default []
  11251. */
  11252. "asStripeClasses": null,
  11253. /**
  11254. * If restoring a table - we should restore its striping classes as well
  11255. * @type array
  11256. * @default []
  11257. */
  11258. "asDestroyStripes": [],
  11259. /**
  11260. * If restoring a table - we should restore its width
  11261. * @type int
  11262. * @default 0
  11263. */
  11264. "sDestroyWidth": 0,
  11265. /**
  11266. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11267. * @type array
  11268. * @default []
  11269. */
  11270. "aoRowCallback": [],
  11271. /**
  11272. * Callback functions for the header on each draw.
  11273. * @type array
  11274. * @default []
  11275. */
  11276. "aoHeaderCallback": [],
  11277. /**
  11278. * Callback function for the footer on each draw.
  11279. * @type array
  11280. * @default []
  11281. */
  11282. "aoFooterCallback": [],
  11283. /**
  11284. * Array of callback functions for draw callback functions
  11285. * @type array
  11286. * @default []
  11287. */
  11288. "aoDrawCallback": [],
  11289. /**
  11290. * Array of callback functions for row created function
  11291. * @type array
  11292. * @default []
  11293. */
  11294. "aoRowCreatedCallback": [],
  11295. /**
  11296. * Callback functions for just before the table is redrawn. A return of
  11297. * false will be used to cancel the draw.
  11298. * @type array
  11299. * @default []
  11300. */
  11301. "aoPreDrawCallback": [],
  11302. /**
  11303. * Callback functions for when the table has been initialised.
  11304. * @type array
  11305. * @default []
  11306. */
  11307. "aoInitComplete": [],
  11308. /**
  11309. * Callbacks for modifying the settings to be stored for state saving, prior to
  11310. * saving state.
  11311. * @type array
  11312. * @default []
  11313. */
  11314. "aoStateSaveParams": [],
  11315. /**
  11316. * Callbacks for modifying the settings that have been stored for state saving
  11317. * prior to using the stored values to restore the state.
  11318. * @type array
  11319. * @default []
  11320. */
  11321. "aoStateLoadParams": [],
  11322. /**
  11323. * Callbacks for operating on the settings object once the saved state has been
  11324. * loaded
  11325. * @type array
  11326. * @default []
  11327. */
  11328. "aoStateLoaded": [],
  11329. /**
  11330. * Cache the table ID for quick access
  11331. * @type string
  11332. * @default <i>Empty string</i>
  11333. */
  11334. "sTableId": "",
  11335. /**
  11336. * The TABLE node for the main table
  11337. * @type node
  11338. * @default null
  11339. */
  11340. "nTable": null,
  11341. /**
  11342. * Permanent ref to the thead element
  11343. * @type node
  11344. * @default null
  11345. */
  11346. "nTHead": null,
  11347. /**
  11348. * Permanent ref to the tfoot element - if it exists
  11349. * @type node
  11350. * @default null
  11351. */
  11352. "nTFoot": null,
  11353. /**
  11354. * Permanent ref to the tbody element
  11355. * @type node
  11356. * @default null
  11357. */
  11358. "nTBody": null,
  11359. /**
  11360. * Cache the wrapper node (contains all DataTables controlled elements)
  11361. * @type node
  11362. * @default null
  11363. */
  11364. "nTableWrapper": null,
  11365. /**
  11366. * Indicate if when using server-side processing the loading of data
  11367. * should be deferred until the second draw.
  11368. * Note that this parameter will be set by the initialisation routine. To
  11369. * set a default use {@link DataTable.defaults}.
  11370. * @type boolean
  11371. * @default false
  11372. */
  11373. "bDeferLoading": false,
  11374. /**
  11375. * Indicate if all required information has been read in
  11376. * @type boolean
  11377. * @default false
  11378. */
  11379. "bInitialised": false,
  11380. /**
  11381. * Information about open rows. Each object in the array has the parameters
  11382. * 'nTr' and 'nParent'
  11383. * @type array
  11384. * @default []
  11385. */
  11386. "aoOpenRows": [],
  11387. /**
  11388. * Dictate the positioning of DataTables' control elements - see
  11389. * {@link DataTable.model.oInit.sDom}.
  11390. * Note that this parameter will be set by the initialisation routine. To
  11391. * set a default use {@link DataTable.defaults}.
  11392. * @type string
  11393. * @default null
  11394. */
  11395. "sDom": null,
  11396. /**
  11397. * Search delay (in mS)
  11398. * @type integer
  11399. * @default null
  11400. */
  11401. "searchDelay": null,
  11402. /**
  11403. * Which type of pagination should be used.
  11404. * Note that this parameter will be set by the initialisation routine. To
  11405. * set a default use {@link DataTable.defaults}.
  11406. * @type string
  11407. * @default two_button
  11408. */
  11409. "sPaginationType": "two_button",
  11410. /**
  11411. * The state duration (for `stateSave`) in seconds.
  11412. * Note that this parameter will be set by the initialisation routine. To
  11413. * set a default use {@link DataTable.defaults}.
  11414. * @type int
  11415. * @default 0
  11416. */
  11417. "iStateDuration": 0,
  11418. /**
  11419. * Array of callback functions for state saving. Each array element is an
  11420. * object with the following parameters:
  11421. * <ul>
  11422. * <li>function:fn - function to call. Takes two parameters, oSettings
  11423. * and the JSON string to save that has been thus far created. Returns
  11424. * a JSON string to be inserted into a json object
  11425. * (i.e. '"param": [ 0, 1, 2]')</li>
  11426. * <li>string:sName - name of callback</li>
  11427. * </ul>
  11428. * @type array
  11429. * @default []
  11430. */
  11431. "aoStateSave": [],
  11432. /**
  11433. * Array of callback functions for state loading. Each array element is an
  11434. * object with the following parameters:
  11435. * <ul>
  11436. * <li>function:fn - function to call. Takes two parameters, oSettings
  11437. * and the object stored. May return false to cancel state loading</li>
  11438. * <li>string:sName - name of callback</li>
  11439. * </ul>
  11440. * @type array
  11441. * @default []
  11442. */
  11443. "aoStateLoad": [],
  11444. /**
  11445. * State that was saved. Useful for back reference
  11446. * @type object
  11447. * @default null
  11448. */
  11449. "oSavedState": null,
  11450. /**
  11451. * State that was loaded. Useful for back reference
  11452. * @type object
  11453. * @default null
  11454. */
  11455. "oLoadedState": null,
  11456. /**
  11457. * Source url for AJAX data for the table.
  11458. * Note that this parameter will be set by the initialisation routine. To
  11459. * set a default use {@link DataTable.defaults}.
  11460. * @type string
  11461. * @default null
  11462. */
  11463. "sAjaxSource": null,
  11464. /**
  11465. * Property from a given object from which to read the table data from. This
  11466. * can be an empty string (when not server-side processing), in which case
  11467. * it is assumed an an array is given directly.
  11468. * Note that this parameter will be set by the initialisation routine. To
  11469. * set a default use {@link DataTable.defaults}.
  11470. * @type string
  11471. */
  11472. "sAjaxDataProp": null,
  11473. /**
  11474. * Note if draw should be blocked while getting data
  11475. * @type boolean
  11476. * @default true
  11477. */
  11478. "bAjaxDataGet": true,
  11479. /**
  11480. * The last jQuery XHR object that was used for server-side data gathering.
  11481. * This can be used for working with the XHR information in one of the
  11482. * callbacks
  11483. * @type object
  11484. * @default null
  11485. */
  11486. "jqXHR": null,
  11487. /**
  11488. * JSON returned from the server in the last Ajax request
  11489. * @type object
  11490. * @default undefined
  11491. */
  11492. "json": undefined,
  11493. /**
  11494. * Data submitted as part of the last Ajax request
  11495. * @type object
  11496. * @default undefined
  11497. */
  11498. "oAjaxData": undefined,
  11499. /**
  11500. * Function to get the server-side data.
  11501. * Note that this parameter will be set by the initialisation routine. To
  11502. * set a default use {@link DataTable.defaults}.
  11503. * @type function
  11504. */
  11505. "fnServerData": null,
  11506. /**
  11507. * Functions which are called prior to sending an Ajax request so extra
  11508. * parameters can easily be sent to the server
  11509. * @type array
  11510. * @default []
  11511. */
  11512. "aoServerParams": [],
  11513. /**
  11514. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11515. * required).
  11516. * Note that this parameter will be set by the initialisation routine. To
  11517. * set a default use {@link DataTable.defaults}.
  11518. * @type string
  11519. */
  11520. "sServerMethod": null,
  11521. /**
  11522. * Format numbers for display.
  11523. * Note that this parameter will be set by the initialisation routine. To
  11524. * set a default use {@link DataTable.defaults}.
  11525. * @type function
  11526. */
  11527. "fnFormatNumber": null,
  11528. /**
  11529. * List of options that can be used for the user selectable length menu.
  11530. * Note that this parameter will be set by the initialisation routine. To
  11531. * set a default use {@link DataTable.defaults}.
  11532. * @type array
  11533. * @default []
  11534. */
  11535. "aLengthMenu": null,
  11536. /**
  11537. * Counter for the draws that the table does. Also used as a tracker for
  11538. * server-side processing
  11539. * @type int
  11540. * @default 0
  11541. */
  11542. "iDraw": 0,
  11543. /**
  11544. * Indicate if a redraw is being done - useful for Ajax
  11545. * @type boolean
  11546. * @default false
  11547. */
  11548. "bDrawing": false,
  11549. /**
  11550. * Draw index (iDraw) of the last error when parsing the returned data
  11551. * @type int
  11552. * @default -1
  11553. */
  11554. "iDrawError": -1,
  11555. /**
  11556. * Paging display length
  11557. * @type int
  11558. * @default 10
  11559. */
  11560. "_iDisplayLength": 10,
  11561. /**
  11562. * Paging start point - aiDisplay index
  11563. * @type int
  11564. * @default 0
  11565. */
  11566. "_iDisplayStart": 0,
  11567. /**
  11568. * Server-side processing - number of records in the result set
  11569. * (i.e. before filtering), Use fnRecordsTotal rather than
  11570. * this property to get the value of the number of records, regardless of
  11571. * the server-side processing setting.
  11572. * @type int
  11573. * @default 0
  11574. * @private
  11575. */
  11576. "_iRecordsTotal": 0,
  11577. /**
  11578. * Server-side processing - number of records in the current display set
  11579. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11580. * this property to get the value of the number of records, regardless of
  11581. * the server-side processing setting.
  11582. * @type boolean
  11583. * @default 0
  11584. * @private
  11585. */
  11586. "_iRecordsDisplay": 0,
  11587. /**
  11588. * Flag to indicate if jQuery UI marking and classes should be used.
  11589. * Note that this parameter will be set by the initialisation routine. To
  11590. * set a default use {@link DataTable.defaults}.
  11591. * @type boolean
  11592. */
  11593. "bJUI": null,
  11594. /**
  11595. * The classes to use for the table
  11596. * @type object
  11597. * @default {}
  11598. */
  11599. "oClasses": {},
  11600. /**
  11601. * Flag attached to the settings object so you can check in the draw
  11602. * callback if filtering has been done in the draw. Deprecated in favour of
  11603. * events.
  11604. * @type boolean
  11605. * @default false
  11606. * @deprecated
  11607. */
  11608. "bFiltered": false,
  11609. /**
  11610. * Flag attached to the settings object so you can check in the draw
  11611. * callback if sorting has been done in the draw. Deprecated in favour of
  11612. * events.
  11613. * @type boolean
  11614. * @default false
  11615. * @deprecated
  11616. */
  11617. "bSorted": false,
  11618. /**
  11619. * Indicate that if multiple rows are in the header and there is more than
  11620. * one unique cell per column, if the top one (true) or bottom one (false)
  11621. * should be used for sorting / title by DataTables.
  11622. * Note that this parameter will be set by the initialisation routine. To
  11623. * set a default use {@link DataTable.defaults}.
  11624. * @type boolean
  11625. */
  11626. "bSortCellsTop": null,
  11627. /**
  11628. * Initialisation object that is used for the table
  11629. * @type object
  11630. * @default null
  11631. */
  11632. "oInit": null,
  11633. /**
  11634. * Destroy callback functions - for plug-ins to attach themselves to the
  11635. * destroy so they can clean up markup and events.
  11636. * @type array
  11637. * @default []
  11638. */
  11639. "aoDestroyCallback": [],
  11640. /**
  11641. * Get the number of records in the current record set, before filtering
  11642. * @type function
  11643. */
  11644. "fnRecordsTotal": function ()
  11645. {
  11646. return _fnDataSource( this ) == 'ssp' ?
  11647. this._iRecordsTotal * 1 :
  11648. this.aiDisplayMaster.length;
  11649. },
  11650. /**
  11651. * Get the number of records in the current record set, after filtering
  11652. * @type function
  11653. */
  11654. "fnRecordsDisplay": function ()
  11655. {
  11656. return _fnDataSource( this ) == 'ssp' ?
  11657. this._iRecordsDisplay * 1 :
  11658. this.aiDisplay.length;
  11659. },
  11660. /**
  11661. * Get the display end point - aiDisplay index
  11662. * @type function
  11663. */
  11664. "fnDisplayEnd": function ()
  11665. {
  11666. var
  11667. len = this._iDisplayLength,
  11668. start = this._iDisplayStart,
  11669. calc = start + len,
  11670. records = this.aiDisplay.length,
  11671. features = this.oFeatures,
  11672. paginate = features.bPaginate;
  11673. if ( features.bServerSide ) {
  11674. return paginate === false || len === -1 ?
  11675. start + records :
  11676. Math.min( start+len, this._iRecordsDisplay );
  11677. }
  11678. else {
  11679. return ! paginate || calc>records || len===-1 ?
  11680. records :
  11681. calc;
  11682. }
  11683. },
  11684. /**
  11685. * The DataTables object for this table
  11686. * @type object
  11687. * @default null
  11688. */
  11689. "oInstance": null,
  11690. /**
  11691. * Unique identifier for each instance of the DataTables object. If there
  11692. * is an ID on the table node, then it takes that value, otherwise an
  11693. * incrementing internal counter is used.
  11694. * @type string
  11695. * @default null
  11696. */
  11697. "sInstance": null,
  11698. /**
  11699. * tabindex attribute value that is added to DataTables control elements, allowing
  11700. * keyboard navigation of the table and its controls.
  11701. */
  11702. "iTabIndex": 0,
  11703. /**
  11704. * DIV container for the footer scrolling table if scrolling
  11705. */
  11706. "nScrollHead": null,
  11707. /**
  11708. * DIV container for the footer scrolling table if scrolling
  11709. */
  11710. "nScrollFoot": null,
  11711. /**
  11712. * Last applied sort
  11713. * @type array
  11714. * @default []
  11715. */
  11716. "aLastSort": [],
  11717. /**
  11718. * Stored plug-in instances
  11719. * @type object
  11720. * @default {}
  11721. */
  11722. "oPlugins": {}
  11723. };
  11724. /**
  11725. * Extension object for DataTables that is used to provide all extension
  11726. * options.
  11727. *
  11728. * Note that the `DataTable.ext` object is available through
  11729. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11730. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11731. * @namespace
  11732. * @extends DataTable.models.ext
  11733. */
  11734. /**
  11735. * DataTables extensions
  11736. *
  11737. * This namespace acts as a collection area for plug-ins that can be used to
  11738. * extend DataTables capabilities. Indeed many of the build in methods
  11739. * use this method to provide their own capabilities (sorting methods for
  11740. * example).
  11741. *
  11742. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11743. * reasons
  11744. *
  11745. * @namespace
  11746. */
  11747. DataTable.ext = _ext = {
  11748. /**
  11749. * Buttons. For use with the Buttons extension for DataTables. This is
  11750. * defined here so other extensions can define buttons regardless of load
  11751. * order. It is _not_ used by DataTables core.
  11752. *
  11753. * @type object
  11754. * @default {}
  11755. */
  11756. buttons: {},
  11757. /**
  11758. * Element class names
  11759. *
  11760. * @type object
  11761. * @default {}
  11762. */
  11763. classes: {},
  11764. /**
  11765. * Error reporting.
  11766. *
  11767. * How should DataTables report an error. Can take the value 'alert',
  11768. * 'throw', 'none' or a function.
  11769. *
  11770. * @type string|function
  11771. * @default alert
  11772. */
  11773. errMode: "alert",
  11774. /**
  11775. * Feature plug-ins.
  11776. *
  11777. * This is an array of objects which describe the feature plug-ins that are
  11778. * available to DataTables. These feature plug-ins are then available for
  11779. * use through the `dom` initialisation option.
  11780. *
  11781. * Each feature plug-in is described by an object which must have the
  11782. * following properties:
  11783. *
  11784. * * `fnInit` - function that is used to initialise the plug-in,
  11785. * * `cFeature` - a character so the feature can be enabled by the `dom`
  11786. * instillation option. This is case sensitive.
  11787. *
  11788. * The `fnInit` function has the following input parameters:
  11789. *
  11790. * 1. `{object}` DataTables settings object: see
  11791. * {@link DataTable.models.oSettings}
  11792. *
  11793. * And the following return is expected:
  11794. *
  11795. * * {node|null} The element which contains your feature. Note that the
  11796. * return may also be void if your plug-in does not require to inject any
  11797. * DOM elements into DataTables control (`dom`) - for example this might
  11798. * be useful when developing a plug-in which allows table control via
  11799. * keyboard entry
  11800. *
  11801. * @type array
  11802. *
  11803. * @example
  11804. * $.fn.dataTable.ext.features.push( {
  11805. * "fnInit": function( oSettings ) {
  11806. * return new TableTools( { "oDTSettings": oSettings } );
  11807. * },
  11808. * "cFeature": "T"
  11809. * } );
  11810. */
  11811. feature: [],
  11812. /**
  11813. * Row searching.
  11814. *
  11815. * This method of searching is complimentary to the default type based
  11816. * searching, and a lot more comprehensive as it allows you complete control
  11817. * over the searching logic. Each element in this array is a function
  11818. * (parameters described below) that is called for every row in the table,
  11819. * and your logic decides if it should be included in the searching data set
  11820. * or not.
  11821. *
  11822. * Searching functions have the following input parameters:
  11823. *
  11824. * 1. `{object}` DataTables settings object: see
  11825. * {@link DataTable.models.oSettings}
  11826. * 2. `{array|object}` Data for the row to be processed (same as the
  11827. * original format that was passed in as the data source, or an array
  11828. * from a DOM data source
  11829. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  11830. * can be useful to retrieve the `TR` element if you need DOM interaction.
  11831. *
  11832. * And the following return is expected:
  11833. *
  11834. * * {boolean} Include the row in the searched result set (true) or not
  11835. * (false)
  11836. *
  11837. * Note that as with the main search ability in DataTables, technically this
  11838. * is "filtering", since it is subtractive. However, for consistency in
  11839. * naming we call it searching here.
  11840. *
  11841. * @type array
  11842. * @default []
  11843. *
  11844. * @example
  11845. * // The following example shows custom search being applied to the
  11846. * // fourth column (i.e. the data[3] index) based on two input values
  11847. * // from the end-user, matching the data in a certain range.
  11848. * $.fn.dataTable.ext.search.push(
  11849. * function( settings, data, dataIndex ) {
  11850. * var min = document.getElementById('min').value * 1;
  11851. * var max = document.getElementById('max').value * 1;
  11852. * var version = data[3] == "-" ? 0 : data[3]*1;
  11853. *
  11854. * if ( min == "" && max == "" ) {
  11855. * return true;
  11856. * }
  11857. * else if ( min == "" && version < max ) {
  11858. * return true;
  11859. * }
  11860. * else if ( min < version && "" == max ) {
  11861. * return true;
  11862. * }
  11863. * else if ( min < version && version < max ) {
  11864. * return true;
  11865. * }
  11866. * return false;
  11867. * }
  11868. * );
  11869. */
  11870. search: [],
  11871. /**
  11872. * Selector extensions
  11873. *
  11874. * The `selector` option can be used to extend the options available for the
  11875. * selector modifier options (`selector-modifier` object data type) that
  11876. * each of the three built in selector types offer (row, column and cell +
  11877. * their plural counterparts). For example the Select extension uses this
  11878. * mechanism to provide an option to select only rows, columns and cells
  11879. * that have been marked as selected by the end user (`{selected: true}`),
  11880. * which can be used in conjunction with the existing built in selector
  11881. * options.
  11882. *
  11883. * Each property is an array to which functions can be pushed. The functions
  11884. * take three attributes:
  11885. *
  11886. * * Settings object for the host table
  11887. * * Options object (`selector-modifier` object type)
  11888. * * Array of selected item indexes
  11889. *
  11890. * The return is an array of the resulting item indexes after the custom
  11891. * selector has been applied.
  11892. *
  11893. * @type object
  11894. */
  11895. selector: {
  11896. cell: [],
  11897. column: [],
  11898. row: []
  11899. },
  11900. /**
  11901. * Internal functions, exposed for used in plug-ins.
  11902. *
  11903. * Please note that you should not need to use the internal methods for
  11904. * anything other than a plug-in (and even then, try to avoid if possible).
  11905. * The internal function may change between releases.
  11906. *
  11907. * @type object
  11908. * @default {}
  11909. */
  11910. internal: {},
  11911. /**
  11912. * Legacy configuration options. Enable and disable legacy options that
  11913. * are available in DataTables.
  11914. *
  11915. * @type object
  11916. */
  11917. legacy: {
  11918. /**
  11919. * Enable / disable DataTables 1.9 compatible server-side processing
  11920. * requests
  11921. *
  11922. * @type boolean
  11923. * @default null
  11924. */
  11925. ajax: null
  11926. },
  11927. /**
  11928. * Pagination plug-in methods.
  11929. *
  11930. * Each entry in this object is a function and defines which buttons should
  11931. * be shown by the pagination rendering method that is used for the table:
  11932. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  11933. * buttons are displayed in the document, while the functions here tell it
  11934. * what buttons to display. This is done by returning an array of button
  11935. * descriptions (what each button will do).
  11936. *
  11937. * Pagination types (the four built in options and any additional plug-in
  11938. * options defined here) can be used through the `paginationType`
  11939. * initialisation parameter.
  11940. *
  11941. * The functions defined take two parameters:
  11942. *
  11943. * 1. `{int} page` The current page index
  11944. * 2. `{int} pages` The number of pages in the table
  11945. *
  11946. * Each function is expected to return an array where each element of the
  11947. * array can be one of:
  11948. *
  11949. * * `first` - Jump to first page when activated
  11950. * * `last` - Jump to last page when activated
  11951. * * `previous` - Show previous page when activated
  11952. * * `next` - Show next page when activated
  11953. * * `{int}` - Show page of the index given
  11954. * * `{array}` - A nested array containing the above elements to add a
  11955. * containing 'DIV' element (might be useful for styling).
  11956. *
  11957. * Note that DataTables v1.9- used this object slightly differently whereby
  11958. * an object with two functions would be defined for each plug-in. That
  11959. * ability is still supported by DataTables 1.10+ to provide backwards
  11960. * compatibility, but this option of use is now decremented and no longer
  11961. * documented in DataTables 1.10+.
  11962. *
  11963. * @type object
  11964. * @default {}
  11965. *
  11966. * @example
  11967. * // Show previous, next and current page buttons only
  11968. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  11969. * return [ 'previous', page, 'next' ];
  11970. * };
  11971. */
  11972. pager: {},
  11973. renderer: {
  11974. pageButton: {},
  11975. header: {}
  11976. },
  11977. /**
  11978. * Ordering plug-ins - custom data source
  11979. *
  11980. * The extension options for ordering of data available here is complimentary
  11981. * to the default type based ordering that DataTables typically uses. It
  11982. * allows much greater control over the the data that is being used to
  11983. * order a column, but is necessarily therefore more complex.
  11984. *
  11985. * This type of ordering is useful if you want to do ordering based on data
  11986. * live from the DOM (for example the contents of an 'input' element) rather
  11987. * than just the static string that DataTables knows of.
  11988. *
  11989. * The way these plug-ins work is that you create an array of the values you
  11990. * wish to be ordering for the column in question and then return that
  11991. * array. The data in the array much be in the index order of the rows in
  11992. * the table (not the currently ordering order!). Which order data gathering
  11993. * function is run here depends on the `dt-init columns.orderDataType`
  11994. * parameter that is used for the column (if any).
  11995. *
  11996. * The functions defined take two parameters:
  11997. *
  11998. * 1. `{object}` DataTables settings object: see
  11999. * {@link DataTable.models.oSettings}
  12000. * 2. `{int}` Target column index
  12001. *
  12002. * Each function is expected to return an array:
  12003. *
  12004. * * `{array}` Data for the column to be ordering upon
  12005. *
  12006. * @type array
  12007. *
  12008. * @example
  12009. * // Ordering using `input` node values
  12010. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12011. * {
  12012. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12013. * return $('input', td).val();
  12014. * } );
  12015. * }
  12016. */
  12017. order: {},
  12018. /**
  12019. * Type based plug-ins.
  12020. *
  12021. * Each column in DataTables has a type assigned to it, either by automatic
  12022. * detection or by direct assignment using the `type` option for the column.
  12023. * The type of a column will effect how it is ordering and search (plug-ins
  12024. * can also make use of the column type if required).
  12025. *
  12026. * @namespace
  12027. */
  12028. type: {
  12029. /**
  12030. * Type detection functions.
  12031. *
  12032. * The functions defined in this object are used to automatically detect
  12033. * a column's type, making initialisation of DataTables super easy, even
  12034. * when complex data is in the table.
  12035. *
  12036. * The functions defined take two parameters:
  12037. *
  12038. * 1. `{*}` Data from the column cell to be analysed
  12039. * 2. `{settings}` DataTables settings object. This can be used to
  12040. * perform context specific type detection - for example detection
  12041. * based on language settings such as using a comma for a decimal
  12042. * place. Generally speaking the options from the settings will not
  12043. * be required
  12044. *
  12045. * Each function is expected to return:
  12046. *
  12047. * * `{string|null}` Data type detected, or null if unknown (and thus
  12048. * pass it on to the other type detection functions.
  12049. *
  12050. * @type array
  12051. *
  12052. * @example
  12053. * // Currency type detection plug-in:
  12054. * $.fn.dataTable.ext.type.detect.push(
  12055. * function ( data, settings ) {
  12056. * // Check the numeric part
  12057. * if ( ! $.isNumeric( data.substring(1) ) ) {
  12058. * return null;
  12059. * }
  12060. *
  12061. * // Check prefixed by currency
  12062. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12063. * return 'currency';
  12064. * }
  12065. * return null;
  12066. * }
  12067. * );
  12068. */
  12069. detect: [],
  12070. /**
  12071. * Type based search formatting.
  12072. *
  12073. * The type based searching functions can be used to pre-format the
  12074. * data to be search on. For example, it can be used to strip HTML
  12075. * tags or to de-format telephone numbers for numeric only searching.
  12076. *
  12077. * Note that is a search is not defined for a column of a given type,
  12078. * no search formatting will be performed.
  12079. *
  12080. * Pre-processing of searching data plug-ins - When you assign the sType
  12081. * for a column (or have it automatically detected for you by DataTables
  12082. * or a type detection plug-in), you will typically be using this for
  12083. * custom sorting, but it can also be used to provide custom searching
  12084. * by allowing you to pre-processing the data and returning the data in
  12085. * the format that should be searched upon. This is done by adding
  12086. * functions this object with a parameter name which matches the sType
  12087. * for that target column. This is the corollary of <i>afnSortData</i>
  12088. * for searching data.
  12089. *
  12090. * The functions defined take a single parameter:
  12091. *
  12092. * 1. `{*}` Data from the column cell to be prepared for searching
  12093. *
  12094. * Each function is expected to return:
  12095. *
  12096. * * `{string|null}` Formatted string that will be used for the searching.
  12097. *
  12098. * @type object
  12099. * @default {}
  12100. *
  12101. * @example
  12102. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12103. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12104. * }
  12105. */
  12106. search: {},
  12107. /**
  12108. * Type based ordering.
  12109. *
  12110. * The column type tells DataTables what ordering to apply to the table
  12111. * when a column is sorted upon. The order for each type that is defined,
  12112. * is defined by the functions available in this object.
  12113. *
  12114. * Each ordering option can be described by three properties added to
  12115. * this object:
  12116. *
  12117. * * `{type}-pre` - Pre-formatting function
  12118. * * `{type}-asc` - Ascending order function
  12119. * * `{type}-desc` - Descending order function
  12120. *
  12121. * All three can be used together, only `{type}-pre` or only
  12122. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12123. * that only `{type}-pre` is used, as this provides the optimal
  12124. * implementation in terms of speed, although the others are provided
  12125. * for compatibility with existing Javascript sort functions.
  12126. *
  12127. * `{type}-pre`: Functions defined take a single parameter:
  12128. *
  12129. * 1. `{*}` Data from the column cell to be prepared for ordering
  12130. *
  12131. * And return:
  12132. *
  12133. * * `{*}` Data to be sorted upon
  12134. *
  12135. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12136. * functions, taking two parameters:
  12137. *
  12138. * 1. `{*}` Data to compare to the second parameter
  12139. * 2. `{*}` Data to compare to the first parameter
  12140. *
  12141. * And returning:
  12142. *
  12143. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12144. * than the second parameter, ===0 if the two parameters are equal and
  12145. * >0 if the first parameter should be sorted height than the second
  12146. * parameter.
  12147. *
  12148. * @type object
  12149. * @default {}
  12150. *
  12151. * @example
  12152. * // Numeric ordering of formatted numbers with a pre-formatter
  12153. * $.extend( $.fn.dataTable.ext.type.order, {
  12154. * "string-pre": function(x) {
  12155. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12156. * return parseFloat( a );
  12157. * }
  12158. * } );
  12159. *
  12160. * @example
  12161. * // Case-sensitive string ordering, with no pre-formatting method
  12162. * $.extend( $.fn.dataTable.ext.order, {
  12163. * "string-case-asc": function(x,y) {
  12164. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12165. * },
  12166. * "string-case-desc": function(x,y) {
  12167. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12168. * }
  12169. * } );
  12170. */
  12171. order: {}
  12172. },
  12173. /**
  12174. * Unique DataTables instance counter
  12175. *
  12176. * @type int
  12177. * @private
  12178. */
  12179. _unique: 0,
  12180. //
  12181. // Depreciated
  12182. // The following properties are retained for backwards compatiblity only.
  12183. // The should not be used in new projects and will be removed in a future
  12184. // version
  12185. //
  12186. /**
  12187. * Version check function.
  12188. * @type function
  12189. * @depreciated Since 1.10
  12190. */
  12191. fnVersionCheck: DataTable.fnVersionCheck,
  12192. /**
  12193. * Index for what 'this' index API functions should use
  12194. * @type int
  12195. * @deprecated Since v1.10
  12196. */
  12197. iApiIndex: 0,
  12198. /**
  12199. * jQuery UI class container
  12200. * @type object
  12201. * @deprecated Since v1.10
  12202. */
  12203. oJUIClasses: {},
  12204. /**
  12205. * Software version
  12206. * @type string
  12207. * @deprecated Since v1.10
  12208. */
  12209. sVersion: DataTable.version
  12210. };
  12211. //
  12212. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12213. //
  12214. $.extend( _ext, {
  12215. afnFiltering: _ext.search,
  12216. aTypes: _ext.type.detect,
  12217. ofnSearch: _ext.type.search,
  12218. oSort: _ext.type.order,
  12219. afnSortData: _ext.order,
  12220. aoFeatures: _ext.feature,
  12221. oApi: _ext.internal,
  12222. oStdClasses: _ext.classes,
  12223. oPagination: _ext.pager
  12224. } );
  12225. $.extend( DataTable.ext.classes, {
  12226. "sTable": "dataTable",
  12227. "sNoFooter": "no-footer",
  12228. /* Paging buttons */
  12229. "sPageButton": "paginate_button",
  12230. "sPageButtonActive": "current",
  12231. "sPageButtonDisabled": "disabled",
  12232. /* Striping classes */
  12233. "sStripeOdd": "odd",
  12234. "sStripeEven": "even",
  12235. /* Empty row */
  12236. "sRowEmpty": "dataTables_empty",
  12237. /* Features */
  12238. "sWrapper": "dataTables_wrapper",
  12239. "sFilter": "dataTables_filter",
  12240. "sInfo": "dataTables_info",
  12241. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12242. "sLength": "dataTables_length",
  12243. "sProcessing": "dataTables_processing",
  12244. /* Sorting */
  12245. "sSortAsc": "sorting_asc",
  12246. "sSortDesc": "sorting_desc",
  12247. "sSortable": "sorting", /* Sortable in both directions */
  12248. "sSortableAsc": "sorting_asc_disabled",
  12249. "sSortableDesc": "sorting_desc_disabled",
  12250. "sSortableNone": "sorting_disabled",
  12251. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12252. /* Filtering */
  12253. "sFilterInput": "",
  12254. /* Page length */
  12255. "sLengthSelect": "",
  12256. /* Scrolling */
  12257. "sScrollWrapper": "dataTables_scroll",
  12258. "sScrollHead": "dataTables_scrollHead",
  12259. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12260. "sScrollBody": "dataTables_scrollBody",
  12261. "sScrollFoot": "dataTables_scrollFoot",
  12262. "sScrollFootInner": "dataTables_scrollFootInner",
  12263. /* Misc */
  12264. "sHeaderTH": "",
  12265. "sFooterTH": "",
  12266. // Deprecated
  12267. "sSortJUIAsc": "",
  12268. "sSortJUIDesc": "",
  12269. "sSortJUI": "",
  12270. "sSortJUIAscAllowed": "",
  12271. "sSortJUIDescAllowed": "",
  12272. "sSortJUIWrapper": "",
  12273. "sSortIcon": "",
  12274. "sJUIHeader": "",
  12275. "sJUIFooter": ""
  12276. } );
  12277. (function() {
  12278. // Reused strings for better compression. Closure compiler appears to have a
  12279. // weird edge case where it is trying to expand strings rather than use the
  12280. // variable version. This results in about 200 bytes being added, for very
  12281. // little preference benefit since it this run on script load only.
  12282. var _empty = '';
  12283. _empty = '';
  12284. var _stateDefault = _empty + 'ui-state-default';
  12285. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  12286. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  12287. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  12288. /* Full numbers paging buttons */
  12289. "sPageButton": "fg-button ui-button "+_stateDefault,
  12290. "sPageButtonActive": "ui-state-disabled",
  12291. "sPageButtonDisabled": "ui-state-disabled",
  12292. /* Features */
  12293. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  12294. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  12295. /* Sorting */
  12296. "sSortAsc": _stateDefault+" sorting_asc",
  12297. "sSortDesc": _stateDefault+" sorting_desc",
  12298. "sSortable": _stateDefault+" sorting",
  12299. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  12300. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  12301. "sSortableNone": _stateDefault+" sorting_disabled",
  12302. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  12303. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  12304. "sSortJUI": _sortIcon+"carat-2-n-s",
  12305. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  12306. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  12307. "sSortJUIWrapper": "DataTables_sort_wrapper",
  12308. "sSortIcon": "DataTables_sort_icon",
  12309. /* Scrolling */
  12310. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  12311. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  12312. /* Misc */
  12313. "sHeaderTH": _stateDefault,
  12314. "sFooterTH": _stateDefault,
  12315. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  12316. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  12317. } );
  12318. }());
  12319. var extPagination = DataTable.ext.pager;
  12320. function _numbers ( page, pages ) {
  12321. var
  12322. numbers = [],
  12323. buttons = extPagination.numbers_length,
  12324. half = Math.floor( buttons / 2 ),
  12325. i = 1;
  12326. if ( pages <= buttons ) {
  12327. numbers = _range( 0, pages );
  12328. }
  12329. else if ( page <= half ) {
  12330. numbers = _range( 0, buttons-2 );
  12331. numbers.push( 'ellipsis' );
  12332. numbers.push( pages-1 );
  12333. }
  12334. else if ( page >= pages - 1 - half ) {
  12335. numbers = _range( pages-(buttons-2), pages );
  12336. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12337. numbers.splice( 0, 0, 0 );
  12338. }
  12339. else {
  12340. numbers = _range( page-half+2, page+half-1 );
  12341. numbers.push( 'ellipsis' );
  12342. numbers.push( pages-1 );
  12343. numbers.splice( 0, 0, 'ellipsis' );
  12344. numbers.splice( 0, 0, 0 );
  12345. }
  12346. numbers.DT_el = 'span';
  12347. return numbers;
  12348. }
  12349. $.extend( extPagination, {
  12350. simple: function ( page, pages ) {
  12351. return [ 'previous', 'next' ];
  12352. },
  12353. full: function ( page, pages ) {
  12354. return [ 'first', 'previous', 'next', 'last' ];
  12355. },
  12356. simple_numbers: function ( page, pages ) {
  12357. return [ 'previous', _numbers(page, pages), 'next' ];
  12358. },
  12359. full_numbers: function ( page, pages ) {
  12360. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12361. },
  12362. // For testing and plug-ins to use
  12363. _numbers: _numbers,
  12364. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12365. numbers_length: 7
  12366. } );
  12367. $.extend( true, DataTable.ext.renderer, {
  12368. pageButton: {
  12369. _: function ( settings, host, idx, buttons, page, pages ) {
  12370. var classes = settings.oClasses;
  12371. var lang = settings.oLanguage.oPaginate;
  12372. var btnDisplay, btnClass, counter=0;
  12373. var attach = function( container, buttons ) {
  12374. var i, ien, node, button;
  12375. var clickHandler = function ( e ) {
  12376. _fnPageChange( settings, e.data.action, true );
  12377. };
  12378. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12379. button = buttons[i];
  12380. if ( $.isArray( button ) ) {
  12381. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12382. .appendTo( container );
  12383. attach( inner, button );
  12384. }
  12385. else {
  12386. btnDisplay = '';
  12387. btnClass = '';
  12388. switch ( button ) {
  12389. case 'ellipsis':
  12390. container.append('<span class="ellipsis">&#x2026;</span>');
  12391. break;
  12392. case 'first':
  12393. btnDisplay = lang.sFirst;
  12394. btnClass = button + (page > 0 ?
  12395. '' : ' '+classes.sPageButtonDisabled);
  12396. break;
  12397. case 'previous':
  12398. btnDisplay = lang.sPrevious;
  12399. btnClass = button + (page > 0 ?
  12400. '' : ' '+classes.sPageButtonDisabled);
  12401. break;
  12402. case 'next':
  12403. btnDisplay = lang.sNext;
  12404. btnClass = button + (page < pages-1 ?
  12405. '' : ' '+classes.sPageButtonDisabled);
  12406. break;
  12407. case 'last':
  12408. btnDisplay = lang.sLast;
  12409. btnClass = button + (page < pages-1 ?
  12410. '' : ' '+classes.sPageButtonDisabled);
  12411. break;
  12412. default:
  12413. btnDisplay = button + 1;
  12414. btnClass = page === button ?
  12415. classes.sPageButtonActive : '';
  12416. break;
  12417. }
  12418. if ( btnDisplay ) {
  12419. node = $('<a>', {
  12420. 'class': classes.sPageButton+' '+btnClass,
  12421. 'aria-controls': settings.sTableId,
  12422. 'data-dt-idx': counter,
  12423. 'tabindex': settings.iTabIndex,
  12424. 'id': idx === 0 && typeof button === 'string' ?
  12425. settings.sTableId +'_'+ button :
  12426. null
  12427. } )
  12428. .html( btnDisplay )
  12429. .appendTo( container );
  12430. _fnBindAction(
  12431. node, {action: button}, clickHandler
  12432. );
  12433. counter++;
  12434. }
  12435. }
  12436. }
  12437. };
  12438. // IE9 throws an 'unknown error' if document.activeElement is used
  12439. // inside an iframe or frame. Try / catch the error. Not good for
  12440. // accessibility, but neither are frames.
  12441. var activeEl;
  12442. try {
  12443. // Because this approach is destroying and recreating the paging
  12444. // elements, focus is lost on the select button which is bad for
  12445. // accessibility. So we want to restore focus once the draw has
  12446. // completed
  12447. activeEl = $(document.activeElement).data('dt-idx');
  12448. }
  12449. catch (e) {}
  12450. attach( $(host).empty(), buttons );
  12451. if ( activeEl ) {
  12452. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12453. }
  12454. }
  12455. }
  12456. } );
  12457. // Built in type detection. See model.ext.aTypes for information about
  12458. // what is required from this methods.
  12459. $.extend( DataTable.ext.type.detect, [
  12460. // Plain numbers - first since V8 detects some plain numbers as dates
  12461. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12462. function ( d, settings )
  12463. {
  12464. var decimal = settings.oLanguage.sDecimal;
  12465. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12466. },
  12467. // Dates (only those recognised by the browser's Date.parse)
  12468. function ( d, settings )
  12469. {
  12470. // V8 will remove any unknown characters at the start and end of the
  12471. // expression, leading to false matches such as `$245.12` or `10%` being
  12472. // a valid date. See forum thread 18941 for detail.
  12473. if ( d && !(d instanceof Date) && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
  12474. return null;
  12475. }
  12476. var parsed = Date.parse(d);
  12477. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12478. },
  12479. // Formatted numbers
  12480. function ( d, settings )
  12481. {
  12482. var decimal = settings.oLanguage.sDecimal;
  12483. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12484. },
  12485. // HTML numeric
  12486. function ( d, settings )
  12487. {
  12488. var decimal = settings.oLanguage.sDecimal;
  12489. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12490. },
  12491. // HTML numeric, formatted
  12492. function ( d, settings )
  12493. {
  12494. var decimal = settings.oLanguage.sDecimal;
  12495. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12496. },
  12497. // HTML (this is strict checking - there must be html)
  12498. function ( d, settings )
  12499. {
  12500. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12501. 'html' : null;
  12502. }
  12503. ] );
  12504. // Filter formatting functions. See model.ext.ofnSearch for information about
  12505. // what is required from these methods.
  12506. //
  12507. // Note that additional search methods are added for the html numbers and
  12508. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12509. // place is
  12510. $.extend( DataTable.ext.type.search, {
  12511. html: function ( data ) {
  12512. return _empty(data) ?
  12513. data :
  12514. typeof data === 'string' ?
  12515. data
  12516. .replace( _re_new_lines, " " )
  12517. .replace( _re_html, "" ) :
  12518. '';
  12519. },
  12520. string: function ( data ) {
  12521. return _empty(data) ?
  12522. data :
  12523. typeof data === 'string' ?
  12524. data.replace( _re_new_lines, " " ) :
  12525. data;
  12526. }
  12527. } );
  12528. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12529. if ( d !== 0 && (!d || d === '-') ) {
  12530. return -Infinity;
  12531. }
  12532. // If a decimal place other than `.` is used, it needs to be given to the
  12533. // function so we can detect it and replace with a `.` which is the only
  12534. // decimal place Javascript recognises - it is not locale aware.
  12535. if ( decimalPlace ) {
  12536. d = _numToDecimal( d, decimalPlace );
  12537. }
  12538. if ( d.replace ) {
  12539. if ( re1 ) {
  12540. d = d.replace( re1, '' );
  12541. }
  12542. if ( re2 ) {
  12543. d = d.replace( re2, '' );
  12544. }
  12545. }
  12546. return d * 1;
  12547. };
  12548. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12549. // in a function to provide an easy ability for the language options to add
  12550. // additional methods if a non-period decimal place is used.
  12551. function _addNumericSort ( decimalPlace ) {
  12552. $.each(
  12553. {
  12554. // Plain numbers
  12555. "num": function ( d ) {
  12556. return __numericReplace( d, decimalPlace );
  12557. },
  12558. // Formatted numbers
  12559. "num-fmt": function ( d ) {
  12560. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12561. },
  12562. // HTML numeric
  12563. "html-num": function ( d ) {
  12564. return __numericReplace( d, decimalPlace, _re_html );
  12565. },
  12566. // HTML numeric, formatted
  12567. "html-num-fmt": function ( d ) {
  12568. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12569. }
  12570. },
  12571. function ( key, fn ) {
  12572. // Add the ordering method
  12573. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12574. // For HTML types add a search formatter that will strip the HTML
  12575. if ( key.match(/^html\-/) ) {
  12576. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12577. }
  12578. }
  12579. );
  12580. }
  12581. // Default sort methods
  12582. $.extend( _ext.type.order, {
  12583. // Dates
  12584. "date-pre": function ( d ) {
  12585. return Date.parse( d ) || 0;
  12586. },
  12587. // html
  12588. "html-pre": function ( a ) {
  12589. return _empty(a) ?
  12590. '' :
  12591. a.replace ?
  12592. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12593. a+'';
  12594. },
  12595. // string
  12596. "string-pre": function ( a ) {
  12597. // This is a little complex, but faster than always calling toString,
  12598. // http://jsperf.com/tostring-v-check
  12599. return _empty(a) ?
  12600. '' :
  12601. typeof a === 'string' ?
  12602. a.toLowerCase() :
  12603. ! a.toString ?
  12604. '' :
  12605. a.toString();
  12606. },
  12607. // string-asc and -desc are retained only for compatibility with the old
  12608. // sort methods
  12609. "string-asc": function ( x, y ) {
  12610. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12611. },
  12612. "string-desc": function ( x, y ) {
  12613. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12614. }
  12615. } );
  12616. // Numeric sorting types - order doesn't matter here
  12617. _addNumericSort( '' );
  12618. $.extend( true, DataTable.ext.renderer, {
  12619. header: {
  12620. _: function ( settings, cell, column, classes ) {
  12621. // No additional mark-up required
  12622. // Attach a sort listener to update on sort - note that using the
  12623. // `DT` namespace will allow the event to be removed automatically
  12624. // on destroy, while the `dt` namespaced event is the one we are
  12625. // listening for
  12626. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12627. if ( settings !== ctx ) { // need to check this this is the host
  12628. return; // table, not a nested one
  12629. }
  12630. var colIdx = column.idx;
  12631. cell
  12632. .removeClass(
  12633. column.sSortingClass +' '+
  12634. classes.sSortAsc +' '+
  12635. classes.sSortDesc
  12636. )
  12637. .addClass( columns[ colIdx ] == 'asc' ?
  12638. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12639. classes.sSortDesc :
  12640. column.sSortingClass
  12641. );
  12642. } );
  12643. },
  12644. jqueryui: function ( settings, cell, column, classes ) {
  12645. $('<div/>')
  12646. .addClass( classes.sSortJUIWrapper )
  12647. .append( cell.contents() )
  12648. .append( $('<span/>')
  12649. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12650. )
  12651. .appendTo( cell );
  12652. // Attach a sort listener to update on sort
  12653. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12654. if ( settings !== ctx ) {
  12655. return;
  12656. }
  12657. var colIdx = column.idx;
  12658. cell
  12659. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12660. .addClass( columns[ colIdx ] == 'asc' ?
  12661. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12662. classes.sSortDesc :
  12663. column.sSortingClass
  12664. );
  12665. cell
  12666. .find( 'span.'+classes.sSortIcon )
  12667. .removeClass(
  12668. classes.sSortJUIAsc +" "+
  12669. classes.sSortJUIDesc +" "+
  12670. classes.sSortJUI +" "+
  12671. classes.sSortJUIAscAllowed +" "+
  12672. classes.sSortJUIDescAllowed
  12673. )
  12674. .addClass( columns[ colIdx ] == 'asc' ?
  12675. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12676. classes.sSortJUIDesc :
  12677. column.sSortingClassJUI
  12678. );
  12679. } );
  12680. }
  12681. }
  12682. } );
  12683. /*
  12684. * Public helper functions. These aren't used internally by DataTables, or
  12685. * called by any of the options passed into DataTables, but they can be used
  12686. * externally by developers working with DataTables. They are helper functions
  12687. * to make working with DataTables a little bit easier.
  12688. */
  12689. /**
  12690. * Helpers for `columns.render`.
  12691. *
  12692. * The options defined here can be used with the `columns.render` initialisation
  12693. * option to provide a display renderer. The following functions are defined:
  12694. *
  12695. * * `number` - Will format numeric data (defined by `columns.data`) for
  12696. * display, retaining the original unformatted data for sorting and filtering.
  12697. * It takes 4 parameters:
  12698. * * `string` - Thousands grouping separator
  12699. * * `string` - Decimal point indicator
  12700. * * `integer` - Number of decimal points to show
  12701. * * `string` (optional) - Prefix.
  12702. *
  12703. * @example
  12704. * // Column definition using the number renderer
  12705. * {
  12706. * data: "salary",
  12707. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  12708. * }
  12709. *
  12710. * @namespace
  12711. */
  12712. DataTable.render = {
  12713. number: function ( thousands, decimal, precision, prefix ) {
  12714. return {
  12715. display: function ( d ) {
  12716. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  12717. return d;
  12718. }
  12719. var negative = d < 0 ? '-' : '';
  12720. d = Math.abs( parseFloat( d ) );
  12721. var intPart = parseInt( d, 10 );
  12722. var floatPart = precision ?
  12723. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  12724. '';
  12725. return negative + (prefix||'') +
  12726. intPart.toString().replace(
  12727. /\B(?=(\d{3})+(?!\d))/g, thousands
  12728. ) +
  12729. floatPart;
  12730. }
  12731. };
  12732. }
  12733. };
  12734. /*
  12735. * This is really a good bit rubbish this method of exposing the internal methods
  12736. * publicly... - To be fixed in 2.0 using methods on the prototype
  12737. */
  12738. /**
  12739. * Create a wrapper function for exporting an internal functions to an external API.
  12740. * @param {string} fn API function name
  12741. * @returns {function} wrapped function
  12742. * @memberof DataTable#internal
  12743. */
  12744. function _fnExternApiFunc (fn)
  12745. {
  12746. return function() {
  12747. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  12748. Array.prototype.slice.call(arguments)
  12749. );
  12750. return DataTable.ext.internal[fn].apply( this, args );
  12751. };
  12752. }
  12753. /**
  12754. * Reference to internal functions for use by plug-in developers. Note that
  12755. * these methods are references to internal functions and are considered to be
  12756. * private. If you use these methods, be aware that they are liable to change
  12757. * between versions.
  12758. * @namespace
  12759. */
  12760. $.extend( DataTable.ext.internal, {
  12761. _fnExternApiFunc: _fnExternApiFunc,
  12762. _fnBuildAjax: _fnBuildAjax,
  12763. _fnAjaxUpdate: _fnAjaxUpdate,
  12764. _fnAjaxParameters: _fnAjaxParameters,
  12765. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  12766. _fnAjaxDataSrc: _fnAjaxDataSrc,
  12767. _fnAddColumn: _fnAddColumn,
  12768. _fnColumnOptions: _fnColumnOptions,
  12769. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  12770. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  12771. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  12772. _fnVisbleColumns: _fnVisbleColumns,
  12773. _fnGetColumns: _fnGetColumns,
  12774. _fnColumnTypes: _fnColumnTypes,
  12775. _fnApplyColumnDefs: _fnApplyColumnDefs,
  12776. _fnHungarianMap: _fnHungarianMap,
  12777. _fnCamelToHungarian: _fnCamelToHungarian,
  12778. _fnLanguageCompat: _fnLanguageCompat,
  12779. _fnBrowserDetect: _fnBrowserDetect,
  12780. _fnAddData: _fnAddData,
  12781. _fnAddTr: _fnAddTr,
  12782. _fnNodeToDataIndex: _fnNodeToDataIndex,
  12783. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  12784. _fnGetCellData: _fnGetCellData,
  12785. _fnSetCellData: _fnSetCellData,
  12786. _fnSplitObjNotation: _fnSplitObjNotation,
  12787. _fnGetObjectDataFn: _fnGetObjectDataFn,
  12788. _fnSetObjectDataFn: _fnSetObjectDataFn,
  12789. _fnGetDataMaster: _fnGetDataMaster,
  12790. _fnClearTable: _fnClearTable,
  12791. _fnDeleteIndex: _fnDeleteIndex,
  12792. _fnInvalidate: _fnInvalidate,
  12793. _fnGetRowElements: _fnGetRowElements,
  12794. _fnCreateTr: _fnCreateTr,
  12795. _fnBuildHead: _fnBuildHead,
  12796. _fnDrawHead: _fnDrawHead,
  12797. _fnDraw: _fnDraw,
  12798. _fnReDraw: _fnReDraw,
  12799. _fnAddOptionsHtml: _fnAddOptionsHtml,
  12800. _fnDetectHeader: _fnDetectHeader,
  12801. _fnGetUniqueThs: _fnGetUniqueThs,
  12802. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  12803. _fnFilterComplete: _fnFilterComplete,
  12804. _fnFilterCustom: _fnFilterCustom,
  12805. _fnFilterColumn: _fnFilterColumn,
  12806. _fnFilter: _fnFilter,
  12807. _fnFilterCreateSearch: _fnFilterCreateSearch,
  12808. _fnEscapeRegex: _fnEscapeRegex,
  12809. _fnFilterData: _fnFilterData,
  12810. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  12811. _fnUpdateInfo: _fnUpdateInfo,
  12812. _fnInfoMacros: _fnInfoMacros,
  12813. _fnInitialise: _fnInitialise,
  12814. _fnInitComplete: _fnInitComplete,
  12815. _fnLengthChange: _fnLengthChange,
  12816. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  12817. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  12818. _fnPageChange: _fnPageChange,
  12819. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  12820. _fnProcessingDisplay: _fnProcessingDisplay,
  12821. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  12822. _fnScrollDraw: _fnScrollDraw,
  12823. _fnApplyToChildren: _fnApplyToChildren,
  12824. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  12825. _fnThrottle: _fnThrottle,
  12826. _fnConvertToWidth: _fnConvertToWidth,
  12827. _fnScrollingWidthAdjust: _fnScrollingWidthAdjust,
  12828. _fnGetWidestNode: _fnGetWidestNode,
  12829. _fnGetMaxLenString: _fnGetMaxLenString,
  12830. _fnStringToCss: _fnStringToCss,
  12831. _fnScrollBarWidth: _fnScrollBarWidth,
  12832. _fnSortFlatten: _fnSortFlatten,
  12833. _fnSort: _fnSort,
  12834. _fnSortAria: _fnSortAria,
  12835. _fnSortListener: _fnSortListener,
  12836. _fnSortAttachListener: _fnSortAttachListener,
  12837. _fnSortingClasses: _fnSortingClasses,
  12838. _fnSortData: _fnSortData,
  12839. _fnSaveState: _fnSaveState,
  12840. _fnLoadState: _fnLoadState,
  12841. _fnSettingsFromNode: _fnSettingsFromNode,
  12842. _fnLog: _fnLog,
  12843. _fnMap: _fnMap,
  12844. _fnBindAction: _fnBindAction,
  12845. _fnCallbackReg: _fnCallbackReg,
  12846. _fnCallbackFire: _fnCallbackFire,
  12847. _fnLengthOverflow: _fnLengthOverflow,
  12848. _fnRenderer: _fnRenderer,
  12849. _fnDataSource: _fnDataSource,
  12850. _fnRowAttributes: _fnRowAttributes,
  12851. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  12852. // in 1.10, so this dead-end function is
  12853. // added to prevent errors
  12854. } );
  12855. // jQuery access
  12856. $.fn.dataTable = DataTable;
  12857. // Legacy aliases
  12858. $.fn.dataTableSettings = DataTable.settings;
  12859. $.fn.dataTableExt = DataTable.ext;
  12860. // With a capital `D` we return a DataTables API instance rather than a
  12861. // jQuery object
  12862. $.fn.DataTable = function ( opts ) {
  12863. return $(this).dataTable( opts ).api();
  12864. };
  12865. // All properties that are available to $.fn.dataTable should also be
  12866. // available on $.fn.DataTable
  12867. $.each( DataTable, function ( prop, val ) {
  12868. $.fn.DataTable[ prop ] = val;
  12869. } );
  12870. // Information about events fired by DataTables - for documentation.
  12871. /**
  12872. * Draw event, fired whenever the table is redrawn on the page, at the same
  12873. * point as fnDrawCallback. This may be useful for binding events or
  12874. * performing calculations when the table is altered at all.
  12875. * @name DataTable#draw.dt
  12876. * @event
  12877. * @param {event} e jQuery event object
  12878. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12879. */
  12880. /**
  12881. * Search event, fired when the searching applied to the table (using the
  12882. * built-in global search, or column filters) is altered.
  12883. * @name DataTable#search.dt
  12884. * @event
  12885. * @param {event} e jQuery event object
  12886. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12887. */
  12888. /**
  12889. * Page change event, fired when the paging of the table is altered.
  12890. * @name DataTable#page.dt
  12891. * @event
  12892. * @param {event} e jQuery event object
  12893. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12894. */
  12895. /**
  12896. * Order event, fired when the ordering applied to the table is altered.
  12897. * @name DataTable#order.dt
  12898. * @event
  12899. * @param {event} e jQuery event object
  12900. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12901. */
  12902. /**
  12903. * DataTables initialisation complete event, fired when the table is fully
  12904. * drawn, including Ajax data loaded, if Ajax data is required.
  12905. * @name DataTable#init.dt
  12906. * @event
  12907. * @param {event} e jQuery event object
  12908. * @param {object} oSettings DataTables settings object
  12909. * @param {object} json The JSON object request from the server - only
  12910. * present if client-side Ajax sourced data is used</li></ol>
  12911. */
  12912. /**
  12913. * State save event, fired when the table has changed state a new state save
  12914. * is required. This event allows modification of the state saving object
  12915. * prior to actually doing the save, including addition or other state
  12916. * properties (for plug-ins) or modification of a DataTables core property.
  12917. * @name DataTable#stateSaveParams.dt
  12918. * @event
  12919. * @param {event} e jQuery event object
  12920. * @param {object} oSettings DataTables settings object
  12921. * @param {object} json The state information to be saved
  12922. */
  12923. /**
  12924. * State load event, fired when the table is loading state from the stored
  12925. * data, but prior to the settings object being modified by the saved state
  12926. * - allowing modification of the saved state is required or loading of
  12927. * state for a plug-in.
  12928. * @name DataTable#stateLoadParams.dt
  12929. * @event
  12930. * @param {event} e jQuery event object
  12931. * @param {object} oSettings DataTables settings object
  12932. * @param {object} json The saved state information
  12933. */
  12934. /**
  12935. * State loaded event, fired when state has been loaded from stored data and
  12936. * the settings object has been modified by the loaded data.
  12937. * @name DataTable#stateLoaded.dt
  12938. * @event
  12939. * @param {event} e jQuery event object
  12940. * @param {object} oSettings DataTables settings object
  12941. * @param {object} json The saved state information
  12942. */
  12943. /**
  12944. * Processing event, fired when DataTables is doing some kind of processing
  12945. * (be it, order, searcg or anything else). It can be used to indicate to
  12946. * the end user that there is something happening, or that something has
  12947. * finished.
  12948. * @name DataTable#processing.dt
  12949. * @event
  12950. * @param {event} e jQuery event object
  12951. * @param {object} oSettings DataTables settings object
  12952. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  12953. */
  12954. /**
  12955. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  12956. * request to made to the server for new data. This event is called before
  12957. * DataTables processed the returned data, so it can also be used to pre-
  12958. * process the data returned from the server, if needed.
  12959. *
  12960. * Note that this trigger is called in `fnServerData`, if you override
  12961. * `fnServerData` and which to use this event, you need to trigger it in you
  12962. * success function.
  12963. * @name DataTable#xhr.dt
  12964. * @event
  12965. * @param {event} e jQuery event object
  12966. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12967. * @param {object} json JSON returned from the server
  12968. *
  12969. * @example
  12970. * // Use a custom property returned from the server in another DOM element
  12971. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12972. * $('#status').html( json.status );
  12973. * } );
  12974. *
  12975. * @example
  12976. * // Pre-process the data returned from the server
  12977. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12978. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  12979. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  12980. * }
  12981. * // Note no return - manipulate the data directly in the JSON object.
  12982. * } );
  12983. */
  12984. /**
  12985. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  12986. * or passing the bDestroy:true parameter in the initialisation object. This
  12987. * can be used to remove bound events, added DOM nodes, etc.
  12988. * @name DataTable#destroy.dt
  12989. * @event
  12990. * @param {event} e jQuery event object
  12991. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12992. */
  12993. /**
  12994. * Page length change event, fired when number of records to show on each
  12995. * page (the length) is changed.
  12996. * @name DataTable#length.dt
  12997. * @event
  12998. * @param {event} e jQuery event object
  12999. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13000. * @param {integer} len New length
  13001. */
  13002. /**
  13003. * Column sizing has changed.
  13004. * @name DataTable#column-sizing.dt
  13005. * @event
  13006. * @param {event} e jQuery event object
  13007. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13008. */
  13009. /**
  13010. * Column visibility has changed.
  13011. * @name DataTable#column-visibility.dt
  13012. * @event
  13013. * @param {event} e jQuery event object
  13014. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13015. * @param {int} column Column index
  13016. * @param {bool} vis `false` if column now hidden, or `true` if visible
  13017. */
  13018. return $.fn.dataTable;
  13019. }));
  13020. }(window, document));