jquery.dataTables.js 425 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867
  1. /*! DataTables 1.10.5
  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.5
  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. // U+2009 is thin space and U+202F is narrow no-break space, both used in many
  101. // standards as thousands separators
  102. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F]/g;
  103. var _empty = function ( d ) {
  104. return !d || d === true || d === '-' ? true : false;
  105. };
  106. var _intVal = function ( s ) {
  107. var integer = parseInt( s, 10 );
  108. return !isNaN(integer) && isFinite(s) ? integer : null;
  109. };
  110. // Convert from a formatted number with characters other than `.` as the
  111. // decimal place, to a Javascript number
  112. var _numToDecimal = function ( num, decimalPoint ) {
  113. // Cache created regular expressions for speed as this function is called often
  114. if ( ! _re_dic[ decimalPoint ] ) {
  115. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  116. }
  117. return typeof num === 'string' && decimalPoint !== '.' ?
  118. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  119. num;
  120. };
  121. var _isNumber = function ( d, decimalPoint, formatted ) {
  122. var strType = typeof d === 'string';
  123. if ( decimalPoint && strType ) {
  124. d = _numToDecimal( d, decimalPoint );
  125. }
  126. if ( formatted && strType ) {
  127. d = d.replace( _re_formatted_numeric, '' );
  128. }
  129. return _empty( d ) || (!isNaN( parseFloat(d) ) && isFinite( d ));
  130. };
  131. // A string without HTML in it can be considered to be HTML still
  132. var _isHtml = function ( d ) {
  133. return _empty( d ) || typeof d === 'string';
  134. };
  135. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  136. if ( _empty( d ) ) {
  137. return true;
  138. }
  139. var html = _isHtml( d );
  140. return ! html ?
  141. null :
  142. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  143. true :
  144. null;
  145. };
  146. var _pluck = function ( a, prop, prop2 ) {
  147. var out = [];
  148. var i=0, ien=a.length;
  149. // Could have the test in the loop for slightly smaller code, but speed
  150. // is essential here
  151. if ( prop2 !== undefined ) {
  152. for ( ; i<ien ; i++ ) {
  153. if ( a[i] && a[i][ prop ] ) {
  154. out.push( a[i][ prop ][ prop2 ] );
  155. }
  156. }
  157. }
  158. else {
  159. for ( ; i<ien ; i++ ) {
  160. if ( a[i] ) {
  161. out.push( a[i][ prop ] );
  162. }
  163. }
  164. }
  165. return out;
  166. };
  167. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  168. // as the indexes to pick from `a`
  169. var _pluck_order = function ( a, order, prop, prop2 )
  170. {
  171. var out = [];
  172. var i=0, ien=order.length;
  173. // Could have the test in the loop for slightly smaller code, but speed
  174. // is essential here
  175. if ( prop2 !== undefined ) {
  176. for ( ; i<ien ; i++ ) {
  177. if ( a[ order[i] ][ prop ] ) {
  178. out.push( a[ order[i] ][ prop ][ prop2 ] );
  179. }
  180. }
  181. }
  182. else {
  183. for ( ; i<ien ; i++ ) {
  184. out.push( a[ order[i] ][ prop ] );
  185. }
  186. }
  187. return out;
  188. };
  189. var _range = function ( len, start )
  190. {
  191. var out = [];
  192. var end;
  193. if ( start === undefined ) {
  194. start = 0;
  195. end = len;
  196. }
  197. else {
  198. end = start;
  199. start = len;
  200. }
  201. for ( var i=start ; i<end ; i++ ) {
  202. out.push( i );
  203. }
  204. return out;
  205. };
  206. var _removeEmpty = function ( a )
  207. {
  208. var out = [];
  209. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  210. if ( a[i] ) { // careful - will remove all falsy values!
  211. out.push( a[i] );
  212. }
  213. }
  214. return out;
  215. };
  216. var _stripHtml = function ( d ) {
  217. return d.replace( _re_html, '' );
  218. };
  219. /**
  220. * Find the unique elements in a source array.
  221. *
  222. * @param {array} src Source array
  223. * @return {array} Array of unique items
  224. * @ignore
  225. */
  226. var _unique = function ( src )
  227. {
  228. // A faster unique method is to use object keys to identify used values,
  229. // but this doesn't work with arrays or objects, which we must also
  230. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  231. // information.
  232. var
  233. out = [],
  234. val,
  235. i, ien=src.length,
  236. j, k=0;
  237. again: for ( i=0 ; i<ien ; i++ ) {
  238. val = src[i];
  239. for ( j=0 ; j<k ; j++ ) {
  240. if ( out[j] === val ) {
  241. continue again;
  242. }
  243. }
  244. out.push( val );
  245. k++;
  246. }
  247. return out;
  248. };
  249. /**
  250. * Create a mapping object that allows camel case parameters to be looked up
  251. * for their Hungarian counterparts. The mapping is stored in a private
  252. * parameter called `_hungarianMap` which can be accessed on the source object.
  253. * @param {object} o
  254. * @memberof DataTable#oApi
  255. */
  256. function _fnHungarianMap ( o )
  257. {
  258. var
  259. hungarian = 'a aa ai ao as b fn i m o s ',
  260. match,
  261. newKey,
  262. map = {};
  263. $.each( o, function (key, val) {
  264. match = key.match(/^([^A-Z]+?)([A-Z])/);
  265. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  266. {
  267. newKey = key.replace( match[0], match[2].toLowerCase() );
  268. map[ newKey ] = key;
  269. if ( match[1] === 'o' )
  270. {
  271. _fnHungarianMap( o[key] );
  272. }
  273. }
  274. } );
  275. o._hungarianMap = map;
  276. }
  277. /**
  278. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  279. * created by _fnHungarianMap.
  280. * @param {object} src The model object which holds all parameters that can be
  281. * mapped.
  282. * @param {object} user The object to convert from camel case to Hungarian.
  283. * @param {boolean} force When set to `true`, properties which already have a
  284. * Hungarian value in the `user` object will be overwritten. Otherwise they
  285. * won't be.
  286. * @memberof DataTable#oApi
  287. */
  288. function _fnCamelToHungarian ( src, user, force )
  289. {
  290. if ( ! src._hungarianMap ) {
  291. _fnHungarianMap( src );
  292. }
  293. var hungarianKey;
  294. $.each( user, function (key, val) {
  295. hungarianKey = src._hungarianMap[ key ];
  296. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  297. {
  298. // For objects, we need to buzz down into the object to copy parameters
  299. if ( hungarianKey.charAt(0) === 'o' )
  300. {
  301. // Copy the camelCase options over to the hungarian
  302. if ( ! user[ hungarianKey ] ) {
  303. user[ hungarianKey ] = {};
  304. }
  305. $.extend( true, user[hungarianKey], user[key] );
  306. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  307. }
  308. else {
  309. user[hungarianKey] = user[ key ];
  310. }
  311. }
  312. } );
  313. }
  314. /**
  315. * Language compatibility - when certain options are given, and others aren't, we
  316. * need to duplicate the values over, in order to provide backwards compatibility
  317. * with older language files.
  318. * @param {object} oSettings dataTables settings object
  319. * @memberof DataTable#oApi
  320. */
  321. function _fnLanguageCompat( lang )
  322. {
  323. var defaults = DataTable.defaults.oLanguage;
  324. var zeroRecords = lang.sZeroRecords;
  325. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  326. * sZeroRecords - assuming that is given.
  327. */
  328. if ( ! lang.sEmptyTable && zeroRecords &&
  329. defaults.sEmptyTable === "No data available in table" )
  330. {
  331. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  332. }
  333. /* Likewise with loading records */
  334. if ( ! lang.sLoadingRecords && zeroRecords &&
  335. defaults.sLoadingRecords === "Loading..." )
  336. {
  337. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  338. }
  339. // Old parameter name of the thousands separator mapped onto the new
  340. if ( lang.sInfoThousands ) {
  341. lang.sThousands = lang.sInfoThousands;
  342. }
  343. var decimal = lang.sDecimal;
  344. if ( decimal ) {
  345. _addNumericSort( decimal );
  346. }
  347. }
  348. /**
  349. * Map one parameter onto another
  350. * @param {object} o Object to map
  351. * @param {*} knew The new parameter name
  352. * @param {*} old The old parameter name
  353. */
  354. var _fnCompatMap = function ( o, knew, old ) {
  355. if ( o[ knew ] !== undefined ) {
  356. o[ old ] = o[ knew ];
  357. }
  358. };
  359. /**
  360. * Provide backwards compatibility for the main DT options. Note that the new
  361. * options are mapped onto the old parameters, so this is an external interface
  362. * change only.
  363. * @param {object} init Object to map
  364. */
  365. function _fnCompatOpts ( init )
  366. {
  367. _fnCompatMap( init, 'ordering', 'bSort' );
  368. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  369. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  370. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  371. _fnCompatMap( init, 'order', 'aaSorting' );
  372. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  373. _fnCompatMap( init, 'paging', 'bPaginate' );
  374. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  375. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  376. _fnCompatMap( init, 'searching', 'bFilter' );
  377. // Column search objects are in an array, so it needs to be converted
  378. // element by element
  379. var searchCols = init.aoSearchCols;
  380. if ( searchCols ) {
  381. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  382. if ( searchCols[i] ) {
  383. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  384. }
  385. }
  386. }
  387. }
  388. /**
  389. * Provide backwards compatibility for column options. Note that the new options
  390. * are mapped onto the old parameters, so this is an external interface change
  391. * only.
  392. * @param {object} init Object to map
  393. */
  394. function _fnCompatCols ( init )
  395. {
  396. _fnCompatMap( init, 'orderable', 'bSortable' );
  397. _fnCompatMap( init, 'orderData', 'aDataSort' );
  398. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  399. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  400. }
  401. /**
  402. * Browser feature detection for capabilities, quirks
  403. * @param {object} settings dataTables settings object
  404. * @memberof DataTable#oApi
  405. */
  406. function _fnBrowserDetect( settings )
  407. {
  408. var browser = settings.oBrowser;
  409. // Scrolling feature / quirks detection
  410. var n = $('<div/>')
  411. .css( {
  412. position: 'absolute',
  413. top: 0,
  414. left: 0,
  415. height: 1,
  416. width: 1,
  417. overflow: 'hidden'
  418. } )
  419. .append(
  420. $('<div/>')
  421. .css( {
  422. position: 'absolute',
  423. top: 1,
  424. left: 1,
  425. width: 100,
  426. overflow: 'scroll'
  427. } )
  428. .append(
  429. $('<div class="test"/>')
  430. .css( {
  431. width: '100%',
  432. height: 10
  433. } )
  434. )
  435. )
  436. .appendTo( 'body' );
  437. var test = n.find('.test');
  438. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  439. // include the width of the scrollbar, while other browsers ensure the inner
  440. // element is contained without forcing scrolling
  441. browser.bScrollOversize = test[0].offsetWidth === 100;
  442. // In rtl text layout, some browsers (most, but not all) will place the
  443. // scrollbar on the left, rather than the right.
  444. browser.bScrollbarLeft = test.offset().left !== 1;
  445. n.remove();
  446. }
  447. /**
  448. * Array.prototype reduce[Right] method, used for browsers which don't support
  449. * JS 1.6. Done this way to reduce code size, since we iterate either way
  450. * @param {object} settings dataTables settings object
  451. * @memberof DataTable#oApi
  452. */
  453. function _fnReduce ( that, fn, init, start, end, inc )
  454. {
  455. var
  456. i = start,
  457. value,
  458. isSet = false;
  459. if ( init !== undefined ) {
  460. value = init;
  461. isSet = true;
  462. }
  463. while ( i !== end ) {
  464. if ( ! that.hasOwnProperty(i) ) {
  465. continue;
  466. }
  467. value = isSet ?
  468. fn( value, that[i], i, that ) :
  469. that[i];
  470. isSet = true;
  471. i += inc;
  472. }
  473. return value;
  474. }
  475. /**
  476. * Add a column to the list used for the table with default values
  477. * @param {object} oSettings dataTables settings object
  478. * @param {node} nTh The th element for this column
  479. * @memberof DataTable#oApi
  480. */
  481. function _fnAddColumn( oSettings, nTh )
  482. {
  483. // Add column to aoColumns array
  484. var oDefaults = DataTable.defaults.column;
  485. var iCol = oSettings.aoColumns.length;
  486. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  487. "nTh": nTh ? nTh : document.createElement('th'),
  488. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  489. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  490. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  491. idx: iCol
  492. } );
  493. oSettings.aoColumns.push( oCol );
  494. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  495. // passed into extend can be undefined. This allows the user to give a default
  496. // with only some of the parameters defined, and also not give a default
  497. var searchCols = oSettings.aoPreSearchCols;
  498. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  499. // Use the default column options function to initialise classes etc
  500. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  501. }
  502. /**
  503. * Apply options for a column
  504. * @param {object} oSettings dataTables settings object
  505. * @param {int} iCol column index to consider
  506. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  507. * @memberof DataTable#oApi
  508. */
  509. function _fnColumnOptions( oSettings, iCol, oOptions )
  510. {
  511. var oCol = oSettings.aoColumns[ iCol ];
  512. var oClasses = oSettings.oClasses;
  513. var th = $(oCol.nTh);
  514. // Try to get width information from the DOM. We can't get it from CSS
  515. // as we'd need to parse the CSS stylesheet. `width` option can override
  516. if ( ! oCol.sWidthOrig ) {
  517. // Width attribute
  518. oCol.sWidthOrig = th.attr('width') || null;
  519. // Style attribute
  520. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  521. if ( t ) {
  522. oCol.sWidthOrig = t[1];
  523. }
  524. }
  525. /* User specified column options */
  526. if ( oOptions !== undefined && oOptions !== null )
  527. {
  528. // Backwards compatibility
  529. _fnCompatCols( oOptions );
  530. // Map camel case parameters to their Hungarian counterparts
  531. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  532. /* Backwards compatibility for mDataProp */
  533. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  534. {
  535. oOptions.mData = oOptions.mDataProp;
  536. }
  537. if ( oOptions.sType )
  538. {
  539. oCol._sManualType = oOptions.sType;
  540. }
  541. // `class` is a reserved word in Javascript, so we need to provide
  542. // the ability to use a valid name for the camel case input
  543. if ( oOptions.className && ! oOptions.sClass )
  544. {
  545. oOptions.sClass = oOptions.className;
  546. }
  547. $.extend( oCol, oOptions );
  548. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  549. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  550. * priority if defined
  551. */
  552. if ( typeof oOptions.iDataSort === 'number' )
  553. {
  554. oCol.aDataSort = [ oOptions.iDataSort ];
  555. }
  556. _fnMap( oCol, oOptions, "aDataSort" );
  557. }
  558. /* Cache the data get and set functions for speed */
  559. var mDataSrc = oCol.mData;
  560. var mData = _fnGetObjectDataFn( mDataSrc );
  561. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  562. var attrTest = function( src ) {
  563. return typeof src === 'string' && src.indexOf('@') !== -1;
  564. };
  565. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  566. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  567. );
  568. oCol.fnGetData = function (rowData, type, meta) {
  569. var innerData = mData( rowData, type, undefined, meta );
  570. return mRender && type ?
  571. mRender( innerData, type, rowData, meta ) :
  572. innerData;
  573. };
  574. oCol.fnSetData = function ( rowData, val, meta ) {
  575. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  576. };
  577. // Indicate if DataTables should read DOM data as an object or array
  578. // Used in _fnGetRowElements
  579. if ( typeof mDataSrc !== 'number' ) {
  580. oSettings._rowReadObject = true;
  581. }
  582. /* Feature sorting overrides column specific when off */
  583. if ( !oSettings.oFeatures.bSort )
  584. {
  585. oCol.bSortable = false;
  586. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  587. }
  588. /* Check that the class assignment is correct for sorting */
  589. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  590. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  591. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  592. {
  593. oCol.sSortingClass = oClasses.sSortableNone;
  594. oCol.sSortingClassJUI = "";
  595. }
  596. else if ( bAsc && !bDesc )
  597. {
  598. oCol.sSortingClass = oClasses.sSortableAsc;
  599. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  600. }
  601. else if ( !bAsc && bDesc )
  602. {
  603. oCol.sSortingClass = oClasses.sSortableDesc;
  604. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  605. }
  606. else
  607. {
  608. oCol.sSortingClass = oClasses.sSortable;
  609. oCol.sSortingClassJUI = oClasses.sSortJUI;
  610. }
  611. }
  612. /**
  613. * Adjust the table column widths for new data. Note: you would probably want to
  614. * do a redraw after calling this function!
  615. * @param {object} settings dataTables settings object
  616. * @memberof DataTable#oApi
  617. */
  618. function _fnAdjustColumnSizing ( settings )
  619. {
  620. /* Not interested in doing column width calculation if auto-width is disabled */
  621. if ( settings.oFeatures.bAutoWidth !== false )
  622. {
  623. var columns = settings.aoColumns;
  624. _fnCalculateColumnWidths( settings );
  625. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  626. {
  627. columns[i].nTh.style.width = columns[i].sWidth;
  628. }
  629. }
  630. var scroll = settings.oScroll;
  631. if ( scroll.sY !== '' || scroll.sX !== '')
  632. {
  633. _fnScrollDraw( settings );
  634. }
  635. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  636. }
  637. /**
  638. * Covert the index of a visible column to the index in the data array (take account
  639. * of hidden columns)
  640. * @param {object} oSettings dataTables settings object
  641. * @param {int} iMatch Visible column index to lookup
  642. * @returns {int} i the data index
  643. * @memberof DataTable#oApi
  644. */
  645. function _fnVisibleToColumnIndex( oSettings, iMatch )
  646. {
  647. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  648. return typeof aiVis[iMatch] === 'number' ?
  649. aiVis[iMatch] :
  650. null;
  651. }
  652. /**
  653. * Covert the index of an index in the data array and convert it to the visible
  654. * column index (take account of hidden columns)
  655. * @param {int} iMatch Column index to lookup
  656. * @param {object} oSettings dataTables settings object
  657. * @returns {int} i the data index
  658. * @memberof DataTable#oApi
  659. */
  660. function _fnColumnIndexToVisible( oSettings, iMatch )
  661. {
  662. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  663. var iPos = $.inArray( iMatch, aiVis );
  664. return iPos !== -1 ? iPos : null;
  665. }
  666. /**
  667. * Get the number of visible columns
  668. * @param {object} oSettings dataTables settings object
  669. * @returns {int} i the number of visible columns
  670. * @memberof DataTable#oApi
  671. */
  672. function _fnVisbleColumns( oSettings )
  673. {
  674. return _fnGetColumns( oSettings, 'bVisible' ).length;
  675. }
  676. /**
  677. * Get an array of column indexes that match a given property
  678. * @param {object} oSettings dataTables settings object
  679. * @param {string} sParam Parameter in aoColumns to look for - typically
  680. * bVisible or bSearchable
  681. * @returns {array} Array of indexes with matched properties
  682. * @memberof DataTable#oApi
  683. */
  684. function _fnGetColumns( oSettings, sParam )
  685. {
  686. var a = [];
  687. $.map( oSettings.aoColumns, function(val, i) {
  688. if ( val[sParam] ) {
  689. a.push( i );
  690. }
  691. } );
  692. return a;
  693. }
  694. /**
  695. * Calculate the 'type' of a column
  696. * @param {object} settings dataTables settings object
  697. * @memberof DataTable#oApi
  698. */
  699. function _fnColumnTypes ( settings )
  700. {
  701. var columns = settings.aoColumns;
  702. var data = settings.aoData;
  703. var types = DataTable.ext.type.detect;
  704. var i, ien, j, jen, k, ken;
  705. var col, cell, detectedType, cache;
  706. // For each column, spin over the
  707. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  708. col = columns[i];
  709. cache = [];
  710. if ( ! col.sType && col._sManualType ) {
  711. col.sType = col._sManualType;
  712. }
  713. else if ( ! col.sType ) {
  714. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  715. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  716. // Use a cache array so we only need to get the type data
  717. // from the formatter once (when using multiple detectors)
  718. if ( cache[k] === undefined ) {
  719. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  720. }
  721. detectedType = types[j]( cache[k], settings );
  722. // If null, then this type can't apply to this column, so
  723. // rather than testing all cells, break out. There is an
  724. // exception for the last type which is `html`. We need to
  725. // scan all rows since it is possible to mix string and HTML
  726. // types
  727. if ( ! detectedType && j !== types.length-1 ) {
  728. break;
  729. }
  730. // Only a single match is needed for html type since it is
  731. // bottom of the pile and very similar to string
  732. if ( detectedType === 'html' ) {
  733. break;
  734. }
  735. }
  736. // Type is valid for all data points in the column - use this
  737. // type
  738. if ( detectedType ) {
  739. col.sType = detectedType;
  740. break;
  741. }
  742. }
  743. // Fall back - if no type was detected, always use string
  744. if ( ! col.sType ) {
  745. col.sType = 'string';
  746. }
  747. }
  748. }
  749. }
  750. /**
  751. * Take the column definitions and static columns arrays and calculate how
  752. * they relate to column indexes. The callback function will then apply the
  753. * definition found for a column to a suitable configuration object.
  754. * @param {object} oSettings dataTables settings object
  755. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  756. * @param {array} aoCols The aoColumns array that defines columns individually
  757. * @param {function} fn Callback function - takes two parameters, the calculated
  758. * column index and the definition for that column.
  759. * @memberof DataTable#oApi
  760. */
  761. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  762. {
  763. var i, iLen, j, jLen, k, kLen, def;
  764. var columns = oSettings.aoColumns;
  765. // Column definitions with aTargets
  766. if ( aoColDefs )
  767. {
  768. /* Loop over the definitions array - loop in reverse so first instance has priority */
  769. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  770. {
  771. def = aoColDefs[i];
  772. /* Each definition can target multiple columns, as it is an array */
  773. var aTargets = def.targets !== undefined ?
  774. def.targets :
  775. def.aTargets;
  776. if ( ! $.isArray( aTargets ) )
  777. {
  778. aTargets = [ aTargets ];
  779. }
  780. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  781. {
  782. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  783. {
  784. /* Add columns that we don't yet know about */
  785. while( columns.length <= aTargets[j] )
  786. {
  787. _fnAddColumn( oSettings );
  788. }
  789. /* Integer, basic index */
  790. fn( aTargets[j], def );
  791. }
  792. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  793. {
  794. /* Negative integer, right to left column counting */
  795. fn( columns.length+aTargets[j], def );
  796. }
  797. else if ( typeof aTargets[j] === 'string' )
  798. {
  799. /* Class name matching on TH element */
  800. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  801. {
  802. if ( aTargets[j] == "_all" ||
  803. $(columns[k].nTh).hasClass( aTargets[j] ) )
  804. {
  805. fn( k, def );
  806. }
  807. }
  808. }
  809. }
  810. }
  811. }
  812. // Statically defined columns array
  813. if ( aoCols )
  814. {
  815. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  816. {
  817. fn( i, aoCols[i] );
  818. }
  819. }
  820. }
  821. /**
  822. * Add a data array to the table, creating DOM node etc. This is the parallel to
  823. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  824. * DOM source.
  825. * @param {object} oSettings dataTables settings object
  826. * @param {array} aData data array to be added
  827. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  828. * DataTables will create a row automatically
  829. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  830. * if nTr is.
  831. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  832. * @memberof DataTable#oApi
  833. */
  834. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  835. {
  836. /* Create the object for storing information about this new row */
  837. var iRow = oSettings.aoData.length;
  838. var oData = $.extend( true, {}, DataTable.models.oRow, {
  839. src: nTr ? 'dom' : 'data'
  840. } );
  841. oData._aData = aDataIn;
  842. oSettings.aoData.push( oData );
  843. /* Create the cells */
  844. var nTd, sThisType;
  845. var columns = oSettings.aoColumns;
  846. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  847. {
  848. // When working with a row, the data source object must be populated. In
  849. // all other cases, the data source object is already populated, so we
  850. // don't overwrite it, which might break bindings etc
  851. if ( nTr ) {
  852. _fnSetCellData( oSettings, iRow, i, _fnGetCellData( oSettings, iRow, i ) );
  853. }
  854. columns[i].sType = null;
  855. }
  856. /* Add to the display array */
  857. oSettings.aiDisplayMaster.push( iRow );
  858. /* Create the DOM information, or register it if already present */
  859. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  860. {
  861. _fnCreateTr( oSettings, iRow, nTr, anTds );
  862. }
  863. return iRow;
  864. }
  865. /**
  866. * Add one or more TR elements to the table. Generally we'd expect to
  867. * use this for reading data from a DOM sourced table, but it could be
  868. * used for an TR element. Note that if a TR is given, it is used (i.e.
  869. * it is not cloned).
  870. * @param {object} settings dataTables settings object
  871. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  872. * @returns {array} Array of indexes for the added rows
  873. * @memberof DataTable#oApi
  874. */
  875. function _fnAddTr( settings, trs )
  876. {
  877. var row;
  878. // Allow an individual node to be passed in
  879. if ( ! (trs instanceof $) ) {
  880. trs = $(trs);
  881. }
  882. return trs.map( function (i, el) {
  883. row = _fnGetRowElements( settings, el );
  884. return _fnAddData( settings, row.data, el, row.cells );
  885. } );
  886. }
  887. /**
  888. * Take a TR element and convert it to an index in aoData
  889. * @param {object} oSettings dataTables settings object
  890. * @param {node} n the TR element to find
  891. * @returns {int} index if the node is found, null if not
  892. * @memberof DataTable#oApi
  893. */
  894. function _fnNodeToDataIndex( oSettings, n )
  895. {
  896. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  897. }
  898. /**
  899. * Take a TD element and convert it into a column data index (not the visible index)
  900. * @param {object} oSettings dataTables settings object
  901. * @param {int} iRow The row number the TD/TH can be found in
  902. * @param {node} n The TD/TH element to find
  903. * @returns {int} index if the node is found, -1 if not
  904. * @memberof DataTable#oApi
  905. */
  906. function _fnNodeToColumnIndex( oSettings, iRow, n )
  907. {
  908. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  909. }
  910. /**
  911. * Get the data for a given cell from the internal cache, taking into account data mapping
  912. * @param {object} settings dataTables settings object
  913. * @param {int} rowIdx aoData row id
  914. * @param {int} colIdx Column index
  915. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  916. * @returns {*} Cell data
  917. * @memberof DataTable#oApi
  918. */
  919. function _fnGetCellData( settings, rowIdx, colIdx, type )
  920. {
  921. var draw = settings.iDraw;
  922. var col = settings.aoColumns[colIdx];
  923. var rowData = settings.aoData[rowIdx]._aData;
  924. var defaultContent = col.sDefaultContent;
  925. var cellData = col.fnGetData( rowData, type, {
  926. settings: settings,
  927. row: rowIdx,
  928. col: colIdx
  929. } );
  930. if ( cellData === undefined ) {
  931. if ( settings.iDrawError != draw && defaultContent === null ) {
  932. _fnLog( settings, 0, "Requested unknown parameter "+
  933. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  934. " for row "+rowIdx, 4 );
  935. settings.iDrawError = draw;
  936. }
  937. return defaultContent;
  938. }
  939. /* When the data source is null, we can use default column data */
  940. if ( (cellData === rowData || cellData === null) && defaultContent !== null ) {
  941. cellData = defaultContent;
  942. }
  943. else if ( typeof cellData === 'function' ) {
  944. // If the data source is a function, then we run it and use the return,
  945. // executing in the scope of the data object (for instances)
  946. return cellData.call( rowData );
  947. }
  948. if ( cellData === null && type == 'display' ) {
  949. return '';
  950. }
  951. return cellData;
  952. }
  953. /**
  954. * Set the value for a specific cell, into the internal data cache
  955. * @param {object} settings dataTables settings object
  956. * @param {int} rowIdx aoData row id
  957. * @param {int} colIdx Column index
  958. * @param {*} val Value to set
  959. * @memberof DataTable#oApi
  960. */
  961. function _fnSetCellData( settings, rowIdx, colIdx, val )
  962. {
  963. var col = settings.aoColumns[colIdx];
  964. var rowData = settings.aoData[rowIdx]._aData;
  965. col.fnSetData( rowData, val, {
  966. settings: settings,
  967. row: rowIdx,
  968. col: colIdx
  969. } );
  970. }
  971. // Private variable that is used to match action syntax in the data property object
  972. var __reArray = /\[.*?\]$/;
  973. var __reFn = /\(\)$/;
  974. /**
  975. * Split string on periods, taking into account escaped periods
  976. * @param {string} str String to split
  977. * @return {array} Split string
  978. */
  979. function _fnSplitObjNotation( str )
  980. {
  981. return $.map( str.match(/(\\.|[^\.])+/g), function ( s ) {
  982. return s.replace(/\\./g, '.');
  983. } );
  984. }
  985. /**
  986. * Return a function that can be used to get data from a source object, taking
  987. * into account the ability to use nested objects as a source
  988. * @param {string|int|function} mSource The data source for the object
  989. * @returns {function} Data get function
  990. * @memberof DataTable#oApi
  991. */
  992. function _fnGetObjectDataFn( mSource )
  993. {
  994. if ( $.isPlainObject( mSource ) )
  995. {
  996. /* Build an object of get functions, and wrap them in a single call */
  997. var o = {};
  998. $.each( mSource, function (key, val) {
  999. if ( val ) {
  1000. o[key] = _fnGetObjectDataFn( val );
  1001. }
  1002. } );
  1003. return function (data, type, row, meta) {
  1004. var t = o[type] || o._;
  1005. return t !== undefined ?
  1006. t(data, type, row, meta) :
  1007. data;
  1008. };
  1009. }
  1010. else if ( mSource === null )
  1011. {
  1012. /* Give an empty string for rendering / sorting etc */
  1013. return function (data) { // type, row and meta also passed, but not used
  1014. return data;
  1015. };
  1016. }
  1017. else if ( typeof mSource === 'function' )
  1018. {
  1019. return function (data, type, row, meta) {
  1020. return mSource( data, type, row, meta );
  1021. };
  1022. }
  1023. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1024. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1025. {
  1026. /* If there is a . in the source string then the data source is in a
  1027. * nested object so we loop over the data for each level to get the next
  1028. * level down. On each loop we test for undefined, and if found immediately
  1029. * return. This allows entire objects to be missing and sDefaultContent to
  1030. * be used if defined, rather than throwing an error
  1031. */
  1032. var fetchData = function (data, type, src) {
  1033. var arrayNotation, funcNotation, out, innerSrc;
  1034. if ( src !== "" )
  1035. {
  1036. var a = _fnSplitObjNotation( src );
  1037. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1038. {
  1039. // Check if we are dealing with special notation
  1040. arrayNotation = a[i].match(__reArray);
  1041. funcNotation = a[i].match(__reFn);
  1042. if ( arrayNotation )
  1043. {
  1044. // Array notation
  1045. a[i] = a[i].replace(__reArray, '');
  1046. // Condition allows simply [] to be passed in
  1047. if ( a[i] !== "" ) {
  1048. data = data[ a[i] ];
  1049. }
  1050. out = [];
  1051. // Get the remainder of the nested object to get
  1052. a.splice( 0, i+1 );
  1053. innerSrc = a.join('.');
  1054. // Traverse each entry in the array getting the properties requested
  1055. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  1056. out.push( fetchData( data[j], type, innerSrc ) );
  1057. }
  1058. // If a string is given in between the array notation indicators, that
  1059. // is used to join the strings together, otherwise an array is returned
  1060. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  1061. data = (join==="") ? out : out.join(join);
  1062. // The inner call to fetchData has already traversed through the remainder
  1063. // of the source requested, so we exit from the loop
  1064. break;
  1065. }
  1066. else if ( funcNotation )
  1067. {
  1068. // Function call
  1069. a[i] = a[i].replace(__reFn, '');
  1070. data = data[ a[i] ]();
  1071. continue;
  1072. }
  1073. if ( data === null || data[ a[i] ] === undefined )
  1074. {
  1075. return undefined;
  1076. }
  1077. data = data[ a[i] ];
  1078. }
  1079. }
  1080. return data;
  1081. };
  1082. return function (data, type) { // row and meta also passed, but not used
  1083. return fetchData( data, type, mSource );
  1084. };
  1085. }
  1086. else
  1087. {
  1088. /* Array or flat object mapping */
  1089. return function (data, type) { // row and meta also passed, but not used
  1090. return data[mSource];
  1091. };
  1092. }
  1093. }
  1094. /**
  1095. * Return a function that can be used to set data from a source object, taking
  1096. * into account the ability to use nested objects as a source
  1097. * @param {string|int|function} mSource The data source for the object
  1098. * @returns {function} Data set function
  1099. * @memberof DataTable#oApi
  1100. */
  1101. function _fnSetObjectDataFn( mSource )
  1102. {
  1103. if ( $.isPlainObject( mSource ) )
  1104. {
  1105. /* Unlike get, only the underscore (global) option is used for for
  1106. * setting data since we don't know the type here. This is why an object
  1107. * option is not documented for `mData` (which is read/write), but it is
  1108. * for `mRender` which is read only.
  1109. */
  1110. return _fnSetObjectDataFn( mSource._ );
  1111. }
  1112. else if ( mSource === null )
  1113. {
  1114. /* Nothing to do when the data source is null */
  1115. return function () {};
  1116. }
  1117. else if ( typeof mSource === 'function' )
  1118. {
  1119. return function (data, val, meta) {
  1120. mSource( data, 'set', val, meta );
  1121. };
  1122. }
  1123. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1124. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1125. {
  1126. /* Like the get, we need to get data from a nested object */
  1127. var setData = function (data, val, src) {
  1128. var a = _fnSplitObjNotation( src ), b;
  1129. var aLast = a[a.length-1];
  1130. var arrayNotation, funcNotation, o, innerSrc;
  1131. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  1132. {
  1133. // Check if we are dealing with an array notation request
  1134. arrayNotation = a[i].match(__reArray);
  1135. funcNotation = a[i].match(__reFn);
  1136. if ( arrayNotation )
  1137. {
  1138. a[i] = a[i].replace(__reArray, '');
  1139. data[ a[i] ] = [];
  1140. // Get the remainder of the nested object to set so we can recurse
  1141. b = a.slice();
  1142. b.splice( 0, i+1 );
  1143. innerSrc = b.join('.');
  1144. // Traverse each entry in the array setting the properties requested
  1145. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  1146. {
  1147. o = {};
  1148. setData( o, val[j], innerSrc );
  1149. data[ a[i] ].push( o );
  1150. }
  1151. // The inner call to setData has already traversed through the remainder
  1152. // of the source and has set the data, thus we can exit here
  1153. return;
  1154. }
  1155. else if ( funcNotation )
  1156. {
  1157. // Function call
  1158. a[i] = a[i].replace(__reFn, '');
  1159. data = data[ a[i] ]( val );
  1160. }
  1161. // If the nested object doesn't currently exist - since we are
  1162. // trying to set the value - create it
  1163. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  1164. {
  1165. data[ a[i] ] = {};
  1166. }
  1167. data = data[ a[i] ];
  1168. }
  1169. // Last item in the input - i.e, the actual set
  1170. if ( aLast.match(__reFn ) )
  1171. {
  1172. // Function call
  1173. data = data[ aLast.replace(__reFn, '') ]( val );
  1174. }
  1175. else
  1176. {
  1177. // If array notation is used, we just want to strip it and use the property name
  1178. // and assign the value. If it isn't used, then we get the result we want anyway
  1179. data[ aLast.replace(__reArray, '') ] = val;
  1180. }
  1181. };
  1182. return function (data, val) { // meta is also passed in, but not used
  1183. return setData( data, val, mSource );
  1184. };
  1185. }
  1186. else
  1187. {
  1188. /* Array or flat object mapping */
  1189. return function (data, val) { // meta is also passed in, but not used
  1190. data[mSource] = val;
  1191. };
  1192. }
  1193. }
  1194. /**
  1195. * Return an array with the full table data
  1196. * @param {object} oSettings dataTables settings object
  1197. * @returns array {array} aData Master data array
  1198. * @memberof DataTable#oApi
  1199. */
  1200. function _fnGetDataMaster ( settings )
  1201. {
  1202. return _pluck( settings.aoData, '_aData' );
  1203. }
  1204. /**
  1205. * Nuke the table
  1206. * @param {object} oSettings dataTables settings object
  1207. * @memberof DataTable#oApi
  1208. */
  1209. function _fnClearTable( settings )
  1210. {
  1211. settings.aoData.length = 0;
  1212. settings.aiDisplayMaster.length = 0;
  1213. settings.aiDisplay.length = 0;
  1214. }
  1215. /**
  1216. * Take an array of integers (index array) and remove a target integer (value - not
  1217. * the key!)
  1218. * @param {array} a Index array to target
  1219. * @param {int} iTarget value to find
  1220. * @memberof DataTable#oApi
  1221. */
  1222. function _fnDeleteIndex( a, iTarget, splice )
  1223. {
  1224. var iTargetIndex = -1;
  1225. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1226. {
  1227. if ( a[i] == iTarget )
  1228. {
  1229. iTargetIndex = i;
  1230. }
  1231. else if ( a[i] > iTarget )
  1232. {
  1233. a[i]--;
  1234. }
  1235. }
  1236. if ( iTargetIndex != -1 && splice === undefined )
  1237. {
  1238. a.splice( iTargetIndex, 1 );
  1239. }
  1240. }
  1241. /**
  1242. * Mark cached data as invalid such that a re-read of the data will occur when
  1243. * the cached data is next requested. Also update from the data source object.
  1244. *
  1245. * @param {object} settings DataTables settings object
  1246. * @param {int} rowIdx Row index to invalidate
  1247. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  1248. * or 'data'
  1249. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  1250. * row will be invalidated
  1251. * @memberof DataTable#oApi
  1252. *
  1253. * @todo For the modularisation of v1.11 this will need to become a callback, so
  1254. * the sort and filter methods can subscribe to it. That will required
  1255. * initialisation options for sorting, which is why it is not already baked in
  1256. */
  1257. function _fnInvalidate( settings, rowIdx, src, colIdx )
  1258. {
  1259. var row = settings.aoData[ rowIdx ];
  1260. var i, ien;
  1261. var cellWrite = function ( cell, col ) {
  1262. // This is very frustrating, but in IE if you just write directly
  1263. // to innerHTML, and elements that are overwritten are GC'ed,
  1264. // even if there is a reference to them elsewhere
  1265. while ( cell.childNodes.length ) {
  1266. cell.removeChild( cell.firstChild );
  1267. }
  1268. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  1269. };
  1270. // Are we reading last data from DOM or the data object?
  1271. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  1272. // Read the data from the DOM
  1273. row._aData = _fnGetRowElements(
  1274. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  1275. )
  1276. .data;
  1277. }
  1278. else {
  1279. // Reading from data object, update the DOM
  1280. var cells = row.anCells;
  1281. if ( cells ) {
  1282. if ( colIdx !== undefined ) {
  1283. cellWrite( cells[colIdx], colIdx );
  1284. }
  1285. else {
  1286. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1287. cellWrite( cells[i], i );
  1288. }
  1289. }
  1290. }
  1291. }
  1292. // For both row and cell invalidation, the cached data for sorting and
  1293. // filtering is nulled out
  1294. row._aSortData = null;
  1295. row._aFilterData = null;
  1296. // Invalidate the type for a specific column (if given) or all columns since
  1297. // the data might have changed
  1298. var cols = settings.aoColumns;
  1299. if ( colIdx !== undefined ) {
  1300. cols[ colIdx ].sType = null;
  1301. }
  1302. else {
  1303. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  1304. cols[i].sType = null;
  1305. }
  1306. // Update DataTables special `DT_*` attributes for the row
  1307. _fnRowAttributes( row );
  1308. }
  1309. }
  1310. /**
  1311. * Build a data source object from an HTML row, reading the contents of the
  1312. * cells that are in the row.
  1313. *
  1314. * @param {object} settings DataTables settings object
  1315. * @param {node|object} TR element from which to read data or existing row
  1316. * object from which to re-read the data from the cells
  1317. * @param {int} [colIdx] Optional column index
  1318. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  1319. * parameter should also be given and will be used to write the data into.
  1320. * Only the column in question will be written
  1321. * @returns {object} Object with two parameters: `data` the data read, in
  1322. * document order, and `cells` and array of nodes (they can be useful to the
  1323. * caller, so rather than needing a second traversal to get them, just return
  1324. * them from here).
  1325. * @memberof DataTable#oApi
  1326. */
  1327. function _fnGetRowElements( settings, row, colIdx, d )
  1328. {
  1329. var
  1330. tds = [],
  1331. td = row.firstChild,
  1332. name, col, o, i=0, contents,
  1333. columns = settings.aoColumns,
  1334. objectRead = settings._rowReadObject;
  1335. // Allow the data object to be passed in, or construct
  1336. d = d || objectRead ? {} : [];
  1337. var attr = function ( str, td ) {
  1338. if ( typeof str === 'string' ) {
  1339. var idx = str.indexOf('@');
  1340. if ( idx !== -1 ) {
  1341. var attr = str.substring( idx+1 );
  1342. var setter = _fnSetObjectDataFn( str );
  1343. setter( d, td.getAttribute( attr ) );
  1344. }
  1345. }
  1346. };
  1347. // Read data from a cell and store into the data object
  1348. var cellProcess = function ( cell ) {
  1349. if ( colIdx === undefined || colIdx === i ) {
  1350. col = columns[i];
  1351. contents = $.trim(cell.innerHTML);
  1352. if ( col && col._bAttrSrc ) {
  1353. var setter = _fnSetObjectDataFn( col.mData._ );
  1354. setter( d, contents );
  1355. attr( col.mData.sort, cell );
  1356. attr( col.mData.type, cell );
  1357. attr( col.mData.filter, cell );
  1358. }
  1359. else {
  1360. // Depending on the `data` option for the columns the data can
  1361. // be read to either an object or an array.
  1362. if ( objectRead ) {
  1363. if ( ! col._setter ) {
  1364. // Cache the setter function
  1365. col._setter = _fnSetObjectDataFn( col.mData );
  1366. }
  1367. col._setter( d, contents );
  1368. }
  1369. else {
  1370. d[i] = contents;
  1371. }
  1372. }
  1373. }
  1374. i++;
  1375. };
  1376. if ( td ) {
  1377. // `tr` element was passed in
  1378. while ( td ) {
  1379. name = td.nodeName.toUpperCase();
  1380. if ( name == "TD" || name == "TH" ) {
  1381. cellProcess( td );
  1382. tds.push( td );
  1383. }
  1384. td = td.nextSibling;
  1385. }
  1386. }
  1387. else {
  1388. // Existing row object passed in
  1389. tds = row.anCells;
  1390. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  1391. cellProcess( tds[j] );
  1392. }
  1393. }
  1394. return {
  1395. data: d,
  1396. cells: tds
  1397. };
  1398. }
  1399. /**
  1400. * Create a new TR element (and it's TD children) for a row
  1401. * @param {object} oSettings dataTables settings object
  1402. * @param {int} iRow Row to consider
  1403. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  1404. * DataTables will create a row automatically
  1405. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  1406. * if nTr is.
  1407. * @memberof DataTable#oApi
  1408. */
  1409. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  1410. {
  1411. var
  1412. row = oSettings.aoData[iRow],
  1413. rowData = row._aData,
  1414. cells = [],
  1415. nTr, nTd, oCol,
  1416. i, iLen;
  1417. if ( row.nTr === null )
  1418. {
  1419. nTr = nTrIn || document.createElement('tr');
  1420. row.nTr = nTr;
  1421. row.anCells = cells;
  1422. /* Use a private property on the node to allow reserve mapping from the node
  1423. * to the aoData array for fast look up
  1424. */
  1425. nTr._DT_RowIndex = iRow;
  1426. /* Special parameters can be given by the data source to be used on the row */
  1427. _fnRowAttributes( row );
  1428. /* Process each column */
  1429. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  1430. {
  1431. oCol = oSettings.aoColumns[i];
  1432. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  1433. cells.push( nTd );
  1434. // Need to create the HTML if new, or if a rendering function is defined
  1435. if ( !nTrIn || oCol.mRender || oCol.mData !== i )
  1436. {
  1437. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  1438. }
  1439. /* Add user defined class */
  1440. if ( oCol.sClass )
  1441. {
  1442. nTd.className += ' '+oCol.sClass;
  1443. }
  1444. // Visibility - add or remove as required
  1445. if ( oCol.bVisible && ! nTrIn )
  1446. {
  1447. nTr.appendChild( nTd );
  1448. }
  1449. else if ( ! oCol.bVisible && nTrIn )
  1450. {
  1451. nTd.parentNode.removeChild( nTd );
  1452. }
  1453. if ( oCol.fnCreatedCell )
  1454. {
  1455. oCol.fnCreatedCell.call( oSettings.oInstance,
  1456. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  1457. );
  1458. }
  1459. }
  1460. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  1461. }
  1462. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  1463. // and deployed
  1464. row.nTr.setAttribute( 'role', 'row' );
  1465. }
  1466. /**
  1467. * Add attributes to a row based on the special `DT_*` parameters in a data
  1468. * source object.
  1469. * @param {object} DataTables row object for the row to be modified
  1470. * @memberof DataTable#oApi
  1471. */
  1472. function _fnRowAttributes( row )
  1473. {
  1474. var tr = row.nTr;
  1475. var data = row._aData;
  1476. if ( tr ) {
  1477. if ( data.DT_RowId ) {
  1478. tr.id = data.DT_RowId;
  1479. }
  1480. if ( data.DT_RowClass ) {
  1481. // Remove any classes added by DT_RowClass before
  1482. var a = data.DT_RowClass.split(' ');
  1483. row.__rowc = row.__rowc ?
  1484. _unique( row.__rowc.concat( a ) ) :
  1485. a;
  1486. $(tr)
  1487. .removeClass( row.__rowc.join(' ') )
  1488. .addClass( data.DT_RowClass );
  1489. }
  1490. if ( data.DT_RowAttr ) {
  1491. $(tr).attr( data.DT_RowAttr );
  1492. }
  1493. if ( data.DT_RowData ) {
  1494. $(tr).data( data.DT_RowData );
  1495. }
  1496. }
  1497. }
  1498. /**
  1499. * Create the HTML header for the table
  1500. * @param {object} oSettings dataTables settings object
  1501. * @memberof DataTable#oApi
  1502. */
  1503. function _fnBuildHead( oSettings )
  1504. {
  1505. var i, ien, cell, row, column;
  1506. var thead = oSettings.nTHead;
  1507. var tfoot = oSettings.nTFoot;
  1508. var createHeader = $('th, td', thead).length === 0;
  1509. var classes = oSettings.oClasses;
  1510. var columns = oSettings.aoColumns;
  1511. if ( createHeader ) {
  1512. row = $('<tr/>').appendTo( thead );
  1513. }
  1514. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1515. column = columns[i];
  1516. cell = $( column.nTh ).addClass( column.sClass );
  1517. if ( createHeader ) {
  1518. cell.appendTo( row );
  1519. }
  1520. // 1.11 move into sorting
  1521. if ( oSettings.oFeatures.bSort ) {
  1522. cell.addClass( column.sSortingClass );
  1523. if ( column.bSortable !== false ) {
  1524. cell
  1525. .attr( 'tabindex', oSettings.iTabIndex )
  1526. .attr( 'aria-controls', oSettings.sTableId );
  1527. _fnSortAttachListener( oSettings, column.nTh, i );
  1528. }
  1529. }
  1530. if ( column.sTitle != cell.html() ) {
  1531. cell.html( column.sTitle );
  1532. }
  1533. _fnRenderer( oSettings, 'header' )(
  1534. oSettings, cell, column, classes
  1535. );
  1536. }
  1537. if ( createHeader ) {
  1538. _fnDetectHeader( oSettings.aoHeader, thead );
  1539. }
  1540. /* ARIA role for the rows */
  1541. $(thead).find('>tr').attr('role', 'row');
  1542. /* Deal with the footer - add classes if required */
  1543. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  1544. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  1545. // Cache the footer cells. Note that we only take the cells from the first
  1546. // row in the footer. If there is more than one row the user wants to
  1547. // interact with, they need to use the table().foot() method. Note also this
  1548. // allows cells to be used for multiple columns using colspan
  1549. if ( tfoot !== null ) {
  1550. var cells = oSettings.aoFooter[0];
  1551. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1552. column = columns[i];
  1553. column.nTf = cells[i].cell;
  1554. if ( column.sClass ) {
  1555. $(column.nTf).addClass( column.sClass );
  1556. }
  1557. }
  1558. }
  1559. }
  1560. /**
  1561. * Draw the header (or footer) element based on the column visibility states. The
  1562. * methodology here is to use the layout array from _fnDetectHeader, modified for
  1563. * the instantaneous column visibility, to construct the new layout. The grid is
  1564. * traversed over cell at a time in a rows x columns grid fashion, although each
  1565. * cell insert can cover multiple elements in the grid - which is tracks using the
  1566. * aApplied array. Cell inserts in the grid will only occur where there isn't
  1567. * already a cell in that position.
  1568. * @param {object} oSettings dataTables settings object
  1569. * @param array {objects} aoSource Layout array from _fnDetectHeader
  1570. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  1571. * @memberof DataTable#oApi
  1572. */
  1573. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  1574. {
  1575. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  1576. var aoLocal = [];
  1577. var aApplied = [];
  1578. var iColumns = oSettings.aoColumns.length;
  1579. var iRowspan, iColspan;
  1580. if ( ! aoSource )
  1581. {
  1582. return;
  1583. }
  1584. if ( bIncludeHidden === undefined )
  1585. {
  1586. bIncludeHidden = false;
  1587. }
  1588. /* Make a copy of the master layout array, but without the visible columns in it */
  1589. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  1590. {
  1591. aoLocal[i] = aoSource[i].slice();
  1592. aoLocal[i].nTr = aoSource[i].nTr;
  1593. /* Remove any columns which are currently hidden */
  1594. for ( j=iColumns-1 ; j>=0 ; j-- )
  1595. {
  1596. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  1597. {
  1598. aoLocal[i].splice( j, 1 );
  1599. }
  1600. }
  1601. /* Prep the applied array - it needs an element for each row */
  1602. aApplied.push( [] );
  1603. }
  1604. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  1605. {
  1606. nLocalTr = aoLocal[i].nTr;
  1607. /* All cells are going to be replaced, so empty out the row */
  1608. if ( nLocalTr )
  1609. {
  1610. while( (n = nLocalTr.firstChild) )
  1611. {
  1612. nLocalTr.removeChild( n );
  1613. }
  1614. }
  1615. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  1616. {
  1617. iRowspan = 1;
  1618. iColspan = 1;
  1619. /* Check to see if there is already a cell (row/colspan) covering our target
  1620. * insert point. If there is, then there is nothing to do.
  1621. */
  1622. if ( aApplied[i][j] === undefined )
  1623. {
  1624. nLocalTr.appendChild( aoLocal[i][j].cell );
  1625. aApplied[i][j] = 1;
  1626. /* Expand the cell to cover as many rows as needed */
  1627. while ( aoLocal[i+iRowspan] !== undefined &&
  1628. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  1629. {
  1630. aApplied[i+iRowspan][j] = 1;
  1631. iRowspan++;
  1632. }
  1633. /* Expand the cell to cover as many columns as needed */
  1634. while ( aoLocal[i][j+iColspan] !== undefined &&
  1635. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  1636. {
  1637. /* Must update the applied array over the rows for the columns */
  1638. for ( k=0 ; k<iRowspan ; k++ )
  1639. {
  1640. aApplied[i+k][j+iColspan] = 1;
  1641. }
  1642. iColspan++;
  1643. }
  1644. /* Do the actual expansion in the DOM */
  1645. $(aoLocal[i][j].cell)
  1646. .attr('rowspan', iRowspan)
  1647. .attr('colspan', iColspan);
  1648. }
  1649. }
  1650. }
  1651. }
  1652. /**
  1653. * Insert the required TR nodes into the table for display
  1654. * @param {object} oSettings dataTables settings object
  1655. * @memberof DataTable#oApi
  1656. */
  1657. function _fnDraw( oSettings )
  1658. {
  1659. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  1660. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  1661. if ( $.inArray( false, aPreDraw ) !== -1 )
  1662. {
  1663. _fnProcessingDisplay( oSettings, false );
  1664. return;
  1665. }
  1666. var i, iLen, n;
  1667. var anRows = [];
  1668. var iRowCount = 0;
  1669. var asStripeClasses = oSettings.asStripeClasses;
  1670. var iStripes = asStripeClasses.length;
  1671. var iOpenRows = oSettings.aoOpenRows.length;
  1672. var oLang = oSettings.oLanguage;
  1673. var iInitDisplayStart = oSettings.iInitDisplayStart;
  1674. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  1675. var aiDisplay = oSettings.aiDisplay;
  1676. oSettings.bDrawing = true;
  1677. /* Check and see if we have an initial draw position from state saving */
  1678. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  1679. {
  1680. oSettings._iDisplayStart = bServerSide ?
  1681. iInitDisplayStart :
  1682. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  1683. 0 :
  1684. iInitDisplayStart;
  1685. oSettings.iInitDisplayStart = -1;
  1686. }
  1687. var iDisplayStart = oSettings._iDisplayStart;
  1688. var iDisplayEnd = oSettings.fnDisplayEnd();
  1689. /* Server-side processing draw intercept */
  1690. if ( oSettings.bDeferLoading )
  1691. {
  1692. oSettings.bDeferLoading = false;
  1693. oSettings.iDraw++;
  1694. _fnProcessingDisplay( oSettings, false );
  1695. }
  1696. else if ( !bServerSide )
  1697. {
  1698. oSettings.iDraw++;
  1699. }
  1700. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  1701. {
  1702. return;
  1703. }
  1704. if ( aiDisplay.length !== 0 )
  1705. {
  1706. var iStart = bServerSide ? 0 : iDisplayStart;
  1707. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  1708. for ( var j=iStart ; j<iEnd ; j++ )
  1709. {
  1710. var iDataIndex = aiDisplay[j];
  1711. var aoData = oSettings.aoData[ iDataIndex ];
  1712. if ( aoData.nTr === null )
  1713. {
  1714. _fnCreateTr( oSettings, iDataIndex );
  1715. }
  1716. var nRow = aoData.nTr;
  1717. /* Remove the old striping classes and then add the new one */
  1718. if ( iStripes !== 0 )
  1719. {
  1720. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  1721. if ( aoData._sRowStripe != sStripe )
  1722. {
  1723. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  1724. aoData._sRowStripe = sStripe;
  1725. }
  1726. }
  1727. // Row callback functions - might want to manipulate the row
  1728. // iRowCount and j are not currently documented. Are they at all
  1729. // useful?
  1730. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  1731. [nRow, aoData._aData, iRowCount, j] );
  1732. anRows.push( nRow );
  1733. iRowCount++;
  1734. }
  1735. }
  1736. else
  1737. {
  1738. /* Table is empty - create a row with an empty message in it */
  1739. var sZero = oLang.sZeroRecords;
  1740. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  1741. {
  1742. sZero = oLang.sLoadingRecords;
  1743. }
  1744. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  1745. {
  1746. sZero = oLang.sEmptyTable;
  1747. }
  1748. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  1749. .append( $('<td />', {
  1750. 'valign': 'top',
  1751. 'colSpan': _fnVisbleColumns( oSettings ),
  1752. 'class': oSettings.oClasses.sRowEmpty
  1753. } ).html( sZero ) )[0];
  1754. }
  1755. /* Header and footer callbacks */
  1756. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  1757. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1758. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  1759. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1760. var body = $(oSettings.nTBody);
  1761. body.children().detach();
  1762. body.append( $(anRows) );
  1763. /* Call all required callback functions for the end of a draw */
  1764. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  1765. /* Draw is complete, sorting and filtering must be as well */
  1766. oSettings.bSorted = false;
  1767. oSettings.bFiltered = false;
  1768. oSettings.bDrawing = false;
  1769. }
  1770. /**
  1771. * Redraw the table - taking account of the various features which are enabled
  1772. * @param {object} oSettings dataTables settings object
  1773. * @param {boolean} [holdPosition] Keep the current paging position. By default
  1774. * the paging is reset to the first page
  1775. * @memberof DataTable#oApi
  1776. */
  1777. function _fnReDraw( settings, holdPosition )
  1778. {
  1779. var
  1780. features = settings.oFeatures,
  1781. sort = features.bSort,
  1782. filter = features.bFilter;
  1783. if ( sort ) {
  1784. _fnSort( settings );
  1785. }
  1786. if ( filter ) {
  1787. _fnFilterComplete( settings, settings.oPreviousSearch );
  1788. }
  1789. else {
  1790. // No filtering, so we want to just use the display master
  1791. settings.aiDisplay = settings.aiDisplayMaster.slice();
  1792. }
  1793. if ( holdPosition !== true ) {
  1794. settings._iDisplayStart = 0;
  1795. }
  1796. // Let any modules know about the draw hold position state (used by
  1797. // scrolling internally)
  1798. settings._drawHold = holdPosition;
  1799. _fnDraw( settings );
  1800. settings._drawHold = false;
  1801. }
  1802. /**
  1803. * Add the options to the page HTML for the table
  1804. * @param {object} oSettings dataTables settings object
  1805. * @memberof DataTable#oApi
  1806. */
  1807. function _fnAddOptionsHtml ( oSettings )
  1808. {
  1809. var classes = oSettings.oClasses;
  1810. var table = $(oSettings.nTable);
  1811. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  1812. var features = oSettings.oFeatures;
  1813. // All DataTables are wrapped in a div
  1814. var insert = $('<div/>', {
  1815. id: oSettings.sTableId+'_wrapper',
  1816. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  1817. } );
  1818. oSettings.nHolding = holding[0];
  1819. oSettings.nTableWrapper = insert[0];
  1820. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  1821. /* Loop over the user set positioning and place the elements as needed */
  1822. var aDom = oSettings.sDom.split('');
  1823. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  1824. for ( var i=0 ; i<aDom.length ; i++ )
  1825. {
  1826. featureNode = null;
  1827. cOption = aDom[i];
  1828. if ( cOption == '<' )
  1829. {
  1830. /* New container div */
  1831. nNewNode = $('<div/>')[0];
  1832. /* Check to see if we should append an id and/or a class name to the container */
  1833. cNext = aDom[i+1];
  1834. if ( cNext == "'" || cNext == '"' )
  1835. {
  1836. sAttr = "";
  1837. j = 2;
  1838. while ( aDom[i+j] != cNext )
  1839. {
  1840. sAttr += aDom[i+j];
  1841. j++;
  1842. }
  1843. /* Replace jQuery UI constants @todo depreciated */
  1844. if ( sAttr == "H" )
  1845. {
  1846. sAttr = classes.sJUIHeader;
  1847. }
  1848. else if ( sAttr == "F" )
  1849. {
  1850. sAttr = classes.sJUIFooter;
  1851. }
  1852. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  1853. * breaks the string into parts and applies them as needed
  1854. */
  1855. if ( sAttr.indexOf('.') != -1 )
  1856. {
  1857. var aSplit = sAttr.split('.');
  1858. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  1859. nNewNode.className = aSplit[1];
  1860. }
  1861. else if ( sAttr.charAt(0) == "#" )
  1862. {
  1863. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  1864. }
  1865. else
  1866. {
  1867. nNewNode.className = sAttr;
  1868. }
  1869. i += j; /* Move along the position array */
  1870. }
  1871. insert.append( nNewNode );
  1872. insert = $(nNewNode);
  1873. }
  1874. else if ( cOption == '>' )
  1875. {
  1876. /* End container div */
  1877. insert = insert.parent();
  1878. }
  1879. // @todo Move options into their own plugins?
  1880. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  1881. {
  1882. /* Length */
  1883. featureNode = _fnFeatureHtmlLength( oSettings );
  1884. }
  1885. else if ( cOption == 'f' && features.bFilter )
  1886. {
  1887. /* Filter */
  1888. featureNode = _fnFeatureHtmlFilter( oSettings );
  1889. }
  1890. else if ( cOption == 'r' && features.bProcessing )
  1891. {
  1892. /* pRocessing */
  1893. featureNode = _fnFeatureHtmlProcessing( oSettings );
  1894. }
  1895. else if ( cOption == 't' )
  1896. {
  1897. /* Table */
  1898. featureNode = _fnFeatureHtmlTable( oSettings );
  1899. }
  1900. else if ( cOption == 'i' && features.bInfo )
  1901. {
  1902. /* Info */
  1903. featureNode = _fnFeatureHtmlInfo( oSettings );
  1904. }
  1905. else if ( cOption == 'p' && features.bPaginate )
  1906. {
  1907. /* Pagination */
  1908. featureNode = _fnFeatureHtmlPaginate( oSettings );
  1909. }
  1910. else if ( DataTable.ext.feature.length !== 0 )
  1911. {
  1912. /* Plug-in features */
  1913. var aoFeatures = DataTable.ext.feature;
  1914. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  1915. {
  1916. if ( cOption == aoFeatures[k].cFeature )
  1917. {
  1918. featureNode = aoFeatures[k].fnInit( oSettings );
  1919. break;
  1920. }
  1921. }
  1922. }
  1923. /* Add to the 2D features array */
  1924. if ( featureNode )
  1925. {
  1926. var aanFeatures = oSettings.aanFeatures;
  1927. if ( ! aanFeatures[cOption] )
  1928. {
  1929. aanFeatures[cOption] = [];
  1930. }
  1931. aanFeatures[cOption].push( featureNode );
  1932. insert.append( featureNode );
  1933. }
  1934. }
  1935. /* Built our DOM structure - replace the holding div with what we want */
  1936. holding.replaceWith( insert );
  1937. }
  1938. /**
  1939. * Use the DOM source to create up an array of header cells. The idea here is to
  1940. * create a layout grid (array) of rows x columns, which contains a reference
  1941. * to the cell that that point in the grid (regardless of col/rowspan), such that
  1942. * any column / row could be removed and the new grid constructed
  1943. * @param array {object} aLayout Array to store the calculated layout in
  1944. * @param {node} nThead The header/footer element for the table
  1945. * @memberof DataTable#oApi
  1946. */
  1947. function _fnDetectHeader ( aLayout, nThead )
  1948. {
  1949. var nTrs = $(nThead).children('tr');
  1950. var nTr, nCell;
  1951. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  1952. var bUnique;
  1953. var fnShiftCol = function ( a, i, j ) {
  1954. var k = a[i];
  1955. while ( k[j] ) {
  1956. j++;
  1957. }
  1958. return j;
  1959. };
  1960. aLayout.splice( 0, aLayout.length );
  1961. /* We know how many rows there are in the layout - so prep it */
  1962. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1963. {
  1964. aLayout.push( [] );
  1965. }
  1966. /* Calculate a layout array */
  1967. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1968. {
  1969. nTr = nTrs[i];
  1970. iColumn = 0;
  1971. /* For every cell in the row... */
  1972. nCell = nTr.firstChild;
  1973. while ( nCell ) {
  1974. if ( nCell.nodeName.toUpperCase() == "TD" ||
  1975. nCell.nodeName.toUpperCase() == "TH" )
  1976. {
  1977. /* Get the col and rowspan attributes from the DOM and sanitise them */
  1978. iColspan = nCell.getAttribute('colspan') * 1;
  1979. iRowspan = nCell.getAttribute('rowspan') * 1;
  1980. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  1981. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  1982. /* There might be colspan cells already in this row, so shift our target
  1983. * accordingly
  1984. */
  1985. iColShifted = fnShiftCol( aLayout, i, iColumn );
  1986. /* Cache calculation for unique columns */
  1987. bUnique = iColspan === 1 ? true : false;
  1988. /* If there is col / rowspan, copy the information into the layout grid */
  1989. for ( l=0 ; l<iColspan ; l++ )
  1990. {
  1991. for ( k=0 ; k<iRowspan ; k++ )
  1992. {
  1993. aLayout[i+k][iColShifted+l] = {
  1994. "cell": nCell,
  1995. "unique": bUnique
  1996. };
  1997. aLayout[i+k].nTr = nTr;
  1998. }
  1999. }
  2000. }
  2001. nCell = nCell.nextSibling;
  2002. }
  2003. }
  2004. }
  2005. /**
  2006. * Get an array of unique th elements, one for each column
  2007. * @param {object} oSettings dataTables settings object
  2008. * @param {node} nHeader automatically detect the layout from this node - optional
  2009. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  2010. * @returns array {node} aReturn list of unique th's
  2011. * @memberof DataTable#oApi
  2012. */
  2013. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  2014. {
  2015. var aReturn = [];
  2016. if ( !aLayout )
  2017. {
  2018. aLayout = oSettings.aoHeader;
  2019. if ( nHeader )
  2020. {
  2021. aLayout = [];
  2022. _fnDetectHeader( aLayout, nHeader );
  2023. }
  2024. }
  2025. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  2026. {
  2027. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  2028. {
  2029. if ( aLayout[i][j].unique &&
  2030. (!aReturn[j] || !oSettings.bSortCellsTop) )
  2031. {
  2032. aReturn[j] = aLayout[i][j].cell;
  2033. }
  2034. }
  2035. }
  2036. return aReturn;
  2037. }
  2038. /**
  2039. * Create an Ajax call based on the table's settings, taking into account that
  2040. * parameters can have multiple forms, and backwards compatibility.
  2041. *
  2042. * @param {object} oSettings dataTables settings object
  2043. * @param {array} data Data to send to the server, required by
  2044. * DataTables - may be augmented by developer callbacks
  2045. * @param {function} fn Callback function to run when data is obtained
  2046. */
  2047. function _fnBuildAjax( oSettings, data, fn )
  2048. {
  2049. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  2050. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  2051. // Convert to object based for 1.10+ if using the old array scheme which can
  2052. // come from server-side processing or serverParams
  2053. if ( data && $.isArray(data) ) {
  2054. var tmp = {};
  2055. var rbracket = /(.*?)\[\]$/;
  2056. $.each( data, function (key, val) {
  2057. var match = val.name.match(rbracket);
  2058. if ( match ) {
  2059. // Support for arrays
  2060. var name = match[0];
  2061. if ( ! tmp[ name ] ) {
  2062. tmp[ name ] = [];
  2063. }
  2064. tmp[ name ].push( val.value );
  2065. }
  2066. else {
  2067. tmp[val.name] = val.value;
  2068. }
  2069. } );
  2070. data = tmp;
  2071. }
  2072. var ajaxData;
  2073. var ajax = oSettings.ajax;
  2074. var instance = oSettings.oInstance;
  2075. if ( $.isPlainObject( ajax ) && ajax.data )
  2076. {
  2077. ajaxData = ajax.data;
  2078. var newData = $.isFunction( ajaxData ) ?
  2079. ajaxData( data ) : // fn can manipulate data or return an object
  2080. ajaxData; // object or array to merge
  2081. // If the function returned something, use that alone
  2082. data = $.isFunction( ajaxData ) && newData ?
  2083. newData :
  2084. $.extend( true, data, newData );
  2085. // Remove the data property as we've resolved it already and don't want
  2086. // jQuery to do it again (it is restored at the end of the function)
  2087. delete ajax.data;
  2088. }
  2089. var baseAjax = {
  2090. "data": data,
  2091. "success": function (json) {
  2092. var error = json.error || json.sError;
  2093. if ( error ) {
  2094. oSettings.oApi._fnLog( oSettings, 0, error );
  2095. }
  2096. oSettings.json = json;
  2097. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] );
  2098. fn( json );
  2099. },
  2100. "dataType": "json",
  2101. "cache": false,
  2102. "type": oSettings.sServerMethod,
  2103. "error": function (xhr, error, thrown) {
  2104. var log = oSettings.oApi._fnLog;
  2105. if ( error == "parsererror" ) {
  2106. log( oSettings, 0, 'Invalid JSON response', 1 );
  2107. }
  2108. else if ( xhr.readyState === 4 ) {
  2109. log( oSettings, 0, 'Ajax error', 7 );
  2110. }
  2111. _fnProcessingDisplay( oSettings, false );
  2112. }
  2113. };
  2114. // Store the data submitted for the API
  2115. oSettings.oAjaxData = data;
  2116. // Allow plug-ins and external processes to modify the data
  2117. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  2118. if ( oSettings.fnServerData )
  2119. {
  2120. // DataTables 1.9- compatibility
  2121. oSettings.fnServerData.call( instance,
  2122. oSettings.sAjaxSource,
  2123. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  2124. return { name: key, value: val };
  2125. } ),
  2126. fn,
  2127. oSettings
  2128. );
  2129. }
  2130. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  2131. {
  2132. // DataTables 1.9- compatibility
  2133. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  2134. url: ajax || oSettings.sAjaxSource
  2135. } ) );
  2136. }
  2137. else if ( $.isFunction( ajax ) )
  2138. {
  2139. // Is a function - let the caller define what needs to be done
  2140. oSettings.jqXHR = ajax.call( instance, data, fn, oSettings );
  2141. }
  2142. else
  2143. {
  2144. // Object to extend the base settings
  2145. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  2146. // Restore for next time around
  2147. ajax.data = ajaxData;
  2148. }
  2149. }
  2150. /**
  2151. * Update the table using an Ajax call
  2152. * @param {object} settings dataTables settings object
  2153. * @returns {boolean} Block the table drawing or not
  2154. * @memberof DataTable#oApi
  2155. */
  2156. function _fnAjaxUpdate( settings )
  2157. {
  2158. if ( settings.bAjaxDataGet ) {
  2159. settings.iDraw++;
  2160. _fnProcessingDisplay( settings, true );
  2161. _fnBuildAjax(
  2162. settings,
  2163. _fnAjaxParameters( settings ),
  2164. function(json) {
  2165. _fnAjaxUpdateDraw( settings, json );
  2166. }
  2167. );
  2168. return false;
  2169. }
  2170. return true;
  2171. }
  2172. /**
  2173. * Build up the parameters in an object needed for a server-side processing
  2174. * request. Note that this is basically done twice, is different ways - a modern
  2175. * method which is used by default in DataTables 1.10 which uses objects and
  2176. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  2177. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  2178. * option is set.
  2179. * @param {object} oSettings dataTables settings object
  2180. * @returns {bool} block the table drawing or not
  2181. * @memberof DataTable#oApi
  2182. */
  2183. function _fnAjaxParameters( settings )
  2184. {
  2185. var
  2186. columns = settings.aoColumns,
  2187. columnCount = columns.length,
  2188. features = settings.oFeatures,
  2189. preSearch = settings.oPreviousSearch,
  2190. preColSearch = settings.aoPreSearchCols,
  2191. i, data = [], dataProp, column, columnSearch,
  2192. sort = _fnSortFlatten( settings ),
  2193. displayStart = settings._iDisplayStart,
  2194. displayLength = features.bPaginate !== false ?
  2195. settings._iDisplayLength :
  2196. -1;
  2197. var param = function ( name, value ) {
  2198. data.push( { 'name': name, 'value': value } );
  2199. };
  2200. // DataTables 1.9- compatible method
  2201. param( 'sEcho', settings.iDraw );
  2202. param( 'iColumns', columnCount );
  2203. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  2204. param( 'iDisplayStart', displayStart );
  2205. param( 'iDisplayLength', displayLength );
  2206. // DataTables 1.10+ method
  2207. var d = {
  2208. draw: settings.iDraw,
  2209. columns: [],
  2210. order: [],
  2211. start: displayStart,
  2212. length: displayLength,
  2213. search: {
  2214. value: preSearch.sSearch,
  2215. regex: preSearch.bRegex
  2216. }
  2217. };
  2218. for ( i=0 ; i<columnCount ; i++ ) {
  2219. column = columns[i];
  2220. columnSearch = preColSearch[i];
  2221. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  2222. d.columns.push( {
  2223. data: dataProp,
  2224. name: column.sName,
  2225. searchable: column.bSearchable,
  2226. orderable: column.bSortable,
  2227. search: {
  2228. value: columnSearch.sSearch,
  2229. regex: columnSearch.bRegex
  2230. }
  2231. } );
  2232. param( "mDataProp_"+i, dataProp );
  2233. if ( features.bFilter ) {
  2234. param( 'sSearch_'+i, columnSearch.sSearch );
  2235. param( 'bRegex_'+i, columnSearch.bRegex );
  2236. param( 'bSearchable_'+i, column.bSearchable );
  2237. }
  2238. if ( features.bSort ) {
  2239. param( 'bSortable_'+i, column.bSortable );
  2240. }
  2241. }
  2242. if ( features.bFilter ) {
  2243. param( 'sSearch', preSearch.sSearch );
  2244. param( 'bRegex', preSearch.bRegex );
  2245. }
  2246. if ( features.bSort ) {
  2247. $.each( sort, function ( i, val ) {
  2248. d.order.push( { column: val.col, dir: val.dir } );
  2249. param( 'iSortCol_'+i, val.col );
  2250. param( 'sSortDir_'+i, val.dir );
  2251. } );
  2252. param( 'iSortingCols', sort.length );
  2253. }
  2254. // If the legacy.ajax parameter is null, then we automatically decide which
  2255. // form to use, based on sAjaxSource
  2256. var legacy = DataTable.ext.legacy.ajax;
  2257. if ( legacy === null ) {
  2258. return settings.sAjaxSource ? data : d;
  2259. }
  2260. // Otherwise, if legacy has been specified then we use that to decide on the
  2261. // form
  2262. return legacy ? data : d;
  2263. }
  2264. /**
  2265. * Data the data from the server (nuking the old) and redraw the table
  2266. * @param {object} oSettings dataTables settings object
  2267. * @param {object} json json data return from the server.
  2268. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  2269. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  2270. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  2271. * @param {array} json.aaData The data to display on this page
  2272. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  2273. * @memberof DataTable#oApi
  2274. */
  2275. function _fnAjaxUpdateDraw ( settings, json )
  2276. {
  2277. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  2278. // Support both
  2279. var compat = function ( old, modern ) {
  2280. return json[old] !== undefined ? json[old] : json[modern];
  2281. };
  2282. var draw = compat( 'sEcho', 'draw' );
  2283. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  2284. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  2285. if ( draw ) {
  2286. // Protect against out of sequence returns
  2287. if ( draw*1 < settings.iDraw ) {
  2288. return;
  2289. }
  2290. settings.iDraw = draw * 1;
  2291. }
  2292. _fnClearTable( settings );
  2293. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  2294. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  2295. var data = _fnAjaxDataSrc( settings, json );
  2296. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  2297. _fnAddData( settings, data[i] );
  2298. }
  2299. settings.aiDisplay = settings.aiDisplayMaster.slice();
  2300. settings.bAjaxDataGet = false;
  2301. _fnDraw( settings );
  2302. if ( ! settings._bInitComplete ) {
  2303. _fnInitComplete( settings, json );
  2304. }
  2305. settings.bAjaxDataGet = true;
  2306. _fnProcessingDisplay( settings, false );
  2307. }
  2308. /**
  2309. * Get the data from the JSON data source to use for drawing a table. Using
  2310. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  2311. * source object, or from a processing function.
  2312. * @param {object} oSettings dataTables settings object
  2313. * @param {object} json Data source object / array from the server
  2314. * @return {array} Array of data to use
  2315. */
  2316. function _fnAjaxDataSrc ( oSettings, json )
  2317. {
  2318. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  2319. oSettings.ajax.dataSrc :
  2320. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  2321. // Compatibility with 1.9-. In order to read from aaData, check if the
  2322. // default has been changed, if not, check for aaData
  2323. if ( dataSrc === 'data' ) {
  2324. return json.aaData || json[dataSrc];
  2325. }
  2326. return dataSrc !== "" ?
  2327. _fnGetObjectDataFn( dataSrc )( json ) :
  2328. json;
  2329. }
  2330. /**
  2331. * Generate the node required for filtering text
  2332. * @returns {node} Filter control element
  2333. * @param {object} oSettings dataTables settings object
  2334. * @memberof DataTable#oApi
  2335. */
  2336. function _fnFeatureHtmlFilter ( settings )
  2337. {
  2338. var classes = settings.oClasses;
  2339. var tableId = settings.sTableId;
  2340. var language = settings.oLanguage;
  2341. var previousSearch = settings.oPreviousSearch;
  2342. var features = settings.aanFeatures;
  2343. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  2344. var str = language.sSearch;
  2345. str = str.match(/_INPUT_/) ?
  2346. str.replace('_INPUT_', input) :
  2347. str+input;
  2348. var filter = $('<div/>', {
  2349. 'id': ! features.f ? tableId+'_filter' : null,
  2350. 'class': classes.sFilter
  2351. } )
  2352. .append( $('<label/>' ).append( str ) );
  2353. var searchFn = function() {
  2354. /* Update all other filter input elements for the new display */
  2355. var n = features.f;
  2356. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  2357. /* Now do the filter */
  2358. if ( val != previousSearch.sSearch ) {
  2359. _fnFilterComplete( settings, {
  2360. "sSearch": val,
  2361. "bRegex": previousSearch.bRegex,
  2362. "bSmart": previousSearch.bSmart ,
  2363. "bCaseInsensitive": previousSearch.bCaseInsensitive
  2364. } );
  2365. // Need to redraw, without resorting
  2366. settings._iDisplayStart = 0;
  2367. _fnDraw( settings );
  2368. }
  2369. };
  2370. var searchDelay = settings.searchDelay !== null ?
  2371. settings.searchDelay :
  2372. _fnDataSource( settings ) === 'ssp' ?
  2373. 400 :
  2374. 0;
  2375. var jqFilter = $('input', filter)
  2376. .val( previousSearch.sSearch )
  2377. .attr( 'placeholder', language.sSearchPlaceholder )
  2378. .bind(
  2379. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  2380. searchDelay ?
  2381. _fnThrottle( searchFn, searchDelay ) :
  2382. searchFn
  2383. )
  2384. .bind( 'keypress.DT', function(e) {
  2385. /* Prevent form submission */
  2386. if ( e.keyCode == 13 ) {
  2387. return false;
  2388. }
  2389. } )
  2390. .attr('aria-controls', tableId);
  2391. // Update the input elements whenever the table is filtered
  2392. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  2393. if ( settings === s ) {
  2394. // IE9 throws an 'unknown error' if document.activeElement is used
  2395. // inside an iframe or frame...
  2396. try {
  2397. if ( jqFilter[0] !== document.activeElement ) {
  2398. jqFilter.val( previousSearch.sSearch );
  2399. }
  2400. }
  2401. catch ( e ) {}
  2402. }
  2403. } );
  2404. return filter[0];
  2405. }
  2406. /**
  2407. * Filter the table using both the global filter and column based filtering
  2408. * @param {object} oSettings dataTables settings object
  2409. * @param {object} oSearch search information
  2410. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  2411. * @memberof DataTable#oApi
  2412. */
  2413. function _fnFilterComplete ( oSettings, oInput, iForce )
  2414. {
  2415. var oPrevSearch = oSettings.oPreviousSearch;
  2416. var aoPrevSearch = oSettings.aoPreSearchCols;
  2417. var fnSaveFilter = function ( oFilter ) {
  2418. /* Save the filtering values */
  2419. oPrevSearch.sSearch = oFilter.sSearch;
  2420. oPrevSearch.bRegex = oFilter.bRegex;
  2421. oPrevSearch.bSmart = oFilter.bSmart;
  2422. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  2423. };
  2424. var fnRegex = function ( o ) {
  2425. // Backwards compatibility with the bEscapeRegex option
  2426. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  2427. };
  2428. // Resolve any column types that are unknown due to addition or invalidation
  2429. // @todo As per sort - can this be moved into an event handler?
  2430. _fnColumnTypes( oSettings );
  2431. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  2432. if ( _fnDataSource( oSettings ) != 'ssp' )
  2433. {
  2434. /* Global filter */
  2435. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  2436. fnSaveFilter( oInput );
  2437. /* Now do the individual column filter */
  2438. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  2439. {
  2440. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  2441. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  2442. }
  2443. /* Custom filtering */
  2444. _fnFilterCustom( oSettings );
  2445. }
  2446. else
  2447. {
  2448. fnSaveFilter( oInput );
  2449. }
  2450. /* Tell the draw function we have been filtering */
  2451. oSettings.bFiltered = true;
  2452. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  2453. }
  2454. /**
  2455. * Apply custom filtering functions
  2456. * @param {object} oSettings dataTables settings object
  2457. * @memberof DataTable#oApi
  2458. */
  2459. function _fnFilterCustom( settings )
  2460. {
  2461. var filters = DataTable.ext.search;
  2462. var displayRows = settings.aiDisplay;
  2463. var row, rowIdx;
  2464. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  2465. var rows = [];
  2466. // Loop over each row and see if it should be included
  2467. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  2468. rowIdx = displayRows[ j ];
  2469. row = settings.aoData[ rowIdx ];
  2470. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  2471. rows.push( rowIdx );
  2472. }
  2473. }
  2474. // So the array reference doesn't break set the results into the
  2475. // existing array
  2476. displayRows.length = 0;
  2477. displayRows.push.apply( displayRows, rows );
  2478. }
  2479. }
  2480. /**
  2481. * Filter the table on a per-column basis
  2482. * @param {object} oSettings dataTables settings object
  2483. * @param {string} sInput string to filter on
  2484. * @param {int} iColumn column to filter
  2485. * @param {bool} bRegex treat search string as a regular expression or not
  2486. * @param {bool} bSmart use smart filtering or not
  2487. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  2488. * @memberof DataTable#oApi
  2489. */
  2490. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  2491. {
  2492. if ( searchStr === '' ) {
  2493. return;
  2494. }
  2495. var data;
  2496. var display = settings.aiDisplay;
  2497. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  2498. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  2499. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  2500. if ( ! rpSearch.test( data ) ) {
  2501. display.splice( i, 1 );
  2502. }
  2503. }
  2504. }
  2505. /**
  2506. * Filter the data table based on user input and draw the table
  2507. * @param {object} settings dataTables settings object
  2508. * @param {string} input string to filter on
  2509. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  2510. * @param {bool} regex treat as a regular expression or not
  2511. * @param {bool} smart perform smart filtering or not
  2512. * @param {bool} caseInsensitive Do case insenstive matching or not
  2513. * @memberof DataTable#oApi
  2514. */
  2515. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  2516. {
  2517. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  2518. var prevSearch = settings.oPreviousSearch.sSearch;
  2519. var displayMaster = settings.aiDisplayMaster;
  2520. var display, invalidated, i;
  2521. // Need to take account of custom filtering functions - always filter
  2522. if ( DataTable.ext.search.length !== 0 ) {
  2523. force = true;
  2524. }
  2525. // Check if any of the rows were invalidated
  2526. invalidated = _fnFilterData( settings );
  2527. // If the input is blank - we just want the full data set
  2528. if ( input.length <= 0 ) {
  2529. settings.aiDisplay = displayMaster.slice();
  2530. }
  2531. else {
  2532. // New search - start from the master array
  2533. if ( invalidated ||
  2534. force ||
  2535. prevSearch.length > input.length ||
  2536. input.indexOf(prevSearch) !== 0 ||
  2537. settings.bSorted // On resort, the display master needs to be
  2538. // re-filtered since indexes will have changed
  2539. ) {
  2540. settings.aiDisplay = displayMaster.slice();
  2541. }
  2542. // Search the display array
  2543. display = settings.aiDisplay;
  2544. for ( i=display.length-1 ; i>=0 ; i-- ) {
  2545. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  2546. display.splice( i, 1 );
  2547. }
  2548. }
  2549. }
  2550. }
  2551. /**
  2552. * Build a regular expression object suitable for searching a table
  2553. * @param {string} sSearch string to search for
  2554. * @param {bool} bRegex treat as a regular expression or not
  2555. * @param {bool} bSmart perform smart filtering or not
  2556. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  2557. * @returns {RegExp} constructed object
  2558. * @memberof DataTable#oApi
  2559. */
  2560. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  2561. {
  2562. search = regex ?
  2563. search :
  2564. _fnEscapeRegex( search );
  2565. if ( smart ) {
  2566. /* For smart filtering we want to allow the search to work regardless of
  2567. * word order. We also want double quoted text to be preserved, so word
  2568. * order is important - a la google. So this is what we want to
  2569. * generate:
  2570. *
  2571. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  2572. */
  2573. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || '', function ( word ) {
  2574. if ( word.charAt(0) === '"' ) {
  2575. var m = word.match( /^"(.*)"$/ );
  2576. word = m ? m[1] : word;
  2577. }
  2578. return word.replace('"', '');
  2579. } );
  2580. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  2581. }
  2582. return new RegExp( search, caseInsensitive ? 'i' : '' );
  2583. }
  2584. /**
  2585. * Escape a string such that it can be used in a regular expression
  2586. * @param {string} sVal string to escape
  2587. * @returns {string} escaped string
  2588. * @memberof DataTable#oApi
  2589. */
  2590. function _fnEscapeRegex ( sVal )
  2591. {
  2592. return sVal.replace( _re_escape_regex, '\\$1' );
  2593. }
  2594. var __filter_div = $('<div>')[0];
  2595. var __filter_div_textContent = __filter_div.textContent !== undefined;
  2596. // Update the filtering data for each row if needed (by invalidation or first run)
  2597. function _fnFilterData ( settings )
  2598. {
  2599. var columns = settings.aoColumns;
  2600. var column;
  2601. var i, j, ien, jen, filterData, cellData, row;
  2602. var fomatters = DataTable.ext.type.search;
  2603. var wasInvalidated = false;
  2604. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  2605. row = settings.aoData[i];
  2606. if ( ! row._aFilterData ) {
  2607. filterData = [];
  2608. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  2609. column = columns[j];
  2610. if ( column.bSearchable ) {
  2611. cellData = _fnGetCellData( settings, i, j, 'filter' );
  2612. if ( fomatters[ column.sType ] ) {
  2613. cellData = fomatters[ column.sType ]( cellData );
  2614. }
  2615. // Search in DataTables 1.10 is string based. In 1.11 this
  2616. // should be altered to also allow strict type checking.
  2617. if ( cellData === null ) {
  2618. cellData = '';
  2619. }
  2620. if ( typeof cellData !== 'string' && cellData.toString ) {
  2621. cellData = cellData.toString();
  2622. }
  2623. }
  2624. else {
  2625. cellData = '';
  2626. }
  2627. // If it looks like there is an HTML entity in the string,
  2628. // attempt to decode it so sorting works as expected. Note that
  2629. // we could use a single line of jQuery to do this, but the DOM
  2630. // method used here is much faster http://jsperf.com/html-decode
  2631. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  2632. __filter_div.innerHTML = cellData;
  2633. cellData = __filter_div_textContent ?
  2634. __filter_div.textContent :
  2635. __filter_div.innerText;
  2636. }
  2637. if ( cellData.replace ) {
  2638. cellData = cellData.replace(/[\r\n]/g, '');
  2639. }
  2640. filterData.push( cellData );
  2641. }
  2642. row._aFilterData = filterData;
  2643. row._sFilterRow = filterData.join(' ');
  2644. wasInvalidated = true;
  2645. }
  2646. }
  2647. return wasInvalidated;
  2648. }
  2649. /**
  2650. * Convert from the internal Hungarian notation to camelCase for external
  2651. * interaction
  2652. * @param {object} obj Object to convert
  2653. * @returns {object} Inverted object
  2654. * @memberof DataTable#oApi
  2655. */
  2656. function _fnSearchToCamel ( obj )
  2657. {
  2658. return {
  2659. search: obj.sSearch,
  2660. smart: obj.bSmart,
  2661. regex: obj.bRegex,
  2662. caseInsensitive: obj.bCaseInsensitive
  2663. };
  2664. }
  2665. /**
  2666. * Convert from camelCase notation to the internal Hungarian. We could use the
  2667. * Hungarian convert function here, but this is cleaner
  2668. * @param {object} obj Object to convert
  2669. * @returns {object} Inverted object
  2670. * @memberof DataTable#oApi
  2671. */
  2672. function _fnSearchToHung ( obj )
  2673. {
  2674. return {
  2675. sSearch: obj.search,
  2676. bSmart: obj.smart,
  2677. bRegex: obj.regex,
  2678. bCaseInsensitive: obj.caseInsensitive
  2679. };
  2680. }
  2681. /**
  2682. * Generate the node required for the info display
  2683. * @param {object} oSettings dataTables settings object
  2684. * @returns {node} Information element
  2685. * @memberof DataTable#oApi
  2686. */
  2687. function _fnFeatureHtmlInfo ( settings )
  2688. {
  2689. var
  2690. tid = settings.sTableId,
  2691. nodes = settings.aanFeatures.i,
  2692. n = $('<div/>', {
  2693. 'class': settings.oClasses.sInfo,
  2694. 'id': ! nodes ? tid+'_info' : null
  2695. } );
  2696. if ( ! nodes ) {
  2697. // Update display on each draw
  2698. settings.aoDrawCallback.push( {
  2699. "fn": _fnUpdateInfo,
  2700. "sName": "information"
  2701. } );
  2702. n
  2703. .attr( 'role', 'status' )
  2704. .attr( 'aria-live', 'polite' );
  2705. // Table is described by our info div
  2706. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  2707. }
  2708. return n[0];
  2709. }
  2710. /**
  2711. * Update the information elements in the display
  2712. * @param {object} settings dataTables settings object
  2713. * @memberof DataTable#oApi
  2714. */
  2715. function _fnUpdateInfo ( settings )
  2716. {
  2717. /* Show information about the table */
  2718. var nodes = settings.aanFeatures.i;
  2719. if ( nodes.length === 0 ) {
  2720. return;
  2721. }
  2722. var
  2723. lang = settings.oLanguage,
  2724. start = settings._iDisplayStart+1,
  2725. end = settings.fnDisplayEnd(),
  2726. max = settings.fnRecordsTotal(),
  2727. total = settings.fnRecordsDisplay(),
  2728. out = total ?
  2729. lang.sInfo :
  2730. lang.sInfoEmpty;
  2731. if ( total !== max ) {
  2732. /* Record set after filtering */
  2733. out += ' ' + lang.sInfoFiltered;
  2734. }
  2735. // Convert the macros
  2736. out += lang.sInfoPostFix;
  2737. out = _fnInfoMacros( settings, out );
  2738. var callback = lang.fnInfoCallback;
  2739. if ( callback !== null ) {
  2740. out = callback.call( settings.oInstance,
  2741. settings, start, end, max, total, out
  2742. );
  2743. }
  2744. $(nodes).html( out );
  2745. }
  2746. function _fnInfoMacros ( settings, str )
  2747. {
  2748. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  2749. // internally
  2750. var
  2751. formatter = settings.fnFormatNumber,
  2752. start = settings._iDisplayStart+1,
  2753. len = settings._iDisplayLength,
  2754. vis = settings.fnRecordsDisplay(),
  2755. all = len === -1;
  2756. return str.
  2757. replace(/_START_/g, formatter.call( settings, start ) ).
  2758. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  2759. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  2760. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  2761. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  2762. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  2763. }
  2764. /**
  2765. * Draw the table for the first time, adding all required features
  2766. * @param {object} settings dataTables settings object
  2767. * @memberof DataTable#oApi
  2768. */
  2769. function _fnInitialise ( settings )
  2770. {
  2771. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  2772. var columns = settings.aoColumns, column;
  2773. var features = settings.oFeatures;
  2774. /* Ensure that the table data is fully initialised */
  2775. if ( ! settings.bInitialised ) {
  2776. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  2777. return;
  2778. }
  2779. /* Show the display HTML options */
  2780. _fnAddOptionsHtml( settings );
  2781. /* Build and draw the header / footer for the table */
  2782. _fnBuildHead( settings );
  2783. _fnDrawHead( settings, settings.aoHeader );
  2784. _fnDrawHead( settings, settings.aoFooter );
  2785. /* Okay to show that something is going on now */
  2786. _fnProcessingDisplay( settings, true );
  2787. /* Calculate sizes for columns */
  2788. if ( features.bAutoWidth ) {
  2789. _fnCalculateColumnWidths( settings );
  2790. }
  2791. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  2792. column = columns[i];
  2793. if ( column.sWidth ) {
  2794. column.nTh.style.width = _fnStringToCss( column.sWidth );
  2795. }
  2796. }
  2797. // If there is default sorting required - let's do it. The sort function
  2798. // will do the drawing for us. Otherwise we draw the table regardless of the
  2799. // Ajax source - this allows the table to look initialised for Ajax sourcing
  2800. // data (show 'loading' message possibly)
  2801. _fnReDraw( settings );
  2802. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  2803. var dataSrc = _fnDataSource( settings );
  2804. if ( dataSrc != 'ssp' ) {
  2805. // if there is an ajax source load the data
  2806. if ( dataSrc == 'ajax' ) {
  2807. _fnBuildAjax( settings, [], function(json) {
  2808. var aData = _fnAjaxDataSrc( settings, json );
  2809. // Got the data - add it to the table
  2810. for ( i=0 ; i<aData.length ; i++ ) {
  2811. _fnAddData( settings, aData[i] );
  2812. }
  2813. // Reset the init display for cookie saving. We've already done
  2814. // a filter, and therefore cleared it before. So we need to make
  2815. // it appear 'fresh'
  2816. settings.iInitDisplayStart = iAjaxStart;
  2817. _fnReDraw( settings );
  2818. _fnProcessingDisplay( settings, false );
  2819. _fnInitComplete( settings, json );
  2820. }, settings );
  2821. }
  2822. else {
  2823. _fnProcessingDisplay( settings, false );
  2824. _fnInitComplete( settings );
  2825. }
  2826. }
  2827. }
  2828. /**
  2829. * Draw the table for the first time, adding all required features
  2830. * @param {object} oSettings dataTables settings object
  2831. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  2832. * with client-side processing (optional)
  2833. * @memberof DataTable#oApi
  2834. */
  2835. function _fnInitComplete ( settings, json )
  2836. {
  2837. settings._bInitComplete = true;
  2838. // On an Ajax load we now have data and therefore want to apply the column
  2839. // sizing
  2840. if ( json ) {
  2841. _fnAdjustColumnSizing( settings );
  2842. }
  2843. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  2844. }
  2845. function _fnLengthChange ( settings, val )
  2846. {
  2847. var len = parseInt( val, 10 );
  2848. settings._iDisplayLength = len;
  2849. _fnLengthOverflow( settings );
  2850. // Fire length change event
  2851. _fnCallbackFire( settings, null, 'length', [settings, len] );
  2852. }
  2853. /**
  2854. * Generate the node required for user display length changing
  2855. * @param {object} settings dataTables settings object
  2856. * @returns {node} Display length feature node
  2857. * @memberof DataTable#oApi
  2858. */
  2859. function _fnFeatureHtmlLength ( settings )
  2860. {
  2861. var
  2862. classes = settings.oClasses,
  2863. tableId = settings.sTableId,
  2864. menu = settings.aLengthMenu,
  2865. d2 = $.isArray( menu[0] ),
  2866. lengths = d2 ? menu[0] : menu,
  2867. language = d2 ? menu[1] : menu;
  2868. var select = $('<select/>', {
  2869. 'name': tableId+'_length',
  2870. 'aria-controls': tableId,
  2871. 'class': classes.sLengthSelect
  2872. } );
  2873. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  2874. select[0][ i ] = new Option( language[i], lengths[i] );
  2875. }
  2876. var div = $('<div><label/></div>').addClass( classes.sLength );
  2877. if ( ! settings.aanFeatures.l ) {
  2878. div[0].id = tableId+'_length';
  2879. }
  2880. div.children().append(
  2881. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  2882. );
  2883. // Can't use `select` variable as user might provide their own and the
  2884. // reference is broken by the use of outerHTML
  2885. $('select', div)
  2886. .val( settings._iDisplayLength )
  2887. .bind( 'change.DT', function(e) {
  2888. _fnLengthChange( settings, $(this).val() );
  2889. _fnDraw( settings );
  2890. } );
  2891. // Update node value whenever anything changes the table's length
  2892. $(settings.nTable).bind( 'length.dt.DT', function (e, s, len) {
  2893. if ( settings === s ) {
  2894. $('select', div).val( len );
  2895. }
  2896. } );
  2897. return div[0];
  2898. }
  2899. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2900. * Note that most of the paging logic is done in
  2901. * DataTable.ext.pager
  2902. */
  2903. /**
  2904. * Generate the node required for default pagination
  2905. * @param {object} oSettings dataTables settings object
  2906. * @returns {node} Pagination feature node
  2907. * @memberof DataTable#oApi
  2908. */
  2909. function _fnFeatureHtmlPaginate ( settings )
  2910. {
  2911. var
  2912. type = settings.sPaginationType,
  2913. plugin = DataTable.ext.pager[ type ],
  2914. modern = typeof plugin === 'function',
  2915. redraw = function( settings ) {
  2916. _fnDraw( settings );
  2917. },
  2918. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  2919. features = settings.aanFeatures;
  2920. if ( ! modern ) {
  2921. plugin.fnInit( settings, node, redraw );
  2922. }
  2923. /* Add a draw callback for the pagination on first instance, to update the paging display */
  2924. if ( ! features.p )
  2925. {
  2926. node.id = settings.sTableId+'_paginate';
  2927. settings.aoDrawCallback.push( {
  2928. "fn": function( settings ) {
  2929. if ( modern ) {
  2930. var
  2931. start = settings._iDisplayStart,
  2932. len = settings._iDisplayLength,
  2933. visRecords = settings.fnRecordsDisplay(),
  2934. all = len === -1,
  2935. page = all ? 0 : Math.ceil( start / len ),
  2936. pages = all ? 1 : Math.ceil( visRecords / len ),
  2937. buttons = plugin(page, pages),
  2938. i, ien;
  2939. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  2940. _fnRenderer( settings, 'pageButton' )(
  2941. settings, features.p[i], i, buttons, page, pages
  2942. );
  2943. }
  2944. }
  2945. else {
  2946. plugin.fnUpdate( settings, redraw );
  2947. }
  2948. },
  2949. "sName": "pagination"
  2950. } );
  2951. }
  2952. return node;
  2953. }
  2954. /**
  2955. * Alter the display settings to change the page
  2956. * @param {object} settings DataTables settings object
  2957. * @param {string|int} action Paging action to take: "first", "previous",
  2958. * "next" or "last" or page number to jump to (integer)
  2959. * @param [bool] redraw Automatically draw the update or not
  2960. * @returns {bool} true page has changed, false - no change
  2961. * @memberof DataTable#oApi
  2962. */
  2963. function _fnPageChange ( settings, action, redraw )
  2964. {
  2965. var
  2966. start = settings._iDisplayStart,
  2967. len = settings._iDisplayLength,
  2968. records = settings.fnRecordsDisplay();
  2969. if ( records === 0 || len === -1 )
  2970. {
  2971. start = 0;
  2972. }
  2973. else if ( typeof action === "number" )
  2974. {
  2975. start = action * len;
  2976. if ( start > records )
  2977. {
  2978. start = 0;
  2979. }
  2980. }
  2981. else if ( action == "first" )
  2982. {
  2983. start = 0;
  2984. }
  2985. else if ( action == "previous" )
  2986. {
  2987. start = len >= 0 ?
  2988. start - len :
  2989. 0;
  2990. if ( start < 0 )
  2991. {
  2992. start = 0;
  2993. }
  2994. }
  2995. else if ( action == "next" )
  2996. {
  2997. if ( start + len < records )
  2998. {
  2999. start += len;
  3000. }
  3001. }
  3002. else if ( action == "last" )
  3003. {
  3004. start = Math.floor( (records-1) / len) * len;
  3005. }
  3006. else
  3007. {
  3008. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  3009. }
  3010. var changed = settings._iDisplayStart !== start;
  3011. settings._iDisplayStart = start;
  3012. if ( changed ) {
  3013. _fnCallbackFire( settings, null, 'page', [settings] );
  3014. if ( redraw ) {
  3015. _fnDraw( settings );
  3016. }
  3017. }
  3018. return changed;
  3019. }
  3020. /**
  3021. * Generate the node required for the processing node
  3022. * @param {object} settings dataTables settings object
  3023. * @returns {node} Processing element
  3024. * @memberof DataTable#oApi
  3025. */
  3026. function _fnFeatureHtmlProcessing ( settings )
  3027. {
  3028. return $('<div/>', {
  3029. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  3030. 'class': settings.oClasses.sProcessing
  3031. } )
  3032. .html( settings.oLanguage.sProcessing )
  3033. .insertBefore( settings.nTable )[0];
  3034. }
  3035. /**
  3036. * Display or hide the processing indicator
  3037. * @param {object} settings dataTables settings object
  3038. * @param {bool} show Show the processing indicator (true) or not (false)
  3039. * @memberof DataTable#oApi
  3040. */
  3041. function _fnProcessingDisplay ( settings, show )
  3042. {
  3043. if ( settings.oFeatures.bProcessing ) {
  3044. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  3045. }
  3046. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  3047. }
  3048. /**
  3049. * Add any control elements for the table - specifically scrolling
  3050. * @param {object} settings dataTables settings object
  3051. * @returns {node} Node to add to the DOM
  3052. * @memberof DataTable#oApi
  3053. */
  3054. function _fnFeatureHtmlTable ( settings )
  3055. {
  3056. var table = $(settings.nTable);
  3057. // Add the ARIA grid role to the table
  3058. table.attr( 'role', 'grid' );
  3059. // Scrolling from here on in
  3060. var scroll = settings.oScroll;
  3061. if ( scroll.sX === '' && scroll.sY === '' ) {
  3062. return settings.nTable;
  3063. }
  3064. var scrollX = scroll.sX;
  3065. var scrollY = scroll.sY;
  3066. var classes = settings.oClasses;
  3067. var caption = table.children('caption');
  3068. var captionSide = caption.length ? caption[0]._captionSide : null;
  3069. var headerClone = $( table[0].cloneNode(false) );
  3070. var footerClone = $( table[0].cloneNode(false) );
  3071. var footer = table.children('tfoot');
  3072. var _div = '<div/>';
  3073. var size = function ( s ) {
  3074. return !s ? null : _fnStringToCss( s );
  3075. };
  3076. // This is fairly messy, but with x scrolling enabled, if the table has a
  3077. // width attribute, regardless of any width applied using the column width
  3078. // options, the browser will shrink or grow the table as needed to fit into
  3079. // that 100%. That would make the width options useless. So we remove it.
  3080. // This is okay, under the assumption that width:100% is applied to the
  3081. // table in CSS (it is in the default stylesheet) which will set the table
  3082. // width as appropriate (the attribute and css behave differently...)
  3083. if ( scroll.sX && table.attr('width') === '100%' ) {
  3084. table.removeAttr('width');
  3085. }
  3086. if ( ! footer.length ) {
  3087. footer = null;
  3088. }
  3089. /*
  3090. * The HTML structure that we want to generate in this function is:
  3091. * div - scroller
  3092. * div - scroll head
  3093. * div - scroll head inner
  3094. * table - scroll head table
  3095. * thead - thead
  3096. * div - scroll body
  3097. * table - table (master table)
  3098. * thead - thead clone for sizing
  3099. * tbody - tbody
  3100. * div - scroll foot
  3101. * div - scroll foot inner
  3102. * table - scroll foot table
  3103. * tfoot - tfoot
  3104. */
  3105. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  3106. .append(
  3107. $(_div, { 'class': classes.sScrollHead } )
  3108. .css( {
  3109. overflow: 'hidden',
  3110. position: 'relative',
  3111. border: 0,
  3112. width: scrollX ? size(scrollX) : '100%'
  3113. } )
  3114. .append(
  3115. $(_div, { 'class': classes.sScrollHeadInner } )
  3116. .css( {
  3117. 'box-sizing': 'content-box',
  3118. width: scroll.sXInner || '100%'
  3119. } )
  3120. .append(
  3121. headerClone
  3122. .removeAttr('id')
  3123. .css( 'margin-left', 0 )
  3124. .append( captionSide === 'top' ? caption : null )
  3125. .append(
  3126. table.children('thead')
  3127. )
  3128. )
  3129. )
  3130. )
  3131. .append(
  3132. $(_div, { 'class': classes.sScrollBody } )
  3133. .css( {
  3134. overflow: 'auto',
  3135. height: size( scrollY ),
  3136. width: size( scrollX )
  3137. } )
  3138. .append( table )
  3139. );
  3140. if ( footer ) {
  3141. scroller.append(
  3142. $(_div, { 'class': classes.sScrollFoot } )
  3143. .css( {
  3144. overflow: 'hidden',
  3145. border: 0,
  3146. width: scrollX ? size(scrollX) : '100%'
  3147. } )
  3148. .append(
  3149. $(_div, { 'class': classes.sScrollFootInner } )
  3150. .append(
  3151. footerClone
  3152. .removeAttr('id')
  3153. .css( 'margin-left', 0 )
  3154. .append( captionSide === 'bottom' ? caption : null )
  3155. .append(
  3156. table.children('tfoot')
  3157. )
  3158. )
  3159. )
  3160. );
  3161. }
  3162. var children = scroller.children();
  3163. var scrollHead = children[0];
  3164. var scrollBody = children[1];
  3165. var scrollFoot = footer ? children[2] : null;
  3166. // When the body is scrolled, then we also want to scroll the headers
  3167. if ( scrollX ) {
  3168. $(scrollBody).on( 'scroll.DT', function (e) {
  3169. var scrollLeft = this.scrollLeft;
  3170. scrollHead.scrollLeft = scrollLeft;
  3171. if ( footer ) {
  3172. scrollFoot.scrollLeft = scrollLeft;
  3173. }
  3174. } );
  3175. }
  3176. settings.nScrollHead = scrollHead;
  3177. settings.nScrollBody = scrollBody;
  3178. settings.nScrollFoot = scrollFoot;
  3179. // On redraw - align columns
  3180. settings.aoDrawCallback.push( {
  3181. "fn": _fnScrollDraw,
  3182. "sName": "scrolling"
  3183. } );
  3184. return scroller[0];
  3185. }
  3186. /**
  3187. * Update the header, footer and body tables for resizing - i.e. column
  3188. * alignment.
  3189. *
  3190. * Welcome to the most horrible function DataTables. The process that this
  3191. * function follows is basically:
  3192. * 1. Re-create the table inside the scrolling div
  3193. * 2. Take live measurements from the DOM
  3194. * 3. Apply the measurements to align the columns
  3195. * 4. Clean up
  3196. *
  3197. * @param {object} settings dataTables settings object
  3198. * @memberof DataTable#oApi
  3199. */
  3200. function _fnScrollDraw ( settings )
  3201. {
  3202. // Given that this is such a monster function, a lot of variables are use
  3203. // to try and keep the minimised size as small as possible
  3204. var
  3205. scroll = settings.oScroll,
  3206. scrollX = scroll.sX,
  3207. scrollXInner = scroll.sXInner,
  3208. scrollY = scroll.sY,
  3209. barWidth = scroll.iBarWidth,
  3210. divHeader = $(settings.nScrollHead),
  3211. divHeaderStyle = divHeader[0].style,
  3212. divHeaderInner = divHeader.children('div'),
  3213. divHeaderInnerStyle = divHeaderInner[0].style,
  3214. divHeaderTable = divHeaderInner.children('table'),
  3215. divBodyEl = settings.nScrollBody,
  3216. divBody = $(divBodyEl),
  3217. divBodyStyle = divBodyEl.style,
  3218. divFooter = $(settings.nScrollFoot),
  3219. divFooterInner = divFooter.children('div'),
  3220. divFooterTable = divFooterInner.children('table'),
  3221. header = $(settings.nTHead),
  3222. table = $(settings.nTable),
  3223. tableEl = table[0],
  3224. tableStyle = tableEl.style,
  3225. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  3226. browser = settings.oBrowser,
  3227. ie67 = browser.bScrollOversize,
  3228. headerTrgEls, footerTrgEls,
  3229. headerSrcEls, footerSrcEls,
  3230. headerCopy, footerCopy,
  3231. headerWidths=[], footerWidths=[],
  3232. headerContent=[],
  3233. idx, correction, sanityWidth,
  3234. zeroOut = function(nSizer) {
  3235. var style = nSizer.style;
  3236. style.paddingTop = "0";
  3237. style.paddingBottom = "0";
  3238. style.borderTopWidth = "0";
  3239. style.borderBottomWidth = "0";
  3240. style.height = 0;
  3241. };
  3242. /*
  3243. * 1. Re-create the table inside the scrolling div
  3244. */
  3245. // Remove the old minimised thead and tfoot elements in the inner table
  3246. table.children('thead, tfoot').remove();
  3247. // Clone the current header and footer elements and then place it into the inner table
  3248. headerCopy = header.clone().prependTo( table );
  3249. headerTrgEls = header.find('tr'); // original header is in its own table
  3250. headerSrcEls = headerCopy.find('tr');
  3251. headerCopy.find('th, td').removeAttr('tabindex');
  3252. if ( footer ) {
  3253. footerCopy = footer.clone().prependTo( table );
  3254. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  3255. footerSrcEls = footerCopy.find('tr');
  3256. }
  3257. /*
  3258. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  3259. */
  3260. // Remove old sizing and apply the calculated column widths
  3261. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  3262. // calculated sizes to this header
  3263. if ( ! scrollX )
  3264. {
  3265. divBodyStyle.width = '100%';
  3266. divHeader[0].style.width = '100%';
  3267. }
  3268. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  3269. idx = _fnVisibleToColumnIndex( settings, i );
  3270. el.style.width = settings.aoColumns[idx].sWidth;
  3271. } );
  3272. if ( footer ) {
  3273. _fnApplyToChildren( function(n) {
  3274. n.style.width = "";
  3275. }, footerSrcEls );
  3276. }
  3277. // If scroll collapse is enabled, when we put the headers back into the body for sizing, we
  3278. // will end up forcing the scrollbar to appear, making our measurements wrong for when we
  3279. // then hide it (end of this function), so add the header height to the body scroller.
  3280. if ( scroll.bCollapse && scrollY !== "" ) {
  3281. divBodyStyle.height = (divBody[0].offsetHeight + header[0].offsetHeight)+"px";
  3282. }
  3283. // Size the table as a whole
  3284. sanityWidth = table.outerWidth();
  3285. if ( scrollX === "" ) {
  3286. // No x scrolling
  3287. tableStyle.width = "100%";
  3288. // IE7 will make the width of the table when 100% include the scrollbar
  3289. // - which is shouldn't. When there is a scrollbar we need to take this
  3290. // into account.
  3291. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  3292. divBody.css('overflow-y') == "scroll")
  3293. ) {
  3294. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  3295. }
  3296. }
  3297. else
  3298. {
  3299. // x scrolling
  3300. if ( scrollXInner !== "" ) {
  3301. // x scroll inner has been given - use it
  3302. tableStyle.width = _fnStringToCss(scrollXInner);
  3303. }
  3304. else if ( sanityWidth == divBody.width() && divBody.height() < table.height() ) {
  3305. // There is y-scrolling - try to take account of the y scroll bar
  3306. tableStyle.width = _fnStringToCss( sanityWidth-barWidth );
  3307. if ( table.outerWidth() > sanityWidth-barWidth ) {
  3308. // Not possible to take account of it
  3309. tableStyle.width = _fnStringToCss( sanityWidth );
  3310. }
  3311. }
  3312. else {
  3313. // When all else fails
  3314. tableStyle.width = _fnStringToCss( sanityWidth );
  3315. }
  3316. }
  3317. // Recalculate the sanity width - now that we've applied the required width,
  3318. // before it was a temporary variable. This is required because the column
  3319. // width calculation is done before this table DOM is created.
  3320. sanityWidth = table.outerWidth();
  3321. // Hidden header should have zero height, so remove padding and borders. Then
  3322. // set the width based on the real headers
  3323. // Apply all styles in one pass
  3324. _fnApplyToChildren( zeroOut, headerSrcEls );
  3325. // Read all widths in next pass
  3326. _fnApplyToChildren( function(nSizer) {
  3327. headerContent.push( nSizer.innerHTML );
  3328. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3329. }, headerSrcEls );
  3330. // Apply all widths in final pass
  3331. _fnApplyToChildren( function(nToSize, i) {
  3332. nToSize.style.width = headerWidths[i];
  3333. }, headerTrgEls );
  3334. $(headerSrcEls).height(0);
  3335. /* Same again with the footer if we have one */
  3336. if ( footer )
  3337. {
  3338. _fnApplyToChildren( zeroOut, footerSrcEls );
  3339. _fnApplyToChildren( function(nSizer) {
  3340. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3341. }, footerSrcEls );
  3342. _fnApplyToChildren( function(nToSize, i) {
  3343. nToSize.style.width = footerWidths[i];
  3344. }, footerTrgEls );
  3345. $(footerSrcEls).height(0);
  3346. }
  3347. /*
  3348. * 3. Apply the measurements
  3349. */
  3350. // "Hide" the header and footer that we used for the sizing. We need to keep
  3351. // the content of the cell so that the width applied to the header and body
  3352. // both match, but we want to hide it completely. We want to also fix their
  3353. // width to what they currently are
  3354. _fnApplyToChildren( function(nSizer, i) {
  3355. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  3356. nSizer.style.width = headerWidths[i];
  3357. }, headerSrcEls );
  3358. if ( footer )
  3359. {
  3360. _fnApplyToChildren( function(nSizer, i) {
  3361. nSizer.innerHTML = "";
  3362. nSizer.style.width = footerWidths[i];
  3363. }, footerSrcEls );
  3364. }
  3365. // Sanity check that the table is of a sensible width. If not then we are going to get
  3366. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  3367. if ( table.outerWidth() < sanityWidth )
  3368. {
  3369. // The min width depends upon if we have a vertical scrollbar visible or not */
  3370. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  3371. divBody.css('overflow-y') == "scroll")) ?
  3372. sanityWidth+barWidth :
  3373. sanityWidth;
  3374. // IE6/7 are a law unto themselves...
  3375. if ( ie67 && (divBodyEl.scrollHeight >
  3376. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  3377. ) {
  3378. tableStyle.width = _fnStringToCss( correction-barWidth );
  3379. }
  3380. // And give the user a warning that we've stopped the table getting too small
  3381. if ( scrollX === "" || scrollXInner !== "" ) {
  3382. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  3383. }
  3384. }
  3385. else
  3386. {
  3387. correction = '100%';
  3388. }
  3389. // Apply to the container elements
  3390. divBodyStyle.width = _fnStringToCss( correction );
  3391. divHeaderStyle.width = _fnStringToCss( correction );
  3392. if ( footer ) {
  3393. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  3394. }
  3395. /*
  3396. * 4. Clean up
  3397. */
  3398. if ( ! scrollY ) {
  3399. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  3400. * the scrollbar height from the visible display, rather than adding it on. We need to
  3401. * set the height in order to sort this. Don't want to do it in any other browsers.
  3402. */
  3403. if ( ie67 ) {
  3404. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  3405. }
  3406. }
  3407. if ( scrollY && scroll.bCollapse ) {
  3408. divBodyStyle.height = _fnStringToCss( scrollY );
  3409. var iExtra = (scrollX && tableEl.offsetWidth > divBodyEl.offsetWidth) ?
  3410. barWidth :
  3411. 0;
  3412. if ( tableEl.offsetHeight < divBodyEl.offsetHeight ) {
  3413. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+iExtra );
  3414. }
  3415. }
  3416. /* Finally set the width's of the header and footer tables */
  3417. var iOuterWidth = table.outerWidth();
  3418. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  3419. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  3420. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  3421. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  3422. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  3423. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  3424. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  3425. if ( footer ) {
  3426. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  3427. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  3428. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  3429. }
  3430. /* Adjust the position of the header in case we loose the y-scrollbar */
  3431. divBody.scroll();
  3432. // If sorting or filtering has occurred, jump the scrolling back to the top
  3433. // only if we aren't holding the position
  3434. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  3435. divBodyEl.scrollTop = 0;
  3436. }
  3437. }
  3438. /**
  3439. * Apply a given function to the display child nodes of an element array (typically
  3440. * TD children of TR rows
  3441. * @param {function} fn Method to apply to the objects
  3442. * @param array {nodes} an1 List of elements to look through for display children
  3443. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  3444. * @memberof DataTable#oApi
  3445. */
  3446. function _fnApplyToChildren( fn, an1, an2 )
  3447. {
  3448. var index=0, i=0, iLen=an1.length;
  3449. var nNode1, nNode2;
  3450. while ( i < iLen ) {
  3451. nNode1 = an1[i].firstChild;
  3452. nNode2 = an2 ? an2[i].firstChild : null;
  3453. while ( nNode1 ) {
  3454. if ( nNode1.nodeType === 1 ) {
  3455. if ( an2 ) {
  3456. fn( nNode1, nNode2, index );
  3457. }
  3458. else {
  3459. fn( nNode1, index );
  3460. }
  3461. index++;
  3462. }
  3463. nNode1 = nNode1.nextSibling;
  3464. nNode2 = an2 ? nNode2.nextSibling : null;
  3465. }
  3466. i++;
  3467. }
  3468. }
  3469. var __re_html_remove = /<.*?>/g;
  3470. /**
  3471. * Calculate the width of columns for the table
  3472. * @param {object} oSettings dataTables settings object
  3473. * @memberof DataTable#oApi
  3474. */
  3475. function _fnCalculateColumnWidths ( oSettings )
  3476. {
  3477. var
  3478. table = oSettings.nTable,
  3479. columns = oSettings.aoColumns,
  3480. scroll = oSettings.oScroll,
  3481. scrollY = scroll.sY,
  3482. scrollX = scroll.sX,
  3483. scrollXInner = scroll.sXInner,
  3484. columnCount = columns.length,
  3485. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  3486. headerCells = $('th', oSettings.nTHead),
  3487. tableWidthAttr = table.style.width || table.getAttribute('width'), // from DOM element
  3488. tableContainer = table.parentNode,
  3489. userInputs = false,
  3490. i, column, columnIdx, width, outerWidth;
  3491. /* Convert any user input sizes into pixel sizes */
  3492. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3493. column = columns[ visibleColumns[i] ];
  3494. if ( column.sWidth !== null ) {
  3495. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  3496. userInputs = true;
  3497. }
  3498. }
  3499. /* If the number of columns in the DOM equals the number that we have to
  3500. * process in DataTables, then we can use the offsets that are created by
  3501. * the web- browser. No custom sizes can be set in order for this to happen,
  3502. * nor scrolling used
  3503. */
  3504. if ( ! userInputs && ! scrollX && ! scrollY &&
  3505. columnCount == _fnVisbleColumns( oSettings ) &&
  3506. columnCount == headerCells.length
  3507. ) {
  3508. for ( i=0 ; i<columnCount ; i++ ) {
  3509. columns[i].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  3510. }
  3511. }
  3512. else
  3513. {
  3514. // Otherwise construct a single row table with the widest node in the
  3515. // data, assign any user defined widths, then insert it into the DOM and
  3516. // allow the browser to do all the hard work of calculating table widths
  3517. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  3518. .empty()
  3519. .css( 'visibility', 'hidden' )
  3520. .removeAttr( 'id' )
  3521. .append( $(oSettings.nTHead).clone( false ) )
  3522. .append( $(oSettings.nTFoot).clone( false ) )
  3523. .append( $('<tbody><tr/></tbody>') );
  3524. // Remove any assigned widths from the footer (from scrolling)
  3525. tmpTable.find('tfoot th, tfoot td').css('width', '');
  3526. var tr = tmpTable.find( 'tbody tr' );
  3527. // Apply custom sizing to the cloned header
  3528. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  3529. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3530. column = columns[ visibleColumns[i] ];
  3531. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  3532. _fnStringToCss( column.sWidthOrig ) :
  3533. '';
  3534. }
  3535. // Find the widest cell for each column and put it into the table
  3536. if ( oSettings.aoData.length ) {
  3537. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3538. columnIdx = visibleColumns[i];
  3539. column = columns[ columnIdx ];
  3540. $( _fnGetWidestNode( oSettings, columnIdx ) )
  3541. .clone( false )
  3542. .append( column.sContentPadding )
  3543. .appendTo( tr );
  3544. }
  3545. }
  3546. // Table has been built, attach to the document so we can work with it
  3547. tmpTable.appendTo( tableContainer );
  3548. // When scrolling (X or Y) we want to set the width of the table as
  3549. // appropriate. However, when not scrolling leave the table width as it
  3550. // is. This results in slightly different, but I think correct behaviour
  3551. if ( scrollX && scrollXInner ) {
  3552. tmpTable.width( scrollXInner );
  3553. }
  3554. else if ( scrollX ) {
  3555. tmpTable.css( 'width', 'auto' );
  3556. if ( tmpTable.width() < tableContainer.offsetWidth ) {
  3557. tmpTable.width( tableContainer.offsetWidth );
  3558. }
  3559. }
  3560. else if ( scrollY ) {
  3561. tmpTable.width( tableContainer.offsetWidth );
  3562. }
  3563. else if ( tableWidthAttr ) {
  3564. tmpTable.width( tableWidthAttr );
  3565. }
  3566. // Take into account the y scrollbar
  3567. _fnScrollingWidthAdjust( oSettings, tmpTable[0] );
  3568. // Browsers need a bit of a hand when a width is assigned to any columns
  3569. // when x-scrolling as they tend to collapse the table to the min-width,
  3570. // even if we sent the column widths. So we need to keep track of what
  3571. // the table width should be by summing the user given values, and the
  3572. // automatic values
  3573. if ( scrollX )
  3574. {
  3575. var total = 0;
  3576. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3577. column = columns[ visibleColumns[i] ];
  3578. outerWidth = $(headerCells[i]).outerWidth();
  3579. total += column.sWidthOrig === null ?
  3580. outerWidth :
  3581. parseInt( column.sWidth, 10 ) + outerWidth - $(headerCells[i]).width();
  3582. }
  3583. tmpTable.width( _fnStringToCss( total ) );
  3584. table.style.width = _fnStringToCss( total );
  3585. }
  3586. // Get the width of each column in the constructed table
  3587. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3588. column = columns[ visibleColumns[i] ];
  3589. width = $(headerCells[i]).width();
  3590. if ( width ) {
  3591. column.sWidth = _fnStringToCss( width );
  3592. }
  3593. }
  3594. table.style.width = _fnStringToCss( tmpTable.css('width') );
  3595. // Finished with the table - ditch it
  3596. tmpTable.remove();
  3597. }
  3598. // If there is a width attr, we want to attach an event listener which
  3599. // allows the table sizing to automatically adjust when the window is
  3600. // resized. Use the width attr rather than CSS, since we can't know if the
  3601. // CSS is a relative value or absolute - DOM read is always px.
  3602. if ( tableWidthAttr ) {
  3603. table.style.width = _fnStringToCss( tableWidthAttr );
  3604. }
  3605. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  3606. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  3607. _fnAdjustColumnSizing( oSettings );
  3608. } ) );
  3609. oSettings._reszEvt = true;
  3610. }
  3611. }
  3612. /**
  3613. * Throttle the calls to a function. Arguments and context are maintained for
  3614. * the throttled function
  3615. * @param {function} fn Function to be called
  3616. * @param {int} [freq=200] call frequency in mS
  3617. * @returns {function} wrapped function
  3618. * @memberof DataTable#oApi
  3619. */
  3620. function _fnThrottle( fn, freq ) {
  3621. var
  3622. frequency = freq !== undefined ? freq : 200,
  3623. last,
  3624. timer;
  3625. return function () {
  3626. var
  3627. that = this,
  3628. now = +new Date(),
  3629. args = arguments;
  3630. if ( last && now < last + frequency ) {
  3631. clearTimeout( timer );
  3632. timer = setTimeout( function () {
  3633. last = undefined;
  3634. fn.apply( that, args );
  3635. }, frequency );
  3636. }
  3637. else {
  3638. last = now;
  3639. fn.apply( that, args );
  3640. }
  3641. };
  3642. }
  3643. /**
  3644. * Convert a CSS unit width to pixels (e.g. 2em)
  3645. * @param {string} width width to be converted
  3646. * @param {node} parent parent to get the with for (required for relative widths) - optional
  3647. * @returns {int} width in pixels
  3648. * @memberof DataTable#oApi
  3649. */
  3650. function _fnConvertToWidth ( width, parent )
  3651. {
  3652. if ( ! width ) {
  3653. return 0;
  3654. }
  3655. var n = $('<div/>')
  3656. .css( 'width', _fnStringToCss( width ) )
  3657. .appendTo( parent || document.body );
  3658. var val = n[0].offsetWidth;
  3659. n.remove();
  3660. return val;
  3661. }
  3662. /**
  3663. * Adjust a table's width to take account of vertical scroll bar
  3664. * @param {object} oSettings dataTables settings object
  3665. * @param {node} n table node
  3666. * @memberof DataTable#oApi
  3667. */
  3668. function _fnScrollingWidthAdjust ( settings, n )
  3669. {
  3670. var scroll = settings.oScroll;
  3671. if ( scroll.sX || scroll.sY ) {
  3672. // When y-scrolling only, we want to remove the width of the scroll bar
  3673. // so the table + scroll bar will fit into the area available, otherwise
  3674. // we fix the table at its current size with no adjustment
  3675. var correction = ! scroll.sX ? scroll.iBarWidth : 0;
  3676. n.style.width = _fnStringToCss( $(n).outerWidth() - correction );
  3677. }
  3678. }
  3679. /**
  3680. * Get the widest node
  3681. * @param {object} settings dataTables settings object
  3682. * @param {int} colIdx column of interest
  3683. * @returns {node} widest table node
  3684. * @memberof DataTable#oApi
  3685. */
  3686. function _fnGetWidestNode( settings, colIdx )
  3687. {
  3688. var idx = _fnGetMaxLenString( settings, colIdx );
  3689. if ( idx < 0 ) {
  3690. return null;
  3691. }
  3692. var data = settings.aoData[ idx ];
  3693. return ! data.nTr ? // Might not have been created when deferred rendering
  3694. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  3695. data.anCells[ colIdx ];
  3696. }
  3697. /**
  3698. * Get the maximum strlen for each data column
  3699. * @param {object} settings dataTables settings object
  3700. * @param {int} colIdx column of interest
  3701. * @returns {string} max string length for each column
  3702. * @memberof DataTable#oApi
  3703. */
  3704. function _fnGetMaxLenString( settings, colIdx )
  3705. {
  3706. var s, max=-1, maxIdx = -1;
  3707. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3708. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  3709. s = s.replace( __re_html_remove, '' );
  3710. if ( s.length > max ) {
  3711. max = s.length;
  3712. maxIdx = i;
  3713. }
  3714. }
  3715. return maxIdx;
  3716. }
  3717. /**
  3718. * Append a CSS unit (only if required) to a string
  3719. * @param {string} value to css-ify
  3720. * @returns {string} value with css unit
  3721. * @memberof DataTable#oApi
  3722. */
  3723. function _fnStringToCss( s )
  3724. {
  3725. if ( s === null ) {
  3726. return '0px';
  3727. }
  3728. if ( typeof s == 'number' ) {
  3729. return s < 0 ?
  3730. '0px' :
  3731. s+'px';
  3732. }
  3733. // Check it has a unit character already
  3734. return s.match(/\d$/) ?
  3735. s+'px' :
  3736. s;
  3737. }
  3738. /**
  3739. * Get the width of a scroll bar in this browser being used
  3740. * @returns {int} width in pixels
  3741. * @memberof DataTable#oApi
  3742. */
  3743. function _fnScrollBarWidth ()
  3744. {
  3745. // On first run a static variable is set, since this is only needed once.
  3746. // Subsequent runs will just use the previously calculated value
  3747. if ( ! DataTable.__scrollbarWidth ) {
  3748. var inner = $('<p/>').css( {
  3749. width: '100%',
  3750. height: 200,
  3751. padding: 0
  3752. } )[0];
  3753. var outer = $('<div/>')
  3754. .css( {
  3755. position: 'absolute',
  3756. top: 0,
  3757. left: 0,
  3758. width: 200,
  3759. height: 150,
  3760. padding: 0,
  3761. overflow: 'hidden',
  3762. visibility: 'hidden'
  3763. } )
  3764. .append( inner )
  3765. .appendTo( 'body' );
  3766. var w1 = inner.offsetWidth;
  3767. outer.css( 'overflow', 'scroll' );
  3768. var w2 = inner.offsetWidth;
  3769. if ( w1 === w2 ) {
  3770. w2 = outer[0].clientWidth;
  3771. }
  3772. outer.remove();
  3773. DataTable.__scrollbarWidth = w1 - w2;
  3774. }
  3775. return DataTable.__scrollbarWidth;
  3776. }
  3777. function _fnSortFlatten ( settings )
  3778. {
  3779. var
  3780. i, iLen, k, kLen,
  3781. aSort = [],
  3782. aiOrig = [],
  3783. aoColumns = settings.aoColumns,
  3784. aDataSort, iCol, sType, srcCol,
  3785. fixed = settings.aaSortingFixed,
  3786. fixedObj = $.isPlainObject( fixed ),
  3787. nestedSort = [],
  3788. add = function ( a ) {
  3789. if ( a.length && ! $.isArray( a[0] ) ) {
  3790. // 1D array
  3791. nestedSort.push( a );
  3792. }
  3793. else {
  3794. // 2D array
  3795. nestedSort.push.apply( nestedSort, a );
  3796. }
  3797. };
  3798. // Build the sort array, with pre-fix and post-fix options if they have been
  3799. // specified
  3800. if ( $.isArray( fixed ) ) {
  3801. add( fixed );
  3802. }
  3803. if ( fixedObj && fixed.pre ) {
  3804. add( fixed.pre );
  3805. }
  3806. add( settings.aaSorting );
  3807. if (fixedObj && fixed.post ) {
  3808. add( fixed.post );
  3809. }
  3810. for ( i=0 ; i<nestedSort.length ; i++ )
  3811. {
  3812. srcCol = nestedSort[i][0];
  3813. aDataSort = aoColumns[ srcCol ].aDataSort;
  3814. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  3815. {
  3816. iCol = aDataSort[k];
  3817. sType = aoColumns[ iCol ].sType || 'string';
  3818. if ( nestedSort[i]._idx === undefined ) {
  3819. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  3820. }
  3821. aSort.push( {
  3822. src: srcCol,
  3823. col: iCol,
  3824. dir: nestedSort[i][1],
  3825. index: nestedSort[i]._idx,
  3826. type: sType,
  3827. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  3828. } );
  3829. }
  3830. }
  3831. return aSort;
  3832. }
  3833. /**
  3834. * Change the order of the table
  3835. * @param {object} oSettings dataTables settings object
  3836. * @memberof DataTable#oApi
  3837. * @todo This really needs split up!
  3838. */
  3839. function _fnSort ( oSettings )
  3840. {
  3841. var
  3842. i, ien, iLen, j, jLen, k, kLen,
  3843. sDataType, nTh,
  3844. aiOrig = [],
  3845. oExtSort = DataTable.ext.type.order,
  3846. aoData = oSettings.aoData,
  3847. aoColumns = oSettings.aoColumns,
  3848. aDataSort, data, iCol, sType, oSort,
  3849. formatters = 0,
  3850. sortCol,
  3851. displayMaster = oSettings.aiDisplayMaster,
  3852. aSort;
  3853. // Resolve any column types that are unknown due to addition or invalidation
  3854. // @todo Can this be moved into a 'data-ready' handler which is called when
  3855. // data is going to be used in the table?
  3856. _fnColumnTypes( oSettings );
  3857. aSort = _fnSortFlatten( oSettings );
  3858. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  3859. sortCol = aSort[i];
  3860. // Track if we can use the fast sort algorithm
  3861. if ( sortCol.formatter ) {
  3862. formatters++;
  3863. }
  3864. // Load the data needed for the sort, for each cell
  3865. _fnSortData( oSettings, sortCol.col );
  3866. }
  3867. /* No sorting required if server-side or no sorting array */
  3868. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  3869. {
  3870. // Create a value - key array of the current row positions such that we can use their
  3871. // current position during the sort, if values match, in order to perform stable sorting
  3872. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  3873. aiOrig[ displayMaster[i] ] = i;
  3874. }
  3875. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  3876. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  3877. * follow on it's own, but this is what we want (example two column sorting):
  3878. * fnLocalSorting = function(a,b){
  3879. * var iTest;
  3880. * iTest = oSort['string-asc']('data11', 'data12');
  3881. * if (iTest !== 0)
  3882. * return iTest;
  3883. * iTest = oSort['numeric-desc']('data21', 'data22');
  3884. * if (iTest !== 0)
  3885. * return iTest;
  3886. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  3887. * }
  3888. * Basically we have a test for each sorting column, if the data in that column is equal,
  3889. * test the next column. If all columns match, then we use a numeric sort on the row
  3890. * positions in the original data array to provide a stable sort.
  3891. *
  3892. * Note - I know it seems excessive to have two sorting methods, but the first is around
  3893. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  3894. * methods which do not have a pre-sort formatting function.
  3895. */
  3896. if ( formatters === aSort.length ) {
  3897. // All sort types have formatting functions
  3898. displayMaster.sort( function ( a, b ) {
  3899. var
  3900. x, y, k, test, sort,
  3901. len=aSort.length,
  3902. dataA = aoData[a]._aSortData,
  3903. dataB = aoData[b]._aSortData;
  3904. for ( k=0 ; k<len ; k++ ) {
  3905. sort = aSort[k];
  3906. x = dataA[ sort.col ];
  3907. y = dataB[ sort.col ];
  3908. test = x<y ? -1 : x>y ? 1 : 0;
  3909. if ( test !== 0 ) {
  3910. return sort.dir === 'asc' ? test : -test;
  3911. }
  3912. }
  3913. x = aiOrig[a];
  3914. y = aiOrig[b];
  3915. return x<y ? -1 : x>y ? 1 : 0;
  3916. } );
  3917. }
  3918. else {
  3919. // Depreciated - remove in 1.11 (providing a plug-in option)
  3920. // Not all sort types have formatting methods, so we have to call their sorting
  3921. // methods.
  3922. displayMaster.sort( function ( a, b ) {
  3923. var
  3924. x, y, k, l, test, sort, fn,
  3925. len=aSort.length,
  3926. dataA = aoData[a]._aSortData,
  3927. dataB = aoData[b]._aSortData;
  3928. for ( k=0 ; k<len ; k++ ) {
  3929. sort = aSort[k];
  3930. x = dataA[ sort.col ];
  3931. y = dataB[ sort.col ];
  3932. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  3933. test = fn( x, y );
  3934. if ( test !== 0 ) {
  3935. return test;
  3936. }
  3937. }
  3938. x = aiOrig[a];
  3939. y = aiOrig[b];
  3940. return x<y ? -1 : x>y ? 1 : 0;
  3941. } );
  3942. }
  3943. }
  3944. /* Tell the draw function that we have sorted the data */
  3945. oSettings.bSorted = true;
  3946. }
  3947. function _fnSortAria ( settings )
  3948. {
  3949. var label;
  3950. var nextSort;
  3951. var columns = settings.aoColumns;
  3952. var aSort = _fnSortFlatten( settings );
  3953. var oAria = settings.oLanguage.oAria;
  3954. // ARIA attributes - need to loop all columns, to update all (removing old
  3955. // attributes as needed)
  3956. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  3957. {
  3958. var col = columns[i];
  3959. var asSorting = col.asSorting;
  3960. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  3961. var th = col.nTh;
  3962. // IE7 is throwing an error when setting these properties with jQuery's
  3963. // attr() and removeAttr() methods...
  3964. th.removeAttribute('aria-sort');
  3965. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  3966. if ( col.bSortable ) {
  3967. if ( aSort.length > 0 && aSort[0].col == i ) {
  3968. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  3969. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  3970. }
  3971. else {
  3972. nextSort = asSorting[0];
  3973. }
  3974. label = sTitle + ( nextSort === "asc" ?
  3975. oAria.sSortAscending :
  3976. oAria.sSortDescending
  3977. );
  3978. }
  3979. else {
  3980. label = sTitle;
  3981. }
  3982. th.setAttribute('aria-label', label);
  3983. }
  3984. }
  3985. /**
  3986. * Function to run on user sort request
  3987. * @param {object} settings dataTables settings object
  3988. * @param {node} attachTo node to attach the handler to
  3989. * @param {int} colIdx column sorting index
  3990. * @param {boolean} [append=false] Append the requested sort to the existing
  3991. * sort if true (i.e. multi-column sort)
  3992. * @param {function} [callback] callback function
  3993. * @memberof DataTable#oApi
  3994. */
  3995. function _fnSortListener ( settings, colIdx, append, callback )
  3996. {
  3997. var col = settings.aoColumns[ colIdx ];
  3998. var sorting = settings.aaSorting;
  3999. var asSorting = col.asSorting;
  4000. var nextSortIdx;
  4001. var next = function ( a, overflow ) {
  4002. var idx = a._idx;
  4003. if ( idx === undefined ) {
  4004. idx = $.inArray( a[1], asSorting );
  4005. }
  4006. return idx+1 < asSorting.length ?
  4007. idx+1 :
  4008. overflow ?
  4009. null :
  4010. 0;
  4011. };
  4012. // Convert to 2D array if needed
  4013. if ( typeof sorting[0] === 'number' ) {
  4014. sorting = settings.aaSorting = [ sorting ];
  4015. }
  4016. // If appending the sort then we are multi-column sorting
  4017. if ( append && settings.oFeatures.bSortMulti ) {
  4018. // Are we already doing some kind of sort on this column?
  4019. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  4020. if ( sortIdx !== -1 ) {
  4021. // Yes, modify the sort
  4022. nextSortIdx = next( sorting[sortIdx], true );
  4023. if ( nextSortIdx === null ) {
  4024. sorting.splice( sortIdx, 1 );
  4025. }
  4026. else {
  4027. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  4028. sorting[sortIdx]._idx = nextSortIdx;
  4029. }
  4030. }
  4031. else {
  4032. // No sort on this column yet
  4033. sorting.push( [ colIdx, asSorting[0], 0 ] );
  4034. sorting[sorting.length-1]._idx = 0;
  4035. }
  4036. }
  4037. else if ( sorting.length && sorting[0][0] == colIdx ) {
  4038. // Single column - already sorting on this column, modify the sort
  4039. nextSortIdx = next( sorting[0] );
  4040. sorting.length = 1;
  4041. sorting[0][1] = asSorting[ nextSortIdx ];
  4042. sorting[0]._idx = nextSortIdx;
  4043. }
  4044. else {
  4045. // Single column - sort only on this column
  4046. sorting.length = 0;
  4047. sorting.push( [ colIdx, asSorting[0] ] );
  4048. sorting[0]._idx = 0;
  4049. }
  4050. // Run the sort by calling a full redraw
  4051. _fnReDraw( settings );
  4052. // callback used for async user interaction
  4053. if ( typeof callback == 'function' ) {
  4054. callback( settings );
  4055. }
  4056. }
  4057. /**
  4058. * Attach a sort handler (click) to a node
  4059. * @param {object} settings dataTables settings object
  4060. * @param {node} attachTo node to attach the handler to
  4061. * @param {int} colIdx column sorting index
  4062. * @param {function} [callback] callback function
  4063. * @memberof DataTable#oApi
  4064. */
  4065. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  4066. {
  4067. var col = settings.aoColumns[ colIdx ];
  4068. _fnBindAction( attachTo, {}, function (e) {
  4069. /* If the column is not sortable - don't to anything */
  4070. if ( col.bSortable === false ) {
  4071. return;
  4072. }
  4073. // If processing is enabled use a timeout to allow the processing
  4074. // display to be shown - otherwise to it synchronously
  4075. if ( settings.oFeatures.bProcessing ) {
  4076. _fnProcessingDisplay( settings, true );
  4077. setTimeout( function() {
  4078. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4079. // In server-side processing, the draw callback will remove the
  4080. // processing display
  4081. if ( _fnDataSource( settings ) !== 'ssp' ) {
  4082. _fnProcessingDisplay( settings, false );
  4083. }
  4084. }, 0 );
  4085. }
  4086. else {
  4087. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4088. }
  4089. } );
  4090. }
  4091. /**
  4092. * Set the sorting classes on table's body, Note: it is safe to call this function
  4093. * when bSort and bSortClasses are false
  4094. * @param {object} oSettings dataTables settings object
  4095. * @memberof DataTable#oApi
  4096. */
  4097. function _fnSortingClasses( settings )
  4098. {
  4099. var oldSort = settings.aLastSort;
  4100. var sortClass = settings.oClasses.sSortColumn;
  4101. var sort = _fnSortFlatten( settings );
  4102. var features = settings.oFeatures;
  4103. var i, ien, colIdx;
  4104. if ( features.bSort && features.bSortClasses ) {
  4105. // Remove old sorting classes
  4106. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  4107. colIdx = oldSort[i].src;
  4108. // Remove column sorting
  4109. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4110. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  4111. }
  4112. // Add new column sorting
  4113. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  4114. colIdx = sort[i].src;
  4115. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4116. .addClass( sortClass + (i<2 ? i+1 : 3) );
  4117. }
  4118. }
  4119. settings.aLastSort = sort;
  4120. }
  4121. // Get the data to sort a column, be it from cache, fresh (populating the
  4122. // cache), or from a sort formatter
  4123. function _fnSortData( settings, idx )
  4124. {
  4125. // Custom sorting function - provided by the sort data type
  4126. var column = settings.aoColumns[ idx ];
  4127. var customSort = DataTable.ext.order[ column.sSortDataType ];
  4128. var customData;
  4129. if ( customSort ) {
  4130. customData = customSort.call( settings.oInstance, settings, idx,
  4131. _fnColumnIndexToVisible( settings, idx )
  4132. );
  4133. }
  4134. // Use / populate cache
  4135. var row, cellData;
  4136. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  4137. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4138. row = settings.aoData[i];
  4139. if ( ! row._aSortData ) {
  4140. row._aSortData = [];
  4141. }
  4142. if ( ! row._aSortData[idx] || customSort ) {
  4143. cellData = customSort ?
  4144. customData[i] : // If there was a custom sort function, use data from there
  4145. _fnGetCellData( settings, i, idx, 'sort' );
  4146. row._aSortData[ idx ] = formatter ?
  4147. formatter( cellData ) :
  4148. cellData;
  4149. }
  4150. }
  4151. }
  4152. /**
  4153. * Save the state of a table
  4154. * @param {object} oSettings dataTables settings object
  4155. * @memberof DataTable#oApi
  4156. */
  4157. function _fnSaveState ( settings )
  4158. {
  4159. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  4160. {
  4161. return;
  4162. }
  4163. /* Store the interesting variables */
  4164. var state = {
  4165. time: +new Date(),
  4166. start: settings._iDisplayStart,
  4167. length: settings._iDisplayLength,
  4168. order: $.extend( true, [], settings.aaSorting ),
  4169. search: _fnSearchToCamel( settings.oPreviousSearch ),
  4170. columns: $.map( settings.aoColumns, function ( col, i ) {
  4171. return {
  4172. visible: col.bVisible,
  4173. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  4174. };
  4175. } )
  4176. };
  4177. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  4178. settings.oSavedState = state;
  4179. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  4180. }
  4181. /**
  4182. * Attempt to load a saved table state
  4183. * @param {object} oSettings dataTables settings object
  4184. * @param {object} oInit DataTables init object so we can override settings
  4185. * @memberof DataTable#oApi
  4186. */
  4187. function _fnLoadState ( settings, oInit )
  4188. {
  4189. var i, ien;
  4190. var columns = settings.aoColumns;
  4191. if ( ! settings.oFeatures.bStateSave ) {
  4192. return;
  4193. }
  4194. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings );
  4195. if ( ! state || ! state.time ) {
  4196. return;
  4197. }
  4198. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  4199. * cancelling of loading by returning false
  4200. */
  4201. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state] );
  4202. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  4203. return;
  4204. }
  4205. /* Reject old data */
  4206. var duration = settings.iStateDuration;
  4207. if ( duration > 0 && state.time < +new Date() - (duration*1000) ) {
  4208. return;
  4209. }
  4210. // Number of columns have changed - all bets are off, no restore of settings
  4211. if ( columns.length !== state.columns.length ) {
  4212. return;
  4213. }
  4214. // Store the saved state so it might be accessed at any time
  4215. settings.oLoadedState = $.extend( true, {}, state );
  4216. // Restore key features - todo - for 1.11 this needs to be done by
  4217. // subscribed events
  4218. settings._iDisplayStart = state.start;
  4219. settings.iInitDisplayStart = state.start;
  4220. settings._iDisplayLength = state.length;
  4221. settings.aaSorting = [];
  4222. // Order
  4223. $.each( state.order, function ( i, col ) {
  4224. settings.aaSorting.push( col[0] >= columns.length ?
  4225. [ 0, col[1] ] :
  4226. col
  4227. );
  4228. } );
  4229. // Search
  4230. $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) );
  4231. // Columns
  4232. for ( i=0, ien=state.columns.length ; i<ien ; i++ ) {
  4233. var col = state.columns[i];
  4234. // Visibility
  4235. columns[i].bVisible = col.visible;
  4236. // Search
  4237. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  4238. }
  4239. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, state] );
  4240. }
  4241. /**
  4242. * Return the settings object for a particular table
  4243. * @param {node} table table we are using as a dataTable
  4244. * @returns {object} Settings object - or null if not found
  4245. * @memberof DataTable#oApi
  4246. */
  4247. function _fnSettingsFromNode ( table )
  4248. {
  4249. var settings = DataTable.settings;
  4250. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  4251. return idx !== -1 ?
  4252. settings[ idx ] :
  4253. null;
  4254. }
  4255. /**
  4256. * Log an error message
  4257. * @param {object} settings dataTables settings object
  4258. * @param {int} level log error messages, or display them to the user
  4259. * @param {string} msg error message
  4260. * @param {int} tn Technical note id to get more information about the error.
  4261. * @memberof DataTable#oApi
  4262. */
  4263. function _fnLog( settings, level, msg, tn )
  4264. {
  4265. msg = 'DataTables warning: '+
  4266. (settings!==null ? 'table id='+settings.sTableId+' - ' : '')+msg;
  4267. if ( tn ) {
  4268. msg += '. For more information about this error, please see '+
  4269. 'http://datatables.net/tn/'+tn;
  4270. }
  4271. if ( ! level ) {
  4272. // Backwards compatibility pre 1.10
  4273. var ext = DataTable.ext;
  4274. var type = ext.sErrMode || ext.errMode;
  4275. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  4276. if ( type == 'alert' ) {
  4277. alert( msg );
  4278. }
  4279. else if ( type == 'throw' ) {
  4280. throw new Error(msg);
  4281. }
  4282. else if ( typeof type == 'function' ) {
  4283. type( settings, tn, msg );
  4284. }
  4285. }
  4286. else if ( window.console && console.log ) {
  4287. console.log( msg );
  4288. }
  4289. }
  4290. /**
  4291. * See if a property is defined on one object, if so assign it to the other object
  4292. * @param {object} ret target object
  4293. * @param {object} src source object
  4294. * @param {string} name property
  4295. * @param {string} [mappedName] name to map too - optional, name used if not given
  4296. * @memberof DataTable#oApi
  4297. */
  4298. function _fnMap( ret, src, name, mappedName )
  4299. {
  4300. if ( $.isArray( name ) ) {
  4301. $.each( name, function (i, val) {
  4302. if ( $.isArray( val ) ) {
  4303. _fnMap( ret, src, val[0], val[1] );
  4304. }
  4305. else {
  4306. _fnMap( ret, src, val );
  4307. }
  4308. } );
  4309. return;
  4310. }
  4311. if ( mappedName === undefined ) {
  4312. mappedName = name;
  4313. }
  4314. if ( src[name] !== undefined ) {
  4315. ret[mappedName] = src[name];
  4316. }
  4317. }
  4318. /**
  4319. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  4320. * shallow copy arrays. The reason we need to do this, is that we don't want to
  4321. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  4322. * able to override them, but we do want to deep copy arrays.
  4323. * @param {object} out Object to extend
  4324. * @param {object} extender Object from which the properties will be applied to
  4325. * out
  4326. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  4327. * independent copy with the exception of the `data` or `aaData` parameters
  4328. * if they are present. This is so you can pass in a collection to
  4329. * DataTables and have that used as your data source without breaking the
  4330. * references
  4331. * @returns {object} out Reference, just for convenience - out === the return.
  4332. * @memberof DataTable#oApi
  4333. * @todo This doesn't take account of arrays inside the deep copied objects.
  4334. */
  4335. function _fnExtend( out, extender, breakRefs )
  4336. {
  4337. var val;
  4338. for ( var prop in extender ) {
  4339. if ( extender.hasOwnProperty(prop) ) {
  4340. val = extender[prop];
  4341. if ( $.isPlainObject( val ) ) {
  4342. if ( ! $.isPlainObject( out[prop] ) ) {
  4343. out[prop] = {};
  4344. }
  4345. $.extend( true, out[prop], val );
  4346. }
  4347. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  4348. out[prop] = val.slice();
  4349. }
  4350. else {
  4351. out[prop] = val;
  4352. }
  4353. }
  4354. }
  4355. return out;
  4356. }
  4357. /**
  4358. * Bind an event handers to allow a click or return key to activate the callback.
  4359. * This is good for accessibility since a return on the keyboard will have the
  4360. * same effect as a click, if the element has focus.
  4361. * @param {element} n Element to bind the action to
  4362. * @param {object} oData Data object to pass to the triggered function
  4363. * @param {function} fn Callback function for when the event is triggered
  4364. * @memberof DataTable#oApi
  4365. */
  4366. function _fnBindAction( n, oData, fn )
  4367. {
  4368. $(n)
  4369. .bind( 'click.DT', oData, function (e) {
  4370. n.blur(); // Remove focus outline for mouse users
  4371. fn(e);
  4372. } )
  4373. .bind( 'keypress.DT', oData, function (e){
  4374. if ( e.which === 13 ) {
  4375. e.preventDefault();
  4376. fn(e);
  4377. }
  4378. } )
  4379. .bind( 'selectstart.DT', function () {
  4380. /* Take the brutal approach to cancelling text selection */
  4381. return false;
  4382. } );
  4383. }
  4384. /**
  4385. * Register a callback function. Easily allows a callback function to be added to
  4386. * an array store of callback functions that can then all be called together.
  4387. * @param {object} oSettings dataTables settings object
  4388. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  4389. * @param {function} fn Function to be called back
  4390. * @param {string} sName Identifying name for the callback (i.e. a label)
  4391. * @memberof DataTable#oApi
  4392. */
  4393. function _fnCallbackReg( oSettings, sStore, fn, sName )
  4394. {
  4395. if ( fn )
  4396. {
  4397. oSettings[sStore].push( {
  4398. "fn": fn,
  4399. "sName": sName
  4400. } );
  4401. }
  4402. }
  4403. /**
  4404. * Fire callback functions and trigger events. Note that the loop over the
  4405. * callback array store is done backwards! Further note that you do not want to
  4406. * fire off triggers in time sensitive applications (for example cell creation)
  4407. * as its slow.
  4408. * @param {object} settings dataTables settings object
  4409. * @param {string} callbackArr Name of the array storage for the callbacks in
  4410. * oSettings
  4411. * @param {string} event Name of the jQuery custom event to trigger. If null no
  4412. * trigger is fired
  4413. * @param {array} args Array of arguments to pass to the callback function /
  4414. * trigger
  4415. * @memberof DataTable#oApi
  4416. */
  4417. function _fnCallbackFire( settings, callbackArr, e, args )
  4418. {
  4419. var ret = [];
  4420. if ( callbackArr ) {
  4421. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  4422. return val.fn.apply( settings.oInstance, args );
  4423. } );
  4424. }
  4425. if ( e !== null ) {
  4426. $(settings.nTable).trigger( e+'.dt', args );
  4427. }
  4428. return ret;
  4429. }
  4430. function _fnLengthOverflow ( settings )
  4431. {
  4432. var
  4433. start = settings._iDisplayStart,
  4434. end = settings.fnDisplayEnd(),
  4435. len = settings._iDisplayLength;
  4436. /* If we have space to show extra rows (backing up from the end point - then do so */
  4437. if ( start >= end )
  4438. {
  4439. start = end - len;
  4440. }
  4441. // Keep the start record on the current page
  4442. start -= (start % len);
  4443. if ( len === -1 || start < 0 )
  4444. {
  4445. start = 0;
  4446. }
  4447. settings._iDisplayStart = start;
  4448. }
  4449. function _fnRenderer( settings, type )
  4450. {
  4451. var renderer = settings.renderer;
  4452. var host = DataTable.ext.renderer[type];
  4453. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  4454. // Specific renderer for this type. If available use it, otherwise use
  4455. // the default.
  4456. return host[renderer[type]] || host._;
  4457. }
  4458. else if ( typeof renderer === 'string' ) {
  4459. // Common renderer - if there is one available for this type use it,
  4460. // otherwise use the default
  4461. return host[renderer] || host._;
  4462. }
  4463. // Use the default
  4464. return host._;
  4465. }
  4466. /**
  4467. * Detect the data source being used for the table. Used to simplify the code
  4468. * a little (ajax) and to make it compress a little smaller.
  4469. *
  4470. * @param {object} settings dataTables settings object
  4471. * @returns {string} Data source
  4472. * @memberof DataTable#oApi
  4473. */
  4474. function _fnDataSource ( settings )
  4475. {
  4476. if ( settings.oFeatures.bServerSide ) {
  4477. return 'ssp';
  4478. }
  4479. else if ( settings.ajax || settings.sAjaxSource ) {
  4480. return 'ajax';
  4481. }
  4482. return 'dom';
  4483. }
  4484. DataTable = function( options )
  4485. {
  4486. /**
  4487. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  4488. * return the resulting jQuery object.
  4489. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4490. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4491. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  4492. * criterion ("applied") or all TR elements (i.e. no filter).
  4493. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  4494. * Can be either 'current', whereby the current sorting of the table is used, or
  4495. * 'original' whereby the original order the data was read into the table is used.
  4496. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4497. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4498. * 'current' and filter is 'applied', regardless of what they might be given as.
  4499. * @returns {object} jQuery object, filtered by the given selector.
  4500. * @dtopt API
  4501. * @deprecated Since v1.10
  4502. *
  4503. * @example
  4504. * $(document).ready(function() {
  4505. * var oTable = $('#example').dataTable();
  4506. *
  4507. * // Highlight every second row
  4508. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  4509. * } );
  4510. *
  4511. * @example
  4512. * $(document).ready(function() {
  4513. * var oTable = $('#example').dataTable();
  4514. *
  4515. * // Filter to rows with 'Webkit' in them, add a background colour and then
  4516. * // remove the filter, thus highlighting the 'Webkit' rows only.
  4517. * oTable.fnFilter('Webkit');
  4518. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  4519. * oTable.fnFilter('');
  4520. * } );
  4521. */
  4522. this.$ = function ( sSelector, oOpts )
  4523. {
  4524. return this.api(true).$( sSelector, oOpts );
  4525. };
  4526. /**
  4527. * Almost identical to $ in operation, but in this case returns the data for the matched
  4528. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  4529. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  4530. * rows are found, the data returned is the original data array/object that was used to
  4531. * create the row (or a generated array if from a DOM source).
  4532. *
  4533. * This method is often useful in-combination with $ where both functions are given the
  4534. * same parameters and the array indexes will match identically.
  4535. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4536. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4537. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  4538. * criterion ("applied") or all elements (i.e. no filter).
  4539. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  4540. * Can be either 'current', whereby the current sorting of the table is used, or
  4541. * 'original' whereby the original order the data was read into the table is used.
  4542. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4543. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4544. * 'current' and filter is 'applied', regardless of what they might be given as.
  4545. * @returns {array} Data for the matched elements. If any elements, as a result of the
  4546. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  4547. * entry in the array.
  4548. * @dtopt API
  4549. * @deprecated Since v1.10
  4550. *
  4551. * @example
  4552. * $(document).ready(function() {
  4553. * var oTable = $('#example').dataTable();
  4554. *
  4555. * // Get the data from the first row in the table
  4556. * var data = oTable._('tr:first');
  4557. *
  4558. * // Do something useful with the data
  4559. * alert( "First cell is: "+data[0] );
  4560. * } );
  4561. *
  4562. * @example
  4563. * $(document).ready(function() {
  4564. * var oTable = $('#example').dataTable();
  4565. *
  4566. * // Filter to 'Webkit' and get all data for
  4567. * oTable.fnFilter('Webkit');
  4568. * var data = oTable._('tr', {"search": "applied"});
  4569. *
  4570. * // Do something with the data
  4571. * alert( data.length+" rows matched the search" );
  4572. * } );
  4573. */
  4574. this._ = function ( sSelector, oOpts )
  4575. {
  4576. return this.api(true).rows( sSelector, oOpts ).data();
  4577. };
  4578. /**
  4579. * Create a DataTables Api instance, with the currently selected tables for
  4580. * the Api's context.
  4581. * @param {boolean} [traditional=false] Set the API instance's context to be
  4582. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  4583. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  4584. * or if all tables captured in the jQuery object should be used.
  4585. * @return {DataTables.Api}
  4586. */
  4587. this.api = function ( traditional )
  4588. {
  4589. return traditional ?
  4590. new _Api(
  4591. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  4592. ) :
  4593. new _Api( this );
  4594. };
  4595. /**
  4596. * Add a single new row or multiple rows of data to the table. Please note
  4597. * that this is suitable for client-side processing only - if you are using
  4598. * server-side processing (i.e. "bServerSide": true), then to add data, you
  4599. * must add it to the data source, i.e. the server-side, through an Ajax call.
  4600. * @param {array|object} data The data to be added to the table. This can be:
  4601. * <ul>
  4602. * <li>1D array of data - add a single row with the data provided</li>
  4603. * <li>2D array of arrays - add multiple rows in a single call</li>
  4604. * <li>object - data object when using <i>mData</i></li>
  4605. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  4606. * </ul>
  4607. * @param {bool} [redraw=true] redraw the table or not
  4608. * @returns {array} An array of integers, representing the list of indexes in
  4609. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  4610. * the table.
  4611. * @dtopt API
  4612. * @deprecated Since v1.10
  4613. *
  4614. * @example
  4615. * // Global var for counter
  4616. * var giCount = 2;
  4617. *
  4618. * $(document).ready(function() {
  4619. * $('#example').dataTable();
  4620. * } );
  4621. *
  4622. * function fnClickAddRow() {
  4623. * $('#example').dataTable().fnAddData( [
  4624. * giCount+".1",
  4625. * giCount+".2",
  4626. * giCount+".3",
  4627. * giCount+".4" ]
  4628. * );
  4629. *
  4630. * giCount++;
  4631. * }
  4632. */
  4633. this.fnAddData = function( data, redraw )
  4634. {
  4635. var api = this.api( true );
  4636. /* Check if we want to add multiple rows or not */
  4637. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  4638. api.rows.add( data ) :
  4639. api.row.add( data );
  4640. if ( redraw === undefined || redraw ) {
  4641. api.draw();
  4642. }
  4643. return rows.flatten().toArray();
  4644. };
  4645. /**
  4646. * This function will make DataTables recalculate the column sizes, based on the data
  4647. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  4648. * through the sWidth parameter). This can be useful when the width of the table's
  4649. * parent element changes (for example a window resize).
  4650. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  4651. * @dtopt API
  4652. * @deprecated Since v1.10
  4653. *
  4654. * @example
  4655. * $(document).ready(function() {
  4656. * var oTable = $('#example').dataTable( {
  4657. * "sScrollY": "200px",
  4658. * "bPaginate": false
  4659. * } );
  4660. *
  4661. * $(window).bind('resize', function () {
  4662. * oTable.fnAdjustColumnSizing();
  4663. * } );
  4664. * } );
  4665. */
  4666. this.fnAdjustColumnSizing = function ( bRedraw )
  4667. {
  4668. var api = this.api( true ).columns.adjust();
  4669. var settings = api.settings()[0];
  4670. var scroll = settings.oScroll;
  4671. if ( bRedraw === undefined || bRedraw ) {
  4672. api.draw( false );
  4673. }
  4674. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  4675. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  4676. _fnScrollDraw( settings );
  4677. }
  4678. };
  4679. /**
  4680. * Quickly and simply clear a table
  4681. * @param {bool} [bRedraw=true] redraw the table or not
  4682. * @dtopt API
  4683. * @deprecated Since v1.10
  4684. *
  4685. * @example
  4686. * $(document).ready(function() {
  4687. * var oTable = $('#example').dataTable();
  4688. *
  4689. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  4690. * oTable.fnClearTable();
  4691. * } );
  4692. */
  4693. this.fnClearTable = function( bRedraw )
  4694. {
  4695. var api = this.api( true ).clear();
  4696. if ( bRedraw === undefined || bRedraw ) {
  4697. api.draw();
  4698. }
  4699. };
  4700. /**
  4701. * The exact opposite of 'opening' a row, this function will close any rows which
  4702. * are currently 'open'.
  4703. * @param {node} nTr the table row to 'close'
  4704. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  4705. * @dtopt API
  4706. * @deprecated Since v1.10
  4707. *
  4708. * @example
  4709. * $(document).ready(function() {
  4710. * var oTable;
  4711. *
  4712. * // 'open' an information row when a row is clicked on
  4713. * $('#example tbody tr').click( function () {
  4714. * if ( oTable.fnIsOpen(this) ) {
  4715. * oTable.fnClose( this );
  4716. * } else {
  4717. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4718. * }
  4719. * } );
  4720. *
  4721. * oTable = $('#example').dataTable();
  4722. * } );
  4723. */
  4724. this.fnClose = function( nTr )
  4725. {
  4726. this.api( true ).row( nTr ).child.hide();
  4727. };
  4728. /**
  4729. * Remove a row for the table
  4730. * @param {mixed} target The index of the row from aoData to be deleted, or
  4731. * the TR element you want to delete
  4732. * @param {function|null} [callBack] Callback function
  4733. * @param {bool} [redraw=true] Redraw the table or not
  4734. * @returns {array} The row that was deleted
  4735. * @dtopt API
  4736. * @deprecated Since v1.10
  4737. *
  4738. * @example
  4739. * $(document).ready(function() {
  4740. * var oTable = $('#example').dataTable();
  4741. *
  4742. * // Immediately remove the first row
  4743. * oTable.fnDeleteRow( 0 );
  4744. * } );
  4745. */
  4746. this.fnDeleteRow = function( target, callback, redraw )
  4747. {
  4748. var api = this.api( true );
  4749. var rows = api.rows( target );
  4750. var settings = rows.settings()[0];
  4751. var data = settings.aoData[ rows[0][0] ];
  4752. rows.remove();
  4753. if ( callback ) {
  4754. callback.call( this, settings, data );
  4755. }
  4756. if ( redraw === undefined || redraw ) {
  4757. api.draw();
  4758. }
  4759. return data;
  4760. };
  4761. /**
  4762. * Restore the table to it's original state in the DOM by removing all of DataTables
  4763. * enhancements, alterations to the DOM structure of the table and event listeners.
  4764. * @param {boolean} [remove=false] Completely remove the table from the DOM
  4765. * @dtopt API
  4766. * @deprecated Since v1.10
  4767. *
  4768. * @example
  4769. * $(document).ready(function() {
  4770. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  4771. * var oTable = $('#example').dataTable();
  4772. * oTable.fnDestroy();
  4773. * } );
  4774. */
  4775. this.fnDestroy = function ( remove )
  4776. {
  4777. this.api( true ).destroy( remove );
  4778. };
  4779. /**
  4780. * Redraw the table
  4781. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  4782. * @dtopt API
  4783. * @deprecated Since v1.10
  4784. *
  4785. * @example
  4786. * $(document).ready(function() {
  4787. * var oTable = $('#example').dataTable();
  4788. *
  4789. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  4790. * oTable.fnDraw();
  4791. * } );
  4792. */
  4793. this.fnDraw = function( complete )
  4794. {
  4795. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  4796. // into account the new data, but can old position.
  4797. this.api( true ).draw( ! complete );
  4798. };
  4799. /**
  4800. * Filter the input based on data
  4801. * @param {string} sInput String to filter the table on
  4802. * @param {int|null} [iColumn] Column to limit filtering to
  4803. * @param {bool} [bRegex=false] Treat as regular expression or not
  4804. * @param {bool} [bSmart=true] Perform smart filtering or not
  4805. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  4806. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  4807. * @dtopt API
  4808. * @deprecated Since v1.10
  4809. *
  4810. * @example
  4811. * $(document).ready(function() {
  4812. * var oTable = $('#example').dataTable();
  4813. *
  4814. * // Sometime later - filter...
  4815. * oTable.fnFilter( 'test string' );
  4816. * } );
  4817. */
  4818. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  4819. {
  4820. var api = this.api( true );
  4821. if ( iColumn === null || iColumn === undefined ) {
  4822. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  4823. }
  4824. else {
  4825. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  4826. }
  4827. api.draw();
  4828. };
  4829. /**
  4830. * Get the data for the whole table, an individual row or an individual cell based on the
  4831. * provided parameters.
  4832. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  4833. * a TR node then the data source for the whole row will be returned. If given as a
  4834. * TD/TH cell node then iCol will be automatically calculated and the data for the
  4835. * cell returned. If given as an integer, then this is treated as the aoData internal
  4836. * data index for the row (see fnGetPosition) and the data for that row used.
  4837. * @param {int} [col] Optional column index that you want the data of.
  4838. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  4839. * returned. If mRow is defined, just data for that row, and is iCol is
  4840. * defined, only data for the designated cell is returned.
  4841. * @dtopt API
  4842. * @deprecated Since v1.10
  4843. *
  4844. * @example
  4845. * // Row data
  4846. * $(document).ready(function() {
  4847. * oTable = $('#example').dataTable();
  4848. *
  4849. * oTable.$('tr').click( function () {
  4850. * var data = oTable.fnGetData( this );
  4851. * // ... do something with the array / object of data for the row
  4852. * } );
  4853. * } );
  4854. *
  4855. * @example
  4856. * // Individual cell data
  4857. * $(document).ready(function() {
  4858. * oTable = $('#example').dataTable();
  4859. *
  4860. * oTable.$('td').click( function () {
  4861. * var sData = oTable.fnGetData( this );
  4862. * alert( 'The cell clicked on had the value of '+sData );
  4863. * } );
  4864. * } );
  4865. */
  4866. this.fnGetData = function( src, col )
  4867. {
  4868. var api = this.api( true );
  4869. if ( src !== undefined ) {
  4870. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  4871. return col !== undefined || type == 'td' || type == 'th' ?
  4872. api.cell( src, col ).data() :
  4873. api.row( src ).data() || null;
  4874. }
  4875. return api.data().toArray();
  4876. };
  4877. /**
  4878. * Get an array of the TR nodes that are used in the table's body. Note that you will
  4879. * typically want to use the '$' API method in preference to this as it is more
  4880. * flexible.
  4881. * @param {int} [iRow] Optional row index for the TR element you want
  4882. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  4883. * in the table's body, or iRow is defined, just the TR element requested.
  4884. * @dtopt API
  4885. * @deprecated Since v1.10
  4886. *
  4887. * @example
  4888. * $(document).ready(function() {
  4889. * var oTable = $('#example').dataTable();
  4890. *
  4891. * // Get the nodes from the table
  4892. * var nNodes = oTable.fnGetNodes( );
  4893. * } );
  4894. */
  4895. this.fnGetNodes = function( iRow )
  4896. {
  4897. var api = this.api( true );
  4898. return iRow !== undefined ?
  4899. api.row( iRow ).node() :
  4900. api.rows().nodes().flatten().toArray();
  4901. };
  4902. /**
  4903. * Get the array indexes of a particular cell from it's DOM element
  4904. * and column index including hidden columns
  4905. * @param {node} node this can either be a TR, TD or TH in the table's body
  4906. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  4907. * if given as a cell, an array of [row index, column index (visible),
  4908. * column index (all)] is given.
  4909. * @dtopt API
  4910. * @deprecated Since v1.10
  4911. *
  4912. * @example
  4913. * $(document).ready(function() {
  4914. * $('#example tbody td').click( function () {
  4915. * // Get the position of the current data from the node
  4916. * var aPos = oTable.fnGetPosition( this );
  4917. *
  4918. * // Get the data array for this row
  4919. * var aData = oTable.fnGetData( aPos[0] );
  4920. *
  4921. * // Update the data array and return the value
  4922. * aData[ aPos[1] ] = 'clicked';
  4923. * this.innerHTML = 'clicked';
  4924. * } );
  4925. *
  4926. * // Init DataTables
  4927. * oTable = $('#example').dataTable();
  4928. * } );
  4929. */
  4930. this.fnGetPosition = function( node )
  4931. {
  4932. var api = this.api( true );
  4933. var nodeName = node.nodeName.toUpperCase();
  4934. if ( nodeName == 'TR' ) {
  4935. return api.row( node ).index();
  4936. }
  4937. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  4938. var cell = api.cell( node ).index();
  4939. return [
  4940. cell.row,
  4941. cell.columnVisible,
  4942. cell.column
  4943. ];
  4944. }
  4945. return null;
  4946. };
  4947. /**
  4948. * Check to see if a row is 'open' or not.
  4949. * @param {node} nTr the table row to check
  4950. * @returns {boolean} true if the row is currently open, false otherwise
  4951. * @dtopt API
  4952. * @deprecated Since v1.10
  4953. *
  4954. * @example
  4955. * $(document).ready(function() {
  4956. * var oTable;
  4957. *
  4958. * // 'open' an information row when a row is clicked on
  4959. * $('#example tbody tr').click( function () {
  4960. * if ( oTable.fnIsOpen(this) ) {
  4961. * oTable.fnClose( this );
  4962. * } else {
  4963. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4964. * }
  4965. * } );
  4966. *
  4967. * oTable = $('#example').dataTable();
  4968. * } );
  4969. */
  4970. this.fnIsOpen = function( nTr )
  4971. {
  4972. return this.api( true ).row( nTr ).child.isShown();
  4973. };
  4974. /**
  4975. * This function will place a new row directly after a row which is currently
  4976. * on display on the page, with the HTML contents that is passed into the
  4977. * function. This can be used, for example, to ask for confirmation that a
  4978. * particular record should be deleted.
  4979. * @param {node} nTr The table row to 'open'
  4980. * @param {string|node|jQuery} mHtml The HTML to put into the row
  4981. * @param {string} sClass Class to give the new TD cell
  4982. * @returns {node} The row opened. Note that if the table row passed in as the
  4983. * first parameter, is not found in the table, this method will silently
  4984. * return.
  4985. * @dtopt API
  4986. * @deprecated Since v1.10
  4987. *
  4988. * @example
  4989. * $(document).ready(function() {
  4990. * var oTable;
  4991. *
  4992. * // 'open' an information row when a row is clicked on
  4993. * $('#example tbody tr').click( function () {
  4994. * if ( oTable.fnIsOpen(this) ) {
  4995. * oTable.fnClose( this );
  4996. * } else {
  4997. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4998. * }
  4999. * } );
  5000. *
  5001. * oTable = $('#example').dataTable();
  5002. * } );
  5003. */
  5004. this.fnOpen = function( nTr, mHtml, sClass )
  5005. {
  5006. return this.api( true )
  5007. .row( nTr )
  5008. .child( mHtml, sClass )
  5009. .show()
  5010. .child()[0];
  5011. };
  5012. /**
  5013. * Change the pagination - provides the internal logic for pagination in a simple API
  5014. * function. With this function you can have a DataTables table go to the next,
  5015. * previous, first or last pages.
  5016. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  5017. * or page number to jump to (integer), note that page 0 is the first page.
  5018. * @param {bool} [bRedraw=true] Redraw the table or not
  5019. * @dtopt API
  5020. * @deprecated Since v1.10
  5021. *
  5022. * @example
  5023. * $(document).ready(function() {
  5024. * var oTable = $('#example').dataTable();
  5025. * oTable.fnPageChange( 'next' );
  5026. * } );
  5027. */
  5028. this.fnPageChange = function ( mAction, bRedraw )
  5029. {
  5030. var api = this.api( true ).page( mAction );
  5031. if ( bRedraw === undefined || bRedraw ) {
  5032. api.draw(false);
  5033. }
  5034. };
  5035. /**
  5036. * Show a particular column
  5037. * @param {int} iCol The column whose display should be changed
  5038. * @param {bool} bShow Show (true) or hide (false) the column
  5039. * @param {bool} [bRedraw=true] Redraw the table or not
  5040. * @dtopt API
  5041. * @deprecated Since v1.10
  5042. *
  5043. * @example
  5044. * $(document).ready(function() {
  5045. * var oTable = $('#example').dataTable();
  5046. *
  5047. * // Hide the second column after initialisation
  5048. * oTable.fnSetColumnVis( 1, false );
  5049. * } );
  5050. */
  5051. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  5052. {
  5053. var api = this.api( true ).column( iCol ).visible( bShow );
  5054. if ( bRedraw === undefined || bRedraw ) {
  5055. api.columns.adjust().draw();
  5056. }
  5057. };
  5058. /**
  5059. * Get the settings for a particular table for external manipulation
  5060. * @returns {object} DataTables settings object. See
  5061. * {@link DataTable.models.oSettings}
  5062. * @dtopt API
  5063. * @deprecated Since v1.10
  5064. *
  5065. * @example
  5066. * $(document).ready(function() {
  5067. * var oTable = $('#example').dataTable();
  5068. * var oSettings = oTable.fnSettings();
  5069. *
  5070. * // Show an example parameter from the settings
  5071. * alert( oSettings._iDisplayStart );
  5072. * } );
  5073. */
  5074. this.fnSettings = function()
  5075. {
  5076. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  5077. };
  5078. /**
  5079. * Sort the table by a particular column
  5080. * @param {int} iCol the data index to sort on. Note that this will not match the
  5081. * 'display index' if you have hidden data entries
  5082. * @dtopt API
  5083. * @deprecated Since v1.10
  5084. *
  5085. * @example
  5086. * $(document).ready(function() {
  5087. * var oTable = $('#example').dataTable();
  5088. *
  5089. * // Sort immediately with columns 0 and 1
  5090. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  5091. * } );
  5092. */
  5093. this.fnSort = function( aaSort )
  5094. {
  5095. this.api( true ).order( aaSort ).draw();
  5096. };
  5097. /**
  5098. * Attach a sort listener to an element for a given column
  5099. * @param {node} nNode the element to attach the sort listener to
  5100. * @param {int} iColumn the column that a click on this node will sort on
  5101. * @param {function} [fnCallback] callback function when sort is run
  5102. * @dtopt API
  5103. * @deprecated Since v1.10
  5104. *
  5105. * @example
  5106. * $(document).ready(function() {
  5107. * var oTable = $('#example').dataTable();
  5108. *
  5109. * // Sort on column 1, when 'sorter' is clicked on
  5110. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  5111. * } );
  5112. */
  5113. this.fnSortListener = function( nNode, iColumn, fnCallback )
  5114. {
  5115. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  5116. };
  5117. /**
  5118. * Update a table cell or row - this method will accept either a single value to
  5119. * update the cell with, an array of values with one element for each column or
  5120. * an object in the same format as the original data source. The function is
  5121. * self-referencing in order to make the multi column updates easier.
  5122. * @param {object|array|string} mData Data to update the cell/row with
  5123. * @param {node|int} mRow TR element you want to update or the aoData index
  5124. * @param {int} [iColumn] The column to update, give as null or undefined to
  5125. * update a whole row.
  5126. * @param {bool} [bRedraw=true] Redraw the table or not
  5127. * @param {bool} [bAction=true] Perform pre-draw actions or not
  5128. * @returns {int} 0 on success, 1 on error
  5129. * @dtopt API
  5130. * @deprecated Since v1.10
  5131. *
  5132. * @example
  5133. * $(document).ready(function() {
  5134. * var oTable = $('#example').dataTable();
  5135. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  5136. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  5137. * } );
  5138. */
  5139. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  5140. {
  5141. var api = this.api( true );
  5142. if ( iColumn === undefined || iColumn === null ) {
  5143. api.row( mRow ).data( mData );
  5144. }
  5145. else {
  5146. api.cell( mRow, iColumn ).data( mData );
  5147. }
  5148. if ( bAction === undefined || bAction ) {
  5149. api.columns.adjust();
  5150. }
  5151. if ( bRedraw === undefined || bRedraw ) {
  5152. api.draw();
  5153. }
  5154. return 0;
  5155. };
  5156. /**
  5157. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  5158. * to ensure compatibility.
  5159. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  5160. * formats "X" and "X.Y" are also acceptable.
  5161. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  5162. * version, or false if this version of DataTales is not suitable
  5163. * @method
  5164. * @dtopt API
  5165. * @deprecated Since v1.10
  5166. *
  5167. * @example
  5168. * $(document).ready(function() {
  5169. * var oTable = $('#example').dataTable();
  5170. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  5171. * } );
  5172. */
  5173. this.fnVersionCheck = _ext.fnVersionCheck;
  5174. var _that = this;
  5175. var emptyInit = options === undefined;
  5176. var len = this.length;
  5177. if ( emptyInit ) {
  5178. options = {};
  5179. }
  5180. this.oApi = this.internal = _ext.internal;
  5181. // Extend with old style plug-in API methods
  5182. for ( var fn in DataTable.ext.internal ) {
  5183. if ( fn ) {
  5184. this[fn] = _fnExternApiFunc(fn);
  5185. }
  5186. }
  5187. this.each(function() {
  5188. // For each initialisation we want to give it a clean initialisation
  5189. // object that can be bashed around
  5190. var o = {};
  5191. var oInit = len > 1 ? // optimisation for single table case
  5192. _fnExtend( o, options, true ) :
  5193. options;
  5194. /*global oInit,_that,emptyInit*/
  5195. var i=0, iLen, j, jLen, k, kLen;
  5196. var sId = this.getAttribute( 'id' );
  5197. var bInitHandedOff = false;
  5198. var defaults = DataTable.defaults;
  5199. var $this = $(this);
  5200. /* Sanity check */
  5201. if ( this.nodeName.toLowerCase() != 'table' )
  5202. {
  5203. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  5204. return;
  5205. }
  5206. /* Backwards compatibility for the defaults */
  5207. _fnCompatOpts( defaults );
  5208. _fnCompatCols( defaults.column );
  5209. /* Convert the camel-case defaults to Hungarian */
  5210. _fnCamelToHungarian( defaults, defaults, true );
  5211. _fnCamelToHungarian( defaults.column, defaults.column, true );
  5212. /* Setting up the initialisation object */
  5213. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ) );
  5214. /* Check to see if we are re-initialising a table */
  5215. var allSettings = DataTable.settings;
  5216. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  5217. {
  5218. var s = allSettings[i];
  5219. /* Base check on table node */
  5220. if ( s.nTable == this || s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this) )
  5221. {
  5222. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  5223. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  5224. if ( emptyInit || bRetrieve )
  5225. {
  5226. return s.oInstance;
  5227. }
  5228. else if ( bDestroy )
  5229. {
  5230. s.oInstance.fnDestroy();
  5231. break;
  5232. }
  5233. else
  5234. {
  5235. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  5236. return;
  5237. }
  5238. }
  5239. /* If the element we are initialising has the same ID as a table which was previously
  5240. * initialised, but the table nodes don't match (from before) then we destroy the old
  5241. * instance by simply deleting it. This is under the assumption that the table has been
  5242. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  5243. */
  5244. if ( s.sTableId == this.id )
  5245. {
  5246. allSettings.splice( i, 1 );
  5247. break;
  5248. }
  5249. }
  5250. /* Ensure the table has an ID - required for accessibility */
  5251. if ( sId === null || sId === "" )
  5252. {
  5253. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  5254. this.id = sId;
  5255. }
  5256. /* Create the settings object for this table and set some of the default parameters */
  5257. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  5258. "nTable": this,
  5259. "oApi": _that.internal,
  5260. "oInit": oInit,
  5261. "sDestroyWidth": $this[0].style.width,
  5262. "sInstance": sId,
  5263. "sTableId": sId
  5264. } );
  5265. allSettings.push( oSettings );
  5266. // Need to add the instance after the instance after the settings object has been added
  5267. // to the settings array, so we can self reference the table instance if more than one
  5268. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  5269. // Backwards compatibility, before we apply all the defaults
  5270. _fnCompatOpts( oInit );
  5271. if ( oInit.oLanguage )
  5272. {
  5273. _fnLanguageCompat( oInit.oLanguage );
  5274. }
  5275. // If the length menu is given, but the init display length is not, use the length menu
  5276. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  5277. {
  5278. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  5279. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  5280. }
  5281. // Apply the defaults and init options to make a single init object will all
  5282. // options defined from defaults and instance options.
  5283. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  5284. // Map the initialisation options onto the settings object
  5285. _fnMap( oSettings.oFeatures, oInit, [
  5286. "bPaginate",
  5287. "bLengthChange",
  5288. "bFilter",
  5289. "bSort",
  5290. "bSortMulti",
  5291. "bInfo",
  5292. "bProcessing",
  5293. "bAutoWidth",
  5294. "bSortClasses",
  5295. "bServerSide",
  5296. "bDeferRender"
  5297. ] );
  5298. _fnMap( oSettings, oInit, [
  5299. "asStripeClasses",
  5300. "ajax",
  5301. "fnServerData",
  5302. "fnFormatNumber",
  5303. "sServerMethod",
  5304. "aaSorting",
  5305. "aaSortingFixed",
  5306. "aLengthMenu",
  5307. "sPaginationType",
  5308. "sAjaxSource",
  5309. "sAjaxDataProp",
  5310. "iStateDuration",
  5311. "sDom",
  5312. "bSortCellsTop",
  5313. "iTabIndex",
  5314. "fnStateLoadCallback",
  5315. "fnStateSaveCallback",
  5316. "renderer",
  5317. "searchDelay",
  5318. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  5319. [ "oSearch", "oPreviousSearch" ],
  5320. [ "aoSearchCols", "aoPreSearchCols" ],
  5321. [ "iDisplayLength", "_iDisplayLength" ],
  5322. [ "bJQueryUI", "bJUI" ]
  5323. ] );
  5324. _fnMap( oSettings.oScroll, oInit, [
  5325. [ "sScrollX", "sX" ],
  5326. [ "sScrollXInner", "sXInner" ],
  5327. [ "sScrollY", "sY" ],
  5328. [ "bScrollCollapse", "bCollapse" ]
  5329. ] );
  5330. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  5331. /* Callback functions which are array driven */
  5332. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  5333. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  5334. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  5335. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  5336. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  5337. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  5338. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  5339. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  5340. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  5341. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  5342. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  5343. var oClasses = oSettings.oClasses;
  5344. // @todo Remove in 1.11
  5345. if ( oInit.bJQueryUI )
  5346. {
  5347. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  5348. * you want to have multiple tables with multiple independent classes
  5349. */
  5350. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  5351. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  5352. {
  5353. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  5354. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  5355. }
  5356. if ( ! oSettings.renderer ) {
  5357. oSettings.renderer = 'jqueryui';
  5358. }
  5359. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  5360. oSettings.renderer.header = 'jqueryui';
  5361. }
  5362. }
  5363. else
  5364. {
  5365. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  5366. }
  5367. $this.addClass( oClasses.sTable );
  5368. /* Calculate the scroll bar width and cache it for use later on */
  5369. if ( oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "" )
  5370. {
  5371. oSettings.oScroll.iBarWidth = _fnScrollBarWidth();
  5372. }
  5373. if ( oSettings.oScroll.sX === true ) { // Easy initialisation of x-scrolling
  5374. oSettings.oScroll.sX = '100%';
  5375. }
  5376. if ( oSettings.iInitDisplayStart === undefined )
  5377. {
  5378. /* Display start point, taking into account the save saving */
  5379. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  5380. oSettings._iDisplayStart = oInit.iDisplayStart;
  5381. }
  5382. if ( oInit.iDeferLoading !== null )
  5383. {
  5384. oSettings.bDeferLoading = true;
  5385. var tmp = $.isArray( oInit.iDeferLoading );
  5386. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  5387. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  5388. }
  5389. /* Language definitions */
  5390. var oLanguage = oSettings.oLanguage;
  5391. $.extend( true, oLanguage, oInit.oLanguage );
  5392. if ( oLanguage.sUrl !== "" )
  5393. {
  5394. /* Get the language definitions from a file - because this Ajax call makes the language
  5395. * get async to the remainder of this function we use bInitHandedOff to indicate that
  5396. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  5397. */
  5398. $.ajax( {
  5399. dataType: 'json',
  5400. url: oLanguage.sUrl,
  5401. success: function ( json ) {
  5402. _fnLanguageCompat( json );
  5403. _fnCamelToHungarian( defaults.oLanguage, json );
  5404. $.extend( true, oLanguage, json );
  5405. _fnInitialise( oSettings );
  5406. },
  5407. error: function () {
  5408. // Error occurred loading language file, continue on as best we can
  5409. _fnInitialise( oSettings );
  5410. }
  5411. } );
  5412. bInitHandedOff = true;
  5413. }
  5414. /*
  5415. * Stripes
  5416. */
  5417. if ( oInit.asStripeClasses === null )
  5418. {
  5419. oSettings.asStripeClasses =[
  5420. oClasses.sStripeOdd,
  5421. oClasses.sStripeEven
  5422. ];
  5423. }
  5424. /* Remove row stripe classes if they are already on the table row */
  5425. var stripeClasses = oSettings.asStripeClasses;
  5426. var rowOne = $('tbody tr', this).eq(0);
  5427. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  5428. return rowOne.hasClass(el);
  5429. } ) ) !== -1 ) {
  5430. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  5431. oSettings.asDestroyStripes = stripeClasses.slice();
  5432. }
  5433. /*
  5434. * Columns
  5435. * See if we should load columns automatically or use defined ones
  5436. */
  5437. var anThs = [];
  5438. var aoColumnsInit;
  5439. var nThead = this.getElementsByTagName('thead');
  5440. if ( nThead.length !== 0 )
  5441. {
  5442. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  5443. anThs = _fnGetUniqueThs( oSettings );
  5444. }
  5445. /* If not given a column array, generate one with nulls */
  5446. if ( oInit.aoColumns === null )
  5447. {
  5448. aoColumnsInit = [];
  5449. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  5450. {
  5451. aoColumnsInit.push( null );
  5452. }
  5453. }
  5454. else
  5455. {
  5456. aoColumnsInit = oInit.aoColumns;
  5457. }
  5458. /* Add the columns */
  5459. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  5460. {
  5461. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  5462. }
  5463. /* Apply the column definitions */
  5464. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  5465. _fnColumnOptions( oSettings, iCol, oDef );
  5466. } );
  5467. /* HTML5 attribute detection - build an mData object automatically if the
  5468. * attributes are found
  5469. */
  5470. if ( rowOne.length ) {
  5471. var a = function ( cell, name ) {
  5472. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  5473. };
  5474. $.each( _fnGetRowElements( oSettings, rowOne[0] ).cells, function (i, cell) {
  5475. var col = oSettings.aoColumns[i];
  5476. if ( col.mData === i ) {
  5477. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  5478. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  5479. if ( sort !== null || filter !== null ) {
  5480. col.mData = {
  5481. _: i+'.display',
  5482. sort: sort !== null ? i+'.@data-'+sort : undefined,
  5483. type: sort !== null ? i+'.@data-'+sort : undefined,
  5484. filter: filter !== null ? i+'.@data-'+filter : undefined
  5485. };
  5486. _fnColumnOptions( oSettings, i );
  5487. }
  5488. }
  5489. } );
  5490. }
  5491. var features = oSettings.oFeatures;
  5492. /* Must be done after everything which can be overridden by the state saving! */
  5493. if ( oInit.bStateSave )
  5494. {
  5495. features.bStateSave = true;
  5496. _fnLoadState( oSettings, oInit );
  5497. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  5498. }
  5499. /*
  5500. * Sorting
  5501. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  5502. */
  5503. // If aaSorting is not defined, then we use the first indicator in asSorting
  5504. // in case that has been altered, so the default sort reflects that option
  5505. if ( oInit.aaSorting === undefined )
  5506. {
  5507. var sorting = oSettings.aaSorting;
  5508. for ( i=0, iLen=sorting.length ; i<iLen ; i++ )
  5509. {
  5510. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  5511. }
  5512. }
  5513. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  5514. * account, and also will apply sorting disabled classes if disabled
  5515. */
  5516. _fnSortingClasses( oSettings );
  5517. if ( features.bSort )
  5518. {
  5519. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5520. if ( oSettings.bSorted ) {
  5521. var aSort = _fnSortFlatten( oSettings );
  5522. var sortedColumns = {};
  5523. $.each( aSort, function (i, val) {
  5524. sortedColumns[ val.src ] = val.dir;
  5525. } );
  5526. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  5527. _fnSortAria( oSettings );
  5528. }
  5529. } );
  5530. }
  5531. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5532. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  5533. _fnSortingClasses( oSettings );
  5534. }
  5535. }, 'sc' );
  5536. /*
  5537. * Final init
  5538. * Cache the header, body and footer as required, creating them if needed
  5539. */
  5540. /* Browser support detection */
  5541. _fnBrowserDetect( oSettings );
  5542. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  5543. var captions = $this.children('caption').each( function () {
  5544. this._captionSide = $this.css('caption-side');
  5545. } );
  5546. var thead = $this.children('thead');
  5547. if ( thead.length === 0 )
  5548. {
  5549. thead = $('<thead/>').appendTo(this);
  5550. }
  5551. oSettings.nTHead = thead[0];
  5552. var tbody = $this.children('tbody');
  5553. if ( tbody.length === 0 )
  5554. {
  5555. tbody = $('<tbody/>').appendTo(this);
  5556. }
  5557. oSettings.nTBody = tbody[0];
  5558. var tfoot = $this.children('tfoot');
  5559. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  5560. {
  5561. // If we are a scrolling table, and no footer has been given, then we need to create
  5562. // a tfoot element for the caption element to be appended to
  5563. tfoot = $('<tfoot/>').appendTo(this);
  5564. }
  5565. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  5566. $this.addClass( oClasses.sNoFooter );
  5567. }
  5568. else if ( tfoot.length > 0 ) {
  5569. oSettings.nTFoot = tfoot[0];
  5570. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  5571. }
  5572. /* Check if there is data passing into the constructor */
  5573. if ( oInit.aaData )
  5574. {
  5575. for ( i=0 ; i<oInit.aaData.length ; i++ )
  5576. {
  5577. _fnAddData( oSettings, oInit.aaData[ i ] );
  5578. }
  5579. }
  5580. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  5581. {
  5582. /* Grab the data from the page - only do this when deferred loading or no Ajax
  5583. * source since there is no point in reading the DOM data if we are then going
  5584. * to replace it with Ajax data
  5585. */
  5586. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  5587. }
  5588. /* Copy the data index array */
  5589. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  5590. /* Initialisation complete - table can be drawn */
  5591. oSettings.bInitialised = true;
  5592. /* Check if we need to initialise the table (it might not have been handed off to the
  5593. * language processor)
  5594. */
  5595. if ( bInitHandedOff === false )
  5596. {
  5597. _fnInitialise( oSettings );
  5598. }
  5599. } );
  5600. _that = null;
  5601. return this;
  5602. };
  5603. /**
  5604. * Computed structure of the DataTables API, defined by the options passed to
  5605. * `DataTable.Api.register()` when building the API.
  5606. *
  5607. * The structure is built in order to speed creation and extension of the Api
  5608. * objects since the extensions are effectively pre-parsed.
  5609. *
  5610. * The array is an array of objects with the following structure, where this
  5611. * base array represents the Api prototype base:
  5612. *
  5613. * [
  5614. * {
  5615. * name: 'data' -- string - Property name
  5616. * val: function () {}, -- function - Api method (or undefined if just an object
  5617. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5618. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5619. * },
  5620. * {
  5621. * name: 'row'
  5622. * val: {},
  5623. * methodExt: [ ... ],
  5624. * propExt: [
  5625. * {
  5626. * name: 'data'
  5627. * val: function () {},
  5628. * methodExt: [ ... ],
  5629. * propExt: [ ... ]
  5630. * },
  5631. * ...
  5632. * ]
  5633. * }
  5634. * ]
  5635. *
  5636. * @type {Array}
  5637. * @ignore
  5638. */
  5639. var __apiStruct = [];
  5640. /**
  5641. * `Array.prototype` reference.
  5642. *
  5643. * @type object
  5644. * @ignore
  5645. */
  5646. var __arrayProto = Array.prototype;
  5647. /**
  5648. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5649. * take several different forms for ease of use.
  5650. *
  5651. * Each of the input parameter types will be converted to a DataTables settings
  5652. * object where possible.
  5653. *
  5654. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5655. * of:
  5656. *
  5657. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5658. * with be found and used.
  5659. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5660. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5661. * * `object` - DataTables settings object
  5662. * * `DataTables.Api` - API instance
  5663. * @return {array|null} Matching DataTables settings objects. `null` or
  5664. * `undefined` is returned if no matching DataTable is found.
  5665. * @ignore
  5666. */
  5667. var _toSettings = function ( mixed )
  5668. {
  5669. var idx, jq;
  5670. var settings = DataTable.settings;
  5671. var tables = $.map( settings, function (el, i) {
  5672. return el.nTable;
  5673. } );
  5674. if ( ! mixed ) {
  5675. return [];
  5676. }
  5677. else if ( mixed.nTable && mixed.oApi ) {
  5678. // DataTables settings object
  5679. return [ mixed ];
  5680. }
  5681. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5682. // Table node
  5683. idx = $.inArray( mixed, tables );
  5684. return idx !== -1 ? [ settings[idx] ] : null;
  5685. }
  5686. else if ( mixed && typeof mixed.settings === 'function' ) {
  5687. return mixed.settings().toArray();
  5688. }
  5689. else if ( typeof mixed === 'string' ) {
  5690. // jQuery selector
  5691. jq = $(mixed);
  5692. }
  5693. else if ( mixed instanceof $ ) {
  5694. // jQuery object (also DataTables instance)
  5695. jq = mixed;
  5696. }
  5697. if ( jq ) {
  5698. return jq.map( function(i) {
  5699. idx = $.inArray( this, tables );
  5700. return idx !== -1 ? settings[idx] : null;
  5701. } ).toArray();
  5702. }
  5703. };
  5704. /**
  5705. * DataTables API class - used to control and interface with one or more
  5706. * DataTables enhanced tables.
  5707. *
  5708. * The API class is heavily based on jQuery, presenting a chainable interface
  5709. * that you can use to interact with tables. Each instance of the API class has
  5710. * a "context" - i.e. the tables that it will operate on. This could be a single
  5711. * table, all tables on a page or a sub-set thereof.
  5712. *
  5713. * Additionally the API is designed to allow you to easily work with the data in
  5714. * the tables, retrieving and manipulating it as required. This is done by
  5715. * presenting the API class as an array like interface. The contents of the
  5716. * array depend upon the actions requested by each method (for example
  5717. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5718. * return an array of objects or arrays depending upon your table's
  5719. * configuration). The API object has a number of array like methods (`push`,
  5720. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5721. * `unique` etc) to assist your working with the data held in a table.
  5722. *
  5723. * Most methods (those which return an Api instance) are chainable, which means
  5724. * the return from a method call also has all of the methods available that the
  5725. * top level object had. For example, these two calls are equivalent:
  5726. *
  5727. * // Not chained
  5728. * api.row.add( {...} );
  5729. * api.draw();
  5730. *
  5731. * // Chained
  5732. * api.row.add( {...} ).draw();
  5733. *
  5734. * @class DataTable.Api
  5735. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5736. * used to define which DataTables enhanced tables this API will operate on.
  5737. * Can be one of:
  5738. *
  5739. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5740. * with be found and used.
  5741. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5742. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5743. * * `object` - DataTables settings object
  5744. * @param {array} [data] Data to initialise the Api instance with.
  5745. *
  5746. * @example
  5747. * // Direct initialisation during DataTables construction
  5748. * var api = $('#example').DataTable();
  5749. *
  5750. * @example
  5751. * // Initialisation using a DataTables jQuery object
  5752. * var api = $('#example').dataTable().api();
  5753. *
  5754. * @example
  5755. * // Initialisation as a constructor
  5756. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5757. */
  5758. _Api = function ( context, data )
  5759. {
  5760. if ( ! this instanceof _Api ) {
  5761. throw 'DT API must be constructed as a new object';
  5762. // or should it do the 'new' for the caller?
  5763. // return new _Api.apply( this, arguments );
  5764. }
  5765. var settings = [];
  5766. var ctxSettings = function ( o ) {
  5767. var a = _toSettings( o );
  5768. if ( a ) {
  5769. settings.push.apply( settings, a );
  5770. }
  5771. };
  5772. if ( $.isArray( context ) ) {
  5773. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5774. ctxSettings( context[i] );
  5775. }
  5776. }
  5777. else {
  5778. ctxSettings( context );
  5779. }
  5780. // Remove duplicates
  5781. this.context = _unique( settings );
  5782. // Initial data
  5783. if ( data ) {
  5784. this.push.apply( this, data.toArray ? data.toArray() : data );
  5785. }
  5786. // selector
  5787. this.selector = {
  5788. rows: null,
  5789. cols: null,
  5790. opts: null
  5791. };
  5792. _Api.extend( this, this, __apiStruct );
  5793. };
  5794. DataTable.Api = _Api;
  5795. _Api.prototype = /** @lends DataTables.Api */{
  5796. /**
  5797. * Return a new Api instance, comprised of the data held in the current
  5798. * instance, join with the other array(s) and/or value(s).
  5799. *
  5800. * An alias for `Array.prototype.concat`.
  5801. *
  5802. * @type method
  5803. * @param {*} value1 Arrays and/or values to concatenate.
  5804. * @param {*} [...] Additional arrays and/or values to concatenate.
  5805. * @returns {DataTables.Api} New API instance, comprising of the combined
  5806. * array.
  5807. */
  5808. concat: __arrayProto.concat,
  5809. context: [], // array of table settings objects
  5810. each: function ( fn )
  5811. {
  5812. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5813. fn.call( this, this[i], i, this );
  5814. }
  5815. return this;
  5816. },
  5817. eq: function ( idx )
  5818. {
  5819. var ctx = this.context;
  5820. return ctx.length > idx ?
  5821. new _Api( ctx[idx], this[idx] ) :
  5822. null;
  5823. },
  5824. filter: function ( fn )
  5825. {
  5826. var a = [];
  5827. if ( __arrayProto.filter ) {
  5828. a = __arrayProto.filter.call( this, fn, this );
  5829. }
  5830. else {
  5831. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5832. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5833. if ( fn.call( this, this[i], i, this ) ) {
  5834. a.push( this[i] );
  5835. }
  5836. }
  5837. }
  5838. return new _Api( this.context, a );
  5839. },
  5840. flatten: function ()
  5841. {
  5842. var a = [];
  5843. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  5844. },
  5845. join: __arrayProto.join,
  5846. indexOf: __arrayProto.indexOf || function (obj, start)
  5847. {
  5848. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  5849. if ( this[i] === obj ) {
  5850. return i;
  5851. }
  5852. }
  5853. return -1;
  5854. },
  5855. // Note that `alwaysNew` is internal - use iteratorNew externally
  5856. iterator: function ( flatten, type, fn, alwaysNew ) {
  5857. var
  5858. a = [], ret,
  5859. i, ien, j, jen,
  5860. context = this.context,
  5861. rows, items, item,
  5862. selector = this.selector;
  5863. // Argument shifting
  5864. if ( typeof flatten === 'string' ) {
  5865. alwaysNew = fn;
  5866. fn = type;
  5867. type = flatten;
  5868. flatten = false;
  5869. }
  5870. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  5871. var apiInst = new _Api( context[i] );
  5872. if ( type === 'table' ) {
  5873. ret = fn.call( apiInst, context[i], i );
  5874. if ( ret !== undefined ) {
  5875. a.push( ret );
  5876. }
  5877. }
  5878. else if ( type === 'columns' || type === 'rows' ) {
  5879. // this has same length as context - one entry for each table
  5880. ret = fn.call( apiInst, context[i], this[i], i );
  5881. if ( ret !== undefined ) {
  5882. a.push( ret );
  5883. }
  5884. }
  5885. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  5886. // columns and rows share the same structure.
  5887. // 'this' is an array of column indexes for each context
  5888. items = this[i];
  5889. if ( type === 'column-rows' ) {
  5890. rows = _selector_row_indexes( context[i], selector.opts );
  5891. }
  5892. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  5893. item = items[j];
  5894. if ( type === 'cell' ) {
  5895. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  5896. }
  5897. else {
  5898. ret = fn.call( apiInst, context[i], item, i, j, rows );
  5899. }
  5900. if ( ret !== undefined ) {
  5901. a.push( ret );
  5902. }
  5903. }
  5904. }
  5905. }
  5906. if ( a.length || alwaysNew ) {
  5907. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  5908. var apiSelector = api.selector;
  5909. apiSelector.rows = selector.rows;
  5910. apiSelector.cols = selector.cols;
  5911. apiSelector.opts = selector.opts;
  5912. return api;
  5913. }
  5914. return this;
  5915. },
  5916. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  5917. {
  5918. // Bit cheeky...
  5919. return this.indexOf.apply( this.toArray.reverse(), arguments );
  5920. },
  5921. length: 0,
  5922. map: function ( fn )
  5923. {
  5924. var a = [];
  5925. if ( __arrayProto.map ) {
  5926. a = __arrayProto.map.call( this, fn, this );
  5927. }
  5928. else {
  5929. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5930. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5931. a.push( fn.call( this, this[i], i ) );
  5932. }
  5933. }
  5934. return new _Api( this.context, a );
  5935. },
  5936. pluck: function ( prop )
  5937. {
  5938. return this.map( function ( el ) {
  5939. return el[ prop ];
  5940. } );
  5941. },
  5942. pop: __arrayProto.pop,
  5943. push: __arrayProto.push,
  5944. // Does not return an API instance
  5945. reduce: __arrayProto.reduce || function ( fn, init )
  5946. {
  5947. return _fnReduce( this, fn, init, 0, this.length, 1 );
  5948. },
  5949. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  5950. {
  5951. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  5952. },
  5953. reverse: __arrayProto.reverse,
  5954. // Object with rows, columns and opts
  5955. selector: null,
  5956. shift: __arrayProto.shift,
  5957. sort: __arrayProto.sort, // ? name - order?
  5958. splice: __arrayProto.splice,
  5959. toArray: function ()
  5960. {
  5961. return __arrayProto.slice.call( this );
  5962. },
  5963. to$: function ()
  5964. {
  5965. return $( this );
  5966. },
  5967. toJQuery: function ()
  5968. {
  5969. return $( this );
  5970. },
  5971. unique: function ()
  5972. {
  5973. return new _Api( this.context, _unique(this) );
  5974. },
  5975. unshift: __arrayProto.unshift
  5976. };
  5977. _Api.extend = function ( scope, obj, ext )
  5978. {
  5979. // Only extend API instances and static properties of the API
  5980. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  5981. return;
  5982. }
  5983. var
  5984. i, ien,
  5985. j, jen,
  5986. struct, inner,
  5987. methodScoping = function ( scope, fn, struc ) {
  5988. return function () {
  5989. var ret = fn.apply( scope, arguments );
  5990. // Method extension
  5991. _Api.extend( ret, ret, struc.methodExt );
  5992. return ret;
  5993. };
  5994. };
  5995. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  5996. struct = ext[i];
  5997. // Value
  5998. obj[ struct.name ] = typeof struct.val === 'function' ?
  5999. methodScoping( scope, struct.val, struct ) :
  6000. $.isPlainObject( struct.val ) ?
  6001. {} :
  6002. struct.val;
  6003. obj[ struct.name ].__dt_wrapper = true;
  6004. // Property extension
  6005. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6006. }
  6007. };
  6008. // @todo - Is there need for an augment function?
  6009. // _Api.augment = function ( inst, name )
  6010. // {
  6011. // // Find src object in the structure from the name
  6012. // var parts = name.split('.');
  6013. // _Api.extend( inst, obj );
  6014. // };
  6015. // [
  6016. // {
  6017. // name: 'data' -- string - Property name
  6018. // val: function () {}, -- function - Api method (or undefined if just an object
  6019. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6020. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6021. // },
  6022. // {
  6023. // name: 'row'
  6024. // val: {},
  6025. // methodExt: [ ... ],
  6026. // propExt: [
  6027. // {
  6028. // name: 'data'
  6029. // val: function () {},
  6030. // methodExt: [ ... ],
  6031. // propExt: [ ... ]
  6032. // },
  6033. // ...
  6034. // ]
  6035. // }
  6036. // ]
  6037. _Api.register = _api_register = function ( name, val )
  6038. {
  6039. if ( $.isArray( name ) ) {
  6040. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6041. _Api.register( name[j], val );
  6042. }
  6043. return;
  6044. }
  6045. var
  6046. i, ien,
  6047. heir = name.split('.'),
  6048. struct = __apiStruct,
  6049. key, method;
  6050. var find = function ( src, name ) {
  6051. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6052. if ( src[i].name === name ) {
  6053. return src[i];
  6054. }
  6055. }
  6056. return null;
  6057. };
  6058. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6059. method = heir[i].indexOf('()') !== -1;
  6060. key = method ?
  6061. heir[i].replace('()', '') :
  6062. heir[i];
  6063. var src = find( struct, key );
  6064. if ( ! src ) {
  6065. src = {
  6066. name: key,
  6067. val: {},
  6068. methodExt: [],
  6069. propExt: []
  6070. };
  6071. struct.push( src );
  6072. }
  6073. if ( i === ien-1 ) {
  6074. src.val = val;
  6075. }
  6076. else {
  6077. struct = method ?
  6078. src.methodExt :
  6079. src.propExt;
  6080. }
  6081. }
  6082. };
  6083. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6084. _Api.register( pluralName, val );
  6085. _Api.register( singularName, function () {
  6086. var ret = val.apply( this, arguments );
  6087. if ( ret === this ) {
  6088. // Returned item is the API instance that was passed in, return it
  6089. return this;
  6090. }
  6091. else if ( ret instanceof _Api ) {
  6092. // New API instance returned, want the value from the first item
  6093. // in the returned array for the singular result.
  6094. return ret.length ?
  6095. $.isArray( ret[0] ) ?
  6096. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6097. ret[0] :
  6098. undefined;
  6099. }
  6100. // Non-API return - just fire it back
  6101. return ret;
  6102. } );
  6103. };
  6104. /**
  6105. * Selector for HTML tables. Apply the given selector to the give array of
  6106. * DataTables settings objects.
  6107. *
  6108. * @param {string|integer} [selector] jQuery selector string or integer
  6109. * @param {array} Array of DataTables settings objects to be filtered
  6110. * @return {array}
  6111. * @ignore
  6112. */
  6113. var __table_selector = function ( selector, a )
  6114. {
  6115. // Integer is used to pick out a table by index
  6116. if ( typeof selector === 'number' ) {
  6117. return [ a[ selector ] ];
  6118. }
  6119. // Perform a jQuery selector on the table nodes
  6120. var nodes = $.map( a, function (el, i) {
  6121. return el.nTable;
  6122. } );
  6123. return $(nodes)
  6124. .filter( selector )
  6125. .map( function (i) {
  6126. // Need to translate back from the table node to the settings
  6127. var idx = $.inArray( this, nodes );
  6128. return a[ idx ];
  6129. } )
  6130. .toArray();
  6131. };
  6132. /**
  6133. * Context selector for the API's context (i.e. the tables the API instance
  6134. * refers to.
  6135. *
  6136. * @name DataTable.Api#tables
  6137. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6138. * should operate on. If not given, all tables in the current context are
  6139. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6140. * select multiple tables or as an integer to select a single table.
  6141. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6142. */
  6143. _api_register( 'tables()', function ( selector ) {
  6144. // A new instance is created if there was a selector specified
  6145. return selector ?
  6146. new _Api( __table_selector( selector, this.context ) ) :
  6147. this;
  6148. } );
  6149. _api_register( 'table()', function ( selector ) {
  6150. var tables = this.tables( selector );
  6151. var ctx = tables.context;
  6152. // Truncate to the first matched table
  6153. return ctx.length ?
  6154. new _Api( ctx[0] ) :
  6155. tables;
  6156. } );
  6157. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6158. return this.iterator( 'table', function ( ctx ) {
  6159. return ctx.nTable;
  6160. }, 1 );
  6161. } );
  6162. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6163. return this.iterator( 'table', function ( ctx ) {
  6164. return ctx.nTBody;
  6165. }, 1 );
  6166. } );
  6167. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6168. return this.iterator( 'table', function ( ctx ) {
  6169. return ctx.nTHead;
  6170. }, 1 );
  6171. } );
  6172. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6173. return this.iterator( 'table', function ( ctx ) {
  6174. return ctx.nTFoot;
  6175. }, 1 );
  6176. } );
  6177. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6178. return this.iterator( 'table', function ( ctx ) {
  6179. return ctx.nTableWrapper;
  6180. }, 1 );
  6181. } );
  6182. /**
  6183. * Redraw the tables in the current context.
  6184. *
  6185. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6186. * position. A full re-sort and re-filter is performed when this method is
  6187. * called, which is why the pagination reset is the default action.
  6188. * @returns {DataTables.Api} this
  6189. */
  6190. _api_register( 'draw()', function ( resetPaging ) {
  6191. return this.iterator( 'table', function ( settings ) {
  6192. _fnReDraw( settings, resetPaging===false );
  6193. } );
  6194. } );
  6195. /**
  6196. * Get the current page index.
  6197. *
  6198. * @return {integer} Current page index (zero based)
  6199. *//**
  6200. * Set the current page.
  6201. *
  6202. * Note that if you attempt to show a page which does not exist, DataTables will
  6203. * not throw an error, but rather reset the paging.
  6204. *
  6205. * @param {integer|string} action The paging action to take. This can be one of:
  6206. * * `integer` - The page index to jump to
  6207. * * `string` - An action to take:
  6208. * * `first` - Jump to first page.
  6209. * * `next` - Jump to the next page
  6210. * * `previous` - Jump to previous page
  6211. * * `last` - Jump to the last page.
  6212. * @returns {DataTables.Api} this
  6213. */
  6214. _api_register( 'page()', function ( action ) {
  6215. if ( action === undefined ) {
  6216. return this.page.info().page; // not an expensive call
  6217. }
  6218. // else, have an action to take on all tables
  6219. return this.iterator( 'table', function ( settings ) {
  6220. _fnPageChange( settings, action );
  6221. } );
  6222. } );
  6223. /**
  6224. * Paging information for the first table in the current context.
  6225. *
  6226. * If you require paging information for another table, use the `table()` method
  6227. * with a suitable selector.
  6228. *
  6229. * @return {object} Object with the following properties set:
  6230. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6231. * * `pages` - Total number of pages
  6232. * * `start` - Display index for the first record shown on the current page
  6233. * * `end` - Display index for the last record shown on the current page
  6234. * * `length` - Display length (number of records). Note that generally `start
  6235. * + length = end`, but this is not always true, for example if there are
  6236. * only 2 records to show on the final page, with a length of 10.
  6237. * * `recordsTotal` - Full data set length
  6238. * * `recordsDisplay` - Data set length once the current filtering criterion
  6239. * are applied.
  6240. */
  6241. _api_register( 'page.info()', function ( action ) {
  6242. if ( this.context.length === 0 ) {
  6243. return undefined;
  6244. }
  6245. var
  6246. settings = this.context[0],
  6247. start = settings._iDisplayStart,
  6248. len = settings._iDisplayLength,
  6249. visRecords = settings.fnRecordsDisplay(),
  6250. all = len === -1;
  6251. return {
  6252. "page": all ? 0 : Math.floor( start / len ),
  6253. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6254. "start": start,
  6255. "end": settings.fnDisplayEnd(),
  6256. "length": len,
  6257. "recordsTotal": settings.fnRecordsTotal(),
  6258. "recordsDisplay": visRecords
  6259. };
  6260. } );
  6261. /**
  6262. * Get the current page length.
  6263. *
  6264. * @return {integer} Current page length. Note `-1` indicates that all records
  6265. * are to be shown.
  6266. *//**
  6267. * Set the current page length.
  6268. *
  6269. * @param {integer} Page length to set. Use `-1` to show all records.
  6270. * @returns {DataTables.Api} this
  6271. */
  6272. _api_register( 'page.len()', function ( len ) {
  6273. // Note that we can't call this function 'length()' because `length`
  6274. // is a Javascript property of functions which defines how many arguments
  6275. // the function expects.
  6276. if ( len === undefined ) {
  6277. return this.context.length !== 0 ?
  6278. this.context[0]._iDisplayLength :
  6279. undefined;
  6280. }
  6281. // else, set the page length
  6282. return this.iterator( 'table', function ( settings ) {
  6283. _fnLengthChange( settings, len );
  6284. } );
  6285. } );
  6286. var __reload = function ( settings, holdPosition, callback ) {
  6287. if ( _fnDataSource( settings ) == 'ssp' ) {
  6288. _fnReDraw( settings, holdPosition );
  6289. }
  6290. else {
  6291. // Trigger xhr
  6292. _fnProcessingDisplay( settings, true );
  6293. _fnBuildAjax( settings, [], function( json ) {
  6294. _fnClearTable( settings );
  6295. var data = _fnAjaxDataSrc( settings, json );
  6296. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6297. _fnAddData( settings, data[i] );
  6298. }
  6299. _fnReDraw( settings, holdPosition );
  6300. _fnProcessingDisplay( settings, false );
  6301. } );
  6302. }
  6303. // Use the draw event to trigger a callback, regardless of if it is an async
  6304. // or sync draw
  6305. if ( callback ) {
  6306. var api = new _Api( settings );
  6307. api.one( 'draw', function () {
  6308. callback( api.ajax.json() );
  6309. } );
  6310. }
  6311. };
  6312. /**
  6313. * Get the JSON response from the last Ajax request that DataTables made to the
  6314. * server. Note that this returns the JSON from the first table in the current
  6315. * context.
  6316. *
  6317. * @return {object} JSON received from the server.
  6318. */
  6319. _api_register( 'ajax.json()', function () {
  6320. var ctx = this.context;
  6321. if ( ctx.length > 0 ) {
  6322. return ctx[0].json;
  6323. }
  6324. // else return undefined;
  6325. } );
  6326. /**
  6327. * Get the data submitted in the last Ajax request
  6328. */
  6329. _api_register( 'ajax.params()', function () {
  6330. var ctx = this.context;
  6331. if ( ctx.length > 0 ) {
  6332. return ctx[0].oAjaxData;
  6333. }
  6334. // else return undefined;
  6335. } );
  6336. /**
  6337. * Reload tables from the Ajax data source. Note that this function will
  6338. * automatically re-draw the table when the remote data has been loaded.
  6339. *
  6340. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6341. * position. A full re-sort and re-filter is performed when this method is
  6342. * called, which is why the pagination reset is the default action.
  6343. * @returns {DataTables.Api} this
  6344. */
  6345. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6346. return this.iterator( 'table', function (settings) {
  6347. __reload( settings, resetPaging===false, callback );
  6348. } );
  6349. } );
  6350. /**
  6351. * Get the current Ajax URL. Note that this returns the URL from the first
  6352. * table in the current context.
  6353. *
  6354. * @return {string} Current Ajax source URL
  6355. *//**
  6356. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6357. * current context.
  6358. *
  6359. * @param {string} url URL to set.
  6360. * @returns {DataTables.Api} this
  6361. */
  6362. _api_register( 'ajax.url()', function ( url ) {
  6363. var ctx = this.context;
  6364. if ( url === undefined ) {
  6365. // get
  6366. if ( ctx.length === 0 ) {
  6367. return undefined;
  6368. }
  6369. ctx = ctx[0];
  6370. return ctx.ajax ?
  6371. $.isPlainObject( ctx.ajax ) ?
  6372. ctx.ajax.url :
  6373. ctx.ajax :
  6374. ctx.sAjaxSource;
  6375. }
  6376. // set
  6377. return this.iterator( 'table', function ( settings ) {
  6378. if ( $.isPlainObject( settings.ajax ) ) {
  6379. settings.ajax.url = url;
  6380. }
  6381. else {
  6382. settings.ajax = url;
  6383. }
  6384. // No need to consider sAjaxSource here since DataTables gives priority
  6385. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6386. // value of `sAjaxSource` redundant.
  6387. } );
  6388. } );
  6389. /**
  6390. * Load data from the newly set Ajax URL. Note that this method is only
  6391. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6392. * has the same effect as calling `ajax.reload()` but is provided for
  6393. * convenience when setting a new URL. Like `ajax.reload()` it will
  6394. * automatically redraw the table once the remote data has been loaded.
  6395. *
  6396. * @returns {DataTables.Api} this
  6397. */
  6398. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6399. // Same as a reload, but makes sense to present it for easy access after a
  6400. // url change
  6401. return this.iterator( 'table', function ( ctx ) {
  6402. __reload( ctx, resetPaging===false, callback );
  6403. } );
  6404. } );
  6405. var _selector_run = function ( selector, select )
  6406. {
  6407. var
  6408. out = [], res,
  6409. a, i, ien, j, jen,
  6410. selectorType = typeof selector;
  6411. // Can't just check for isArray here, as an API or jQuery instance might be
  6412. // given with their array like look
  6413. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6414. selector = [ selector ];
  6415. }
  6416. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6417. a = selector[i] && selector[i].split ?
  6418. selector[i].split(',') :
  6419. [ selector[i] ];
  6420. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6421. res = select( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6422. if ( res && res.length ) {
  6423. out.push.apply( out, res );
  6424. }
  6425. }
  6426. }
  6427. return out;
  6428. };
  6429. var _selector_opts = function ( opts )
  6430. {
  6431. if ( ! opts ) {
  6432. opts = {};
  6433. }
  6434. // Backwards compatibility for 1.9- which used the terminology filter rather
  6435. // than search
  6436. if ( opts.filter && ! opts.search ) {
  6437. opts.search = opts.filter;
  6438. }
  6439. return {
  6440. search: opts.search || 'none',
  6441. order: opts.order || 'current',
  6442. page: opts.page || 'all'
  6443. };
  6444. };
  6445. var _selector_first = function ( inst )
  6446. {
  6447. // Reduce the API instance to the first item found
  6448. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6449. if ( inst[i].length > 0 ) {
  6450. // Assign the first element to the first item in the instance
  6451. // and truncate the instance and context
  6452. inst[0] = inst[i];
  6453. inst.length = 1;
  6454. inst.context = [ inst.context[i] ];
  6455. return inst;
  6456. }
  6457. }
  6458. // Not found - return an empty instance
  6459. inst.length = 0;
  6460. return inst;
  6461. };
  6462. var _selector_row_indexes = function ( settings, opts )
  6463. {
  6464. var
  6465. i, ien, tmp, a=[],
  6466. displayFiltered = settings.aiDisplay,
  6467. displayMaster = settings.aiDisplayMaster;
  6468. var
  6469. search = opts.search, // none, applied, removed
  6470. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6471. page = opts.page; // all, current
  6472. if ( _fnDataSource( settings ) == 'ssp' ) {
  6473. // In server-side processing mode, most options are irrelevant since
  6474. // rows not shown don't exist and the index order is the applied order
  6475. // Removed is a special case - for consistency just return an empty
  6476. // array
  6477. return search === 'removed' ?
  6478. [] :
  6479. _range( 0, displayMaster.length );
  6480. }
  6481. else if ( page == 'current' ) {
  6482. // Current page implies that order=current and fitler=applied, since it is
  6483. // fairly senseless otherwise, regardless of what order and search actually
  6484. // are
  6485. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6486. a.push( displayFiltered[i] );
  6487. }
  6488. }
  6489. else if ( order == 'current' || order == 'applied' ) {
  6490. a = search == 'none' ?
  6491. displayMaster.slice() : // no search
  6492. search == 'applied' ?
  6493. displayFiltered.slice() : // applied search
  6494. $.map( displayMaster, function (el, i) { // removed search
  6495. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6496. } );
  6497. }
  6498. else if ( order == 'index' || order == 'original' ) {
  6499. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6500. if ( search == 'none' ) {
  6501. a.push( i );
  6502. }
  6503. else { // applied | removed
  6504. tmp = $.inArray( i, displayFiltered );
  6505. if ((tmp === -1 && search == 'removed') ||
  6506. (tmp >= 0 && search == 'applied') )
  6507. {
  6508. a.push( i );
  6509. }
  6510. }
  6511. }
  6512. }
  6513. return a;
  6514. };
  6515. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6516. * Rows
  6517. *
  6518. * {} - no selector - use all available rows
  6519. * {integer} - row aoData index
  6520. * {node} - TR node
  6521. * {string} - jQuery selector to apply to the TR elements
  6522. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6523. *
  6524. */
  6525. var __row_selector = function ( settings, selector, opts )
  6526. {
  6527. return _selector_run( selector, function ( sel ) {
  6528. var selInt = _intVal( sel );
  6529. var i, ien;
  6530. // Short cut - selector is a number and no options provided (default is
  6531. // all records, so no need to check if the index is in there, since it
  6532. // must be - dev error if the index doesn't exist).
  6533. if ( selInt !== null && ! opts ) {
  6534. return [ selInt ];
  6535. }
  6536. var rows = _selector_row_indexes( settings, opts );
  6537. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6538. // Selector - integer
  6539. return [ selInt ];
  6540. }
  6541. else if ( ! sel ) {
  6542. // Selector - none
  6543. return rows;
  6544. }
  6545. // Selector - function
  6546. if ( typeof sel === 'function' ) {
  6547. return $.map( rows, function (idx) {
  6548. var row = settings.aoData[ idx ];
  6549. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6550. } );
  6551. }
  6552. // Get nodes in the order from the `rows` array with null values removed
  6553. var nodes = _removeEmpty(
  6554. _pluck_order( settings.aoData, rows, 'nTr' )
  6555. );
  6556. // Selector - node
  6557. if ( sel.nodeName ) {
  6558. if ( $.inArray( sel, nodes ) !== -1 ) {
  6559. return [ sel._DT_RowIndex ]; // sel is a TR node that is in the table
  6560. // and DataTables adds a prop for fast lookup
  6561. }
  6562. }
  6563. // Selector - jQuery selector string, array of nodes or jQuery object/
  6564. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6565. // it also allows arrays, so this will cope with all three options
  6566. return $(nodes)
  6567. .filter( sel )
  6568. .map( function () {
  6569. return this._DT_RowIndex;
  6570. } )
  6571. .toArray();
  6572. } );
  6573. };
  6574. /**
  6575. *
  6576. */
  6577. _api_register( 'rows()', function ( selector, opts ) {
  6578. // argument shifting
  6579. if ( selector === undefined ) {
  6580. selector = '';
  6581. }
  6582. else if ( $.isPlainObject( selector ) ) {
  6583. opts = selector;
  6584. selector = '';
  6585. }
  6586. opts = _selector_opts( opts );
  6587. var inst = this.iterator( 'table', function ( settings ) {
  6588. return __row_selector( settings, selector, opts );
  6589. }, 1 );
  6590. // Want argument shifting here and in __row_selector?
  6591. inst.selector.rows = selector;
  6592. inst.selector.opts = opts;
  6593. return inst;
  6594. } );
  6595. _api_register( 'rows().nodes()', function () {
  6596. return this.iterator( 'row', function ( settings, row ) {
  6597. return settings.aoData[ row ].nTr || undefined;
  6598. }, 1 );
  6599. } );
  6600. _api_register( 'rows().data()', function () {
  6601. return this.iterator( true, 'rows', function ( settings, rows ) {
  6602. return _pluck_order( settings.aoData, rows, '_aData' );
  6603. }, 1 );
  6604. } );
  6605. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6606. return this.iterator( 'row', function ( settings, row ) {
  6607. var r = settings.aoData[ row ];
  6608. return type === 'search' ? r._aFilterData : r._aSortData;
  6609. }, 1 );
  6610. } );
  6611. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6612. return this.iterator( 'row', function ( settings, row ) {
  6613. _fnInvalidate( settings, row, src );
  6614. } );
  6615. } );
  6616. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6617. return this.iterator( 'row', function ( settings, row ) {
  6618. return row;
  6619. }, 1 );
  6620. } );
  6621. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6622. var that = this;
  6623. return this.iterator( 'row', function ( settings, row, thatIdx ) {
  6624. var data = settings.aoData;
  6625. data.splice( row, 1 );
  6626. // Update the _DT_RowIndex parameter on all rows in the table
  6627. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6628. if ( data[i].nTr !== null ) {
  6629. data[i].nTr._DT_RowIndex = i;
  6630. }
  6631. }
  6632. // Remove the target row from the search array
  6633. var displayIndex = $.inArray( row, settings.aiDisplay );
  6634. // Delete from the display arrays
  6635. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6636. _fnDeleteIndex( settings.aiDisplay, row );
  6637. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6638. // Check for an 'overflow' they case for displaying the table
  6639. _fnLengthOverflow( settings );
  6640. } );
  6641. } );
  6642. _api_register( 'rows.add()', function ( rows ) {
  6643. var newRows = this.iterator( 'table', function ( settings ) {
  6644. var row, i, ien;
  6645. var out = [];
  6646. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6647. row = rows[i];
  6648. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6649. out.push( _fnAddTr( settings, row )[0] );
  6650. }
  6651. else {
  6652. out.push( _fnAddData( settings, row ) );
  6653. }
  6654. }
  6655. return out;
  6656. }, 1 );
  6657. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6658. var modRows = this.rows( -1 );
  6659. modRows.pop();
  6660. modRows.push.apply( modRows, newRows.toArray() );
  6661. return modRows;
  6662. } );
  6663. /**
  6664. *
  6665. */
  6666. _api_register( 'row()', function ( selector, opts ) {
  6667. return _selector_first( this.rows( selector, opts ) );
  6668. } );
  6669. _api_register( 'row().data()', function ( data ) {
  6670. var ctx = this.context;
  6671. if ( data === undefined ) {
  6672. // Get
  6673. return ctx.length && this.length ?
  6674. ctx[0].aoData[ this[0] ]._aData :
  6675. undefined;
  6676. }
  6677. // Set
  6678. ctx[0].aoData[ this[0] ]._aData = data;
  6679. // Automatically invalidate
  6680. _fnInvalidate( ctx[0], this[0], 'data' );
  6681. return this;
  6682. } );
  6683. _api_register( 'row().node()', function () {
  6684. var ctx = this.context;
  6685. return ctx.length && this.length ?
  6686. ctx[0].aoData[ this[0] ].nTr || null :
  6687. null;
  6688. } );
  6689. _api_register( 'row.add()', function ( row ) {
  6690. // Allow a jQuery object to be passed in - only a single row is added from
  6691. // it though - the first element in the set
  6692. if ( row instanceof $ && row.length ) {
  6693. row = row[0];
  6694. }
  6695. var rows = this.iterator( 'table', function ( settings ) {
  6696. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6697. return _fnAddTr( settings, row )[0];
  6698. }
  6699. return _fnAddData( settings, row );
  6700. } );
  6701. // Return an Api.rows() extended instance, with the newly added row selected
  6702. return this.row( rows[0] );
  6703. } );
  6704. var __details_add = function ( ctx, row, data, klass )
  6705. {
  6706. // Convert to array of TR elements
  6707. var rows = [];
  6708. var addRow = function ( r, k ) {
  6709. // If we get a TR element, then just add it directly - up to the dev
  6710. // to add the correct number of columns etc
  6711. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  6712. rows.push( r );
  6713. }
  6714. else {
  6715. // Otherwise create a row with a wrapper
  6716. var created = $('<tr><td/></tr>').addClass( k );
  6717. $('td', created)
  6718. .addClass( k )
  6719. .html( r )
  6720. [0].colSpan = _fnVisbleColumns( ctx );
  6721. rows.push( created[0] );
  6722. }
  6723. };
  6724. if ( $.isArray( data ) || data instanceof $ ) {
  6725. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6726. addRow( data[i], klass );
  6727. }
  6728. }
  6729. else {
  6730. addRow( data, klass );
  6731. }
  6732. if ( row._details ) {
  6733. row._details.remove();
  6734. }
  6735. row._details = $(rows);
  6736. // If the children were already shown, that state should be retained
  6737. if ( row._detailsShow ) {
  6738. row._details.insertAfter( row.nTr );
  6739. }
  6740. };
  6741. var __details_remove = function ( api, idx )
  6742. {
  6743. var ctx = api.context;
  6744. if ( ctx.length ) {
  6745. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  6746. if ( row._details ) {
  6747. row._details.remove();
  6748. row._detailsShow = undefined;
  6749. row._details = undefined;
  6750. }
  6751. }
  6752. };
  6753. var __details_display = function ( api, show ) {
  6754. var ctx = api.context;
  6755. if ( ctx.length && api.length ) {
  6756. var row = ctx[0].aoData[ api[0] ];
  6757. if ( row._details ) {
  6758. row._detailsShow = show;
  6759. if ( show ) {
  6760. row._details.insertAfter( row.nTr );
  6761. }
  6762. else {
  6763. row._details.detach();
  6764. }
  6765. __details_events( ctx[0] );
  6766. }
  6767. }
  6768. };
  6769. var __details_events = function ( settings )
  6770. {
  6771. var api = new _Api( settings );
  6772. var namespace = '.dt.DT_details';
  6773. var drawEvent = 'draw'+namespace;
  6774. var colvisEvent = 'column-visibility'+namespace;
  6775. var destroyEvent = 'destroy'+namespace;
  6776. var data = settings.aoData;
  6777. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  6778. if ( _pluck( data, '_details' ).length > 0 ) {
  6779. // On each draw, insert the required elements into the document
  6780. api.on( drawEvent, function ( e, ctx ) {
  6781. if ( settings !== ctx ) {
  6782. return;
  6783. }
  6784. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  6785. // Internal data grab
  6786. var row = data[ idx ];
  6787. if ( row._detailsShow ) {
  6788. row._details.insertAfter( row.nTr );
  6789. }
  6790. } );
  6791. } );
  6792. // Column visibility change - update the colspan
  6793. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  6794. if ( settings !== ctx ) {
  6795. return;
  6796. }
  6797. // Update the colspan for the details rows (note, only if it already has
  6798. // a colspan)
  6799. var row, visible = _fnVisbleColumns( ctx );
  6800. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6801. row = data[i];
  6802. if ( row._details ) {
  6803. row._details.children('td[colspan]').attr('colspan', visible );
  6804. }
  6805. }
  6806. } );
  6807. // Table destroyed - nuke any child rows
  6808. api.on( destroyEvent, function ( e, ctx ) {
  6809. if ( settings !== ctx ) {
  6810. return;
  6811. }
  6812. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6813. if ( data[i]._details ) {
  6814. __details_remove( api, i );
  6815. }
  6816. }
  6817. } );
  6818. }
  6819. };
  6820. // Strings for the method names to help minification
  6821. var _emp = '';
  6822. var _child_obj = _emp+'row().child';
  6823. var _child_mth = _child_obj+'()';
  6824. // data can be:
  6825. // tr
  6826. // string
  6827. // jQuery or array of any of the above
  6828. _api_register( _child_mth, function ( data, klass ) {
  6829. var ctx = this.context;
  6830. if ( data === undefined ) {
  6831. // get
  6832. return ctx.length && this.length ?
  6833. ctx[0].aoData[ this[0] ]._details :
  6834. undefined;
  6835. }
  6836. else if ( data === true ) {
  6837. // show
  6838. this.child.show();
  6839. }
  6840. else if ( data === false ) {
  6841. // remove
  6842. __details_remove( this );
  6843. }
  6844. else if ( ctx.length && this.length ) {
  6845. // set
  6846. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  6847. }
  6848. return this;
  6849. } );
  6850. _api_register( [
  6851. _child_obj+'.show()',
  6852. _child_mth+'.show()' // only when `child()` was called with parameters (without
  6853. ], function ( show ) { // it returns an object and this method is not executed)
  6854. __details_display( this, true );
  6855. return this;
  6856. } );
  6857. _api_register( [
  6858. _child_obj+'.hide()',
  6859. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  6860. ], function () { // it returns an object and this method is not executed)
  6861. __details_display( this, false );
  6862. return this;
  6863. } );
  6864. _api_register( [
  6865. _child_obj+'.remove()',
  6866. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  6867. ], function () { // it returns an object and this method is not executed)
  6868. __details_remove( this );
  6869. return this;
  6870. } );
  6871. _api_register( _child_obj+'.isShown()', function () {
  6872. var ctx = this.context;
  6873. if ( ctx.length && this.length ) {
  6874. // _detailsShown as false or undefined will fall through to return false
  6875. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  6876. }
  6877. return false;
  6878. } );
  6879. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6880. * Columns
  6881. *
  6882. * {integer} - column index (>=0 count from left, <0 count from right)
  6883. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  6884. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  6885. * "{string}:name" - column name
  6886. * "{string}" - jQuery selector on column header nodes
  6887. *
  6888. */
  6889. // can be an array of these items, comma separated list, or an array of comma
  6890. // separated lists
  6891. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  6892. // r1 and r2 are redundant - but it means that the parameters match for the
  6893. // iterator callback in columns().data()
  6894. var __columnData = function ( settings, column, r1, r2, rows ) {
  6895. var a = [];
  6896. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  6897. a.push( _fnGetCellData( settings, rows[row], column ) );
  6898. }
  6899. return a;
  6900. };
  6901. var __column_selector = function ( settings, selector, opts )
  6902. {
  6903. var
  6904. columns = settings.aoColumns,
  6905. names = _pluck( columns, 'sName' ),
  6906. nodes = _pluck( columns, 'nTh' );
  6907. return _selector_run( selector, function ( s ) {
  6908. var selInt = _intVal( s );
  6909. // Selector - all
  6910. if ( s === '' ) {
  6911. return _range( columns.length );
  6912. }
  6913. // Selector - index
  6914. if ( selInt !== null ) {
  6915. return [ selInt >= 0 ?
  6916. selInt : // Count from left
  6917. columns.length + selInt // Count from right (+ because its a negative value)
  6918. ];
  6919. }
  6920. // Selector = function
  6921. if ( typeof s === 'function' ) {
  6922. var rows = _selector_row_indexes( settings, opts );
  6923. return $.map( columns, function (col, idx) {
  6924. return s(
  6925. idx,
  6926. __columnData( settings, idx, 0, 0, rows ),
  6927. nodes[ idx ]
  6928. ) ? idx : null;
  6929. } );
  6930. }
  6931. // jQuery or string selector
  6932. var match = typeof s === 'string' ?
  6933. s.match( __re_column_selector ) :
  6934. '';
  6935. if ( match ) {
  6936. switch( match[2] ) {
  6937. case 'visIdx':
  6938. case 'visible':
  6939. var idx = parseInt( match[1], 10 );
  6940. // Visible index given, convert to column index
  6941. if ( idx < 0 ) {
  6942. // Counting from the right
  6943. var visColumns = $.map( columns, function (col,i) {
  6944. return col.bVisible ? i : null;
  6945. } );
  6946. return [ visColumns[ visColumns.length + idx ] ];
  6947. }
  6948. // Counting from the left
  6949. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  6950. case 'name':
  6951. // match by name. `names` is column index complete and in order
  6952. return $.map( names, function (name, i) {
  6953. return name === match[1] ? i : null;
  6954. } );
  6955. }
  6956. }
  6957. else {
  6958. // jQuery selector on the TH elements for the columns
  6959. return $( nodes )
  6960. .filter( s )
  6961. .map( function () {
  6962. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  6963. } )
  6964. .toArray();
  6965. }
  6966. } );
  6967. };
  6968. var __setColumnVis = function ( settings, column, vis, recalc ) {
  6969. var
  6970. cols = settings.aoColumns,
  6971. col = cols[ column ],
  6972. data = settings.aoData,
  6973. row, cells, i, ien, tr;
  6974. // Get
  6975. if ( vis === undefined ) {
  6976. return col.bVisible;
  6977. }
  6978. // Set
  6979. // No change
  6980. if ( col.bVisible === vis ) {
  6981. return;
  6982. }
  6983. if ( vis ) {
  6984. // Insert column
  6985. // Need to decide if we should use appendChild or insertBefore
  6986. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  6987. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6988. tr = data[i].nTr;
  6989. cells = data[i].anCells;
  6990. if ( tr ) {
  6991. // insertBefore can act like appendChild if 2nd arg is null
  6992. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  6993. }
  6994. }
  6995. }
  6996. else {
  6997. // Remove column
  6998. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  6999. }
  7000. // Common actions
  7001. col.bVisible = vis;
  7002. _fnDrawHead( settings, settings.aoHeader );
  7003. _fnDrawHead( settings, settings.aoFooter );
  7004. if ( recalc === undefined || recalc ) {
  7005. // Automatically adjust column sizing
  7006. _fnAdjustColumnSizing( settings );
  7007. // Realign columns for scrolling
  7008. if ( settings.oScroll.sX || settings.oScroll.sY ) {
  7009. _fnScrollDraw( settings );
  7010. }
  7011. }
  7012. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis] );
  7013. _fnSaveState( settings );
  7014. };
  7015. /**
  7016. *
  7017. */
  7018. _api_register( 'columns()', function ( selector, opts ) {
  7019. // argument shifting
  7020. if ( selector === undefined ) {
  7021. selector = '';
  7022. }
  7023. else if ( $.isPlainObject( selector ) ) {
  7024. opts = selector;
  7025. selector = '';
  7026. }
  7027. opts = _selector_opts( opts );
  7028. var inst = this.iterator( 'table', function ( settings ) {
  7029. return __column_selector( settings, selector, opts );
  7030. }, 1 );
  7031. // Want argument shifting here and in _row_selector?
  7032. inst.selector.cols = selector;
  7033. inst.selector.opts = opts;
  7034. return inst;
  7035. } );
  7036. /**
  7037. *
  7038. */
  7039. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7040. return this.iterator( 'column', function ( settings, column ) {
  7041. return settings.aoColumns[column].nTh;
  7042. }, 1 );
  7043. } );
  7044. /**
  7045. *
  7046. */
  7047. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7048. return this.iterator( 'column', function ( settings, column ) {
  7049. return settings.aoColumns[column].nTf;
  7050. }, 1 );
  7051. } );
  7052. /**
  7053. *
  7054. */
  7055. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7056. return this.iterator( 'column-rows', __columnData, 1 );
  7057. } );
  7058. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7059. return this.iterator( 'column', function ( settings, column ) {
  7060. return settings.aoColumns[column].mData;
  7061. }, 1 );
  7062. } );
  7063. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7064. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7065. return _pluck_order( settings.aoData, rows,
  7066. type === 'search' ? '_aFilterData' : '_aSortData', column
  7067. );
  7068. }, 1 );
  7069. } );
  7070. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7071. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7072. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7073. }, 1 );
  7074. } );
  7075. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7076. return this.iterator( 'column', function ( settings, column ) {
  7077. if ( vis === undefined ) {
  7078. return settings.aoColumns[ column ].bVisible;
  7079. } // else
  7080. __setColumnVis( settings, column, vis, calc );
  7081. } );
  7082. } );
  7083. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7084. return this.iterator( 'column', function ( settings, column ) {
  7085. return type === 'visible' ?
  7086. _fnColumnIndexToVisible( settings, column ) :
  7087. column;
  7088. }, 1 );
  7089. } );
  7090. // _api_register( 'columns().show()', function () {
  7091. // var selector = this.selector;
  7092. // return this.columns( selector.cols, selector.opts ).visible( true );
  7093. // } );
  7094. // _api_register( 'columns().hide()', function () {
  7095. // var selector = this.selector;
  7096. // return this.columns( selector.cols, selector.opts ).visible( false );
  7097. // } );
  7098. _api_register( 'columns.adjust()', function () {
  7099. return this.iterator( 'table', function ( settings ) {
  7100. _fnAdjustColumnSizing( settings );
  7101. }, 1 );
  7102. } );
  7103. // Convert from one column index type, to another type
  7104. _api_register( 'column.index()', function ( type, idx ) {
  7105. if ( this.context.length !== 0 ) {
  7106. var ctx = this.context[0];
  7107. if ( type === 'fromVisible' || type === 'toData' ) {
  7108. return _fnVisibleToColumnIndex( ctx, idx );
  7109. }
  7110. else if ( type === 'fromData' || type === 'toVisible' ) {
  7111. return _fnColumnIndexToVisible( ctx, idx );
  7112. }
  7113. }
  7114. } );
  7115. _api_register( 'column()', function ( selector, opts ) {
  7116. return _selector_first( this.columns( selector, opts ) );
  7117. } );
  7118. var __cell_selector = function ( settings, selector, opts )
  7119. {
  7120. var data = settings.aoData;
  7121. var rows = _selector_row_indexes( settings, opts );
  7122. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7123. var allCells = $( [].concat.apply([], cells) );
  7124. var row;
  7125. var columns = settings.aoColumns.length;
  7126. var a, i, ien, j, o, host;
  7127. return _selector_run( selector, function ( s ) {
  7128. var fnSelector = typeof s === 'function';
  7129. if ( s === null || s === undefined || fnSelector ) {
  7130. // All cells and function selectors
  7131. a = [];
  7132. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7133. row = rows[i];
  7134. for ( j=0 ; j<columns ; j++ ) {
  7135. o = {
  7136. row: row,
  7137. column: j
  7138. };
  7139. if ( fnSelector ) {
  7140. // Selector - function
  7141. host = settings.aoData[ row ];
  7142. if ( s( o, _fnGetCellData(settings, row, j), host.anCells[j] ) ) {
  7143. a.push( o );
  7144. }
  7145. }
  7146. else {
  7147. // Selector - all
  7148. a.push( o );
  7149. }
  7150. }
  7151. }
  7152. return a;
  7153. }
  7154. // Selector - index
  7155. if ( $.isPlainObject( s ) ) {
  7156. return [s];
  7157. }
  7158. // Selector - jQuery filtered cells
  7159. return allCells
  7160. .filter( s )
  7161. .map( function (i, el) {
  7162. row = el.parentNode._DT_RowIndex;
  7163. return {
  7164. row: row,
  7165. column: $.inArray( el, data[ row ].anCells )
  7166. };
  7167. } )
  7168. .toArray();
  7169. } );
  7170. };
  7171. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7172. // Argument shifting
  7173. if ( $.isPlainObject( rowSelector ) ) {
  7174. // Indexes
  7175. if ( typeof rowSelector.row !== undefined ) {
  7176. opts = columnSelector;
  7177. columnSelector = null;
  7178. }
  7179. else {
  7180. opts = rowSelector;
  7181. rowSelector = null;
  7182. }
  7183. }
  7184. if ( $.isPlainObject( columnSelector ) ) {
  7185. opts = columnSelector;
  7186. columnSelector = null;
  7187. }
  7188. // Cell selector
  7189. if ( columnSelector === null || columnSelector === undefined ) {
  7190. return this.iterator( 'table', function ( settings ) {
  7191. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7192. } );
  7193. }
  7194. // Row + column selector
  7195. var columns = this.columns( columnSelector, opts );
  7196. var rows = this.rows( rowSelector, opts );
  7197. var a, i, ien, j, jen;
  7198. var cells = this.iterator( 'table', function ( settings, idx ) {
  7199. a = [];
  7200. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7201. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7202. a.push( {
  7203. row: rows[idx][i],
  7204. column: columns[idx][j]
  7205. } );
  7206. }
  7207. }
  7208. return a;
  7209. }, 1 );
  7210. $.extend( cells.selector, {
  7211. cols: columnSelector,
  7212. rows: rowSelector,
  7213. opts: opts
  7214. } );
  7215. return cells;
  7216. } );
  7217. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7218. return this.iterator( 'cell', function ( settings, row, column ) {
  7219. var cells = settings.aoData[ row ].anCells;
  7220. return cells ?
  7221. cells[ column ] :
  7222. undefined;
  7223. }, 1 );
  7224. } );
  7225. _api_register( 'cells().data()', function () {
  7226. return this.iterator( 'cell', function ( settings, row, column ) {
  7227. return _fnGetCellData( settings, row, column );
  7228. }, 1 );
  7229. } );
  7230. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7231. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7232. return this.iterator( 'cell', function ( settings, row, column ) {
  7233. return settings.aoData[ row ][ type ][ column ];
  7234. }, 1 );
  7235. } );
  7236. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7237. return this.iterator( 'cell', function ( settings, row, column ) {
  7238. return _fnGetCellData( settings, row, column, type );
  7239. }, 1 );
  7240. } );
  7241. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7242. return this.iterator( 'cell', function ( settings, row, column ) {
  7243. return {
  7244. row: row,
  7245. column: column,
  7246. columnVisible: _fnColumnIndexToVisible( settings, column )
  7247. };
  7248. }, 1 );
  7249. } );
  7250. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7251. return this.iterator( 'cell', function ( settings, row, column ) {
  7252. _fnInvalidate( settings, row, src, column );
  7253. } );
  7254. } );
  7255. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7256. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7257. } );
  7258. _api_register( 'cell().data()', function ( data ) {
  7259. var ctx = this.context;
  7260. var cell = this[0];
  7261. if ( data === undefined ) {
  7262. // Get
  7263. return ctx.length && cell.length ?
  7264. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7265. undefined;
  7266. }
  7267. // Set
  7268. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7269. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7270. return this;
  7271. } );
  7272. /**
  7273. * Get current ordering (sorting) that has been applied to the table.
  7274. *
  7275. * @returns {array} 2D array containing the sorting information for the first
  7276. * table in the current context. Each element in the parent array represents
  7277. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7278. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7279. * the column index that the sorting condition applies to, the second is the
  7280. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7281. * index of the sorting order from the `column.sorting` initialisation array.
  7282. *//**
  7283. * Set the ordering for the table.
  7284. *
  7285. * @param {integer} order Column index to sort upon.
  7286. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7287. * @returns {DataTables.Api} this
  7288. *//**
  7289. * Set the ordering for the table.
  7290. *
  7291. * @param {array} order 1D array of sorting information to be applied.
  7292. * @param {array} [...] Optional additional sorting conditions
  7293. * @returns {DataTables.Api} this
  7294. *//**
  7295. * Set the ordering for the table.
  7296. *
  7297. * @param {array} order 2D array of sorting information to be applied.
  7298. * @returns {DataTables.Api} this
  7299. */
  7300. _api_register( 'order()', function ( order, dir ) {
  7301. var ctx = this.context;
  7302. if ( order === undefined ) {
  7303. // get
  7304. return ctx.length !== 0 ?
  7305. ctx[0].aaSorting :
  7306. undefined;
  7307. }
  7308. // set
  7309. if ( typeof order === 'number' ) {
  7310. // Simple column / direction passed in
  7311. order = [ [ order, dir ] ];
  7312. }
  7313. else if ( ! $.isArray( order[0] ) ) {
  7314. // Arguments passed in (list of 1D arrays)
  7315. order = Array.prototype.slice.call( arguments );
  7316. }
  7317. // otherwise a 2D array was passed in
  7318. return this.iterator( 'table', function ( settings ) {
  7319. settings.aaSorting = order.slice();
  7320. } );
  7321. } );
  7322. /**
  7323. * Attach a sort listener to an element for a given column
  7324. *
  7325. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7326. * listener to. This can take the form of a single DOM node, a jQuery
  7327. * collection of nodes or a jQuery selector which will identify the node(s).
  7328. * @param {integer} column the column that a click on this node will sort on
  7329. * @param {function} [callback] callback function when sort is run
  7330. * @returns {DataTables.Api} this
  7331. */
  7332. _api_register( 'order.listener()', function ( node, column, callback ) {
  7333. return this.iterator( 'table', function ( settings ) {
  7334. _fnSortAttachListener( settings, node, column, callback );
  7335. } );
  7336. } );
  7337. // Order by the selected column(s)
  7338. _api_register( [
  7339. 'columns().order()',
  7340. 'column().order()'
  7341. ], function ( dir ) {
  7342. var that = this;
  7343. return this.iterator( 'table', function ( settings, i ) {
  7344. var sort = [];
  7345. $.each( that[i], function (j, col) {
  7346. sort.push( [ col, dir ] );
  7347. } );
  7348. settings.aaSorting = sort;
  7349. } );
  7350. } );
  7351. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7352. var ctx = this.context;
  7353. if ( input === undefined ) {
  7354. // get
  7355. return ctx.length !== 0 ?
  7356. ctx[0].oPreviousSearch.sSearch :
  7357. undefined;
  7358. }
  7359. // set
  7360. return this.iterator( 'table', function ( settings ) {
  7361. if ( ! settings.oFeatures.bFilter ) {
  7362. return;
  7363. }
  7364. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7365. "sSearch": input+"",
  7366. "bRegex": regex === null ? false : regex,
  7367. "bSmart": smart === null ? true : smart,
  7368. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7369. } ), 1 );
  7370. } );
  7371. } );
  7372. _api_registerPlural(
  7373. 'columns().search()',
  7374. 'column().search()',
  7375. function ( input, regex, smart, caseInsen ) {
  7376. return this.iterator( 'column', function ( settings, column ) {
  7377. var preSearch = settings.aoPreSearchCols;
  7378. if ( input === undefined ) {
  7379. // get
  7380. return preSearch[ column ].sSearch;
  7381. }
  7382. // set
  7383. if ( ! settings.oFeatures.bFilter ) {
  7384. return;
  7385. }
  7386. $.extend( preSearch[ column ], {
  7387. "sSearch": input+"",
  7388. "bRegex": regex === null ? false : regex,
  7389. "bSmart": smart === null ? true : smart,
  7390. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7391. } );
  7392. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7393. } );
  7394. }
  7395. );
  7396. /*
  7397. * State API methods
  7398. */
  7399. _api_register( 'state()', function () {
  7400. return this.context.length ?
  7401. this.context[0].oSavedState :
  7402. null;
  7403. } );
  7404. _api_register( 'state.clear()', function () {
  7405. return this.iterator( 'table', function ( settings ) {
  7406. // Save an empty object
  7407. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7408. } );
  7409. } );
  7410. _api_register( 'state.loaded()', function () {
  7411. return this.context.length ?
  7412. this.context[0].oLoadedState :
  7413. null;
  7414. } );
  7415. _api_register( 'state.save()', function () {
  7416. return this.iterator( 'table', function ( settings ) {
  7417. _fnSaveState( settings );
  7418. } );
  7419. } );
  7420. /**
  7421. * Provide a common method for plug-ins to check the version of DataTables being
  7422. * used, in order to ensure compatibility.
  7423. *
  7424. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7425. * Note that the formats "X" and "X.Y" are also acceptable.
  7426. * @returns {boolean} true if this version of DataTables is greater or equal to
  7427. * the required version, or false if this version of DataTales is not
  7428. * suitable
  7429. * @static
  7430. * @dtopt API-Static
  7431. *
  7432. * @example
  7433. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7434. */
  7435. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7436. {
  7437. var aThis = DataTable.version.split('.');
  7438. var aThat = version.split('.');
  7439. var iThis, iThat;
  7440. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7441. iThis = parseInt( aThis[i], 10 ) || 0;
  7442. iThat = parseInt( aThat[i], 10 ) || 0;
  7443. // Parts are the same, keep comparing
  7444. if (iThis === iThat) {
  7445. continue;
  7446. }
  7447. // Parts are different, return immediately
  7448. return iThis > iThat;
  7449. }
  7450. return true;
  7451. };
  7452. /**
  7453. * Check if a `<table>` node is a DataTable table already or not.
  7454. *
  7455. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7456. * selector for the table to test. Note that if more than more than one
  7457. * table is passed on, only the first will be checked
  7458. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7459. * @static
  7460. * @dtopt API-Static
  7461. *
  7462. * @example
  7463. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7464. * $('#example').dataTable();
  7465. * }
  7466. */
  7467. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7468. {
  7469. var t = $(table).get(0);
  7470. var is = false;
  7471. $.each( DataTable.settings, function (i, o) {
  7472. if ( o.nTable === t ||
  7473. $('table', o.nScrollHead)[0] === t ||
  7474. $('table', o.nScrollFoot)[0] === t
  7475. ) {
  7476. is = true;
  7477. }
  7478. } );
  7479. return is;
  7480. };
  7481. /**
  7482. * Get all DataTable tables that have been initialised - optionally you can
  7483. * select to get only currently visible tables.
  7484. *
  7485. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7486. * or visible tables only.
  7487. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7488. * DataTables
  7489. * @static
  7490. * @dtopt API-Static
  7491. *
  7492. * @example
  7493. * $.each( $.fn.dataTable.tables(true), function () {
  7494. * $(table).DataTable().columns.adjust();
  7495. * } );
  7496. */
  7497. DataTable.tables = DataTable.fnTables = function ( visible )
  7498. {
  7499. return $.map( DataTable.settings, function (o) {
  7500. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7501. return o.nTable;
  7502. }
  7503. } );
  7504. };
  7505. /**
  7506. * DataTables utility methods
  7507. *
  7508. * This namespace provides helper methods that DataTables uses internally to
  7509. * create a DataTable, but which are not exclusively used only for DataTables.
  7510. * These methods can be used by extension authors to save the duplication of
  7511. * code.
  7512. *
  7513. * @namespace
  7514. */
  7515. DataTable.util = {
  7516. /**
  7517. * Throttle the calls to a function. Arguments and context are maintained
  7518. * for the throttled function.
  7519. *
  7520. * @param {function} fn Function to be called
  7521. * @param {integer} freq Call frequency in mS
  7522. * @return {function} Wrapped function
  7523. */
  7524. throttle: _fnThrottle,
  7525. /**
  7526. * Escape a string such that it can be used in a regular expression
  7527. *
  7528. * @param {string} sVal string to escape
  7529. * @returns {string} escaped string
  7530. */
  7531. escapeRegex: _fnEscapeRegex
  7532. };
  7533. /**
  7534. * Convert from camel case parameters to Hungarian notation. This is made public
  7535. * for the extensions to provide the same ability as DataTables core to accept
  7536. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7537. * parameters.
  7538. *
  7539. * @param {object} src The model object which holds all parameters that can be
  7540. * mapped.
  7541. * @param {object} user The object to convert from camel case to Hungarian.
  7542. * @param {boolean} force When set to `true`, properties which already have a
  7543. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7544. * won't be.
  7545. */
  7546. DataTable.camelToHungarian = _fnCamelToHungarian;
  7547. /**
  7548. *
  7549. */
  7550. _api_register( '$()', function ( selector, opts ) {
  7551. var
  7552. rows = this.rows( opts ).nodes(), // Get all rows
  7553. jqRows = $(rows);
  7554. return $( [].concat(
  7555. jqRows.filter( selector ).toArray(),
  7556. jqRows.find( selector ).toArray()
  7557. ) );
  7558. } );
  7559. // jQuery functions to operate on the tables
  7560. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7561. _api_register( key+'()', function ( /* event, handler */ ) {
  7562. var args = Array.prototype.slice.call(arguments);
  7563. // Add the `dt` namespace automatically if it isn't already present
  7564. if ( ! args[0].match(/\.dt\b/) ) {
  7565. args[0] += '.dt';
  7566. }
  7567. var inst = $( this.tables().nodes() );
  7568. inst[key].apply( inst, args );
  7569. return this;
  7570. } );
  7571. } );
  7572. _api_register( 'clear()', function () {
  7573. return this.iterator( 'table', function ( settings ) {
  7574. _fnClearTable( settings );
  7575. } );
  7576. } );
  7577. _api_register( 'settings()', function () {
  7578. return new _Api( this.context, this.context );
  7579. } );
  7580. _api_register( 'data()', function () {
  7581. return this.iterator( 'table', function ( settings ) {
  7582. return _pluck( settings.aoData, '_aData' );
  7583. } ).flatten();
  7584. } );
  7585. _api_register( 'destroy()', function ( remove ) {
  7586. remove = remove || false;
  7587. return this.iterator( 'table', function ( settings ) {
  7588. var orig = settings.nTableWrapper.parentNode;
  7589. var classes = settings.oClasses;
  7590. var table = settings.nTable;
  7591. var tbody = settings.nTBody;
  7592. var thead = settings.nTHead;
  7593. var tfoot = settings.nTFoot;
  7594. var jqTable = $(table);
  7595. var jqTbody = $(tbody);
  7596. var jqWrapper = $(settings.nTableWrapper);
  7597. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7598. var i, ien;
  7599. // Flag to note that the table is currently being destroyed - no action
  7600. // should be taken
  7601. settings.bDestroying = true;
  7602. // Fire off the destroy callbacks for plug-ins etc
  7603. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7604. // If not being removed from the document, make all columns visible
  7605. if ( ! remove ) {
  7606. new _Api( settings ).columns().visible( true );
  7607. }
  7608. // Blitz all `DT` namespaced events (these are internal events, the
  7609. // lowercase, `dt` events are user subscribed and they are responsible
  7610. // for removing them
  7611. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  7612. $(window).unbind('.DT-'+settings.sInstance);
  7613. // When scrolling we had to break the table up - restore it
  7614. if ( table != thead.parentNode ) {
  7615. jqTable.children('thead').detach();
  7616. jqTable.append( thead );
  7617. }
  7618. if ( tfoot && table != tfoot.parentNode ) {
  7619. jqTable.children('tfoot').detach();
  7620. jqTable.append( tfoot );
  7621. }
  7622. // Remove the DataTables generated nodes, events and classes
  7623. jqTable.detach();
  7624. jqWrapper.detach();
  7625. settings.aaSorting = [];
  7626. settings.aaSortingFixed = [];
  7627. _fnSortingClasses( settings );
  7628. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7629. $('th, td', thead).removeClass( classes.sSortable+' '+
  7630. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7631. );
  7632. if ( settings.bJUI ) {
  7633. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  7634. $('th, td', thead).each( function () {
  7635. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  7636. $(this).append( wrapper.contents() );
  7637. wrapper.detach();
  7638. } );
  7639. }
  7640. if ( ! remove && orig ) {
  7641. // insertBefore acts like appendChild if !arg[1]
  7642. orig.insertBefore( table, settings.nTableReinsertBefore );
  7643. }
  7644. // Add the TR elements back into the table in their original order
  7645. jqTbody.children().detach();
  7646. jqTbody.append( rows );
  7647. // Restore the width of the original table - was read from the style property,
  7648. // so we can restore directly to that
  7649. jqTable
  7650. .css( 'width', settings.sDestroyWidth )
  7651. .removeClass( classes.sTable );
  7652. // If the were originally stripe classes - then we add them back here.
  7653. // Note this is not fool proof (for example if not all rows had stripe
  7654. // classes - but it's a good effort without getting carried away
  7655. ien = settings.asDestroyStripes.length;
  7656. if ( ien ) {
  7657. jqTbody.children().each( function (i) {
  7658. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7659. } );
  7660. }
  7661. /* Remove the settings object from the settings array */
  7662. var idx = $.inArray( settings, DataTable.settings );
  7663. if ( idx !== -1 ) {
  7664. DataTable.settings.splice( idx, 1 );
  7665. }
  7666. } );
  7667. } );
  7668. /**
  7669. * Version string for plug-ins to check compatibility. Allowed format is
  7670. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7671. * only for non-release builds. See http://semver.org/ for more information.
  7672. * @member
  7673. * @type string
  7674. * @default Version number
  7675. */
  7676. DataTable.version = "1.10.5";
  7677. /**
  7678. * Private data store, containing all of the settings objects that are
  7679. * created for the tables on a given page.
  7680. *
  7681. * Note that the `DataTable.settings` object is aliased to
  7682. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7683. * manipulated, or `jQuery.fn.dataTable.settings`.
  7684. * @member
  7685. * @type array
  7686. * @default []
  7687. * @private
  7688. */
  7689. DataTable.settings = [];
  7690. /**
  7691. * Object models container, for the various models that DataTables has
  7692. * available to it. These models define the objects that are used to hold
  7693. * the active state and configuration of the table.
  7694. * @namespace
  7695. */
  7696. DataTable.models = {};
  7697. /**
  7698. * Template object for the way in which DataTables holds information about
  7699. * search information for the global filter and individual column filters.
  7700. * @namespace
  7701. */
  7702. DataTable.models.oSearch = {
  7703. /**
  7704. * Flag to indicate if the filtering should be case insensitive or not
  7705. * @type boolean
  7706. * @default true
  7707. */
  7708. "bCaseInsensitive": true,
  7709. /**
  7710. * Applied search term
  7711. * @type string
  7712. * @default <i>Empty string</i>
  7713. */
  7714. "sSearch": "",
  7715. /**
  7716. * Flag to indicate if the search term should be interpreted as a
  7717. * regular expression (true) or not (false) and therefore and special
  7718. * regex characters escaped.
  7719. * @type boolean
  7720. * @default false
  7721. */
  7722. "bRegex": false,
  7723. /**
  7724. * Flag to indicate if DataTables is to use its smart filtering or not.
  7725. * @type boolean
  7726. * @default true
  7727. */
  7728. "bSmart": true
  7729. };
  7730. /**
  7731. * Template object for the way in which DataTables holds information about
  7732. * each individual row. This is the object format used for the settings
  7733. * aoData array.
  7734. * @namespace
  7735. */
  7736. DataTable.models.oRow = {
  7737. /**
  7738. * TR element for the row
  7739. * @type node
  7740. * @default null
  7741. */
  7742. "nTr": null,
  7743. /**
  7744. * Array of TD elements for each row. This is null until the row has been
  7745. * created.
  7746. * @type array nodes
  7747. * @default []
  7748. */
  7749. "anCells": null,
  7750. /**
  7751. * Data object from the original data source for the row. This is either
  7752. * an array if using the traditional form of DataTables, or an object if
  7753. * using mData options. The exact type will depend on the passed in
  7754. * data from the data source, or will be an array if using DOM a data
  7755. * source.
  7756. * @type array|object
  7757. * @default []
  7758. */
  7759. "_aData": [],
  7760. /**
  7761. * Sorting data cache - this array is ostensibly the same length as the
  7762. * number of columns (although each index is generated only as it is
  7763. * needed), and holds the data that is used for sorting each column in the
  7764. * row. We do this cache generation at the start of the sort in order that
  7765. * the formatting of the sort data need be done only once for each cell
  7766. * per sort. This array should not be read from or written to by anything
  7767. * other than the master sorting methods.
  7768. * @type array
  7769. * @default null
  7770. * @private
  7771. */
  7772. "_aSortData": null,
  7773. /**
  7774. * Per cell filtering data cache. As per the sort data cache, used to
  7775. * increase the performance of the filtering in DataTables
  7776. * @type array
  7777. * @default null
  7778. * @private
  7779. */
  7780. "_aFilterData": null,
  7781. /**
  7782. * Filtering data cache. This is the same as the cell filtering cache, but
  7783. * in this case a string rather than an array. This is easily computed with
  7784. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  7785. * needed on every search (memory traded for performance)
  7786. * @type array
  7787. * @default null
  7788. * @private
  7789. */
  7790. "_sFilterRow": null,
  7791. /**
  7792. * Cache of the class name that DataTables has applied to the row, so we
  7793. * can quickly look at this variable rather than needing to do a DOM check
  7794. * on className for the nTr property.
  7795. * @type string
  7796. * @default <i>Empty string</i>
  7797. * @private
  7798. */
  7799. "_sRowStripe": "",
  7800. /**
  7801. * Denote if the original data source was from the DOM, or the data source
  7802. * object. This is used for invalidating data, so DataTables can
  7803. * automatically read data from the original source, unless uninstructed
  7804. * otherwise.
  7805. * @type string
  7806. * @default null
  7807. * @private
  7808. */
  7809. "src": null
  7810. };
  7811. /**
  7812. * Template object for the column information object in DataTables. This object
  7813. * is held in the settings aoColumns array and contains all the information that
  7814. * DataTables needs about each individual column.
  7815. *
  7816. * Note that this object is related to {@link DataTable.defaults.column}
  7817. * but this one is the internal data store for DataTables's cache of columns.
  7818. * It should NOT be manipulated outside of DataTables. Any configuration should
  7819. * be done through the initialisation options.
  7820. * @namespace
  7821. */
  7822. DataTable.models.oColumn = {
  7823. /**
  7824. * Column index. This could be worked out on-the-fly with $.inArray, but it
  7825. * is faster to just hold it as a variable
  7826. * @type integer
  7827. * @default null
  7828. */
  7829. "idx": null,
  7830. /**
  7831. * A list of the columns that sorting should occur on when this column
  7832. * is sorted. That this property is an array allows multi-column sorting
  7833. * to be defined for a column (for example first name / last name columns
  7834. * would benefit from this). The values are integers pointing to the
  7835. * columns to be sorted on (typically it will be a single integer pointing
  7836. * at itself, but that doesn't need to be the case).
  7837. * @type array
  7838. */
  7839. "aDataSort": null,
  7840. /**
  7841. * Define the sorting directions that are applied to the column, in sequence
  7842. * as the column is repeatedly sorted upon - i.e. the first value is used
  7843. * as the sorting direction when the column if first sorted (clicked on).
  7844. * Sort it again (click again) and it will move on to the next index.
  7845. * Repeat until loop.
  7846. * @type array
  7847. */
  7848. "asSorting": null,
  7849. /**
  7850. * Flag to indicate if the column is searchable, and thus should be included
  7851. * in the filtering or not.
  7852. * @type boolean
  7853. */
  7854. "bSearchable": null,
  7855. /**
  7856. * Flag to indicate if the column is sortable or not.
  7857. * @type boolean
  7858. */
  7859. "bSortable": null,
  7860. /**
  7861. * Flag to indicate if the column is currently visible in the table or not
  7862. * @type boolean
  7863. */
  7864. "bVisible": null,
  7865. /**
  7866. * Store for manual type assignment using the `column.type` option. This
  7867. * is held in store so we can manipulate the column's `sType` property.
  7868. * @type string
  7869. * @default null
  7870. * @private
  7871. */
  7872. "_sManualType": null,
  7873. /**
  7874. * Flag to indicate if HTML5 data attributes should be used as the data
  7875. * source for filtering or sorting. True is either are.
  7876. * @type boolean
  7877. * @default false
  7878. * @private
  7879. */
  7880. "_bAttrSrc": false,
  7881. /**
  7882. * Developer definable function that is called whenever a cell is created (Ajax source,
  7883. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  7884. * allowing you to modify the DOM element (add background colour for example) when the
  7885. * element is available.
  7886. * @type function
  7887. * @param {element} nTd The TD node that has been created
  7888. * @param {*} sData The Data for the cell
  7889. * @param {array|object} oData The data for the whole row
  7890. * @param {int} iRow The row index for the aoData data store
  7891. * @default null
  7892. */
  7893. "fnCreatedCell": null,
  7894. /**
  7895. * Function to get data from a cell in a column. You should <b>never</b>
  7896. * access data directly through _aData internally in DataTables - always use
  7897. * the method attached to this property. It allows mData to function as
  7898. * required. This function is automatically assigned by the column
  7899. * initialisation method
  7900. * @type function
  7901. * @param {array|object} oData The data array/object for the array
  7902. * (i.e. aoData[]._aData)
  7903. * @param {string} sSpecific The specific data type you want to get -
  7904. * 'display', 'type' 'filter' 'sort'
  7905. * @returns {*} The data for the cell from the given row's data
  7906. * @default null
  7907. */
  7908. "fnGetData": null,
  7909. /**
  7910. * Function to set data for a cell in the column. You should <b>never</b>
  7911. * set the data directly to _aData internally in DataTables - always use
  7912. * this method. It allows mData to function as required. This function
  7913. * is automatically assigned by the column initialisation method
  7914. * @type function
  7915. * @param {array|object} oData The data array/object for the array
  7916. * (i.e. aoData[]._aData)
  7917. * @param {*} sValue Value to set
  7918. * @default null
  7919. */
  7920. "fnSetData": null,
  7921. /**
  7922. * Property to read the value for the cells in the column from the data
  7923. * source array / object. If null, then the default content is used, if a
  7924. * function is given then the return from the function is used.
  7925. * @type function|int|string|null
  7926. * @default null
  7927. */
  7928. "mData": null,
  7929. /**
  7930. * Partner property to mData which is used (only when defined) to get
  7931. * the data - i.e. it is basically the same as mData, but without the
  7932. * 'set' option, and also the data fed to it is the result from mData.
  7933. * This is the rendering method to match the data method of mData.
  7934. * @type function|int|string|null
  7935. * @default null
  7936. */
  7937. "mRender": null,
  7938. /**
  7939. * Unique header TH/TD element for this column - this is what the sorting
  7940. * listener is attached to (if sorting is enabled.)
  7941. * @type node
  7942. * @default null
  7943. */
  7944. "nTh": null,
  7945. /**
  7946. * Unique footer TH/TD element for this column (if there is one). Not used
  7947. * in DataTables as such, but can be used for plug-ins to reference the
  7948. * footer for each column.
  7949. * @type node
  7950. * @default null
  7951. */
  7952. "nTf": null,
  7953. /**
  7954. * The class to apply to all TD elements in the table's TBODY for the column
  7955. * @type string
  7956. * @default null
  7957. */
  7958. "sClass": null,
  7959. /**
  7960. * When DataTables calculates the column widths to assign to each column,
  7961. * it finds the longest string in each column and then constructs a
  7962. * temporary table and reads the widths from that. The problem with this
  7963. * is that "mmm" is much wider then "iiii", but the latter is a longer
  7964. * string - thus the calculation can go wrong (doing it properly and putting
  7965. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  7966. * a "work around" we provide this option. It will append its value to the
  7967. * text that is found to be the longest string for the column - i.e. padding.
  7968. * @type string
  7969. */
  7970. "sContentPadding": null,
  7971. /**
  7972. * Allows a default value to be given for a column's data, and will be used
  7973. * whenever a null data source is encountered (this can be because mData
  7974. * is set to null, or because the data source itself is null).
  7975. * @type string
  7976. * @default null
  7977. */
  7978. "sDefaultContent": null,
  7979. /**
  7980. * Name for the column, allowing reference to the column by name as well as
  7981. * by index (needs a lookup to work by name).
  7982. * @type string
  7983. */
  7984. "sName": null,
  7985. /**
  7986. * Custom sorting data type - defines which of the available plug-ins in
  7987. * afnSortData the custom sorting will use - if any is defined.
  7988. * @type string
  7989. * @default std
  7990. */
  7991. "sSortDataType": 'std',
  7992. /**
  7993. * Class to be applied to the header element when sorting on this column
  7994. * @type string
  7995. * @default null
  7996. */
  7997. "sSortingClass": null,
  7998. /**
  7999. * Class to be applied to the header element when sorting on this column -
  8000. * when jQuery UI theming is used.
  8001. * @type string
  8002. * @default null
  8003. */
  8004. "sSortingClassJUI": null,
  8005. /**
  8006. * Title of the column - what is seen in the TH element (nTh).
  8007. * @type string
  8008. */
  8009. "sTitle": null,
  8010. /**
  8011. * Column sorting and filtering type
  8012. * @type string
  8013. * @default null
  8014. */
  8015. "sType": null,
  8016. /**
  8017. * Width of the column
  8018. * @type string
  8019. * @default null
  8020. */
  8021. "sWidth": null,
  8022. /**
  8023. * Width of the column when it was first "encountered"
  8024. * @type string
  8025. * @default null
  8026. */
  8027. "sWidthOrig": null
  8028. };
  8029. /*
  8030. * Developer note: The properties of the object below are given in Hungarian
  8031. * notation, that was used as the interface for DataTables prior to v1.10, however
  8032. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8033. * breaking backwards compatibility utterly with this change, the Hungarian
  8034. * version is still, internally the primary interface, but is is not documented
  8035. * - hence the @name tags in each doc comment. This allows a Javascript function
  8036. * to create a map from Hungarian notation to camel case (going the other direction
  8037. * would require each property to be listed, which would at around 3K to the size
  8038. * of DataTables, while this method is about a 0.5K hit.
  8039. *
  8040. * Ultimately this does pave the way for Hungarian notation to be dropped
  8041. * completely, but that is a massive amount of work and will break current
  8042. * installs (therefore is on-hold until v2).
  8043. */
  8044. /**
  8045. * Initialisation options that can be given to DataTables at initialisation
  8046. * time.
  8047. * @namespace
  8048. */
  8049. DataTable.defaults = {
  8050. /**
  8051. * An array of data to use for the table, passed in at initialisation which
  8052. * will be used in preference to any data which is already in the DOM. This is
  8053. * particularly useful for constructing tables purely in Javascript, for
  8054. * example with a custom Ajax call.
  8055. * @type array
  8056. * @default null
  8057. *
  8058. * @dtopt Option
  8059. * @name DataTable.defaults.data
  8060. *
  8061. * @example
  8062. * // Using a 2D array data source
  8063. * $(document).ready( function () {
  8064. * $('#example').dataTable( {
  8065. * "data": [
  8066. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8067. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8068. * ],
  8069. * "columns": [
  8070. * { "title": "Engine" },
  8071. * { "title": "Browser" },
  8072. * { "title": "Platform" },
  8073. * { "title": "Version" },
  8074. * { "title": "Grade" }
  8075. * ]
  8076. * } );
  8077. * } );
  8078. *
  8079. * @example
  8080. * // Using an array of objects as a data source (`data`)
  8081. * $(document).ready( function () {
  8082. * $('#example').dataTable( {
  8083. * "data": [
  8084. * {
  8085. * "engine": "Trident",
  8086. * "browser": "Internet Explorer 4.0",
  8087. * "platform": "Win 95+",
  8088. * "version": 4,
  8089. * "grade": "X"
  8090. * },
  8091. * {
  8092. * "engine": "Trident",
  8093. * "browser": "Internet Explorer 5.0",
  8094. * "platform": "Win 95+",
  8095. * "version": 5,
  8096. * "grade": "C"
  8097. * }
  8098. * ],
  8099. * "columns": [
  8100. * { "title": "Engine", "data": "engine" },
  8101. * { "title": "Browser", "data": "browser" },
  8102. * { "title": "Platform", "data": "platform" },
  8103. * { "title": "Version", "data": "version" },
  8104. * { "title": "Grade", "data": "grade" }
  8105. * ]
  8106. * } );
  8107. * } );
  8108. */
  8109. "aaData": null,
  8110. /**
  8111. * If ordering is enabled, then DataTables will perform a first pass sort on
  8112. * initialisation. You can define which column(s) the sort is performed
  8113. * upon, and the sorting direction, with this variable. The `sorting` array
  8114. * should contain an array for each column to be sorted initially containing
  8115. * the column's index and a direction string ('asc' or 'desc').
  8116. * @type array
  8117. * @default [[0,'asc']]
  8118. *
  8119. * @dtopt Option
  8120. * @name DataTable.defaults.order
  8121. *
  8122. * @example
  8123. * // Sort by 3rd column first, and then 4th column
  8124. * $(document).ready( function() {
  8125. * $('#example').dataTable( {
  8126. * "order": [[2,'asc'], [3,'desc']]
  8127. * } );
  8128. * } );
  8129. *
  8130. * // No initial sorting
  8131. * $(document).ready( function() {
  8132. * $('#example').dataTable( {
  8133. * "order": []
  8134. * } );
  8135. * } );
  8136. */
  8137. "aaSorting": [[0,'asc']],
  8138. /**
  8139. * This parameter is basically identical to the `sorting` parameter, but
  8140. * cannot be overridden by user interaction with the table. What this means
  8141. * is that you could have a column (visible or hidden) which the sorting
  8142. * will always be forced on first - any sorting after that (from the user)
  8143. * will then be performed as required. This can be useful for grouping rows
  8144. * together.
  8145. * @type array
  8146. * @default null
  8147. *
  8148. * @dtopt Option
  8149. * @name DataTable.defaults.orderFixed
  8150. *
  8151. * @example
  8152. * $(document).ready( function() {
  8153. * $('#example').dataTable( {
  8154. * "orderFixed": [[0,'asc']]
  8155. * } );
  8156. * } )
  8157. */
  8158. "aaSortingFixed": [],
  8159. /**
  8160. * DataTables can be instructed to load data to display in the table from a
  8161. * Ajax source. This option defines how that Ajax call is made and where to.
  8162. *
  8163. * The `ajax` property has three different modes of operation, depending on
  8164. * how it is defined. These are:
  8165. *
  8166. * * `string` - Set the URL from where the data should be loaded from.
  8167. * * `object` - Define properties for `jQuery.ajax`.
  8168. * * `function` - Custom data get function
  8169. *
  8170. * `string`
  8171. * --------
  8172. *
  8173. * As a string, the `ajax` property simply defines the URL from which
  8174. * DataTables will load data.
  8175. *
  8176. * `object`
  8177. * --------
  8178. *
  8179. * As an object, the parameters in the object are passed to
  8180. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8181. * of the Ajax request. DataTables has a number of default parameters which
  8182. * you can override using this option. Please refer to the jQuery
  8183. * documentation for a full description of the options available, although
  8184. * the following parameters provide additional options in DataTables or
  8185. * require special consideration:
  8186. *
  8187. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8188. * can also be used as a function to manipulate the data DataTables sends
  8189. * to the server. The function takes a single parameter, an object of
  8190. * parameters with the values that DataTables has readied for sending. An
  8191. * object may be returned which will be merged into the DataTables
  8192. * defaults, or you can add the items to the object that was passed in and
  8193. * not return anything from the function. This supersedes `fnServerParams`
  8194. * from DataTables 1.9-.
  8195. *
  8196. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8197. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8198. * from an Ajax source or for server-side processing - this parameter
  8199. * allows that property to be changed. You can use Javascript dotted
  8200. * object notation to get a data source for multiple levels of nesting, or
  8201. * it my be used as a function. As a function it takes a single parameter,
  8202. * the JSON returned from the server, which can be manipulated as
  8203. * required, with the returned value being that used by DataTables as the
  8204. * data source for the table. This supersedes `sAjaxDataProp` from
  8205. * DataTables 1.9-.
  8206. *
  8207. * * `success` - Should not be overridden it is used internally in
  8208. * DataTables. To manipulate / transform the data returned by the server
  8209. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8210. *
  8211. * `function`
  8212. * ----------
  8213. *
  8214. * As a function, making the Ajax call is left up to yourself allowing
  8215. * complete control of the Ajax request. Indeed, if desired, a method other
  8216. * than Ajax could be used to obtain the required data, such as Web storage
  8217. * or an AIR database.
  8218. *
  8219. * The function is given four parameters and no return is required. The
  8220. * parameters are:
  8221. *
  8222. * 1. _object_ - Data to send to the server
  8223. * 2. _function_ - Callback function that must be executed when the required
  8224. * data has been obtained. That data should be passed into the callback
  8225. * as the only parameter
  8226. * 3. _object_ - DataTables settings object for the table
  8227. *
  8228. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8229. *
  8230. * @type string|object|function
  8231. * @default null
  8232. *
  8233. * @dtopt Option
  8234. * @name DataTable.defaults.ajax
  8235. * @since 1.10.0
  8236. *
  8237. * @example
  8238. * // Get JSON data from a file via Ajax.
  8239. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8240. * $('#example').dataTable( {
  8241. * "ajax": "data.json"
  8242. * } );
  8243. *
  8244. * @example
  8245. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8246. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8247. * $('#example').dataTable( {
  8248. * "ajax": {
  8249. * "url": "data.json",
  8250. * "dataSrc": "tableData"
  8251. * }
  8252. * } );
  8253. *
  8254. * @example
  8255. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8256. * // from a plain array rather than an array in an object
  8257. * $('#example').dataTable( {
  8258. * "ajax": {
  8259. * "url": "data.json",
  8260. * "dataSrc": ""
  8261. * }
  8262. * } );
  8263. *
  8264. * @example
  8265. * // Manipulate the data returned from the server - add a link to data
  8266. * // (note this can, should, be done using `render` for the column - this
  8267. * // is just a simple example of how the data can be manipulated).
  8268. * $('#example').dataTable( {
  8269. * "ajax": {
  8270. * "url": "data.json",
  8271. * "dataSrc": function ( json ) {
  8272. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8273. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8274. * }
  8275. * return json;
  8276. * }
  8277. * }
  8278. * } );
  8279. *
  8280. * @example
  8281. * // Add data to the request
  8282. * $('#example').dataTable( {
  8283. * "ajax": {
  8284. * "url": "data.json",
  8285. * "data": function ( d ) {
  8286. * return {
  8287. * "extra_search": $('#extra').val()
  8288. * };
  8289. * }
  8290. * }
  8291. * } );
  8292. *
  8293. * @example
  8294. * // Send request as POST
  8295. * $('#example').dataTable( {
  8296. * "ajax": {
  8297. * "url": "data.json",
  8298. * "type": "POST"
  8299. * }
  8300. * } );
  8301. *
  8302. * @example
  8303. * // Get the data from localStorage (could interface with a form for
  8304. * // adding, editing and removing rows).
  8305. * $('#example').dataTable( {
  8306. * "ajax": function (data, callback, settings) {
  8307. * callback(
  8308. * JSON.parse( localStorage.getItem('dataTablesData') )
  8309. * );
  8310. * }
  8311. * } );
  8312. */
  8313. "ajax": null,
  8314. /**
  8315. * This parameter allows you to readily specify the entries in the length drop
  8316. * down menu that DataTables shows when pagination is enabled. It can be
  8317. * either a 1D array of options which will be used for both the displayed
  8318. * option and the value, or a 2D array which will use the array in the first
  8319. * position as the value, and the array in the second position as the
  8320. * displayed options (useful for language strings such as 'All').
  8321. *
  8322. * Note that the `pageLength` property will be automatically set to the
  8323. * first value given in this array, unless `pageLength` is also provided.
  8324. * @type array
  8325. * @default [ 10, 25, 50, 100 ]
  8326. *
  8327. * @dtopt Option
  8328. * @name DataTable.defaults.lengthMenu
  8329. *
  8330. * @example
  8331. * $(document).ready( function() {
  8332. * $('#example').dataTable( {
  8333. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8334. * } );
  8335. * } );
  8336. */
  8337. "aLengthMenu": [ 10, 25, 50, 100 ],
  8338. /**
  8339. * The `columns` option in the initialisation parameter allows you to define
  8340. * details about the way individual columns behave. For a full list of
  8341. * column options that can be set, please see
  8342. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8343. * define your columns, you must have an entry in the array for every single
  8344. * column that you have in your table (these can be null if you don't which
  8345. * to specify any options).
  8346. * @member
  8347. *
  8348. * @name DataTable.defaults.column
  8349. */
  8350. "aoColumns": null,
  8351. /**
  8352. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8353. * column, multiple columns, or all columns, using the `targets` property of
  8354. * each object in the array. This allows great flexibility when creating
  8355. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8356. * columns you specifically want. `columnDefs` may use any of the column
  8357. * options available: {@link DataTable.defaults.column}, but it _must_
  8358. * have `targets` defined in each object in the array. Values in the `targets`
  8359. * array may be:
  8360. * <ul>
  8361. * <li>a string - class name will be matched on the TH for the column</li>
  8362. * <li>0 or a positive integer - column index counting from the left</li>
  8363. * <li>a negative integer - column index counting from the right</li>
  8364. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8365. * </ul>
  8366. * @member
  8367. *
  8368. * @name DataTable.defaults.columnDefs
  8369. */
  8370. "aoColumnDefs": null,
  8371. /**
  8372. * Basically the same as `search`, this parameter defines the individual column
  8373. * filtering state at initialisation time. The array must be of the same size
  8374. * as the number of columns, and each element be an object with the parameters
  8375. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8376. * accepted and the default will be used.
  8377. * @type array
  8378. * @default []
  8379. *
  8380. * @dtopt Option
  8381. * @name DataTable.defaults.searchCols
  8382. *
  8383. * @example
  8384. * $(document).ready( function() {
  8385. * $('#example').dataTable( {
  8386. * "searchCols": [
  8387. * null,
  8388. * { "search": "My filter" },
  8389. * null,
  8390. * { "search": "^[0-9]", "escapeRegex": false }
  8391. * ]
  8392. * } );
  8393. * } )
  8394. */
  8395. "aoSearchCols": [],
  8396. /**
  8397. * An array of CSS classes that should be applied to displayed rows. This
  8398. * array may be of any length, and DataTables will apply each class
  8399. * sequentially, looping when required.
  8400. * @type array
  8401. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8402. * options</i>
  8403. *
  8404. * @dtopt Option
  8405. * @name DataTable.defaults.stripeClasses
  8406. *
  8407. * @example
  8408. * $(document).ready( function() {
  8409. * $('#example').dataTable( {
  8410. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8411. * } );
  8412. * } )
  8413. */
  8414. "asStripeClasses": null,
  8415. /**
  8416. * Enable or disable automatic column width calculation. This can be disabled
  8417. * as an optimisation (it takes some time to calculate the widths) if the
  8418. * tables widths are passed in using `columns`.
  8419. * @type boolean
  8420. * @default true
  8421. *
  8422. * @dtopt Features
  8423. * @name DataTable.defaults.autoWidth
  8424. *
  8425. * @example
  8426. * $(document).ready( function () {
  8427. * $('#example').dataTable( {
  8428. * "autoWidth": false
  8429. * } );
  8430. * } );
  8431. */
  8432. "bAutoWidth": true,
  8433. /**
  8434. * Deferred rendering can provide DataTables with a huge speed boost when you
  8435. * are using an Ajax or JS data source for the table. This option, when set to
  8436. * true, will cause DataTables to defer the creation of the table elements for
  8437. * each row until they are needed for a draw - saving a significant amount of
  8438. * time.
  8439. * @type boolean
  8440. * @default false
  8441. *
  8442. * @dtopt Features
  8443. * @name DataTable.defaults.deferRender
  8444. *
  8445. * @example
  8446. * $(document).ready( function() {
  8447. * $('#example').dataTable( {
  8448. * "ajax": "sources/arrays.txt",
  8449. * "deferRender": true
  8450. * } );
  8451. * } );
  8452. */
  8453. "bDeferRender": false,
  8454. /**
  8455. * Replace a DataTable which matches the given selector and replace it with
  8456. * one which has the properties of the new initialisation object passed. If no
  8457. * table matches the selector, then the new DataTable will be constructed as
  8458. * per normal.
  8459. * @type boolean
  8460. * @default false
  8461. *
  8462. * @dtopt Options
  8463. * @name DataTable.defaults.destroy
  8464. *
  8465. * @example
  8466. * $(document).ready( function() {
  8467. * $('#example').dataTable( {
  8468. * "srollY": "200px",
  8469. * "paginate": false
  8470. * } );
  8471. *
  8472. * // Some time later....
  8473. * $('#example').dataTable( {
  8474. * "filter": false,
  8475. * "destroy": true
  8476. * } );
  8477. * } );
  8478. */
  8479. "bDestroy": false,
  8480. /**
  8481. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8482. * that it allows the end user to input multiple words (space separated) and
  8483. * will match a row containing those words, even if not in the order that was
  8484. * specified (this allow matching across multiple columns). Note that if you
  8485. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8486. * default filtering input box and retain filtering abilities, please use
  8487. * {@link DataTable.defaults.dom}.
  8488. * @type boolean
  8489. * @default true
  8490. *
  8491. * @dtopt Features
  8492. * @name DataTable.defaults.searching
  8493. *
  8494. * @example
  8495. * $(document).ready( function () {
  8496. * $('#example').dataTable( {
  8497. * "searching": false
  8498. * } );
  8499. * } );
  8500. */
  8501. "bFilter": true,
  8502. /**
  8503. * Enable or disable the table information display. This shows information
  8504. * about the data that is currently visible on the page, including information
  8505. * about filtered data if that action is being performed.
  8506. * @type boolean
  8507. * @default true
  8508. *
  8509. * @dtopt Features
  8510. * @name DataTable.defaults.info
  8511. *
  8512. * @example
  8513. * $(document).ready( function () {
  8514. * $('#example').dataTable( {
  8515. * "info": false
  8516. * } );
  8517. * } );
  8518. */
  8519. "bInfo": true,
  8520. /**
  8521. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8522. * slightly different and additional mark-up from what DataTables has
  8523. * traditionally used).
  8524. * @type boolean
  8525. * @default false
  8526. *
  8527. * @dtopt Features
  8528. * @name DataTable.defaults.jQueryUI
  8529. *
  8530. * @example
  8531. * $(document).ready( function() {
  8532. * $('#example').dataTable( {
  8533. * "jQueryUI": true
  8534. * } );
  8535. * } );
  8536. */
  8537. "bJQueryUI": false,
  8538. /**
  8539. * Allows the end user to select the size of a formatted page from a select
  8540. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8541. * @type boolean
  8542. * @default true
  8543. *
  8544. * @dtopt Features
  8545. * @name DataTable.defaults.lengthChange
  8546. *
  8547. * @example
  8548. * $(document).ready( function () {
  8549. * $('#example').dataTable( {
  8550. * "lengthChange": false
  8551. * } );
  8552. * } );
  8553. */
  8554. "bLengthChange": true,
  8555. /**
  8556. * Enable or disable pagination.
  8557. * @type boolean
  8558. * @default true
  8559. *
  8560. * @dtopt Features
  8561. * @name DataTable.defaults.paging
  8562. *
  8563. * @example
  8564. * $(document).ready( function () {
  8565. * $('#example').dataTable( {
  8566. * "paging": false
  8567. * } );
  8568. * } );
  8569. */
  8570. "bPaginate": true,
  8571. /**
  8572. * Enable or disable the display of a 'processing' indicator when the table is
  8573. * being processed (e.g. a sort). This is particularly useful for tables with
  8574. * large amounts of data where it can take a noticeable amount of time to sort
  8575. * the entries.
  8576. * @type boolean
  8577. * @default false
  8578. *
  8579. * @dtopt Features
  8580. * @name DataTable.defaults.processing
  8581. *
  8582. * @example
  8583. * $(document).ready( function () {
  8584. * $('#example').dataTable( {
  8585. * "processing": true
  8586. * } );
  8587. * } );
  8588. */
  8589. "bProcessing": false,
  8590. /**
  8591. * Retrieve the DataTables object for the given selector. Note that if the
  8592. * table has already been initialised, this parameter will cause DataTables
  8593. * to simply return the object that has already been set up - it will not take
  8594. * account of any changes you might have made to the initialisation object
  8595. * passed to DataTables (setting this parameter to true is an acknowledgement
  8596. * that you understand this). `destroy` can be used to reinitialise a table if
  8597. * you need.
  8598. * @type boolean
  8599. * @default false
  8600. *
  8601. * @dtopt Options
  8602. * @name DataTable.defaults.retrieve
  8603. *
  8604. * @example
  8605. * $(document).ready( function() {
  8606. * initTable();
  8607. * tableActions();
  8608. * } );
  8609. *
  8610. * function initTable ()
  8611. * {
  8612. * return $('#example').dataTable( {
  8613. * "scrollY": "200px",
  8614. * "paginate": false,
  8615. * "retrieve": true
  8616. * } );
  8617. * }
  8618. *
  8619. * function tableActions ()
  8620. * {
  8621. * var table = initTable();
  8622. * // perform API operations with oTable
  8623. * }
  8624. */
  8625. "bRetrieve": false,
  8626. /**
  8627. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8628. * the table's viewport to the given height at all times (useful for layout).
  8629. * However, this can look odd when filtering data down to a small data set,
  8630. * and the footer is left "floating" further down. This parameter (when
  8631. * enabled) will cause DataTables to collapse the table's viewport down when
  8632. * the result set will fit within the given Y height.
  8633. * @type boolean
  8634. * @default false
  8635. *
  8636. * @dtopt Options
  8637. * @name DataTable.defaults.scrollCollapse
  8638. *
  8639. * @example
  8640. * $(document).ready( function() {
  8641. * $('#example').dataTable( {
  8642. * "scrollY": "200",
  8643. * "scrollCollapse": true
  8644. * } );
  8645. * } );
  8646. */
  8647. "bScrollCollapse": false,
  8648. /**
  8649. * Configure DataTables to use server-side processing. Note that the
  8650. * `ajax` parameter must also be given in order to give DataTables a
  8651. * source to obtain the required data for each draw.
  8652. * @type boolean
  8653. * @default false
  8654. *
  8655. * @dtopt Features
  8656. * @dtopt Server-side
  8657. * @name DataTable.defaults.serverSide
  8658. *
  8659. * @example
  8660. * $(document).ready( function () {
  8661. * $('#example').dataTable( {
  8662. * "serverSide": true,
  8663. * "ajax": "xhr.php"
  8664. * } );
  8665. * } );
  8666. */
  8667. "bServerSide": false,
  8668. /**
  8669. * Enable or disable sorting of columns. Sorting of individual columns can be
  8670. * disabled by the `sortable` option for each column.
  8671. * @type boolean
  8672. * @default true
  8673. *
  8674. * @dtopt Features
  8675. * @name DataTable.defaults.ordering
  8676. *
  8677. * @example
  8678. * $(document).ready( function () {
  8679. * $('#example').dataTable( {
  8680. * "ordering": false
  8681. * } );
  8682. * } );
  8683. */
  8684. "bSort": true,
  8685. /**
  8686. * Enable or display DataTables' ability to sort multiple columns at the
  8687. * same time (activated by shift-click by the user).
  8688. * @type boolean
  8689. * @default true
  8690. *
  8691. * @dtopt Options
  8692. * @name DataTable.defaults.orderMulti
  8693. *
  8694. * @example
  8695. * // Disable multiple column sorting ability
  8696. * $(document).ready( function () {
  8697. * $('#example').dataTable( {
  8698. * "orderMulti": false
  8699. * } );
  8700. * } );
  8701. */
  8702. "bSortMulti": true,
  8703. /**
  8704. * Allows control over whether DataTables should use the top (true) unique
  8705. * cell that is found for a single column, or the bottom (false - default).
  8706. * This is useful when using complex headers.
  8707. * @type boolean
  8708. * @default false
  8709. *
  8710. * @dtopt Options
  8711. * @name DataTable.defaults.orderCellsTop
  8712. *
  8713. * @example
  8714. * $(document).ready( function() {
  8715. * $('#example').dataTable( {
  8716. * "orderCellsTop": true
  8717. * } );
  8718. * } );
  8719. */
  8720. "bSortCellsTop": false,
  8721. /**
  8722. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8723. * `sorting\_3` to the columns which are currently being sorted on. This is
  8724. * presented as a feature switch as it can increase processing time (while
  8725. * classes are removed and added) so for large data sets you might want to
  8726. * turn this off.
  8727. * @type boolean
  8728. * @default true
  8729. *
  8730. * @dtopt Features
  8731. * @name DataTable.defaults.orderClasses
  8732. *
  8733. * @example
  8734. * $(document).ready( function () {
  8735. * $('#example').dataTable( {
  8736. * "orderClasses": false
  8737. * } );
  8738. * } );
  8739. */
  8740. "bSortClasses": true,
  8741. /**
  8742. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  8743. * used to save table display information such as pagination information,
  8744. * display length, filtering and sorting. As such when the end user reloads
  8745. * the page the display display will match what thy had previously set up.
  8746. *
  8747. * Due to the use of `localStorage` the default state saving is not supported
  8748. * in IE6 or 7. If state saving is required in those browsers, use
  8749. * `stateSaveCallback` to provide a storage solution such as cookies.
  8750. * @type boolean
  8751. * @default false
  8752. *
  8753. * @dtopt Features
  8754. * @name DataTable.defaults.stateSave
  8755. *
  8756. * @example
  8757. * $(document).ready( function () {
  8758. * $('#example').dataTable( {
  8759. * "stateSave": true
  8760. * } );
  8761. * } );
  8762. */
  8763. "bStateSave": false,
  8764. /**
  8765. * This function is called when a TR element is created (and all TD child
  8766. * elements have been inserted), or registered if using a DOM source, allowing
  8767. * manipulation of the TR element (adding classes etc).
  8768. * @type function
  8769. * @param {node} row "TR" element for the current row
  8770. * @param {array} data Raw data array for this row
  8771. * @param {int} dataIndex The index of this row in the internal aoData array
  8772. *
  8773. * @dtopt Callbacks
  8774. * @name DataTable.defaults.createdRow
  8775. *
  8776. * @example
  8777. * $(document).ready( function() {
  8778. * $('#example').dataTable( {
  8779. * "createdRow": function( row, data, dataIndex ) {
  8780. * // Bold the grade for all 'A' grade browsers
  8781. * if ( data[4] == "A" )
  8782. * {
  8783. * $('td:eq(4)', row).html( '<b>A</b>' );
  8784. * }
  8785. * }
  8786. * } );
  8787. * } );
  8788. */
  8789. "fnCreatedRow": null,
  8790. /**
  8791. * This function is called on every 'draw' event, and allows you to
  8792. * dynamically modify any aspect you want about the created DOM.
  8793. * @type function
  8794. * @param {object} settings DataTables settings object
  8795. *
  8796. * @dtopt Callbacks
  8797. * @name DataTable.defaults.drawCallback
  8798. *
  8799. * @example
  8800. * $(document).ready( function() {
  8801. * $('#example').dataTable( {
  8802. * "drawCallback": function( settings ) {
  8803. * alert( 'DataTables has redrawn the table' );
  8804. * }
  8805. * } );
  8806. * } );
  8807. */
  8808. "fnDrawCallback": null,
  8809. /**
  8810. * Identical to fnHeaderCallback() but for the table footer this function
  8811. * allows you to modify the table footer on every 'draw' event.
  8812. * @type function
  8813. * @param {node} foot "TR" element for the footer
  8814. * @param {array} data Full table data (as derived from the original HTML)
  8815. * @param {int} start Index for the current display starting point in the
  8816. * display array
  8817. * @param {int} end Index for the current display ending point in the
  8818. * display array
  8819. * @param {array int} display Index array to translate the visual position
  8820. * to the full data array
  8821. *
  8822. * @dtopt Callbacks
  8823. * @name DataTable.defaults.footerCallback
  8824. *
  8825. * @example
  8826. * $(document).ready( function() {
  8827. * $('#example').dataTable( {
  8828. * "footerCallback": function( tfoot, data, start, end, display ) {
  8829. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  8830. * }
  8831. * } );
  8832. * } )
  8833. */
  8834. "fnFooterCallback": null,
  8835. /**
  8836. * When rendering large numbers in the information element for the table
  8837. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  8838. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  8839. * rendered as "1,000,000") to help readability for the end user. This
  8840. * function will override the default method DataTables uses.
  8841. * @type function
  8842. * @member
  8843. * @param {int} toFormat number to be formatted
  8844. * @returns {string} formatted string for DataTables to show the number
  8845. *
  8846. * @dtopt Callbacks
  8847. * @name DataTable.defaults.formatNumber
  8848. *
  8849. * @example
  8850. * // Format a number using a single quote for the separator (note that
  8851. * // this can also be done with the language.thousands option)
  8852. * $(document).ready( function() {
  8853. * $('#example').dataTable( {
  8854. * "formatNumber": function ( toFormat ) {
  8855. * return toFormat.toString().replace(
  8856. * /\B(?=(\d{3})+(?!\d))/g, "'"
  8857. * );
  8858. * };
  8859. * } );
  8860. * } );
  8861. */
  8862. "fnFormatNumber": function ( toFormat ) {
  8863. return toFormat.toString().replace(
  8864. /\B(?=(\d{3})+(?!\d))/g,
  8865. this.oLanguage.sThousands
  8866. );
  8867. },
  8868. /**
  8869. * This function is called on every 'draw' event, and allows you to
  8870. * dynamically modify the header row. This can be used to calculate and
  8871. * display useful information about the table.
  8872. * @type function
  8873. * @param {node} head "TR" element for the header
  8874. * @param {array} data Full table data (as derived from the original HTML)
  8875. * @param {int} start Index for the current display starting point in the
  8876. * display array
  8877. * @param {int} end Index for the current display ending point in the
  8878. * display array
  8879. * @param {array int} display Index array to translate the visual position
  8880. * to the full data array
  8881. *
  8882. * @dtopt Callbacks
  8883. * @name DataTable.defaults.headerCallback
  8884. *
  8885. * @example
  8886. * $(document).ready( function() {
  8887. * $('#example').dataTable( {
  8888. * "fheaderCallback": function( head, data, start, end, display ) {
  8889. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  8890. * }
  8891. * } );
  8892. * } )
  8893. */
  8894. "fnHeaderCallback": null,
  8895. /**
  8896. * The information element can be used to convey information about the current
  8897. * state of the table. Although the internationalisation options presented by
  8898. * DataTables are quite capable of dealing with most customisations, there may
  8899. * be times where you wish to customise the string further. This callback
  8900. * allows you to do exactly that.
  8901. * @type function
  8902. * @param {object} oSettings DataTables settings object
  8903. * @param {int} start Starting position in data for the draw
  8904. * @param {int} end End position in data for the draw
  8905. * @param {int} max Total number of rows in the table (regardless of
  8906. * filtering)
  8907. * @param {int} total Total number of rows in the data set, after filtering
  8908. * @param {string} pre The string that DataTables has formatted using it's
  8909. * own rules
  8910. * @returns {string} The string to be displayed in the information element.
  8911. *
  8912. * @dtopt Callbacks
  8913. * @name DataTable.defaults.infoCallback
  8914. *
  8915. * @example
  8916. * $('#example').dataTable( {
  8917. * "infoCallback": function( settings, start, end, max, total, pre ) {
  8918. * return start +" to "+ end;
  8919. * }
  8920. * } );
  8921. */
  8922. "fnInfoCallback": null,
  8923. /**
  8924. * Called when the table has been initialised. Normally DataTables will
  8925. * initialise sequentially and there will be no need for this function,
  8926. * however, this does not hold true when using external language information
  8927. * since that is obtained using an async XHR call.
  8928. * @type function
  8929. * @param {object} settings DataTables settings object
  8930. * @param {object} json The JSON object request from the server - only
  8931. * present if client-side Ajax sourced data is used
  8932. *
  8933. * @dtopt Callbacks
  8934. * @name DataTable.defaults.initComplete
  8935. *
  8936. * @example
  8937. * $(document).ready( function() {
  8938. * $('#example').dataTable( {
  8939. * "initComplete": function(settings, json) {
  8940. * alert( 'DataTables has finished its initialisation.' );
  8941. * }
  8942. * } );
  8943. * } )
  8944. */
  8945. "fnInitComplete": null,
  8946. /**
  8947. * Called at the very start of each table draw and can be used to cancel the
  8948. * draw by returning false, any other return (including undefined) results in
  8949. * the full draw occurring).
  8950. * @type function
  8951. * @param {object} settings DataTables settings object
  8952. * @returns {boolean} False will cancel the draw, anything else (including no
  8953. * return) will allow it to complete.
  8954. *
  8955. * @dtopt Callbacks
  8956. * @name DataTable.defaults.preDrawCallback
  8957. *
  8958. * @example
  8959. * $(document).ready( function() {
  8960. * $('#example').dataTable( {
  8961. * "preDrawCallback": function( settings ) {
  8962. * if ( $('#test').val() == 1 ) {
  8963. * return false;
  8964. * }
  8965. * }
  8966. * } );
  8967. * } );
  8968. */
  8969. "fnPreDrawCallback": null,
  8970. /**
  8971. * This function allows you to 'post process' each row after it have been
  8972. * generated for each table draw, but before it is rendered on screen. This
  8973. * function might be used for setting the row class name etc.
  8974. * @type function
  8975. * @param {node} row "TR" element for the current row
  8976. * @param {array} data Raw data array for this row
  8977. * @param {int} displayIndex The display index for the current table draw
  8978. * @param {int} displayIndexFull The index of the data in the full list of
  8979. * rows (after filtering)
  8980. *
  8981. * @dtopt Callbacks
  8982. * @name DataTable.defaults.rowCallback
  8983. *
  8984. * @example
  8985. * $(document).ready( function() {
  8986. * $('#example').dataTable( {
  8987. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  8988. * // Bold the grade for all 'A' grade browsers
  8989. * if ( data[4] == "A" ) {
  8990. * $('td:eq(4)', row).html( '<b>A</b>' );
  8991. * }
  8992. * }
  8993. * } );
  8994. * } );
  8995. */
  8996. "fnRowCallback": null,
  8997. /**
  8998. * __Deprecated__ The functionality provided by this parameter has now been
  8999. * superseded by that provided through `ajax`, which should be used instead.
  9000. *
  9001. * This parameter allows you to override the default function which obtains
  9002. * the data from the server so something more suitable for your application.
  9003. * For example you could use POST data, or pull information from a Gears or
  9004. * AIR database.
  9005. * @type function
  9006. * @member
  9007. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9008. * @param {array} data A key/value pair object containing the data to send
  9009. * to the server
  9010. * @param {function} callback to be called on completion of the data get
  9011. * process that will draw the data on the page.
  9012. * @param {object} settings DataTables settings object
  9013. *
  9014. * @dtopt Callbacks
  9015. * @dtopt Server-side
  9016. * @name DataTable.defaults.serverData
  9017. *
  9018. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9019. */
  9020. "fnServerData": null,
  9021. /**
  9022. * __Deprecated__ The functionality provided by this parameter has now been
  9023. * superseded by that provided through `ajax`, which should be used instead.
  9024. *
  9025. * It is often useful to send extra data to the server when making an Ajax
  9026. * request - for example custom filtering information, and this callback
  9027. * function makes it trivial to send extra information to the server. The
  9028. * passed in parameter is the data set that has been constructed by
  9029. * DataTables, and you can add to this or modify it as you require.
  9030. * @type function
  9031. * @param {array} data Data array (array of objects which are name/value
  9032. * pairs) that has been constructed by DataTables and will be sent to the
  9033. * server. In the case of Ajax sourced data with server-side processing
  9034. * this will be an empty array, for server-side processing there will be a
  9035. * significant number of parameters!
  9036. * @returns {undefined} Ensure that you modify the data array passed in,
  9037. * as this is passed by reference.
  9038. *
  9039. * @dtopt Callbacks
  9040. * @dtopt Server-side
  9041. * @name DataTable.defaults.serverParams
  9042. *
  9043. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9044. */
  9045. "fnServerParams": null,
  9046. /**
  9047. * Load the table state. With this function you can define from where, and how, the
  9048. * state of a table is loaded. By default DataTables will load from `localStorage`
  9049. * but you might wish to use a server-side database or cookies.
  9050. * @type function
  9051. * @member
  9052. * @param {object} settings DataTables settings object
  9053. * @return {object} The DataTables state object to be loaded
  9054. *
  9055. * @dtopt Callbacks
  9056. * @name DataTable.defaults.stateLoadCallback
  9057. *
  9058. * @example
  9059. * $(document).ready( function() {
  9060. * $('#example').dataTable( {
  9061. * "stateSave": true,
  9062. * "stateLoadCallback": function (settings) {
  9063. * var o;
  9064. *
  9065. * // Send an Ajax request to the server to get the data. Note that
  9066. * // this is a synchronous request.
  9067. * $.ajax( {
  9068. * "url": "/state_load",
  9069. * "async": false,
  9070. * "dataType": "json",
  9071. * "success": function (json) {
  9072. * o = json;
  9073. * }
  9074. * } );
  9075. *
  9076. * return o;
  9077. * }
  9078. * } );
  9079. * } );
  9080. */
  9081. "fnStateLoadCallback": function ( settings ) {
  9082. try {
  9083. return JSON.parse(
  9084. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9085. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9086. )
  9087. );
  9088. } catch (e) {}
  9089. },
  9090. /**
  9091. * Callback which allows modification of the saved state prior to loading that state.
  9092. * This callback is called when the table is loading state from the stored data, but
  9093. * prior to the settings object being modified by the saved state. Note that for
  9094. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9095. * a plug-in.
  9096. * @type function
  9097. * @param {object} settings DataTables settings object
  9098. * @param {object} data The state object that is to be loaded
  9099. *
  9100. * @dtopt Callbacks
  9101. * @name DataTable.defaults.stateLoadParams
  9102. *
  9103. * @example
  9104. * // Remove a saved filter, so filtering is never loaded
  9105. * $(document).ready( function() {
  9106. * $('#example').dataTable( {
  9107. * "stateSave": true,
  9108. * "stateLoadParams": function (settings, data) {
  9109. * data.oSearch.sSearch = "";
  9110. * }
  9111. * } );
  9112. * } );
  9113. *
  9114. * @example
  9115. * // Disallow state loading by returning false
  9116. * $(document).ready( function() {
  9117. * $('#example').dataTable( {
  9118. * "stateSave": true,
  9119. * "stateLoadParams": function (settings, data) {
  9120. * return false;
  9121. * }
  9122. * } );
  9123. * } );
  9124. */
  9125. "fnStateLoadParams": null,
  9126. /**
  9127. * Callback that is called when the state has been loaded from the state saving method
  9128. * and the DataTables settings object has been modified as a result of the loaded state.
  9129. * @type function
  9130. * @param {object} settings DataTables settings object
  9131. * @param {object} data The state object that was loaded
  9132. *
  9133. * @dtopt Callbacks
  9134. * @name DataTable.defaults.stateLoaded
  9135. *
  9136. * @example
  9137. * // Show an alert with the filtering value that was saved
  9138. * $(document).ready( function() {
  9139. * $('#example').dataTable( {
  9140. * "stateSave": true,
  9141. * "stateLoaded": function (settings, data) {
  9142. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9143. * }
  9144. * } );
  9145. * } );
  9146. */
  9147. "fnStateLoaded": null,
  9148. /**
  9149. * Save the table state. This function allows you to define where and how the state
  9150. * information for the table is stored By default DataTables will use `localStorage`
  9151. * but you might wish to use a server-side database or cookies.
  9152. * @type function
  9153. * @member
  9154. * @param {object} settings DataTables settings object
  9155. * @param {object} data The state object to be saved
  9156. *
  9157. * @dtopt Callbacks
  9158. * @name DataTable.defaults.stateSaveCallback
  9159. *
  9160. * @example
  9161. * $(document).ready( function() {
  9162. * $('#example').dataTable( {
  9163. * "stateSave": true,
  9164. * "stateSaveCallback": function (settings, data) {
  9165. * // Send an Ajax request to the server with the state object
  9166. * $.ajax( {
  9167. * "url": "/state_save",
  9168. * "data": data,
  9169. * "dataType": "json",
  9170. * "method": "POST"
  9171. * "success": function () {}
  9172. * } );
  9173. * }
  9174. * } );
  9175. * } );
  9176. */
  9177. "fnStateSaveCallback": function ( settings, data ) {
  9178. try {
  9179. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9180. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9181. JSON.stringify( data )
  9182. );
  9183. } catch (e) {}
  9184. },
  9185. /**
  9186. * Callback which allows modification of the state to be saved. Called when the table
  9187. * has changed state a new state save is required. This method allows modification of
  9188. * the state saving object prior to actually doing the save, including addition or
  9189. * other state properties or modification. Note that for plug-in authors, you should
  9190. * use the `stateSaveParams` event to save parameters for a plug-in.
  9191. * @type function
  9192. * @param {object} settings DataTables settings object
  9193. * @param {object} data The state object to be saved
  9194. *
  9195. * @dtopt Callbacks
  9196. * @name DataTable.defaults.stateSaveParams
  9197. *
  9198. * @example
  9199. * // Remove a saved filter, so filtering is never saved
  9200. * $(document).ready( function() {
  9201. * $('#example').dataTable( {
  9202. * "stateSave": true,
  9203. * "stateSaveParams": function (settings, data) {
  9204. * data.oSearch.sSearch = "";
  9205. * }
  9206. * } );
  9207. * } );
  9208. */
  9209. "fnStateSaveParams": null,
  9210. /**
  9211. * Duration for which the saved state information is considered valid. After this period
  9212. * has elapsed the state will be returned to the default.
  9213. * Value is given in seconds.
  9214. * @type int
  9215. * @default 7200 <i>(2 hours)</i>
  9216. *
  9217. * @dtopt Options
  9218. * @name DataTable.defaults.stateDuration
  9219. *
  9220. * @example
  9221. * $(document).ready( function() {
  9222. * $('#example').dataTable( {
  9223. * "stateDuration": 60*60*24; // 1 day
  9224. * } );
  9225. * } )
  9226. */
  9227. "iStateDuration": 7200,
  9228. /**
  9229. * When enabled DataTables will not make a request to the server for the first
  9230. * page draw - rather it will use the data already on the page (no sorting etc
  9231. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9232. * is used to indicate that deferred loading is required, but it is also used
  9233. * to tell DataTables how many records there are in the full table (allowing
  9234. * the information element and pagination to be displayed correctly). In the case
  9235. * where a filtering is applied to the table on initial load, this can be
  9236. * indicated by giving the parameter as an array, where the first element is
  9237. * the number of records available after filtering and the second element is the
  9238. * number of records without filtering (allowing the table information element
  9239. * to be shown correctly).
  9240. * @type int | array
  9241. * @default null
  9242. *
  9243. * @dtopt Options
  9244. * @name DataTable.defaults.deferLoading
  9245. *
  9246. * @example
  9247. * // 57 records available in the table, no filtering applied
  9248. * $(document).ready( function() {
  9249. * $('#example').dataTable( {
  9250. * "serverSide": true,
  9251. * "ajax": "scripts/server_processing.php",
  9252. * "deferLoading": 57
  9253. * } );
  9254. * } );
  9255. *
  9256. * @example
  9257. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9258. * $(document).ready( function() {
  9259. * $('#example').dataTable( {
  9260. * "serverSide": true,
  9261. * "ajax": "scripts/server_processing.php",
  9262. * "deferLoading": [ 57, 100 ],
  9263. * "search": {
  9264. * "search": "my_filter"
  9265. * }
  9266. * } );
  9267. * } );
  9268. */
  9269. "iDeferLoading": null,
  9270. /**
  9271. * Number of rows to display on a single page when using pagination. If
  9272. * feature enabled (`lengthChange`) then the end user will be able to override
  9273. * this to a custom setting using a pop-up menu.
  9274. * @type int
  9275. * @default 10
  9276. *
  9277. * @dtopt Options
  9278. * @name DataTable.defaults.pageLength
  9279. *
  9280. * @example
  9281. * $(document).ready( function() {
  9282. * $('#example').dataTable( {
  9283. * "pageLength": 50
  9284. * } );
  9285. * } )
  9286. */
  9287. "iDisplayLength": 10,
  9288. /**
  9289. * Define the starting point for data display when using DataTables with
  9290. * pagination. Note that this parameter is the number of records, rather than
  9291. * the page number, so if you have 10 records per page and want to start on
  9292. * the third page, it should be "20".
  9293. * @type int
  9294. * @default 0
  9295. *
  9296. * @dtopt Options
  9297. * @name DataTable.defaults.displayStart
  9298. *
  9299. * @example
  9300. * $(document).ready( function() {
  9301. * $('#example').dataTable( {
  9302. * "displayStart": 20
  9303. * } );
  9304. * } )
  9305. */
  9306. "iDisplayStart": 0,
  9307. /**
  9308. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9309. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9310. * allows you to tab through the controls and press the enter key to activate them.
  9311. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9312. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9313. * disable built-in keyboard navigation.
  9314. * @type int
  9315. * @default 0
  9316. *
  9317. * @dtopt Options
  9318. * @name DataTable.defaults.tabIndex
  9319. *
  9320. * @example
  9321. * $(document).ready( function() {
  9322. * $('#example').dataTable( {
  9323. * "tabIndex": 1
  9324. * } );
  9325. * } );
  9326. */
  9327. "iTabIndex": 0,
  9328. /**
  9329. * Classes that DataTables assigns to the various components and features
  9330. * that it adds to the HTML table. This allows classes to be configured
  9331. * during initialisation in addition to through the static
  9332. * {@link DataTable.ext.oStdClasses} object).
  9333. * @namespace
  9334. * @name DataTable.defaults.classes
  9335. */
  9336. "oClasses": {},
  9337. /**
  9338. * All strings that DataTables uses in the user interface that it creates
  9339. * are defined in this object, allowing you to modified them individually or
  9340. * completely replace them all as required.
  9341. * @namespace
  9342. * @name DataTable.defaults.language
  9343. */
  9344. "oLanguage": {
  9345. /**
  9346. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9347. * actually visible on the page, but will be read by screenreaders, and thus
  9348. * must be internationalised as well).
  9349. * @namespace
  9350. * @name DataTable.defaults.language.aria
  9351. */
  9352. "oAria": {
  9353. /**
  9354. * ARIA label that is added to the table headers when the column may be
  9355. * sorted ascending by activing the column (click or return when focused).
  9356. * Note that the column header is prefixed to this string.
  9357. * @type string
  9358. * @default : activate to sort column ascending
  9359. *
  9360. * @dtopt Language
  9361. * @name DataTable.defaults.language.aria.sortAscending
  9362. *
  9363. * @example
  9364. * $(document).ready( function() {
  9365. * $('#example').dataTable( {
  9366. * "language": {
  9367. * "aria": {
  9368. * "sortAscending": " - click/return to sort ascending"
  9369. * }
  9370. * }
  9371. * } );
  9372. * } );
  9373. */
  9374. "sSortAscending": ": activate to sort column ascending",
  9375. /**
  9376. * ARIA label that is added to the table headers when the column may be
  9377. * sorted descending by activing the column (click or return when focused).
  9378. * Note that the column header is prefixed to this string.
  9379. * @type string
  9380. * @default : activate to sort column ascending
  9381. *
  9382. * @dtopt Language
  9383. * @name DataTable.defaults.language.aria.sortDescending
  9384. *
  9385. * @example
  9386. * $(document).ready( function() {
  9387. * $('#example').dataTable( {
  9388. * "language": {
  9389. * "aria": {
  9390. * "sortDescending": " - click/return to sort descending"
  9391. * }
  9392. * }
  9393. * } );
  9394. * } );
  9395. */
  9396. "sSortDescending": ": activate to sort column descending"
  9397. },
  9398. /**
  9399. * Pagination string used by DataTables for the built-in pagination
  9400. * control types.
  9401. * @namespace
  9402. * @name DataTable.defaults.language.paginate
  9403. */
  9404. "oPaginate": {
  9405. /**
  9406. * Text to use when using the 'full_numbers' type of pagination for the
  9407. * button to take the user to the first page.
  9408. * @type string
  9409. * @default First
  9410. *
  9411. * @dtopt Language
  9412. * @name DataTable.defaults.language.paginate.first
  9413. *
  9414. * @example
  9415. * $(document).ready( function() {
  9416. * $('#example').dataTable( {
  9417. * "language": {
  9418. * "paginate": {
  9419. * "first": "First page"
  9420. * }
  9421. * }
  9422. * } );
  9423. * } );
  9424. */
  9425. "sFirst": "First",
  9426. /**
  9427. * Text to use when using the 'full_numbers' type of pagination for the
  9428. * button to take the user to the last page.
  9429. * @type string
  9430. * @default Last
  9431. *
  9432. * @dtopt Language
  9433. * @name DataTable.defaults.language.paginate.last
  9434. *
  9435. * @example
  9436. * $(document).ready( function() {
  9437. * $('#example').dataTable( {
  9438. * "language": {
  9439. * "paginate": {
  9440. * "last": "Last page"
  9441. * }
  9442. * }
  9443. * } );
  9444. * } );
  9445. */
  9446. "sLast": "Last",
  9447. /**
  9448. * Text to use for the 'next' pagination button (to take the user to the
  9449. * next page).
  9450. * @type string
  9451. * @default Next
  9452. *
  9453. * @dtopt Language
  9454. * @name DataTable.defaults.language.paginate.next
  9455. *
  9456. * @example
  9457. * $(document).ready( function() {
  9458. * $('#example').dataTable( {
  9459. * "language": {
  9460. * "paginate": {
  9461. * "next": "Next page"
  9462. * }
  9463. * }
  9464. * } );
  9465. * } );
  9466. */
  9467. "sNext": "Next",
  9468. /**
  9469. * Text to use for the 'previous' pagination button (to take the user to
  9470. * the previous page).
  9471. * @type string
  9472. * @default Previous
  9473. *
  9474. * @dtopt Language
  9475. * @name DataTable.defaults.language.paginate.previous
  9476. *
  9477. * @example
  9478. * $(document).ready( function() {
  9479. * $('#example').dataTable( {
  9480. * "language": {
  9481. * "paginate": {
  9482. * "previous": "Previous page"
  9483. * }
  9484. * }
  9485. * } );
  9486. * } );
  9487. */
  9488. "sPrevious": "Previous"
  9489. },
  9490. /**
  9491. * This string is shown in preference to `zeroRecords` when the table is
  9492. * empty of data (regardless of filtering). Note that this is an optional
  9493. * parameter - if it is not given, the value of `zeroRecords` will be used
  9494. * instead (either the default or given value).
  9495. * @type string
  9496. * @default No data available in table
  9497. *
  9498. * @dtopt Language
  9499. * @name DataTable.defaults.language.emptyTable
  9500. *
  9501. * @example
  9502. * $(document).ready( function() {
  9503. * $('#example').dataTable( {
  9504. * "language": {
  9505. * "emptyTable": "No data available in table"
  9506. * }
  9507. * } );
  9508. * } );
  9509. */
  9510. "sEmptyTable": "No data available in table",
  9511. /**
  9512. * This string gives information to the end user about the information
  9513. * that is current on display on the page. The following tokens can be
  9514. * used in the string and will be dynamically replaced as the table
  9515. * display updates. This tokens can be placed anywhere in the string, or
  9516. * removed as needed by the language requires:
  9517. *
  9518. * * `\_START\_` - Display index of the first record on the current page
  9519. * * `\_END\_` - Display index of the last record on the current page
  9520. * * `\_TOTAL\_` - Number of records in the table after filtering
  9521. * * `\_MAX\_` - Number of records in the table without filtering
  9522. * * `\_PAGE\_` - Current page number
  9523. * * `\_PAGES\_` - Total number of pages of data in the table
  9524. *
  9525. * @type string
  9526. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9527. *
  9528. * @dtopt Language
  9529. * @name DataTable.defaults.language.info
  9530. *
  9531. * @example
  9532. * $(document).ready( function() {
  9533. * $('#example').dataTable( {
  9534. * "language": {
  9535. * "info": "Showing page _PAGE_ of _PAGES_"
  9536. * }
  9537. * } );
  9538. * } );
  9539. */
  9540. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9541. /**
  9542. * Display information string for when the table is empty. Typically the
  9543. * format of this string should match `info`.
  9544. * @type string
  9545. * @default Showing 0 to 0 of 0 entries
  9546. *
  9547. * @dtopt Language
  9548. * @name DataTable.defaults.language.infoEmpty
  9549. *
  9550. * @example
  9551. * $(document).ready( function() {
  9552. * $('#example').dataTable( {
  9553. * "language": {
  9554. * "infoEmpty": "No entries to show"
  9555. * }
  9556. * } );
  9557. * } );
  9558. */
  9559. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9560. /**
  9561. * When a user filters the information in a table, this string is appended
  9562. * to the information (`info`) to give an idea of how strong the filtering
  9563. * is. The variable _MAX_ is dynamically updated.
  9564. * @type string
  9565. * @default (filtered from _MAX_ total entries)
  9566. *
  9567. * @dtopt Language
  9568. * @name DataTable.defaults.language.infoFiltered
  9569. *
  9570. * @example
  9571. * $(document).ready( function() {
  9572. * $('#example').dataTable( {
  9573. * "language": {
  9574. * "infoFiltered": " - filtering from _MAX_ records"
  9575. * }
  9576. * } );
  9577. * } );
  9578. */
  9579. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9580. /**
  9581. * If can be useful to append extra information to the info string at times,
  9582. * and this variable does exactly that. This information will be appended to
  9583. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9584. * being used) at all times.
  9585. * @type string
  9586. * @default <i>Empty string</i>
  9587. *
  9588. * @dtopt Language
  9589. * @name DataTable.defaults.language.infoPostFix
  9590. *
  9591. * @example
  9592. * $(document).ready( function() {
  9593. * $('#example').dataTable( {
  9594. * "language": {
  9595. * "infoPostFix": "All records shown are derived from real information."
  9596. * }
  9597. * } );
  9598. * } );
  9599. */
  9600. "sInfoPostFix": "",
  9601. /**
  9602. * This decimal place operator is a little different from the other
  9603. * language options since DataTables doesn't output floating point
  9604. * numbers, so it won't ever use this for display of a number. Rather,
  9605. * what this parameter does is modify the sort methods of the table so
  9606. * that numbers which are in a format which has a character other than
  9607. * a period (`.`) as a decimal place will be sorted numerically.
  9608. *
  9609. * Note that numbers with different decimal places cannot be shown in
  9610. * the same table and still be sortable, the table must be consistent.
  9611. * However, multiple different tables on the page can use different
  9612. * decimal place characters.
  9613. * @type string
  9614. * @default
  9615. *
  9616. * @dtopt Language
  9617. * @name DataTable.defaults.language.decimal
  9618. *
  9619. * @example
  9620. * $(document).ready( function() {
  9621. * $('#example').dataTable( {
  9622. * "language": {
  9623. * "decimal": ","
  9624. * "thousands": "."
  9625. * }
  9626. * } );
  9627. * } );
  9628. */
  9629. "sDecimal": "",
  9630. /**
  9631. * DataTables has a build in number formatter (`formatNumber`) which is
  9632. * used to format large numbers that are used in the table information.
  9633. * By default a comma is used, but this can be trivially changed to any
  9634. * character you wish with this parameter.
  9635. * @type string
  9636. * @default ,
  9637. *
  9638. * @dtopt Language
  9639. * @name DataTable.defaults.language.thousands
  9640. *
  9641. * @example
  9642. * $(document).ready( function() {
  9643. * $('#example').dataTable( {
  9644. * "language": {
  9645. * "thousands": "'"
  9646. * }
  9647. * } );
  9648. * } );
  9649. */
  9650. "sThousands": ",",
  9651. /**
  9652. * Detail the action that will be taken when the drop down menu for the
  9653. * pagination length option is changed. The '_MENU_' variable is replaced
  9654. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9655. * with a custom select box if required.
  9656. * @type string
  9657. * @default Show _MENU_ entries
  9658. *
  9659. * @dtopt Language
  9660. * @name DataTable.defaults.language.lengthMenu
  9661. *
  9662. * @example
  9663. * // Language change only
  9664. * $(document).ready( function() {
  9665. * $('#example').dataTable( {
  9666. * "language": {
  9667. * "lengthMenu": "Display _MENU_ records"
  9668. * }
  9669. * } );
  9670. * } );
  9671. *
  9672. * @example
  9673. * // Language and options change
  9674. * $(document).ready( function() {
  9675. * $('#example').dataTable( {
  9676. * "language": {
  9677. * "lengthMenu": 'Display <select>'+
  9678. * '<option value="10">10</option>'+
  9679. * '<option value="20">20</option>'+
  9680. * '<option value="30">30</option>'+
  9681. * '<option value="40">40</option>'+
  9682. * '<option value="50">50</option>'+
  9683. * '<option value="-1">All</option>'+
  9684. * '</select> records'
  9685. * }
  9686. * } );
  9687. * } );
  9688. */
  9689. "sLengthMenu": "Show _MENU_ entries",
  9690. /**
  9691. * When using Ajax sourced data and during the first draw when DataTables is
  9692. * gathering the data, this message is shown in an empty row in the table to
  9693. * indicate to the end user the the data is being loaded. Note that this
  9694. * parameter is not used when loading data by server-side processing, just
  9695. * Ajax sourced data with client-side processing.
  9696. * @type string
  9697. * @default Loading...
  9698. *
  9699. * @dtopt Language
  9700. * @name DataTable.defaults.language.loadingRecords
  9701. *
  9702. * @example
  9703. * $(document).ready( function() {
  9704. * $('#example').dataTable( {
  9705. * "language": {
  9706. * "loadingRecords": "Please wait - loading..."
  9707. * }
  9708. * } );
  9709. * } );
  9710. */
  9711. "sLoadingRecords": "Loading...",
  9712. /**
  9713. * Text which is displayed when the table is processing a user action
  9714. * (usually a sort command or similar).
  9715. * @type string
  9716. * @default Processing...
  9717. *
  9718. * @dtopt Language
  9719. * @name DataTable.defaults.language.processing
  9720. *
  9721. * @example
  9722. * $(document).ready( function() {
  9723. * $('#example').dataTable( {
  9724. * "language": {
  9725. * "processing": "DataTables is currently busy"
  9726. * }
  9727. * } );
  9728. * } );
  9729. */
  9730. "sProcessing": "Processing...",
  9731. /**
  9732. * Details the actions that will be taken when the user types into the
  9733. * filtering input text box. The variable "_INPUT_", if used in the string,
  9734. * is replaced with the HTML text box for the filtering input allowing
  9735. * control over where it appears in the string. If "_INPUT_" is not given
  9736. * then the input box is appended to the string automatically.
  9737. * @type string
  9738. * @default Search:
  9739. *
  9740. * @dtopt Language
  9741. * @name DataTable.defaults.language.search
  9742. *
  9743. * @example
  9744. * // Input text box will be appended at the end automatically
  9745. * $(document).ready( function() {
  9746. * $('#example').dataTable( {
  9747. * "language": {
  9748. * "search": "Filter records:"
  9749. * }
  9750. * } );
  9751. * } );
  9752. *
  9753. * @example
  9754. * // Specify where the filter should appear
  9755. * $(document).ready( function() {
  9756. * $('#example').dataTable( {
  9757. * "language": {
  9758. * "search": "Apply filter _INPUT_ to table"
  9759. * }
  9760. * } );
  9761. * } );
  9762. */
  9763. "sSearch": "Search:",
  9764. /**
  9765. * Assign a `placeholder` attribute to the search `input` element
  9766. * @type string
  9767. * @default
  9768. *
  9769. * @dtopt Language
  9770. * @name DataTable.defaults.language.searchPlaceholder
  9771. */
  9772. "sSearchPlaceholder": "",
  9773. /**
  9774. * All of the language information can be stored in a file on the
  9775. * server-side, which DataTables will look up if this parameter is passed.
  9776. * It must store the URL of the language file, which is in a JSON format,
  9777. * and the object has the same properties as the oLanguage object in the
  9778. * initialiser object (i.e. the above parameters). Please refer to one of
  9779. * the example language files to see how this works in action.
  9780. * @type string
  9781. * @default <i>Empty string - i.e. disabled</i>
  9782. *
  9783. * @dtopt Language
  9784. * @name DataTable.defaults.language.url
  9785. *
  9786. * @example
  9787. * $(document).ready( function() {
  9788. * $('#example').dataTable( {
  9789. * "language": {
  9790. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  9791. * }
  9792. * } );
  9793. * } );
  9794. */
  9795. "sUrl": "",
  9796. /**
  9797. * Text shown inside the table records when the is no information to be
  9798. * displayed after filtering. `emptyTable` is shown when there is simply no
  9799. * information in the table at all (regardless of filtering).
  9800. * @type string
  9801. * @default No matching records found
  9802. *
  9803. * @dtopt Language
  9804. * @name DataTable.defaults.language.zeroRecords
  9805. *
  9806. * @example
  9807. * $(document).ready( function() {
  9808. * $('#example').dataTable( {
  9809. * "language": {
  9810. * "zeroRecords": "No records to display"
  9811. * }
  9812. * } );
  9813. * } );
  9814. */
  9815. "sZeroRecords": "No matching records found"
  9816. },
  9817. /**
  9818. * This parameter allows you to have define the global filtering state at
  9819. * initialisation time. As an object the `search` parameter must be
  9820. * defined, but all other parameters are optional. When `regex` is true,
  9821. * the search string will be treated as a regular expression, when false
  9822. * (default) it will be treated as a straight string. When `smart`
  9823. * DataTables will use it's smart filtering methods (to word match at
  9824. * any point in the data), when false this will not be done.
  9825. * @namespace
  9826. * @extends DataTable.models.oSearch
  9827. *
  9828. * @dtopt Options
  9829. * @name DataTable.defaults.search
  9830. *
  9831. * @example
  9832. * $(document).ready( function() {
  9833. * $('#example').dataTable( {
  9834. * "search": {"search": "Initial search"}
  9835. * } );
  9836. * } )
  9837. */
  9838. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  9839. /**
  9840. * __Deprecated__ The functionality provided by this parameter has now been
  9841. * superseded by that provided through `ajax`, which should be used instead.
  9842. *
  9843. * By default DataTables will look for the property `data` (or `aaData` for
  9844. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  9845. * source or for server-side processing - this parameter allows that
  9846. * property to be changed. You can use Javascript dotted object notation to
  9847. * get a data source for multiple levels of nesting.
  9848. * @type string
  9849. * @default data
  9850. *
  9851. * @dtopt Options
  9852. * @dtopt Server-side
  9853. * @name DataTable.defaults.ajaxDataProp
  9854. *
  9855. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9856. */
  9857. "sAjaxDataProp": "data",
  9858. /**
  9859. * __Deprecated__ The functionality provided by this parameter has now been
  9860. * superseded by that provided through `ajax`, which should be used instead.
  9861. *
  9862. * You can instruct DataTables to load data from an external
  9863. * source using this parameter (use aData if you want to pass data in you
  9864. * already have). Simply provide a url a JSON object can be obtained from.
  9865. * @type string
  9866. * @default null
  9867. *
  9868. * @dtopt Options
  9869. * @dtopt Server-side
  9870. * @name DataTable.defaults.ajaxSource
  9871. *
  9872. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9873. */
  9874. "sAjaxSource": null,
  9875. /**
  9876. * This initialisation variable allows you to specify exactly where in the
  9877. * DOM you want DataTables to inject the various controls it adds to the page
  9878. * (for example you might want the pagination controls at the top of the
  9879. * table). DIV elements (with or without a custom class) can also be added to
  9880. * aid styling. The follow syntax is used:
  9881. * <ul>
  9882. * <li>The following options are allowed:
  9883. * <ul>
  9884. * <li>'l' - Length changing</li>
  9885. * <li>'f' - Filtering input</li>
  9886. * <li>'t' - The table!</li>
  9887. * <li>'i' - Information</li>
  9888. * <li>'p' - Pagination</li>
  9889. * <li>'r' - pRocessing</li>
  9890. * </ul>
  9891. * </li>
  9892. * <li>The following constants are allowed:
  9893. * <ul>
  9894. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  9895. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  9896. * </ul>
  9897. * </li>
  9898. * <li>The following syntax is expected:
  9899. * <ul>
  9900. * <li>'&lt;' and '&gt;' - div elements</li>
  9901. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  9902. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  9903. * </ul>
  9904. * </li>
  9905. * <li>Examples:
  9906. * <ul>
  9907. * <li>'&lt;"wrapper"flipt&gt;'</li>
  9908. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  9909. * </ul>
  9910. * </li>
  9911. * </ul>
  9912. * @type string
  9913. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  9914. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  9915. *
  9916. * @dtopt Options
  9917. * @name DataTable.defaults.dom
  9918. *
  9919. * @example
  9920. * $(document).ready( function() {
  9921. * $('#example').dataTable( {
  9922. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  9923. * } );
  9924. * } );
  9925. */
  9926. "sDom": "lfrtip",
  9927. /**
  9928. * Search delay option. This will throttle full table searches that use the
  9929. * DataTables provided search input element (it does not effect calls to
  9930. * `dt-api search()`, providing a delay before the search is made.
  9931. * @type integer
  9932. * @default 0
  9933. *
  9934. * @dtopt Options
  9935. * @name DataTable.defaults.searchDelay
  9936. *
  9937. * @example
  9938. * $(document).ready( function() {
  9939. * $('#example').dataTable( {
  9940. * "searchDelay": 200
  9941. * } );
  9942. * } )
  9943. */
  9944. "searchDelay": null,
  9945. /**
  9946. * DataTables features four different built-in options for the buttons to
  9947. * display for pagination control:
  9948. *
  9949. * * `simple` - 'Previous' and 'Next' buttons only
  9950. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  9951. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  9952. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  9953. * page numbers
  9954. *
  9955. * Further methods can be added using {@link DataTable.ext.oPagination}.
  9956. * @type string
  9957. * @default simple_numbers
  9958. *
  9959. * @dtopt Options
  9960. * @name DataTable.defaults.pagingType
  9961. *
  9962. * @example
  9963. * $(document).ready( function() {
  9964. * $('#example').dataTable( {
  9965. * "pagingType": "full_numbers"
  9966. * } );
  9967. * } )
  9968. */
  9969. "sPaginationType": "simple_numbers",
  9970. /**
  9971. * Enable horizontal scrolling. When a table is too wide to fit into a
  9972. * certain layout, or you have a large number of columns in the table, you
  9973. * can enable x-scrolling to show the table in a viewport, which can be
  9974. * scrolled. This property can be `true` which will allow the table to
  9975. * scroll horizontally when needed, or any CSS unit, or a number (in which
  9976. * case it will be treated as a pixel measurement). Setting as simply `true`
  9977. * is recommended.
  9978. * @type boolean|string
  9979. * @default <i>blank string - i.e. disabled</i>
  9980. *
  9981. * @dtopt Features
  9982. * @name DataTable.defaults.scrollX
  9983. *
  9984. * @example
  9985. * $(document).ready( function() {
  9986. * $('#example').dataTable( {
  9987. * "scrollX": true,
  9988. * "scrollCollapse": true
  9989. * } );
  9990. * } );
  9991. */
  9992. "sScrollX": "",
  9993. /**
  9994. * This property can be used to force a DataTable to use more width than it
  9995. * might otherwise do when x-scrolling is enabled. For example if you have a
  9996. * table which requires to be well spaced, this parameter is useful for
  9997. * "over-sizing" the table, and thus forcing scrolling. This property can by
  9998. * any CSS unit, or a number (in which case it will be treated as a pixel
  9999. * measurement).
  10000. * @type string
  10001. * @default <i>blank string - i.e. disabled</i>
  10002. *
  10003. * @dtopt Options
  10004. * @name DataTable.defaults.scrollXInner
  10005. *
  10006. * @example
  10007. * $(document).ready( function() {
  10008. * $('#example').dataTable( {
  10009. * "scrollX": "100%",
  10010. * "scrollXInner": "110%"
  10011. * } );
  10012. * } );
  10013. */
  10014. "sScrollXInner": "",
  10015. /**
  10016. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10017. * to the given height, and enable scrolling for any data which overflows the
  10018. * current viewport. This can be used as an alternative to paging to display
  10019. * a lot of data in a small area (although paging and scrolling can both be
  10020. * enabled at the same time). This property can be any CSS unit, or a number
  10021. * (in which case it will be treated as a pixel measurement).
  10022. * @type string
  10023. * @default <i>blank string - i.e. disabled</i>
  10024. *
  10025. * @dtopt Features
  10026. * @name DataTable.defaults.scrollY
  10027. *
  10028. * @example
  10029. * $(document).ready( function() {
  10030. * $('#example').dataTable( {
  10031. * "scrollY": "200px",
  10032. * "paginate": false
  10033. * } );
  10034. * } );
  10035. */
  10036. "sScrollY": "",
  10037. /**
  10038. * __Deprecated__ The functionality provided by this parameter has now been
  10039. * superseded by that provided through `ajax`, which should be used instead.
  10040. *
  10041. * Set the HTTP method that is used to make the Ajax call for server-side
  10042. * processing or Ajax sourced data.
  10043. * @type string
  10044. * @default GET
  10045. *
  10046. * @dtopt Options
  10047. * @dtopt Server-side
  10048. * @name DataTable.defaults.serverMethod
  10049. *
  10050. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10051. */
  10052. "sServerMethod": "GET",
  10053. /**
  10054. * DataTables makes use of renderers when displaying HTML elements for
  10055. * a table. These renderers can be added or modified by plug-ins to
  10056. * generate suitable mark-up for a site. For example the Bootstrap
  10057. * integration plug-in for DataTables uses a paging button renderer to
  10058. * display pagination buttons in the mark-up required by Bootstrap.
  10059. *
  10060. * For further information about the renderers available see
  10061. * DataTable.ext.renderer
  10062. * @type string|object
  10063. * @default null
  10064. *
  10065. * @name DataTable.defaults.renderer
  10066. *
  10067. */
  10068. "renderer": null
  10069. };
  10070. _fnHungarianMap( DataTable.defaults );
  10071. /*
  10072. * Developer note - See note in model.defaults.js about the use of Hungarian
  10073. * notation and camel case.
  10074. */
  10075. /**
  10076. * Column options that can be given to DataTables at initialisation time.
  10077. * @namespace
  10078. */
  10079. DataTable.defaults.column = {
  10080. /**
  10081. * Define which column(s) an order will occur on for this column. This
  10082. * allows a column's ordering to take multiple columns into account when
  10083. * doing a sort or use the data from a different column. For example first
  10084. * name / last name columns make sense to do a multi-column sort over the
  10085. * two columns.
  10086. * @type array|int
  10087. * @default null <i>Takes the value of the column index automatically</i>
  10088. *
  10089. * @name DataTable.defaults.column.orderData
  10090. * @dtopt Columns
  10091. *
  10092. * @example
  10093. * // Using `columnDefs`
  10094. * $(document).ready( function() {
  10095. * $('#example').dataTable( {
  10096. * "columnDefs": [
  10097. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10098. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10099. * { "orderData": 2, "targets": [ 2 ] }
  10100. * ]
  10101. * } );
  10102. * } );
  10103. *
  10104. * @example
  10105. * // Using `columns`
  10106. * $(document).ready( function() {
  10107. * $('#example').dataTable( {
  10108. * "columns": [
  10109. * { "orderData": [ 0, 1 ] },
  10110. * { "orderData": [ 1, 0 ] },
  10111. * { "orderData": 2 },
  10112. * null,
  10113. * null
  10114. * ]
  10115. * } );
  10116. * } );
  10117. */
  10118. "aDataSort": null,
  10119. "iDataSort": -1,
  10120. /**
  10121. * You can control the default ordering direction, and even alter the
  10122. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10123. * using this parameter.
  10124. * @type array
  10125. * @default [ 'asc', 'desc' ]
  10126. *
  10127. * @name DataTable.defaults.column.orderSequence
  10128. * @dtopt Columns
  10129. *
  10130. * @example
  10131. * // Using `columnDefs`
  10132. * $(document).ready( function() {
  10133. * $('#example').dataTable( {
  10134. * "columnDefs": [
  10135. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10136. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10137. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10138. * ]
  10139. * } );
  10140. * } );
  10141. *
  10142. * @example
  10143. * // Using `columns`
  10144. * $(document).ready( function() {
  10145. * $('#example').dataTable( {
  10146. * "columns": [
  10147. * null,
  10148. * { "orderSequence": [ "asc" ] },
  10149. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10150. * { "orderSequence": [ "desc" ] },
  10151. * null
  10152. * ]
  10153. * } );
  10154. * } );
  10155. */
  10156. "asSorting": [ 'asc', 'desc' ],
  10157. /**
  10158. * Enable or disable filtering on the data in this column.
  10159. * @type boolean
  10160. * @default true
  10161. *
  10162. * @name DataTable.defaults.column.searchable
  10163. * @dtopt Columns
  10164. *
  10165. * @example
  10166. * // Using `columnDefs`
  10167. * $(document).ready( function() {
  10168. * $('#example').dataTable( {
  10169. * "columnDefs": [
  10170. * { "searchable": false, "targets": [ 0 ] }
  10171. * ] } );
  10172. * } );
  10173. *
  10174. * @example
  10175. * // Using `columns`
  10176. * $(document).ready( function() {
  10177. * $('#example').dataTable( {
  10178. * "columns": [
  10179. * { "searchable": false },
  10180. * null,
  10181. * null,
  10182. * null,
  10183. * null
  10184. * ] } );
  10185. * } );
  10186. */
  10187. "bSearchable": true,
  10188. /**
  10189. * Enable or disable ordering on this column.
  10190. * @type boolean
  10191. * @default true
  10192. *
  10193. * @name DataTable.defaults.column.orderable
  10194. * @dtopt Columns
  10195. *
  10196. * @example
  10197. * // Using `columnDefs`
  10198. * $(document).ready( function() {
  10199. * $('#example').dataTable( {
  10200. * "columnDefs": [
  10201. * { "orderable": false, "targets": [ 0 ] }
  10202. * ] } );
  10203. * } );
  10204. *
  10205. * @example
  10206. * // Using `columns`
  10207. * $(document).ready( function() {
  10208. * $('#example').dataTable( {
  10209. * "columns": [
  10210. * { "orderable": false },
  10211. * null,
  10212. * null,
  10213. * null,
  10214. * null
  10215. * ] } );
  10216. * } );
  10217. */
  10218. "bSortable": true,
  10219. /**
  10220. * Enable or disable the display of this column.
  10221. * @type boolean
  10222. * @default true
  10223. *
  10224. * @name DataTable.defaults.column.visible
  10225. * @dtopt Columns
  10226. *
  10227. * @example
  10228. * // Using `columnDefs`
  10229. * $(document).ready( function() {
  10230. * $('#example').dataTable( {
  10231. * "columnDefs": [
  10232. * { "visible": false, "targets": [ 0 ] }
  10233. * ] } );
  10234. * } );
  10235. *
  10236. * @example
  10237. * // Using `columns`
  10238. * $(document).ready( function() {
  10239. * $('#example').dataTable( {
  10240. * "columns": [
  10241. * { "visible": false },
  10242. * null,
  10243. * null,
  10244. * null,
  10245. * null
  10246. * ] } );
  10247. * } );
  10248. */
  10249. "bVisible": true,
  10250. /**
  10251. * Developer definable function that is called whenever a cell is created (Ajax source,
  10252. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10253. * allowing you to modify the DOM element (add background colour for example) when the
  10254. * element is available.
  10255. * @type function
  10256. * @param {element} td The TD node that has been created
  10257. * @param {*} cellData The Data for the cell
  10258. * @param {array|object} rowData The data for the whole row
  10259. * @param {int} row The row index for the aoData data store
  10260. * @param {int} col The column index for aoColumns
  10261. *
  10262. * @name DataTable.defaults.column.createdCell
  10263. * @dtopt Columns
  10264. *
  10265. * @example
  10266. * $(document).ready( function() {
  10267. * $('#example').dataTable( {
  10268. * "columnDefs": [ {
  10269. * "targets": [3],
  10270. * "createdCell": function (td, cellData, rowData, row, col) {
  10271. * if ( cellData == "1.7" ) {
  10272. * $(td).css('color', 'blue')
  10273. * }
  10274. * }
  10275. * } ]
  10276. * });
  10277. * } );
  10278. */
  10279. "fnCreatedCell": null,
  10280. /**
  10281. * This parameter has been replaced by `data` in DataTables to ensure naming
  10282. * consistency. `dataProp` can still be used, as there is backwards
  10283. * compatibility in DataTables for this option, but it is strongly
  10284. * recommended that you use `data` in preference to `dataProp`.
  10285. * @name DataTable.defaults.column.dataProp
  10286. */
  10287. /**
  10288. * This property can be used to read data from any data source property,
  10289. * including deeply nested objects / properties. `data` can be given in a
  10290. * number of different ways which effect its behaviour:
  10291. *
  10292. * * `integer` - treated as an array index for the data source. This is the
  10293. * default that DataTables uses (incrementally increased for each column).
  10294. * * `string` - read an object property from the data source. There are
  10295. * three 'special' options that can be used in the string to alter how
  10296. * DataTables reads the data from the source object:
  10297. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10298. * Javascript to read from nested objects, so to can the options
  10299. * specified in `data`. For example: `browser.version` or
  10300. * `browser.name`. If your object parameter name contains a period, use
  10301. * `\\` to escape it - i.e. `first\\.name`.
  10302. * * `[]` - Array notation. DataTables can automatically combine data
  10303. * from and array source, joining the data with the characters provided
  10304. * between the two brackets. For example: `name[, ]` would provide a
  10305. * comma-space separated list from the source array. If no characters
  10306. * are provided between the brackets, the original array source is
  10307. * returned.
  10308. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10309. * execute a function of the name given. For example: `browser()` for a
  10310. * simple function on the data source, `browser.version()` for a
  10311. * function in a nested property or even `browser().version` to get an
  10312. * object property if the function called returns an object. Note that
  10313. * function notation is recommended for use in `render` rather than
  10314. * `data` as it is much simpler to use as a renderer.
  10315. * * `null` - use the original data source for the row rather than plucking
  10316. * data directly from it. This action has effects on two other
  10317. * initialisation options:
  10318. * * `defaultContent` - When null is given as the `data` option and
  10319. * `defaultContent` is specified for the column, the value defined by
  10320. * `defaultContent` will be used for the cell.
  10321. * * `render` - When null is used for the `data` option and the `render`
  10322. * option is specified for the column, the whole data source for the
  10323. * row is used for the renderer.
  10324. * * `function` - the function given will be executed whenever DataTables
  10325. * needs to set or get the data for a cell in the column. The function
  10326. * takes three parameters:
  10327. * * Parameters:
  10328. * * `{array|object}` The data source for the row
  10329. * * `{string}` The type call data requested - this will be 'set' when
  10330. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10331. * when gathering data. Note that when `undefined` is given for the
  10332. * type DataTables expects to get the raw data for the object back<
  10333. * * `{*}` Data to set when the second parameter is 'set'.
  10334. * * Return:
  10335. * * The return value from the function is not required when 'set' is
  10336. * the type of call, but otherwise the return is what will be used
  10337. * for the data requested.
  10338. *
  10339. * Note that `data` is a getter and setter option. If you just require
  10340. * formatting of data for output, you will likely want to use `render` which
  10341. * is simply a getter and thus simpler to use.
  10342. *
  10343. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10344. * name change reflects the flexibility of this property and is consistent
  10345. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10346. * be used by DataTables, as it automatically maps the old name to the new
  10347. * if required.
  10348. *
  10349. * @type string|int|function|null
  10350. * @default null <i>Use automatically calculated column index</i>
  10351. *
  10352. * @name DataTable.defaults.column.data
  10353. * @dtopt Columns
  10354. *
  10355. * @example
  10356. * // Read table data from objects
  10357. * // JSON structure for each row:
  10358. * // {
  10359. * // "engine": {value},
  10360. * // "browser": {value},
  10361. * // "platform": {value},
  10362. * // "version": {value},
  10363. * // "grade": {value}
  10364. * // }
  10365. * $(document).ready( function() {
  10366. * $('#example').dataTable( {
  10367. * "ajaxSource": "sources/objects.txt",
  10368. * "columns": [
  10369. * { "data": "engine" },
  10370. * { "data": "browser" },
  10371. * { "data": "platform" },
  10372. * { "data": "version" },
  10373. * { "data": "grade" }
  10374. * ]
  10375. * } );
  10376. * } );
  10377. *
  10378. * @example
  10379. * // Read information from deeply nested objects
  10380. * // JSON structure for each row:
  10381. * // {
  10382. * // "engine": {value},
  10383. * // "browser": {value},
  10384. * // "platform": {
  10385. * // "inner": {value}
  10386. * // },
  10387. * // "details": [
  10388. * // {value}, {value}
  10389. * // ]
  10390. * // }
  10391. * $(document).ready( function() {
  10392. * $('#example').dataTable( {
  10393. * "ajaxSource": "sources/deep.txt",
  10394. * "columns": [
  10395. * { "data": "engine" },
  10396. * { "data": "browser" },
  10397. * { "data": "platform.inner" },
  10398. * { "data": "platform.details.0" },
  10399. * { "data": "platform.details.1" }
  10400. * ]
  10401. * } );
  10402. * } );
  10403. *
  10404. * @example
  10405. * // Using `data` as a function to provide different information for
  10406. * // sorting, filtering and display. In this case, currency (price)
  10407. * $(document).ready( function() {
  10408. * $('#example').dataTable( {
  10409. * "columnDefs": [ {
  10410. * "targets": [ 0 ],
  10411. * "data": function ( source, type, val ) {
  10412. * if (type === 'set') {
  10413. * source.price = val;
  10414. * // Store the computed dislay and filter values for efficiency
  10415. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10416. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10417. * return;
  10418. * }
  10419. * else if (type === 'display') {
  10420. * return source.price_display;
  10421. * }
  10422. * else if (type === 'filter') {
  10423. * return source.price_filter;
  10424. * }
  10425. * // 'sort', 'type' and undefined all just use the integer
  10426. * return source.price;
  10427. * }
  10428. * } ]
  10429. * } );
  10430. * } );
  10431. *
  10432. * @example
  10433. * // Using default content
  10434. * $(document).ready( function() {
  10435. * $('#example').dataTable( {
  10436. * "columnDefs": [ {
  10437. * "targets": [ 0 ],
  10438. * "data": null,
  10439. * "defaultContent": "Click to edit"
  10440. * } ]
  10441. * } );
  10442. * } );
  10443. *
  10444. * @example
  10445. * // Using array notation - outputting a list from an array
  10446. * $(document).ready( function() {
  10447. * $('#example').dataTable( {
  10448. * "columnDefs": [ {
  10449. * "targets": [ 0 ],
  10450. * "data": "name[, ]"
  10451. * } ]
  10452. * } );
  10453. * } );
  10454. *
  10455. */
  10456. "mData": null,
  10457. /**
  10458. * This property is the rendering partner to `data` and it is suggested that
  10459. * when you want to manipulate data for display (including filtering,
  10460. * sorting etc) without altering the underlying data for the table, use this
  10461. * property. `render` can be considered to be the the read only companion to
  10462. * `data` which is read / write (then as such more complex). Like `data`
  10463. * this option can be given in a number of different ways to effect its
  10464. * behaviour:
  10465. *
  10466. * * `integer` - treated as an array index for the data source. This is the
  10467. * default that DataTables uses (incrementally increased for each column).
  10468. * * `string` - read an object property from the data source. There are
  10469. * three 'special' options that can be used in the string to alter how
  10470. * DataTables reads the data from the source object:
  10471. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10472. * Javascript to read from nested objects, so to can the options
  10473. * specified in `data`. For example: `browser.version` or
  10474. * `browser.name`. If your object parameter name contains a period, use
  10475. * `\\` to escape it - i.e. `first\\.name`.
  10476. * * `[]` - Array notation. DataTables can automatically combine data
  10477. * from and array source, joining the data with the characters provided
  10478. * between the two brackets. For example: `name[, ]` would provide a
  10479. * comma-space separated list from the source array. If no characters
  10480. * are provided between the brackets, the original array source is
  10481. * returned.
  10482. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10483. * execute a function of the name given. For example: `browser()` for a
  10484. * simple function on the data source, `browser.version()` for a
  10485. * function in a nested property or even `browser().version` to get an
  10486. * object property if the function called returns an object.
  10487. * * `object` - use different data for the different data types requested by
  10488. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10489. * of the object is the data type the property refers to and the value can
  10490. * defined using an integer, string or function using the same rules as
  10491. * `render` normally does. Note that an `_` option _must_ be specified.
  10492. * This is the default value to use if you haven't specified a value for
  10493. * the data type requested by DataTables.
  10494. * * `function` - the function given will be executed whenever DataTables
  10495. * needs to set or get the data for a cell in the column. The function
  10496. * takes three parameters:
  10497. * * Parameters:
  10498. * * {array|object} The data source for the row (based on `data`)
  10499. * * {string} The type call data requested - this will be 'filter',
  10500. * 'display', 'type' or 'sort'.
  10501. * * {array|object} The full data source for the row (not based on
  10502. * `data`)
  10503. * * Return:
  10504. * * The return value from the function is what will be used for the
  10505. * data requested.
  10506. *
  10507. * @type string|int|function|object|null
  10508. * @default null Use the data source value.
  10509. *
  10510. * @name DataTable.defaults.column.render
  10511. * @dtopt Columns
  10512. *
  10513. * @example
  10514. * // Create a comma separated list from an array of objects
  10515. * $(document).ready( function() {
  10516. * $('#example').dataTable( {
  10517. * "ajaxSource": "sources/deep.txt",
  10518. * "columns": [
  10519. * { "data": "engine" },
  10520. * { "data": "browser" },
  10521. * {
  10522. * "data": "platform",
  10523. * "render": "[, ].name"
  10524. * }
  10525. * ]
  10526. * } );
  10527. * } );
  10528. *
  10529. * @example
  10530. * // Execute a function to obtain data
  10531. * $(document).ready( function() {
  10532. * $('#example').dataTable( {
  10533. * "columnDefs": [ {
  10534. * "targets": [ 0 ],
  10535. * "data": null, // Use the full data source object for the renderer's source
  10536. * "render": "browserName()"
  10537. * } ]
  10538. * } );
  10539. * } );
  10540. *
  10541. * @example
  10542. * // As an object, extracting different data for the different types
  10543. * // This would be used with a data source such as:
  10544. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10545. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10546. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10547. * // the formatted phone number is the one that is shown in the table.
  10548. * $(document).ready( function() {
  10549. * $('#example').dataTable( {
  10550. * "columnDefs": [ {
  10551. * "targets": [ 0 ],
  10552. * "data": null, // Use the full data source object for the renderer's source
  10553. * "render": {
  10554. * "_": "phone",
  10555. * "filter": "phone_filter",
  10556. * "display": "phone_display"
  10557. * }
  10558. * } ]
  10559. * } );
  10560. * } );
  10561. *
  10562. * @example
  10563. * // Use as a function to create a link from the data source
  10564. * $(document).ready( function() {
  10565. * $('#example').dataTable( {
  10566. * "columnDefs": [ {
  10567. * "targets": [ 0 ],
  10568. * "data": "download_link",
  10569. * "render": function ( data, type, full ) {
  10570. * return '<a href="'+data+'">Download</a>';
  10571. * }
  10572. * } ]
  10573. * } );
  10574. * } );
  10575. */
  10576. "mRender": null,
  10577. /**
  10578. * Change the cell type created for the column - either TD cells or TH cells. This
  10579. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10580. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10581. * @type string
  10582. * @default td
  10583. *
  10584. * @name DataTable.defaults.column.cellType
  10585. * @dtopt Columns
  10586. *
  10587. * @example
  10588. * // Make the first column use TH cells
  10589. * $(document).ready( function() {
  10590. * $('#example').dataTable( {
  10591. * "columnDefs": [ {
  10592. * "targets": [ 0 ],
  10593. * "cellType": "th"
  10594. * } ]
  10595. * } );
  10596. * } );
  10597. */
  10598. "sCellType": "td",
  10599. /**
  10600. * Class to give to each cell in this column.
  10601. * @type string
  10602. * @default <i>Empty string</i>
  10603. *
  10604. * @name DataTable.defaults.column.class
  10605. * @dtopt Columns
  10606. *
  10607. * @example
  10608. * // Using `columnDefs`
  10609. * $(document).ready( function() {
  10610. * $('#example').dataTable( {
  10611. * "columnDefs": [
  10612. * { "class": "my_class", "targets": [ 0 ] }
  10613. * ]
  10614. * } );
  10615. * } );
  10616. *
  10617. * @example
  10618. * // Using `columns`
  10619. * $(document).ready( function() {
  10620. * $('#example').dataTable( {
  10621. * "columns": [
  10622. * { "class": "my_class" },
  10623. * null,
  10624. * null,
  10625. * null,
  10626. * null
  10627. * ]
  10628. * } );
  10629. * } );
  10630. */
  10631. "sClass": "",
  10632. /**
  10633. * When DataTables calculates the column widths to assign to each column,
  10634. * it finds the longest string in each column and then constructs a
  10635. * temporary table and reads the widths from that. The problem with this
  10636. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10637. * string - thus the calculation can go wrong (doing it properly and putting
  10638. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10639. * a "work around" we provide this option. It will append its value to the
  10640. * text that is found to be the longest string for the column - i.e. padding.
  10641. * Generally you shouldn't need this!
  10642. * @type string
  10643. * @default <i>Empty string<i>
  10644. *
  10645. * @name DataTable.defaults.column.contentPadding
  10646. * @dtopt Columns
  10647. *
  10648. * @example
  10649. * // Using `columns`
  10650. * $(document).ready( function() {
  10651. * $('#example').dataTable( {
  10652. * "columns": [
  10653. * null,
  10654. * null,
  10655. * null,
  10656. * {
  10657. * "contentPadding": "mmm"
  10658. * }
  10659. * ]
  10660. * } );
  10661. * } );
  10662. */
  10663. "sContentPadding": "",
  10664. /**
  10665. * Allows a default value to be given for a column's data, and will be used
  10666. * whenever a null data source is encountered (this can be because `data`
  10667. * is set to null, or because the data source itself is null).
  10668. * @type string
  10669. * @default null
  10670. *
  10671. * @name DataTable.defaults.column.defaultContent
  10672. * @dtopt Columns
  10673. *
  10674. * @example
  10675. * // Using `columnDefs`
  10676. * $(document).ready( function() {
  10677. * $('#example').dataTable( {
  10678. * "columnDefs": [
  10679. * {
  10680. * "data": null,
  10681. * "defaultContent": "Edit",
  10682. * "targets": [ -1 ]
  10683. * }
  10684. * ]
  10685. * } );
  10686. * } );
  10687. *
  10688. * @example
  10689. * // Using `columns`
  10690. * $(document).ready( function() {
  10691. * $('#example').dataTable( {
  10692. * "columns": [
  10693. * null,
  10694. * null,
  10695. * null,
  10696. * {
  10697. * "data": null,
  10698. * "defaultContent": "Edit"
  10699. * }
  10700. * ]
  10701. * } );
  10702. * } );
  10703. */
  10704. "sDefaultContent": null,
  10705. /**
  10706. * This parameter is only used in DataTables' server-side processing. It can
  10707. * be exceptionally useful to know what columns are being displayed on the
  10708. * client side, and to map these to database fields. When defined, the names
  10709. * also allow DataTables to reorder information from the server if it comes
  10710. * back in an unexpected order (i.e. if you switch your columns around on the
  10711. * client-side, your server-side code does not also need updating).
  10712. * @type string
  10713. * @default <i>Empty string</i>
  10714. *
  10715. * @name DataTable.defaults.column.name
  10716. * @dtopt Columns
  10717. *
  10718. * @example
  10719. * // Using `columnDefs`
  10720. * $(document).ready( function() {
  10721. * $('#example').dataTable( {
  10722. * "columnDefs": [
  10723. * { "name": "engine", "targets": [ 0 ] },
  10724. * { "name": "browser", "targets": [ 1 ] },
  10725. * { "name": "platform", "targets": [ 2 ] },
  10726. * { "name": "version", "targets": [ 3 ] },
  10727. * { "name": "grade", "targets": [ 4 ] }
  10728. * ]
  10729. * } );
  10730. * } );
  10731. *
  10732. * @example
  10733. * // Using `columns`
  10734. * $(document).ready( function() {
  10735. * $('#example').dataTable( {
  10736. * "columns": [
  10737. * { "name": "engine" },
  10738. * { "name": "browser" },
  10739. * { "name": "platform" },
  10740. * { "name": "version" },
  10741. * { "name": "grade" }
  10742. * ]
  10743. * } );
  10744. * } );
  10745. */
  10746. "sName": "",
  10747. /**
  10748. * Defines a data source type for the ordering which can be used to read
  10749. * real-time information from the table (updating the internally cached
  10750. * version) prior to ordering. This allows ordering to occur on user
  10751. * editable elements such as form inputs.
  10752. * @type string
  10753. * @default std
  10754. *
  10755. * @name DataTable.defaults.column.orderDataType
  10756. * @dtopt Columns
  10757. *
  10758. * @example
  10759. * // Using `columnDefs`
  10760. * $(document).ready( function() {
  10761. * $('#example').dataTable( {
  10762. * "columnDefs": [
  10763. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  10764. * { "type": "numeric", "targets": [ 3 ] },
  10765. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  10766. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  10767. * ]
  10768. * } );
  10769. * } );
  10770. *
  10771. * @example
  10772. * // Using `columns`
  10773. * $(document).ready( function() {
  10774. * $('#example').dataTable( {
  10775. * "columns": [
  10776. * null,
  10777. * null,
  10778. * { "orderDataType": "dom-text" },
  10779. * { "orderDataType": "dom-text", "type": "numeric" },
  10780. * { "orderDataType": "dom-select" },
  10781. * { "orderDataType": "dom-checkbox" }
  10782. * ]
  10783. * } );
  10784. * } );
  10785. */
  10786. "sSortDataType": "std",
  10787. /**
  10788. * The title of this column.
  10789. * @type string
  10790. * @default null <i>Derived from the 'TH' value for this column in the
  10791. * original HTML table.</i>
  10792. *
  10793. * @name DataTable.defaults.column.title
  10794. * @dtopt Columns
  10795. *
  10796. * @example
  10797. * // Using `columnDefs`
  10798. * $(document).ready( function() {
  10799. * $('#example').dataTable( {
  10800. * "columnDefs": [
  10801. * { "title": "My column title", "targets": [ 0 ] }
  10802. * ]
  10803. * } );
  10804. * } );
  10805. *
  10806. * @example
  10807. * // Using `columns`
  10808. * $(document).ready( function() {
  10809. * $('#example').dataTable( {
  10810. * "columns": [
  10811. * { "title": "My column title" },
  10812. * null,
  10813. * null,
  10814. * null,
  10815. * null
  10816. * ]
  10817. * } );
  10818. * } );
  10819. */
  10820. "sTitle": null,
  10821. /**
  10822. * The type allows you to specify how the data for this column will be
  10823. * ordered. Four types (string, numeric, date and html (which will strip
  10824. * HTML tags before ordering)) are currently available. Note that only date
  10825. * formats understood by Javascript's Date() object will be accepted as type
  10826. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  10827. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  10828. * through plug-ins.
  10829. * @type string
  10830. * @default null <i>Auto-detected from raw data</i>
  10831. *
  10832. * @name DataTable.defaults.column.type
  10833. * @dtopt Columns
  10834. *
  10835. * @example
  10836. * // Using `columnDefs`
  10837. * $(document).ready( function() {
  10838. * $('#example').dataTable( {
  10839. * "columnDefs": [
  10840. * { "type": "html", "targets": [ 0 ] }
  10841. * ]
  10842. * } );
  10843. * } );
  10844. *
  10845. * @example
  10846. * // Using `columns`
  10847. * $(document).ready( function() {
  10848. * $('#example').dataTable( {
  10849. * "columns": [
  10850. * { "type": "html" },
  10851. * null,
  10852. * null,
  10853. * null,
  10854. * null
  10855. * ]
  10856. * } );
  10857. * } );
  10858. */
  10859. "sType": null,
  10860. /**
  10861. * Defining the width of the column, this parameter may take any CSS value
  10862. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  10863. * been given a specific width through this interface ensuring that the table
  10864. * remains readable.
  10865. * @type string
  10866. * @default null <i>Automatic</i>
  10867. *
  10868. * @name DataTable.defaults.column.width
  10869. * @dtopt Columns
  10870. *
  10871. * @example
  10872. * // Using `columnDefs`
  10873. * $(document).ready( function() {
  10874. * $('#example').dataTable( {
  10875. * "columnDefs": [
  10876. * { "width": "20%", "targets": [ 0 ] }
  10877. * ]
  10878. * } );
  10879. * } );
  10880. *
  10881. * @example
  10882. * // Using `columns`
  10883. * $(document).ready( function() {
  10884. * $('#example').dataTable( {
  10885. * "columns": [
  10886. * { "width": "20%" },
  10887. * null,
  10888. * null,
  10889. * null,
  10890. * null
  10891. * ]
  10892. * } );
  10893. * } );
  10894. */
  10895. "sWidth": null
  10896. };
  10897. _fnHungarianMap( DataTable.defaults.column );
  10898. /**
  10899. * DataTables settings object - this holds all the information needed for a
  10900. * given table, including configuration, data and current application of the
  10901. * table options. DataTables does not have a single instance for each DataTable
  10902. * with the settings attached to that instance, but rather instances of the
  10903. * DataTable "class" are created on-the-fly as needed (typically by a
  10904. * $().dataTable() call) and the settings object is then applied to that
  10905. * instance.
  10906. *
  10907. * Note that this object is related to {@link DataTable.defaults} but this
  10908. * one is the internal data store for DataTables's cache of columns. It should
  10909. * NOT be manipulated outside of DataTables. Any configuration should be done
  10910. * through the initialisation options.
  10911. * @namespace
  10912. * @todo Really should attach the settings object to individual instances so we
  10913. * don't need to create new instances on each $().dataTable() call (if the
  10914. * table already exists). It would also save passing oSettings around and
  10915. * into every single function. However, this is a very significant
  10916. * architecture change for DataTables and will almost certainly break
  10917. * backwards compatibility with older installations. This is something that
  10918. * will be done in 2.0.
  10919. */
  10920. DataTable.models.oSettings = {
  10921. /**
  10922. * Primary features of DataTables and their enablement state.
  10923. * @namespace
  10924. */
  10925. "oFeatures": {
  10926. /**
  10927. * Flag to say if DataTables should automatically try to calculate the
  10928. * optimum table and columns widths (true) or not (false).
  10929. * Note that this parameter will be set by the initialisation routine. To
  10930. * set a default use {@link DataTable.defaults}.
  10931. * @type boolean
  10932. */
  10933. "bAutoWidth": null,
  10934. /**
  10935. * Delay the creation of TR and TD elements until they are actually
  10936. * needed by a driven page draw. This can give a significant speed
  10937. * increase for Ajax source and Javascript source data, but makes no
  10938. * difference at all fro DOM and server-side processing tables.
  10939. * Note that this parameter will be set by the initialisation routine. To
  10940. * set a default use {@link DataTable.defaults}.
  10941. * @type boolean
  10942. */
  10943. "bDeferRender": null,
  10944. /**
  10945. * Enable filtering on the table or not. Note that if this is disabled
  10946. * then there is no filtering at all on the table, including fnFilter.
  10947. * To just remove the filtering input use sDom and remove the 'f' option.
  10948. * Note that this parameter will be set by the initialisation routine. To
  10949. * set a default use {@link DataTable.defaults}.
  10950. * @type boolean
  10951. */
  10952. "bFilter": null,
  10953. /**
  10954. * Table information element (the 'Showing x of y records' div) enable
  10955. * flag.
  10956. * Note that this parameter will be set by the initialisation routine. To
  10957. * set a default use {@link DataTable.defaults}.
  10958. * @type boolean
  10959. */
  10960. "bInfo": null,
  10961. /**
  10962. * Present a user control allowing the end user to change the page size
  10963. * when pagination is enabled.
  10964. * Note that this parameter will be set by the initialisation routine. To
  10965. * set a default use {@link DataTable.defaults}.
  10966. * @type boolean
  10967. */
  10968. "bLengthChange": null,
  10969. /**
  10970. * Pagination enabled or not. Note that if this is disabled then length
  10971. * changing must also be disabled.
  10972. * Note that this parameter will be set by the initialisation routine. To
  10973. * set a default use {@link DataTable.defaults}.
  10974. * @type boolean
  10975. */
  10976. "bPaginate": null,
  10977. /**
  10978. * Processing indicator enable flag whenever DataTables is enacting a
  10979. * user request - typically an Ajax request for server-side processing.
  10980. * Note that this parameter will be set by the initialisation routine. To
  10981. * set a default use {@link DataTable.defaults}.
  10982. * @type boolean
  10983. */
  10984. "bProcessing": null,
  10985. /**
  10986. * Server-side processing enabled flag - when enabled DataTables will
  10987. * get all data from the server for every draw - there is no filtering,
  10988. * sorting or paging done on the client-side.
  10989. * Note that this parameter will be set by the initialisation routine. To
  10990. * set a default use {@link DataTable.defaults}.
  10991. * @type boolean
  10992. */
  10993. "bServerSide": null,
  10994. /**
  10995. * Sorting enablement flag.
  10996. * Note that this parameter will be set by the initialisation routine. To
  10997. * set a default use {@link DataTable.defaults}.
  10998. * @type boolean
  10999. */
  11000. "bSort": null,
  11001. /**
  11002. * Multi-column sorting
  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. "bSortMulti": null,
  11008. /**
  11009. * Apply a class to the columns which are being sorted to provide a
  11010. * visual highlight or not. This can slow things down when enabled since
  11011. * there is a lot of DOM interaction.
  11012. * Note that this parameter will be set by the initialisation routine. To
  11013. * set a default use {@link DataTable.defaults}.
  11014. * @type boolean
  11015. */
  11016. "bSortClasses": null,
  11017. /**
  11018. * State saving enablement flag.
  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. "bStateSave": null
  11024. },
  11025. /**
  11026. * Scrolling settings for a table.
  11027. * @namespace
  11028. */
  11029. "oScroll": {
  11030. /**
  11031. * When the table is shorter in height than sScrollY, collapse the
  11032. * table container down to the height of the table (when true).
  11033. * Note that this parameter will be set by the initialisation routine. To
  11034. * set a default use {@link DataTable.defaults}.
  11035. * @type boolean
  11036. */
  11037. "bCollapse": null,
  11038. /**
  11039. * Width of the scrollbar for the web-browser's platform. Calculated
  11040. * during table initialisation.
  11041. * @type int
  11042. * @default 0
  11043. */
  11044. "iBarWidth": 0,
  11045. /**
  11046. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11047. * disabled if an empty string.
  11048. * Note that this parameter will be set by the initialisation routine. To
  11049. * set a default use {@link DataTable.defaults}.
  11050. * @type string
  11051. */
  11052. "sX": null,
  11053. /**
  11054. * Width to expand the table to when using x-scrolling. Typically you
  11055. * should not need to use this.
  11056. * Note that this parameter will be set by the initialisation routine. To
  11057. * set a default use {@link DataTable.defaults}.
  11058. * @type string
  11059. * @deprecated
  11060. */
  11061. "sXInner": null,
  11062. /**
  11063. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11064. * if an empty string.
  11065. * Note that this parameter will be set by the initialisation routine. To
  11066. * set a default use {@link DataTable.defaults}.
  11067. * @type string
  11068. */
  11069. "sY": null
  11070. },
  11071. /**
  11072. * Language information for the table.
  11073. * @namespace
  11074. * @extends DataTable.defaults.oLanguage
  11075. */
  11076. "oLanguage": {
  11077. /**
  11078. * Information callback function. See
  11079. * {@link DataTable.defaults.fnInfoCallback}
  11080. * @type function
  11081. * @default null
  11082. */
  11083. "fnInfoCallback": null
  11084. },
  11085. /**
  11086. * Browser support parameters
  11087. * @namespace
  11088. */
  11089. "oBrowser": {
  11090. /**
  11091. * Indicate if the browser incorrectly calculates width:100% inside a
  11092. * scrolling element (IE6/7)
  11093. * @type boolean
  11094. * @default false
  11095. */
  11096. "bScrollOversize": false,
  11097. /**
  11098. * Determine if the vertical scrollbar is on the right or left of the
  11099. * scrolling container - needed for rtl language layout, although not
  11100. * all browsers move the scrollbar (Safari).
  11101. * @type boolean
  11102. * @default false
  11103. */
  11104. "bScrollbarLeft": false
  11105. },
  11106. "ajax": null,
  11107. /**
  11108. * Array referencing the nodes which are used for the features. The
  11109. * parameters of this object match what is allowed by sDom - i.e.
  11110. * <ul>
  11111. * <li>'l' - Length changing</li>
  11112. * <li>'f' - Filtering input</li>
  11113. * <li>'t' - The table!</li>
  11114. * <li>'i' - Information</li>
  11115. * <li>'p' - Pagination</li>
  11116. * <li>'r' - pRocessing</li>
  11117. * </ul>
  11118. * @type array
  11119. * @default []
  11120. */
  11121. "aanFeatures": [],
  11122. /**
  11123. * Store data information - see {@link DataTable.models.oRow} for detailed
  11124. * information.
  11125. * @type array
  11126. * @default []
  11127. */
  11128. "aoData": [],
  11129. /**
  11130. * Array of indexes which are in the current display (after filtering etc)
  11131. * @type array
  11132. * @default []
  11133. */
  11134. "aiDisplay": [],
  11135. /**
  11136. * Array of indexes for display - no filtering
  11137. * @type array
  11138. * @default []
  11139. */
  11140. "aiDisplayMaster": [],
  11141. /**
  11142. * Store information about each column that is in use
  11143. * @type array
  11144. * @default []
  11145. */
  11146. "aoColumns": [],
  11147. /**
  11148. * Store information about the table's header
  11149. * @type array
  11150. * @default []
  11151. */
  11152. "aoHeader": [],
  11153. /**
  11154. * Store information about the table's footer
  11155. * @type array
  11156. * @default []
  11157. */
  11158. "aoFooter": [],
  11159. /**
  11160. * Store the applied global search information in case we want to force a
  11161. * research or compare the old search to a new one.
  11162. * Note that this parameter will be set by the initialisation routine. To
  11163. * set a default use {@link DataTable.defaults}.
  11164. * @namespace
  11165. * @extends DataTable.models.oSearch
  11166. */
  11167. "oPreviousSearch": {},
  11168. /**
  11169. * Store the applied search for each column - see
  11170. * {@link DataTable.models.oSearch} for the format that is used for the
  11171. * filtering information for each column.
  11172. * @type array
  11173. * @default []
  11174. */
  11175. "aoPreSearchCols": [],
  11176. /**
  11177. * Sorting that is applied to the table. Note that the inner arrays are
  11178. * used in the following manner:
  11179. * <ul>
  11180. * <li>Index 0 - column number</li>
  11181. * <li>Index 1 - current sorting direction</li>
  11182. * </ul>
  11183. * Note that this parameter will be set by the initialisation routine. To
  11184. * set a default use {@link DataTable.defaults}.
  11185. * @type array
  11186. * @todo These inner arrays should really be objects
  11187. */
  11188. "aaSorting": null,
  11189. /**
  11190. * Sorting that is always applied to the table (i.e. prefixed in front of
  11191. * aaSorting).
  11192. * Note that this parameter will be set by the initialisation routine. To
  11193. * set a default use {@link DataTable.defaults}.
  11194. * @type array
  11195. * @default []
  11196. */
  11197. "aaSortingFixed": [],
  11198. /**
  11199. * Classes to use for the striping of a table.
  11200. * Note that this parameter will be set by the initialisation routine. To
  11201. * set a default use {@link DataTable.defaults}.
  11202. * @type array
  11203. * @default []
  11204. */
  11205. "asStripeClasses": null,
  11206. /**
  11207. * If restoring a table - we should restore its striping classes as well
  11208. * @type array
  11209. * @default []
  11210. */
  11211. "asDestroyStripes": [],
  11212. /**
  11213. * If restoring a table - we should restore its width
  11214. * @type int
  11215. * @default 0
  11216. */
  11217. "sDestroyWidth": 0,
  11218. /**
  11219. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11220. * @type array
  11221. * @default []
  11222. */
  11223. "aoRowCallback": [],
  11224. /**
  11225. * Callback functions for the header on each draw.
  11226. * @type array
  11227. * @default []
  11228. */
  11229. "aoHeaderCallback": [],
  11230. /**
  11231. * Callback function for the footer on each draw.
  11232. * @type array
  11233. * @default []
  11234. */
  11235. "aoFooterCallback": [],
  11236. /**
  11237. * Array of callback functions for draw callback functions
  11238. * @type array
  11239. * @default []
  11240. */
  11241. "aoDrawCallback": [],
  11242. /**
  11243. * Array of callback functions for row created function
  11244. * @type array
  11245. * @default []
  11246. */
  11247. "aoRowCreatedCallback": [],
  11248. /**
  11249. * Callback functions for just before the table is redrawn. A return of
  11250. * false will be used to cancel the draw.
  11251. * @type array
  11252. * @default []
  11253. */
  11254. "aoPreDrawCallback": [],
  11255. /**
  11256. * Callback functions for when the table has been initialised.
  11257. * @type array
  11258. * @default []
  11259. */
  11260. "aoInitComplete": [],
  11261. /**
  11262. * Callbacks for modifying the settings to be stored for state saving, prior to
  11263. * saving state.
  11264. * @type array
  11265. * @default []
  11266. */
  11267. "aoStateSaveParams": [],
  11268. /**
  11269. * Callbacks for modifying the settings that have been stored for state saving
  11270. * prior to using the stored values to restore the state.
  11271. * @type array
  11272. * @default []
  11273. */
  11274. "aoStateLoadParams": [],
  11275. /**
  11276. * Callbacks for operating on the settings object once the saved state has been
  11277. * loaded
  11278. * @type array
  11279. * @default []
  11280. */
  11281. "aoStateLoaded": [],
  11282. /**
  11283. * Cache the table ID for quick access
  11284. * @type string
  11285. * @default <i>Empty string</i>
  11286. */
  11287. "sTableId": "",
  11288. /**
  11289. * The TABLE node for the main table
  11290. * @type node
  11291. * @default null
  11292. */
  11293. "nTable": null,
  11294. /**
  11295. * Permanent ref to the thead element
  11296. * @type node
  11297. * @default null
  11298. */
  11299. "nTHead": null,
  11300. /**
  11301. * Permanent ref to the tfoot element - if it exists
  11302. * @type node
  11303. * @default null
  11304. */
  11305. "nTFoot": null,
  11306. /**
  11307. * Permanent ref to the tbody element
  11308. * @type node
  11309. * @default null
  11310. */
  11311. "nTBody": null,
  11312. /**
  11313. * Cache the wrapper node (contains all DataTables controlled elements)
  11314. * @type node
  11315. * @default null
  11316. */
  11317. "nTableWrapper": null,
  11318. /**
  11319. * Indicate if when using server-side processing the loading of data
  11320. * should be deferred until the second draw.
  11321. * Note that this parameter will be set by the initialisation routine. To
  11322. * set a default use {@link DataTable.defaults}.
  11323. * @type boolean
  11324. * @default false
  11325. */
  11326. "bDeferLoading": false,
  11327. /**
  11328. * Indicate if all required information has been read in
  11329. * @type boolean
  11330. * @default false
  11331. */
  11332. "bInitialised": false,
  11333. /**
  11334. * Information about open rows. Each object in the array has the parameters
  11335. * 'nTr' and 'nParent'
  11336. * @type array
  11337. * @default []
  11338. */
  11339. "aoOpenRows": [],
  11340. /**
  11341. * Dictate the positioning of DataTables' control elements - see
  11342. * {@link DataTable.model.oInit.sDom}.
  11343. * Note that this parameter will be set by the initialisation routine. To
  11344. * set a default use {@link DataTable.defaults}.
  11345. * @type string
  11346. * @default null
  11347. */
  11348. "sDom": null,
  11349. /**
  11350. * Search delay (in mS)
  11351. * @type integer
  11352. * @default null
  11353. */
  11354. "searchDelay": null,
  11355. /**
  11356. * Which type of pagination should be used.
  11357. * Note that this parameter will be set by the initialisation routine. To
  11358. * set a default use {@link DataTable.defaults}.
  11359. * @type string
  11360. * @default two_button
  11361. */
  11362. "sPaginationType": "two_button",
  11363. /**
  11364. * The state duration (for `stateSave`) in seconds.
  11365. * Note that this parameter will be set by the initialisation routine. To
  11366. * set a default use {@link DataTable.defaults}.
  11367. * @type int
  11368. * @default 0
  11369. */
  11370. "iStateDuration": 0,
  11371. /**
  11372. * Array of callback functions for state saving. Each array element is an
  11373. * object with the following parameters:
  11374. * <ul>
  11375. * <li>function:fn - function to call. Takes two parameters, oSettings
  11376. * and the JSON string to save that has been thus far created. Returns
  11377. * a JSON string to be inserted into a json object
  11378. * (i.e. '"param": [ 0, 1, 2]')</li>
  11379. * <li>string:sName - name of callback</li>
  11380. * </ul>
  11381. * @type array
  11382. * @default []
  11383. */
  11384. "aoStateSave": [],
  11385. /**
  11386. * Array of callback functions for state loading. Each array element is an
  11387. * object with the following parameters:
  11388. * <ul>
  11389. * <li>function:fn - function to call. Takes two parameters, oSettings
  11390. * and the object stored. May return false to cancel state loading</li>
  11391. * <li>string:sName - name of callback</li>
  11392. * </ul>
  11393. * @type array
  11394. * @default []
  11395. */
  11396. "aoStateLoad": [],
  11397. /**
  11398. * State that was saved. Useful for back reference
  11399. * @type object
  11400. * @default null
  11401. */
  11402. "oSavedState": null,
  11403. /**
  11404. * State that was loaded. Useful for back reference
  11405. * @type object
  11406. * @default null
  11407. */
  11408. "oLoadedState": null,
  11409. /**
  11410. * Source url for AJAX data for the table.
  11411. * Note that this parameter will be set by the initialisation routine. To
  11412. * set a default use {@link DataTable.defaults}.
  11413. * @type string
  11414. * @default null
  11415. */
  11416. "sAjaxSource": null,
  11417. /**
  11418. * Property from a given object from which to read the table data from. This
  11419. * can be an empty string (when not server-side processing), in which case
  11420. * it is assumed an an array is given directly.
  11421. * Note that this parameter will be set by the initialisation routine. To
  11422. * set a default use {@link DataTable.defaults}.
  11423. * @type string
  11424. */
  11425. "sAjaxDataProp": null,
  11426. /**
  11427. * Note if draw should be blocked while getting data
  11428. * @type boolean
  11429. * @default true
  11430. */
  11431. "bAjaxDataGet": true,
  11432. /**
  11433. * The last jQuery XHR object that was used for server-side data gathering.
  11434. * This can be used for working with the XHR information in one of the
  11435. * callbacks
  11436. * @type object
  11437. * @default null
  11438. */
  11439. "jqXHR": null,
  11440. /**
  11441. * JSON returned from the server in the last Ajax request
  11442. * @type object
  11443. * @default undefined
  11444. */
  11445. "json": undefined,
  11446. /**
  11447. * Data submitted as part of the last Ajax request
  11448. * @type object
  11449. * @default undefined
  11450. */
  11451. "oAjaxData": undefined,
  11452. /**
  11453. * Function to get the server-side data.
  11454. * Note that this parameter will be set by the initialisation routine. To
  11455. * set a default use {@link DataTable.defaults}.
  11456. * @type function
  11457. */
  11458. "fnServerData": null,
  11459. /**
  11460. * Functions which are called prior to sending an Ajax request so extra
  11461. * parameters can easily be sent to the server
  11462. * @type array
  11463. * @default []
  11464. */
  11465. "aoServerParams": [],
  11466. /**
  11467. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11468. * required).
  11469. * Note that this parameter will be set by the initialisation routine. To
  11470. * set a default use {@link DataTable.defaults}.
  11471. * @type string
  11472. */
  11473. "sServerMethod": null,
  11474. /**
  11475. * Format numbers for display.
  11476. * Note that this parameter will be set by the initialisation routine. To
  11477. * set a default use {@link DataTable.defaults}.
  11478. * @type function
  11479. */
  11480. "fnFormatNumber": null,
  11481. /**
  11482. * List of options that can be used for the user selectable length menu.
  11483. * Note that this parameter will be set by the initialisation routine. To
  11484. * set a default use {@link DataTable.defaults}.
  11485. * @type array
  11486. * @default []
  11487. */
  11488. "aLengthMenu": null,
  11489. /**
  11490. * Counter for the draws that the table does. Also used as a tracker for
  11491. * server-side processing
  11492. * @type int
  11493. * @default 0
  11494. */
  11495. "iDraw": 0,
  11496. /**
  11497. * Indicate if a redraw is being done - useful for Ajax
  11498. * @type boolean
  11499. * @default false
  11500. */
  11501. "bDrawing": false,
  11502. /**
  11503. * Draw index (iDraw) of the last error when parsing the returned data
  11504. * @type int
  11505. * @default -1
  11506. */
  11507. "iDrawError": -1,
  11508. /**
  11509. * Paging display length
  11510. * @type int
  11511. * @default 10
  11512. */
  11513. "_iDisplayLength": 10,
  11514. /**
  11515. * Paging start point - aiDisplay index
  11516. * @type int
  11517. * @default 0
  11518. */
  11519. "_iDisplayStart": 0,
  11520. /**
  11521. * Server-side processing - number of records in the result set
  11522. * (i.e. before filtering), Use fnRecordsTotal rather than
  11523. * this property to get the value of the number of records, regardless of
  11524. * the server-side processing setting.
  11525. * @type int
  11526. * @default 0
  11527. * @private
  11528. */
  11529. "_iRecordsTotal": 0,
  11530. /**
  11531. * Server-side processing - number of records in the current display set
  11532. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11533. * this property to get the value of the number of records, regardless of
  11534. * the server-side processing setting.
  11535. * @type boolean
  11536. * @default 0
  11537. * @private
  11538. */
  11539. "_iRecordsDisplay": 0,
  11540. /**
  11541. * Flag to indicate if jQuery UI marking and classes should be used.
  11542. * Note that this parameter will be set by the initialisation routine. To
  11543. * set a default use {@link DataTable.defaults}.
  11544. * @type boolean
  11545. */
  11546. "bJUI": null,
  11547. /**
  11548. * The classes to use for the table
  11549. * @type object
  11550. * @default {}
  11551. */
  11552. "oClasses": {},
  11553. /**
  11554. * Flag attached to the settings object so you can check in the draw
  11555. * callback if filtering has been done in the draw. Deprecated in favour of
  11556. * events.
  11557. * @type boolean
  11558. * @default false
  11559. * @deprecated
  11560. */
  11561. "bFiltered": false,
  11562. /**
  11563. * Flag attached to the settings object so you can check in the draw
  11564. * callback if sorting has been done in the draw. Deprecated in favour of
  11565. * events.
  11566. * @type boolean
  11567. * @default false
  11568. * @deprecated
  11569. */
  11570. "bSorted": false,
  11571. /**
  11572. * Indicate that if multiple rows are in the header and there is more than
  11573. * one unique cell per column, if the top one (true) or bottom one (false)
  11574. * should be used for sorting / title by DataTables.
  11575. * Note that this parameter will be set by the initialisation routine. To
  11576. * set a default use {@link DataTable.defaults}.
  11577. * @type boolean
  11578. */
  11579. "bSortCellsTop": null,
  11580. /**
  11581. * Initialisation object that is used for the table
  11582. * @type object
  11583. * @default null
  11584. */
  11585. "oInit": null,
  11586. /**
  11587. * Destroy callback functions - for plug-ins to attach themselves to the
  11588. * destroy so they can clean up markup and events.
  11589. * @type array
  11590. * @default []
  11591. */
  11592. "aoDestroyCallback": [],
  11593. /**
  11594. * Get the number of records in the current record set, before filtering
  11595. * @type function
  11596. */
  11597. "fnRecordsTotal": function ()
  11598. {
  11599. return _fnDataSource( this ) == 'ssp' ?
  11600. this._iRecordsTotal * 1 :
  11601. this.aiDisplayMaster.length;
  11602. },
  11603. /**
  11604. * Get the number of records in the current record set, after filtering
  11605. * @type function
  11606. */
  11607. "fnRecordsDisplay": function ()
  11608. {
  11609. return _fnDataSource( this ) == 'ssp' ?
  11610. this._iRecordsDisplay * 1 :
  11611. this.aiDisplay.length;
  11612. },
  11613. /**
  11614. * Get the display end point - aiDisplay index
  11615. * @type function
  11616. */
  11617. "fnDisplayEnd": function ()
  11618. {
  11619. var
  11620. len = this._iDisplayLength,
  11621. start = this._iDisplayStart,
  11622. calc = start + len,
  11623. records = this.aiDisplay.length,
  11624. features = this.oFeatures,
  11625. paginate = features.bPaginate;
  11626. if ( features.bServerSide ) {
  11627. return paginate === false || len === -1 ?
  11628. start + records :
  11629. Math.min( start+len, this._iRecordsDisplay );
  11630. }
  11631. else {
  11632. return ! paginate || calc>records || len===-1 ?
  11633. records :
  11634. calc;
  11635. }
  11636. },
  11637. /**
  11638. * The DataTables object for this table
  11639. * @type object
  11640. * @default null
  11641. */
  11642. "oInstance": null,
  11643. /**
  11644. * Unique identifier for each instance of the DataTables object. If there
  11645. * is an ID on the table node, then it takes that value, otherwise an
  11646. * incrementing internal counter is used.
  11647. * @type string
  11648. * @default null
  11649. */
  11650. "sInstance": null,
  11651. /**
  11652. * tabindex attribute value that is added to DataTables control elements, allowing
  11653. * keyboard navigation of the table and its controls.
  11654. */
  11655. "iTabIndex": 0,
  11656. /**
  11657. * DIV container for the footer scrolling table if scrolling
  11658. */
  11659. "nScrollHead": null,
  11660. /**
  11661. * DIV container for the footer scrolling table if scrolling
  11662. */
  11663. "nScrollFoot": null,
  11664. /**
  11665. * Last applied sort
  11666. * @type array
  11667. * @default []
  11668. */
  11669. "aLastSort": [],
  11670. /**
  11671. * Stored plug-in instances
  11672. * @type object
  11673. * @default {}
  11674. */
  11675. "oPlugins": {}
  11676. };
  11677. /**
  11678. * Extension object for DataTables that is used to provide all extension
  11679. * options.
  11680. *
  11681. * Note that the `DataTable.ext` object is available through
  11682. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11683. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11684. * @namespace
  11685. * @extends DataTable.models.ext
  11686. */
  11687. /**
  11688. * DataTables extensions
  11689. *
  11690. * This namespace acts as a collection area for plug-ins that can be used to
  11691. * extend DataTables capabilities. Indeed many of the build in methods
  11692. * use this method to provide their own capabilities (sorting methods for
  11693. * example).
  11694. *
  11695. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11696. * reasons
  11697. *
  11698. * @namespace
  11699. */
  11700. DataTable.ext = _ext = {
  11701. /**
  11702. * Buttons. For use with the Buttons extension for DataTables. This is
  11703. * defined here so other extensions can define buttons regardless of load
  11704. * order. It is _not_ used by DataTables core.
  11705. *
  11706. * @type object
  11707. * @default {}
  11708. */
  11709. buttons: {},
  11710. /**
  11711. * Element class names
  11712. *
  11713. * @type object
  11714. * @default {}
  11715. */
  11716. classes: {},
  11717. /**
  11718. * Error reporting.
  11719. *
  11720. * How should DataTables report an error. Can take the value 'alert',
  11721. * 'throw', 'none' or a function.
  11722. *
  11723. * @type string|function
  11724. * @default alert
  11725. */
  11726. errMode: "alert",
  11727. /**
  11728. * Feature plug-ins.
  11729. *
  11730. * This is an array of objects which describe the feature plug-ins that are
  11731. * available to DataTables. These feature plug-ins are then available for
  11732. * use through the `dom` initialisation option.
  11733. *
  11734. * Each feature plug-in is described by an object which must have the
  11735. * following properties:
  11736. *
  11737. * * `fnInit` - function that is used to initialise the plug-in,
  11738. * * `cFeature` - a character so the feature can be enabled by the `dom`
  11739. * instillation option. This is case sensitive.
  11740. *
  11741. * The `fnInit` function has the following input parameters:
  11742. *
  11743. * 1. `{object}` DataTables settings object: see
  11744. * {@link DataTable.models.oSettings}
  11745. *
  11746. * And the following return is expected:
  11747. *
  11748. * * {node|null} The element which contains your feature. Note that the
  11749. * return may also be void if your plug-in does not require to inject any
  11750. * DOM elements into DataTables control (`dom`) - for example this might
  11751. * be useful when developing a plug-in which allows table control via
  11752. * keyboard entry
  11753. *
  11754. * @type array
  11755. *
  11756. * @example
  11757. * $.fn.dataTable.ext.features.push( {
  11758. * "fnInit": function( oSettings ) {
  11759. * return new TableTools( { "oDTSettings": oSettings } );
  11760. * },
  11761. * "cFeature": "T"
  11762. * } );
  11763. */
  11764. feature: [],
  11765. /**
  11766. * Row searching.
  11767. *
  11768. * This method of searching is complimentary to the default type based
  11769. * searching, and a lot more comprehensive as it allows you complete control
  11770. * over the searching logic. Each element in this array is a function
  11771. * (parameters described below) that is called for every row in the table,
  11772. * and your logic decides if it should be included in the searching data set
  11773. * or not.
  11774. *
  11775. * Searching functions have the following input parameters:
  11776. *
  11777. * 1. `{object}` DataTables settings object: see
  11778. * {@link DataTable.models.oSettings}
  11779. * 2. `{array|object}` Data for the row to be processed (same as the
  11780. * original format that was passed in as the data source, or an array
  11781. * from a DOM data source
  11782. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  11783. * can be useful to retrieve the `TR` element if you need DOM interaction.
  11784. *
  11785. * And the following return is expected:
  11786. *
  11787. * * {boolean} Include the row in the searched result set (true) or not
  11788. * (false)
  11789. *
  11790. * Note that as with the main search ability in DataTables, technically this
  11791. * is "filtering", since it is subtractive. However, for consistency in
  11792. * naming we call it searching here.
  11793. *
  11794. * @type array
  11795. * @default []
  11796. *
  11797. * @example
  11798. * // The following example shows custom search being applied to the
  11799. * // fourth column (i.e. the data[3] index) based on two input values
  11800. * // from the end-user, matching the data in a certain range.
  11801. * $.fn.dataTable.ext.search.push(
  11802. * function( settings, data, dataIndex ) {
  11803. * var min = document.getElementById('min').value * 1;
  11804. * var max = document.getElementById('max').value * 1;
  11805. * var version = data[3] == "-" ? 0 : data[3]*1;
  11806. *
  11807. * if ( min == "" && max == "" ) {
  11808. * return true;
  11809. * }
  11810. * else if ( min == "" && version < max ) {
  11811. * return true;
  11812. * }
  11813. * else if ( min < version && "" == max ) {
  11814. * return true;
  11815. * }
  11816. * else if ( min < version && version < max ) {
  11817. * return true;
  11818. * }
  11819. * return false;
  11820. * }
  11821. * );
  11822. */
  11823. search: [],
  11824. /**
  11825. * Internal functions, exposed for used in plug-ins.
  11826. *
  11827. * Please note that you should not need to use the internal methods for
  11828. * anything other than a plug-in (and even then, try to avoid if possible).
  11829. * The internal function may change between releases.
  11830. *
  11831. * @type object
  11832. * @default {}
  11833. */
  11834. internal: {},
  11835. /**
  11836. * Legacy configuration options. Enable and disable legacy options that
  11837. * are available in DataTables.
  11838. *
  11839. * @type object
  11840. */
  11841. legacy: {
  11842. /**
  11843. * Enable / disable DataTables 1.9 compatible server-side processing
  11844. * requests
  11845. *
  11846. * @type boolean
  11847. * @default null
  11848. */
  11849. ajax: null
  11850. },
  11851. /**
  11852. * Pagination plug-in methods.
  11853. *
  11854. * Each entry in this object is a function and defines which buttons should
  11855. * be shown by the pagination rendering method that is used for the table:
  11856. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  11857. * buttons are displayed in the document, while the functions here tell it
  11858. * what buttons to display. This is done by returning an array of button
  11859. * descriptions (what each button will do).
  11860. *
  11861. * Pagination types (the four built in options and any additional plug-in
  11862. * options defined here) can be used through the `paginationType`
  11863. * initialisation parameter.
  11864. *
  11865. * The functions defined take two parameters:
  11866. *
  11867. * 1. `{int} page` The current page index
  11868. * 2. `{int} pages` The number of pages in the table
  11869. *
  11870. * Each function is expected to return an array where each element of the
  11871. * array can be one of:
  11872. *
  11873. * * `first` - Jump to first page when activated
  11874. * * `last` - Jump to last page when activated
  11875. * * `previous` - Show previous page when activated
  11876. * * `next` - Show next page when activated
  11877. * * `{int}` - Show page of the index given
  11878. * * `{array}` - A nested array containing the above elements to add a
  11879. * containing 'DIV' element (might be useful for styling).
  11880. *
  11881. * Note that DataTables v1.9- used this object slightly differently whereby
  11882. * an object with two functions would be defined for each plug-in. That
  11883. * ability is still supported by DataTables 1.10+ to provide backwards
  11884. * compatibility, but this option of use is now decremented and no longer
  11885. * documented in DataTables 1.10+.
  11886. *
  11887. * @type object
  11888. * @default {}
  11889. *
  11890. * @example
  11891. * // Show previous, next and current page buttons only
  11892. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  11893. * return [ 'previous', page, 'next' ];
  11894. * };
  11895. */
  11896. pager: {},
  11897. renderer: {
  11898. pageButton: {},
  11899. header: {}
  11900. },
  11901. /**
  11902. * Ordering plug-ins - custom data source
  11903. *
  11904. * The extension options for ordering of data available here is complimentary
  11905. * to the default type based ordering that DataTables typically uses. It
  11906. * allows much greater control over the the data that is being used to
  11907. * order a column, but is necessarily therefore more complex.
  11908. *
  11909. * This type of ordering is useful if you want to do ordering based on data
  11910. * live from the DOM (for example the contents of an 'input' element) rather
  11911. * than just the static string that DataTables knows of.
  11912. *
  11913. * The way these plug-ins work is that you create an array of the values you
  11914. * wish to be ordering for the column in question and then return that
  11915. * array. The data in the array much be in the index order of the rows in
  11916. * the table (not the currently ordering order!). Which order data gathering
  11917. * function is run here depends on the `dt-init columns.orderDataType`
  11918. * parameter that is used for the column (if any).
  11919. *
  11920. * The functions defined take two parameters:
  11921. *
  11922. * 1. `{object}` DataTables settings object: see
  11923. * {@link DataTable.models.oSettings}
  11924. * 2. `{int}` Target column index
  11925. *
  11926. * Each function is expected to return an array:
  11927. *
  11928. * * `{array}` Data for the column to be ordering upon
  11929. *
  11930. * @type array
  11931. *
  11932. * @example
  11933. * // Ordering using `input` node values
  11934. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  11935. * {
  11936. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  11937. * return $('input', td).val();
  11938. * } );
  11939. * }
  11940. */
  11941. order: {},
  11942. /**
  11943. * Type based plug-ins.
  11944. *
  11945. * Each column in DataTables has a type assigned to it, either by automatic
  11946. * detection or by direct assignment using the `type` option for the column.
  11947. * The type of a column will effect how it is ordering and search (plug-ins
  11948. * can also make use of the column type if required).
  11949. *
  11950. * @namespace
  11951. */
  11952. type: {
  11953. /**
  11954. * Type detection functions.
  11955. *
  11956. * The functions defined in this object are used to automatically detect
  11957. * a column's type, making initialisation of DataTables super easy, even
  11958. * when complex data is in the table.
  11959. *
  11960. * The functions defined take two parameters:
  11961. *
  11962. * 1. `{*}` Data from the column cell to be analysed
  11963. * 2. `{settings}` DataTables settings object. This can be used to
  11964. * perform context specific type detection - for example detection
  11965. * based on language settings such as using a comma for a decimal
  11966. * place. Generally speaking the options from the settings will not
  11967. * be required
  11968. *
  11969. * Each function is expected to return:
  11970. *
  11971. * * `{string|null}` Data type detected, or null if unknown (and thus
  11972. * pass it on to the other type detection functions.
  11973. *
  11974. * @type array
  11975. *
  11976. * @example
  11977. * // Currency type detection plug-in:
  11978. * $.fn.dataTable.ext.type.detect.push(
  11979. * function ( data, settings ) {
  11980. * // Check the numeric part
  11981. * if ( ! $.isNumeric( data.substring(1) ) ) {
  11982. * return null;
  11983. * }
  11984. *
  11985. * // Check prefixed by currency
  11986. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  11987. * return 'currency';
  11988. * }
  11989. * return null;
  11990. * }
  11991. * );
  11992. */
  11993. detect: [],
  11994. /**
  11995. * Type based search formatting.
  11996. *
  11997. * The type based searching functions can be used to pre-format the
  11998. * data to be search on. For example, it can be used to strip HTML
  11999. * tags or to de-format telephone numbers for numeric only searching.
  12000. *
  12001. * Note that is a search is not defined for a column of a given type,
  12002. * no search formatting will be performed.
  12003. *
  12004. * Pre-processing of searching data plug-ins - When you assign the sType
  12005. * for a column (or have it automatically detected for you by DataTables
  12006. * or a type detection plug-in), you will typically be using this for
  12007. * custom sorting, but it can also be used to provide custom searching
  12008. * by allowing you to pre-processing the data and returning the data in
  12009. * the format that should be searched upon. This is done by adding
  12010. * functions this object with a parameter name which matches the sType
  12011. * for that target column. This is the corollary of <i>afnSortData</i>
  12012. * for searching data.
  12013. *
  12014. * The functions defined take a single parameter:
  12015. *
  12016. * 1. `{*}` Data from the column cell to be prepared for searching
  12017. *
  12018. * Each function is expected to return:
  12019. *
  12020. * * `{string|null}` Formatted string that will be used for the searching.
  12021. *
  12022. * @type object
  12023. * @default {}
  12024. *
  12025. * @example
  12026. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12027. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12028. * }
  12029. */
  12030. search: {},
  12031. /**
  12032. * Type based ordering.
  12033. *
  12034. * The column type tells DataTables what ordering to apply to the table
  12035. * when a column is sorted upon. The order for each type that is defined,
  12036. * is defined by the functions available in this object.
  12037. *
  12038. * Each ordering option can be described by three properties added to
  12039. * this object:
  12040. *
  12041. * * `{type}-pre` - Pre-formatting function
  12042. * * `{type}-asc` - Ascending order function
  12043. * * `{type}-desc` - Descending order function
  12044. *
  12045. * All three can be used together, only `{type}-pre` or only
  12046. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12047. * that only `{type}-pre` is used, as this provides the optimal
  12048. * implementation in terms of speed, although the others are provided
  12049. * for compatibility with existing Javascript sort functions.
  12050. *
  12051. * `{type}-pre`: Functions defined take a single parameter:
  12052. *
  12053. * 1. `{*}` Data from the column cell to be prepared for ordering
  12054. *
  12055. * And return:
  12056. *
  12057. * * `{*}` Data to be sorted upon
  12058. *
  12059. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12060. * functions, taking two parameters:
  12061. *
  12062. * 1. `{*}` Data to compare to the second parameter
  12063. * 2. `{*}` Data to compare to the first parameter
  12064. *
  12065. * And returning:
  12066. *
  12067. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12068. * than the second parameter, ===0 if the two parameters are equal and
  12069. * >0 if the first parameter should be sorted height than the second
  12070. * parameter.
  12071. *
  12072. * @type object
  12073. * @default {}
  12074. *
  12075. * @example
  12076. * // Numeric ordering of formatted numbers with a pre-formatter
  12077. * $.extend( $.fn.dataTable.ext.type.order, {
  12078. * "string-pre": function(x) {
  12079. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12080. * return parseFloat( a );
  12081. * }
  12082. * } );
  12083. *
  12084. * @example
  12085. * // Case-sensitive string ordering, with no pre-formatting method
  12086. * $.extend( $.fn.dataTable.ext.order, {
  12087. * "string-case-asc": function(x,y) {
  12088. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12089. * },
  12090. * "string-case-desc": function(x,y) {
  12091. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12092. * }
  12093. * } );
  12094. */
  12095. order: {}
  12096. },
  12097. /**
  12098. * Unique DataTables instance counter
  12099. *
  12100. * @type int
  12101. * @private
  12102. */
  12103. _unique: 0,
  12104. //
  12105. // Depreciated
  12106. // The following properties are retained for backwards compatiblity only.
  12107. // The should not be used in new projects and will be removed in a future
  12108. // version
  12109. //
  12110. /**
  12111. * Version check function.
  12112. * @type function
  12113. * @depreciated Since 1.10
  12114. */
  12115. fnVersionCheck: DataTable.fnVersionCheck,
  12116. /**
  12117. * Index for what 'this' index API functions should use
  12118. * @type int
  12119. * @deprecated Since v1.10
  12120. */
  12121. iApiIndex: 0,
  12122. /**
  12123. * jQuery UI class container
  12124. * @type object
  12125. * @deprecated Since v1.10
  12126. */
  12127. oJUIClasses: {},
  12128. /**
  12129. * Software version
  12130. * @type string
  12131. * @deprecated Since v1.10
  12132. */
  12133. sVersion: DataTable.version
  12134. };
  12135. //
  12136. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12137. //
  12138. $.extend( _ext, {
  12139. afnFiltering: _ext.search,
  12140. aTypes: _ext.type.detect,
  12141. ofnSearch: _ext.type.search,
  12142. oSort: _ext.type.order,
  12143. afnSortData: _ext.order,
  12144. aoFeatures: _ext.feature,
  12145. oApi: _ext.internal,
  12146. oStdClasses: _ext.classes,
  12147. oPagination: _ext.pager
  12148. } );
  12149. $.extend( DataTable.ext.classes, {
  12150. "sTable": "dataTable",
  12151. "sNoFooter": "no-footer",
  12152. /* Paging buttons */
  12153. "sPageButton": "paginate_button",
  12154. "sPageButtonActive": "current",
  12155. "sPageButtonDisabled": "disabled",
  12156. /* Striping classes */
  12157. "sStripeOdd": "odd",
  12158. "sStripeEven": "even",
  12159. /* Empty row */
  12160. "sRowEmpty": "dataTables_empty",
  12161. /* Features */
  12162. "sWrapper": "dataTables_wrapper",
  12163. "sFilter": "dataTables_filter",
  12164. "sInfo": "dataTables_info",
  12165. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12166. "sLength": "dataTables_length",
  12167. "sProcessing": "dataTables_processing",
  12168. /* Sorting */
  12169. "sSortAsc": "sorting_asc",
  12170. "sSortDesc": "sorting_desc",
  12171. "sSortable": "sorting", /* Sortable in both directions */
  12172. "sSortableAsc": "sorting_asc_disabled",
  12173. "sSortableDesc": "sorting_desc_disabled",
  12174. "sSortableNone": "sorting_disabled",
  12175. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12176. /* Filtering */
  12177. "sFilterInput": "",
  12178. /* Page length */
  12179. "sLengthSelect": "",
  12180. /* Scrolling */
  12181. "sScrollWrapper": "dataTables_scroll",
  12182. "sScrollHead": "dataTables_scrollHead",
  12183. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12184. "sScrollBody": "dataTables_scrollBody",
  12185. "sScrollFoot": "dataTables_scrollFoot",
  12186. "sScrollFootInner": "dataTables_scrollFootInner",
  12187. /* Misc */
  12188. "sHeaderTH": "",
  12189. "sFooterTH": "",
  12190. // Deprecated
  12191. "sSortJUIAsc": "",
  12192. "sSortJUIDesc": "",
  12193. "sSortJUI": "",
  12194. "sSortJUIAscAllowed": "",
  12195. "sSortJUIDescAllowed": "",
  12196. "sSortJUIWrapper": "",
  12197. "sSortIcon": "",
  12198. "sJUIHeader": "",
  12199. "sJUIFooter": ""
  12200. } );
  12201. (function() {
  12202. // Reused strings for better compression. Closure compiler appears to have a
  12203. // weird edge case where it is trying to expand strings rather than use the
  12204. // variable version. This results in about 200 bytes being added, for very
  12205. // little preference benefit since it this run on script load only.
  12206. var _empty = '';
  12207. _empty = '';
  12208. var _stateDefault = _empty + 'ui-state-default';
  12209. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  12210. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  12211. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  12212. /* Full numbers paging buttons */
  12213. "sPageButton": "fg-button ui-button "+_stateDefault,
  12214. "sPageButtonActive": "ui-state-disabled",
  12215. "sPageButtonDisabled": "ui-state-disabled",
  12216. /* Features */
  12217. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  12218. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  12219. /* Sorting */
  12220. "sSortAsc": _stateDefault+" sorting_asc",
  12221. "sSortDesc": _stateDefault+" sorting_desc",
  12222. "sSortable": _stateDefault+" sorting",
  12223. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  12224. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  12225. "sSortableNone": _stateDefault+" sorting_disabled",
  12226. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  12227. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  12228. "sSortJUI": _sortIcon+"carat-2-n-s",
  12229. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  12230. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  12231. "sSortJUIWrapper": "DataTables_sort_wrapper",
  12232. "sSortIcon": "DataTables_sort_icon",
  12233. /* Scrolling */
  12234. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  12235. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  12236. /* Misc */
  12237. "sHeaderTH": _stateDefault,
  12238. "sFooterTH": _stateDefault,
  12239. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  12240. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  12241. } );
  12242. }());
  12243. var extPagination = DataTable.ext.pager;
  12244. function _numbers ( page, pages ) {
  12245. var
  12246. numbers = [],
  12247. buttons = extPagination.numbers_length,
  12248. half = Math.floor( buttons / 2 ),
  12249. i = 1;
  12250. if ( pages <= buttons ) {
  12251. numbers = _range( 0, pages );
  12252. }
  12253. else if ( page <= half ) {
  12254. numbers = _range( 0, buttons-2 );
  12255. numbers.push( 'ellipsis' );
  12256. numbers.push( pages-1 );
  12257. }
  12258. else if ( page >= pages - 1 - half ) {
  12259. numbers = _range( pages-(buttons-2), pages );
  12260. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12261. numbers.splice( 0, 0, 0 );
  12262. }
  12263. else {
  12264. numbers = _range( page-1, page+2 );
  12265. numbers.push( 'ellipsis' );
  12266. numbers.push( pages-1 );
  12267. numbers.splice( 0, 0, 'ellipsis' );
  12268. numbers.splice( 0, 0, 0 );
  12269. }
  12270. numbers.DT_el = 'span';
  12271. return numbers;
  12272. }
  12273. $.extend( extPagination, {
  12274. simple: function ( page, pages ) {
  12275. return [ 'previous', 'next' ];
  12276. },
  12277. full: function ( page, pages ) {
  12278. return [ 'first', 'previous', 'next', 'last' ];
  12279. },
  12280. simple_numbers: function ( page, pages ) {
  12281. return [ 'previous', _numbers(page, pages), 'next' ];
  12282. },
  12283. full_numbers: function ( page, pages ) {
  12284. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12285. },
  12286. // For testing and plug-ins to use
  12287. _numbers: _numbers,
  12288. numbers_length: 7
  12289. } );
  12290. $.extend( true, DataTable.ext.renderer, {
  12291. pageButton: {
  12292. _: function ( settings, host, idx, buttons, page, pages ) {
  12293. var classes = settings.oClasses;
  12294. var lang = settings.oLanguage.oPaginate;
  12295. var btnDisplay, btnClass, counter=0;
  12296. var attach = function( container, buttons ) {
  12297. var i, ien, node, button;
  12298. var clickHandler = function ( e ) {
  12299. _fnPageChange( settings, e.data.action, true );
  12300. };
  12301. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12302. button = buttons[i];
  12303. if ( $.isArray( button ) ) {
  12304. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12305. .appendTo( container );
  12306. attach( inner, button );
  12307. }
  12308. else {
  12309. btnDisplay = '';
  12310. btnClass = '';
  12311. switch ( button ) {
  12312. case 'ellipsis':
  12313. container.append('<span>&hellip;</span>');
  12314. break;
  12315. case 'first':
  12316. btnDisplay = lang.sFirst;
  12317. btnClass = button + (page > 0 ?
  12318. '' : ' '+classes.sPageButtonDisabled);
  12319. break;
  12320. case 'previous':
  12321. btnDisplay = lang.sPrevious;
  12322. btnClass = button + (page > 0 ?
  12323. '' : ' '+classes.sPageButtonDisabled);
  12324. break;
  12325. case 'next':
  12326. btnDisplay = lang.sNext;
  12327. btnClass = button + (page < pages-1 ?
  12328. '' : ' '+classes.sPageButtonDisabled);
  12329. break;
  12330. case 'last':
  12331. btnDisplay = lang.sLast;
  12332. btnClass = button + (page < pages-1 ?
  12333. '' : ' '+classes.sPageButtonDisabled);
  12334. break;
  12335. default:
  12336. btnDisplay = button + 1;
  12337. btnClass = page === button ?
  12338. classes.sPageButtonActive : '';
  12339. break;
  12340. }
  12341. if ( btnDisplay ) {
  12342. node = $('<a>', {
  12343. 'class': classes.sPageButton+' '+btnClass,
  12344. 'aria-controls': settings.sTableId,
  12345. 'data-dt-idx': counter,
  12346. 'tabindex': settings.iTabIndex,
  12347. 'id': idx === 0 && typeof button === 'string' ?
  12348. settings.sTableId +'_'+ button :
  12349. null
  12350. } )
  12351. .html( btnDisplay )
  12352. .appendTo( container );
  12353. _fnBindAction(
  12354. node, {action: button}, clickHandler
  12355. );
  12356. counter++;
  12357. }
  12358. }
  12359. }
  12360. };
  12361. // IE9 throws an 'unknown error' if document.activeElement is used
  12362. // inside an iframe or frame. Try / catch the error. Not good for
  12363. // accessibility, but neither are frames.
  12364. var activeEl;
  12365. try {
  12366. // Because this approach is destroying and recreating the paging
  12367. // elements, focus is lost on the select button which is bad for
  12368. // accessibility. So we want to restore focus once the draw has
  12369. // completed
  12370. activeEl = $(document.activeElement).data('dt-idx');
  12371. }
  12372. catch (e) {}
  12373. attach( $(host).empty(), buttons );
  12374. if ( activeEl ) {
  12375. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12376. }
  12377. }
  12378. }
  12379. } );
  12380. // Built in type detection. See model.ext.aTypes for information about
  12381. // what is required from this methods.
  12382. $.extend( DataTable.ext.type.detect, [
  12383. // Plain numbers - first since V8 detects some plain numbers as dates
  12384. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12385. function ( d, settings )
  12386. {
  12387. var decimal = settings.oLanguage.sDecimal;
  12388. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12389. },
  12390. // Dates (only those recognised by the browser's Date.parse)
  12391. function ( d, settings )
  12392. {
  12393. // V8 will remove any unknown characters at the start and end of the
  12394. // expression, leading to false matches such as `$245.12` or `10%` being
  12395. // a valid date. See forum thread 18941 for detail.
  12396. if ( d && !(d instanceof Date) && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
  12397. return null;
  12398. }
  12399. var parsed = Date.parse(d);
  12400. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12401. },
  12402. // Formatted numbers
  12403. function ( d, settings )
  12404. {
  12405. var decimal = settings.oLanguage.sDecimal;
  12406. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12407. },
  12408. // HTML numeric
  12409. function ( d, settings )
  12410. {
  12411. var decimal = settings.oLanguage.sDecimal;
  12412. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12413. },
  12414. // HTML numeric, formatted
  12415. function ( d, settings )
  12416. {
  12417. var decimal = settings.oLanguage.sDecimal;
  12418. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12419. },
  12420. // HTML (this is strict checking - there must be html)
  12421. function ( d, settings )
  12422. {
  12423. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12424. 'html' : null;
  12425. }
  12426. ] );
  12427. // Filter formatting functions. See model.ext.ofnSearch for information about
  12428. // what is required from these methods.
  12429. //
  12430. // Note that additional search methods are added for the html numbers and
  12431. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12432. // place is
  12433. $.extend( DataTable.ext.type.search, {
  12434. html: function ( data ) {
  12435. return _empty(data) ?
  12436. data :
  12437. typeof data === 'string' ?
  12438. data
  12439. .replace( _re_new_lines, " " )
  12440. .replace( _re_html, "" ) :
  12441. '';
  12442. },
  12443. string: function ( data ) {
  12444. return _empty(data) ?
  12445. data :
  12446. typeof data === 'string' ?
  12447. data.replace( _re_new_lines, " " ) :
  12448. data;
  12449. }
  12450. } );
  12451. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12452. if ( d !== 0 && (!d || d === '-') ) {
  12453. return -Infinity;
  12454. }
  12455. // If a decimal place other than `.` is used, it needs to be given to the
  12456. // function so we can detect it and replace with a `.` which is the only
  12457. // decimal place Javascript recognises - it is not locale aware.
  12458. if ( decimalPlace ) {
  12459. d = _numToDecimal( d, decimalPlace );
  12460. }
  12461. if ( d.replace ) {
  12462. if ( re1 ) {
  12463. d = d.replace( re1, '' );
  12464. }
  12465. if ( re2 ) {
  12466. d = d.replace( re2, '' );
  12467. }
  12468. }
  12469. return d * 1;
  12470. };
  12471. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12472. // in a function to provide an easy ability for the language options to add
  12473. // additional methods if a non-period decimal place is used.
  12474. function _addNumericSort ( decimalPlace ) {
  12475. $.each(
  12476. {
  12477. // Plain numbers
  12478. "num": function ( d ) {
  12479. return __numericReplace( d, decimalPlace );
  12480. },
  12481. // Formatted numbers
  12482. "num-fmt": function ( d ) {
  12483. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12484. },
  12485. // HTML numeric
  12486. "html-num": function ( d ) {
  12487. return __numericReplace( d, decimalPlace, _re_html );
  12488. },
  12489. // HTML numeric, formatted
  12490. "html-num-fmt": function ( d ) {
  12491. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12492. }
  12493. },
  12494. function ( key, fn ) {
  12495. // Add the ordering method
  12496. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12497. // For HTML types add a search formatter that will strip the HTML
  12498. if ( key.match(/^html\-/) ) {
  12499. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12500. }
  12501. }
  12502. );
  12503. }
  12504. // Default sort methods
  12505. $.extend( _ext.type.order, {
  12506. // Dates
  12507. "date-pre": function ( d ) {
  12508. return Date.parse( d ) || 0;
  12509. },
  12510. // html
  12511. "html-pre": function ( a ) {
  12512. return _empty(a) ?
  12513. '' :
  12514. a.replace ?
  12515. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12516. a+'';
  12517. },
  12518. // string
  12519. "string-pre": function ( a ) {
  12520. // This is a little complex, but faster than always calling toString,
  12521. // http://jsperf.com/tostring-v-check
  12522. return _empty(a) ?
  12523. '' :
  12524. typeof a === 'string' ?
  12525. a.toLowerCase() :
  12526. ! a.toString ?
  12527. '' :
  12528. a.toString();
  12529. },
  12530. // string-asc and -desc are retained only for compatibility with the old
  12531. // sort methods
  12532. "string-asc": function ( x, y ) {
  12533. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12534. },
  12535. "string-desc": function ( x, y ) {
  12536. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12537. }
  12538. } );
  12539. // Numeric sorting types - order doesn't matter here
  12540. _addNumericSort( '' );
  12541. $.extend( true, DataTable.ext.renderer, {
  12542. header: {
  12543. _: function ( settings, cell, column, classes ) {
  12544. // No additional mark-up required
  12545. // Attach a sort listener to update on sort - note that using the
  12546. // `DT` namespace will allow the event to be removed automatically
  12547. // on destroy, while the `dt` namespaced event is the one we are
  12548. // listening for
  12549. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12550. if ( settings !== ctx ) { // need to check this this is the host
  12551. return; // table, not a nested one
  12552. }
  12553. var colIdx = column.idx;
  12554. cell
  12555. .removeClass(
  12556. column.sSortingClass +' '+
  12557. classes.sSortAsc +' '+
  12558. classes.sSortDesc
  12559. )
  12560. .addClass( columns[ colIdx ] == 'asc' ?
  12561. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12562. classes.sSortDesc :
  12563. column.sSortingClass
  12564. );
  12565. } );
  12566. },
  12567. jqueryui: function ( settings, cell, column, classes ) {
  12568. $('<div/>')
  12569. .addClass( classes.sSortJUIWrapper )
  12570. .append( cell.contents() )
  12571. .append( $('<span/>')
  12572. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12573. )
  12574. .appendTo( cell );
  12575. // Attach a sort listener to update on sort
  12576. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12577. if ( settings !== ctx ) {
  12578. return;
  12579. }
  12580. var colIdx = column.idx;
  12581. cell
  12582. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12583. .addClass( columns[ colIdx ] == 'asc' ?
  12584. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12585. classes.sSortDesc :
  12586. column.sSortingClass
  12587. );
  12588. cell
  12589. .find( 'span.'+classes.sSortIcon )
  12590. .removeClass(
  12591. classes.sSortJUIAsc +" "+
  12592. classes.sSortJUIDesc +" "+
  12593. classes.sSortJUI +" "+
  12594. classes.sSortJUIAscAllowed +" "+
  12595. classes.sSortJUIDescAllowed
  12596. )
  12597. .addClass( columns[ colIdx ] == 'asc' ?
  12598. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12599. classes.sSortJUIDesc :
  12600. column.sSortingClassJUI
  12601. );
  12602. } );
  12603. }
  12604. }
  12605. } );
  12606. /*
  12607. * Public helper functions. These aren't used internally by DataTables, or
  12608. * called by any of the options passed into DataTables, but they can be used
  12609. * externally by developers working with DataTables. They are helper functions
  12610. * to make working with DataTables a little bit easier.
  12611. */
  12612. /**
  12613. * Helpers for `columns.render`.
  12614. *
  12615. * The options defined here can be used with the `columns.render` initialisation
  12616. * option to provide a display renderer. The following functions are defined:
  12617. *
  12618. * * `number` - Will format numeric data (defined by `columns.data`) for
  12619. * display, retaining the original unformatted data for sorting and filtering.
  12620. * It takes 4 parameters:
  12621. * * `string` - Thousands grouping separator
  12622. * * `string` - Decimal point indicator
  12623. * * `integer` - Number of decimal points to show
  12624. * * `string` (optional) - Prefix.
  12625. *
  12626. * @example
  12627. * // Column definition using the number renderer
  12628. * {
  12629. * data: "salary",
  12630. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  12631. * }
  12632. *
  12633. * @namespace
  12634. */
  12635. DataTable.render = {
  12636. number: function ( thousands, decimal, precision, prefix ) {
  12637. return {
  12638. display: function ( d ) {
  12639. var negative = d < 0 ? '-' : '';
  12640. d = Math.abs( parseFloat( d ) );
  12641. var intPart = parseInt( d, 10 );
  12642. var floatPart = precision ?
  12643. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  12644. '';
  12645. return negative + (prefix||'') +
  12646. intPart.toString().replace(
  12647. /\B(?=(\d{3})+(?!\d))/g, thousands
  12648. ) +
  12649. floatPart;
  12650. }
  12651. };
  12652. }
  12653. };
  12654. /*
  12655. * This is really a good bit rubbish this method of exposing the internal methods
  12656. * publicly... - To be fixed in 2.0 using methods on the prototype
  12657. */
  12658. /**
  12659. * Create a wrapper function for exporting an internal functions to an external API.
  12660. * @param {string} fn API function name
  12661. * @returns {function} wrapped function
  12662. * @memberof DataTable#internal
  12663. */
  12664. function _fnExternApiFunc (fn)
  12665. {
  12666. return function() {
  12667. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  12668. Array.prototype.slice.call(arguments)
  12669. );
  12670. return DataTable.ext.internal[fn].apply( this, args );
  12671. };
  12672. }
  12673. /**
  12674. * Reference to internal functions for use by plug-in developers. Note that
  12675. * these methods are references to internal functions and are considered to be
  12676. * private. If you use these methods, be aware that they are liable to change
  12677. * between versions.
  12678. * @namespace
  12679. */
  12680. $.extend( DataTable.ext.internal, {
  12681. _fnExternApiFunc: _fnExternApiFunc,
  12682. _fnBuildAjax: _fnBuildAjax,
  12683. _fnAjaxUpdate: _fnAjaxUpdate,
  12684. _fnAjaxParameters: _fnAjaxParameters,
  12685. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  12686. _fnAjaxDataSrc: _fnAjaxDataSrc,
  12687. _fnAddColumn: _fnAddColumn,
  12688. _fnColumnOptions: _fnColumnOptions,
  12689. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  12690. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  12691. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  12692. _fnVisbleColumns: _fnVisbleColumns,
  12693. _fnGetColumns: _fnGetColumns,
  12694. _fnColumnTypes: _fnColumnTypes,
  12695. _fnApplyColumnDefs: _fnApplyColumnDefs,
  12696. _fnHungarianMap: _fnHungarianMap,
  12697. _fnCamelToHungarian: _fnCamelToHungarian,
  12698. _fnLanguageCompat: _fnLanguageCompat,
  12699. _fnBrowserDetect: _fnBrowserDetect,
  12700. _fnAddData: _fnAddData,
  12701. _fnAddTr: _fnAddTr,
  12702. _fnNodeToDataIndex: _fnNodeToDataIndex,
  12703. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  12704. _fnGetCellData: _fnGetCellData,
  12705. _fnSetCellData: _fnSetCellData,
  12706. _fnSplitObjNotation: _fnSplitObjNotation,
  12707. _fnGetObjectDataFn: _fnGetObjectDataFn,
  12708. _fnSetObjectDataFn: _fnSetObjectDataFn,
  12709. _fnGetDataMaster: _fnGetDataMaster,
  12710. _fnClearTable: _fnClearTable,
  12711. _fnDeleteIndex: _fnDeleteIndex,
  12712. _fnInvalidate: _fnInvalidate,
  12713. _fnGetRowElements: _fnGetRowElements,
  12714. _fnCreateTr: _fnCreateTr,
  12715. _fnBuildHead: _fnBuildHead,
  12716. _fnDrawHead: _fnDrawHead,
  12717. _fnDraw: _fnDraw,
  12718. _fnReDraw: _fnReDraw,
  12719. _fnAddOptionsHtml: _fnAddOptionsHtml,
  12720. _fnDetectHeader: _fnDetectHeader,
  12721. _fnGetUniqueThs: _fnGetUniqueThs,
  12722. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  12723. _fnFilterComplete: _fnFilterComplete,
  12724. _fnFilterCustom: _fnFilterCustom,
  12725. _fnFilterColumn: _fnFilterColumn,
  12726. _fnFilter: _fnFilter,
  12727. _fnFilterCreateSearch: _fnFilterCreateSearch,
  12728. _fnEscapeRegex: _fnEscapeRegex,
  12729. _fnFilterData: _fnFilterData,
  12730. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  12731. _fnUpdateInfo: _fnUpdateInfo,
  12732. _fnInfoMacros: _fnInfoMacros,
  12733. _fnInitialise: _fnInitialise,
  12734. _fnInitComplete: _fnInitComplete,
  12735. _fnLengthChange: _fnLengthChange,
  12736. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  12737. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  12738. _fnPageChange: _fnPageChange,
  12739. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  12740. _fnProcessingDisplay: _fnProcessingDisplay,
  12741. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  12742. _fnScrollDraw: _fnScrollDraw,
  12743. _fnApplyToChildren: _fnApplyToChildren,
  12744. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  12745. _fnThrottle: _fnThrottle,
  12746. _fnConvertToWidth: _fnConvertToWidth,
  12747. _fnScrollingWidthAdjust: _fnScrollingWidthAdjust,
  12748. _fnGetWidestNode: _fnGetWidestNode,
  12749. _fnGetMaxLenString: _fnGetMaxLenString,
  12750. _fnStringToCss: _fnStringToCss,
  12751. _fnScrollBarWidth: _fnScrollBarWidth,
  12752. _fnSortFlatten: _fnSortFlatten,
  12753. _fnSort: _fnSort,
  12754. _fnSortAria: _fnSortAria,
  12755. _fnSortListener: _fnSortListener,
  12756. _fnSortAttachListener: _fnSortAttachListener,
  12757. _fnSortingClasses: _fnSortingClasses,
  12758. _fnSortData: _fnSortData,
  12759. _fnSaveState: _fnSaveState,
  12760. _fnLoadState: _fnLoadState,
  12761. _fnSettingsFromNode: _fnSettingsFromNode,
  12762. _fnLog: _fnLog,
  12763. _fnMap: _fnMap,
  12764. _fnBindAction: _fnBindAction,
  12765. _fnCallbackReg: _fnCallbackReg,
  12766. _fnCallbackFire: _fnCallbackFire,
  12767. _fnLengthOverflow: _fnLengthOverflow,
  12768. _fnRenderer: _fnRenderer,
  12769. _fnDataSource: _fnDataSource,
  12770. _fnRowAttributes: _fnRowAttributes,
  12771. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  12772. // in 1.10, so this dead-end function is
  12773. // added to prevent errors
  12774. } );
  12775. // jQuery access
  12776. $.fn.dataTable = DataTable;
  12777. // Legacy aliases
  12778. $.fn.dataTableSettings = DataTable.settings;
  12779. $.fn.dataTableExt = DataTable.ext;
  12780. // With a capital `D` we return a DataTables API instance rather than a
  12781. // jQuery object
  12782. $.fn.DataTable = function ( opts ) {
  12783. return $(this).dataTable( opts ).api();
  12784. };
  12785. // All properties that are available to $.fn.dataTable should also be
  12786. // available on $.fn.DataTable
  12787. $.each( DataTable, function ( prop, val ) {
  12788. $.fn.DataTable[ prop ] = val;
  12789. } );
  12790. // Information about events fired by DataTables - for documentation.
  12791. /**
  12792. * Draw event, fired whenever the table is redrawn on the page, at the same
  12793. * point as fnDrawCallback. This may be useful for binding events or
  12794. * performing calculations when the table is altered at all.
  12795. * @name DataTable#draw.dt
  12796. * @event
  12797. * @param {event} e jQuery event object
  12798. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12799. */
  12800. /**
  12801. * Search event, fired when the searching applied to the table (using the
  12802. * built-in global search, or column filters) is altered.
  12803. * @name DataTable#search.dt
  12804. * @event
  12805. * @param {event} e jQuery event object
  12806. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12807. */
  12808. /**
  12809. * Page change event, fired when the paging of the table is altered.
  12810. * @name DataTable#page.dt
  12811. * @event
  12812. * @param {event} e jQuery event object
  12813. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12814. */
  12815. /**
  12816. * Order event, fired when the ordering applied to the table is altered.
  12817. * @name DataTable#order.dt
  12818. * @event
  12819. * @param {event} e jQuery event object
  12820. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12821. */
  12822. /**
  12823. * DataTables initialisation complete event, fired when the table is fully
  12824. * drawn, including Ajax data loaded, if Ajax data is required.
  12825. * @name DataTable#init.dt
  12826. * @event
  12827. * @param {event} e jQuery event object
  12828. * @param {object} oSettings DataTables settings object
  12829. * @param {object} json The JSON object request from the server - only
  12830. * present if client-side Ajax sourced data is used</li></ol>
  12831. */
  12832. /**
  12833. * State save event, fired when the table has changed state a new state save
  12834. * is required. This event allows modification of the state saving object
  12835. * prior to actually doing the save, including addition or other state
  12836. * properties (for plug-ins) or modification of a DataTables core property.
  12837. * @name DataTable#stateSaveParams.dt
  12838. * @event
  12839. * @param {event} e jQuery event object
  12840. * @param {object} oSettings DataTables settings object
  12841. * @param {object} json The state information to be saved
  12842. */
  12843. /**
  12844. * State load event, fired when the table is loading state from the stored
  12845. * data, but prior to the settings object being modified by the saved state
  12846. * - allowing modification of the saved state is required or loading of
  12847. * state for a plug-in.
  12848. * @name DataTable#stateLoadParams.dt
  12849. * @event
  12850. * @param {event} e jQuery event object
  12851. * @param {object} oSettings DataTables settings object
  12852. * @param {object} json The saved state information
  12853. */
  12854. /**
  12855. * State loaded event, fired when state has been loaded from stored data and
  12856. * the settings object has been modified by the loaded data.
  12857. * @name DataTable#stateLoaded.dt
  12858. * @event
  12859. * @param {event} e jQuery event object
  12860. * @param {object} oSettings DataTables settings object
  12861. * @param {object} json The saved state information
  12862. */
  12863. /**
  12864. * Processing event, fired when DataTables is doing some kind of processing
  12865. * (be it, order, searcg or anything else). It can be used to indicate to
  12866. * the end user that there is something happening, or that something has
  12867. * finished.
  12868. * @name DataTable#processing.dt
  12869. * @event
  12870. * @param {event} e jQuery event object
  12871. * @param {object} oSettings DataTables settings object
  12872. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  12873. */
  12874. /**
  12875. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  12876. * request to made to the server for new data. This event is called before
  12877. * DataTables processed the returned data, so it can also be used to pre-
  12878. * process the data returned from the server, if needed.
  12879. *
  12880. * Note that this trigger is called in `fnServerData`, if you override
  12881. * `fnServerData` and which to use this event, you need to trigger it in you
  12882. * success function.
  12883. * @name DataTable#xhr.dt
  12884. * @event
  12885. * @param {event} e jQuery event object
  12886. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12887. * @param {object} json JSON returned from the server
  12888. *
  12889. * @example
  12890. * // Use a custom property returned from the server in another DOM element
  12891. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12892. * $('#status').html( json.status );
  12893. * } );
  12894. *
  12895. * @example
  12896. * // Pre-process the data returned from the server
  12897. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12898. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  12899. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  12900. * }
  12901. * // Note no return - manipulate the data directly in the JSON object.
  12902. * } );
  12903. */
  12904. /**
  12905. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  12906. * or passing the bDestroy:true parameter in the initialisation object. This
  12907. * can be used to remove bound events, added DOM nodes, etc.
  12908. * @name DataTable#destroy.dt
  12909. * @event
  12910. * @param {event} e jQuery event object
  12911. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12912. */
  12913. /**
  12914. * Page length change event, fired when number of records to show on each
  12915. * page (the length) is changed.
  12916. * @name DataTable#length.dt
  12917. * @event
  12918. * @param {event} e jQuery event object
  12919. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12920. * @param {integer} len New length
  12921. */
  12922. /**
  12923. * Column sizing has changed.
  12924. * @name DataTable#column-sizing.dt
  12925. * @event
  12926. * @param {event} e jQuery event object
  12927. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12928. */
  12929. /**
  12930. * Column visibility has changed.
  12931. * @name DataTable#column-visibility.dt
  12932. * @event
  12933. * @param {event} e jQuery event object
  12934. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12935. * @param {int} column Column index
  12936. * @param {bool} vis `false` if column now hidden, or `true` if visible
  12937. */
  12938. return $.fn.dataTable;
  12939. }));
  12940. }(window, document));