jquery.dataTables.js 171 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077
  1. (/** @lends <global> */function( window, document, undefined ) {
  2. (function( factory ) {
  3. "use strict";
  4. if ( typeof define === 'function' && define.amd ) {
  5. define( ['jquery'], factory );
  6. }
  7. else if ( typeof exports === 'object' ) {
  8. module.exports = function ($) {
  9. return factory( $ || require('jquery') );
  10. };
  11. }
  12. else {
  13. factory( jQuery );
  14. }
  15. }
  16. (/** @lends <global> */function( $ ) {
  17. "use strict";
  18. var DataTable;
  19. var _ext;
  20. var _Api;
  21. var _api_register;
  22. var _api_registerPlural;
  23. var _re_dic = {};
  24. var _re_new_lines = /[\r\n]/g;
  25. var _re_html = /<.*?>/g;
  26. var _re_date_start = /^[\w\+\-]/;
  27. var _re_date_end = /[\w\+\-]$/;
  28. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  29. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi;
  30. var _empty = function ( d ) {
  31. return !d || d === true || d === '-' ? true : false;
  32. };
  33. var _intVal = function ( s ) {
  34. var integer = parseInt( s, 10 );
  35. return !isNaN(integer) && isFinite(s) ? integer : null;
  36. };
  37. var _numToDecimal = function ( num, decimalPoint ) {
  38. if ( ! _re_dic[ decimalPoint ] ) {
  39. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  40. }
  41. return typeof num === 'string' && decimalPoint !== '.' ?
  42. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  43. num;
  44. };
  45. var _isNumber = function ( d, decimalPoint, formatted ) {
  46. var strType = typeof d === 'string';
  47. if ( _empty( d ) ) {
  48. return true;
  49. }
  50. if ( decimalPoint && strType ) {
  51. d = _numToDecimal( d, decimalPoint );
  52. }
  53. if ( formatted && strType ) {
  54. d = d.replace( _re_formatted_numeric, '' );
  55. }
  56. return !isNaN( parseFloat(d) ) && isFinite( d );
  57. };
  58. var _isHtml = function ( d ) {
  59. return _empty( d ) || typeof d === 'string';
  60. };
  61. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  62. if ( _empty( d ) ) {
  63. return true;
  64. }
  65. var html = _isHtml( d );
  66. return ! html ?
  67. null :
  68. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  69. true :
  70. null;
  71. };
  72. var _pluck = function ( a, prop, prop2 ) {
  73. var out = [];
  74. var i=0, ien=a.length;
  75. if ( prop2 !== undefined ) {
  76. for ( ; i<ien ; i++ ) {
  77. if ( a[i] && a[i][ prop ] ) {
  78. out.push( a[i][ prop ][ prop2 ] );
  79. }
  80. }
  81. }
  82. else {
  83. for ( ; i<ien ; i++ ) {
  84. if ( a[i] ) {
  85. out.push( a[i][ prop ] );
  86. }
  87. }
  88. }
  89. return out;
  90. };
  91. var _pluck_order = function ( a, order, prop, prop2 )
  92. {
  93. var out = [];
  94. var i=0, ien=order.length;
  95. if ( prop2 !== undefined ) {
  96. for ( ; i<ien ; i++ ) {
  97. if ( a[ order[i] ][ prop ] ) {
  98. out.push( a[ order[i] ][ prop ][ prop2 ] );
  99. }
  100. }
  101. }
  102. else {
  103. for ( ; i<ien ; i++ ) {
  104. out.push( a[ order[i] ][ prop ] );
  105. }
  106. }
  107. return out;
  108. };
  109. var _range = function ( len, start )
  110. {
  111. var out = [];
  112. var end;
  113. if ( start === undefined ) {
  114. start = 0;
  115. end = len;
  116. }
  117. else {
  118. end = start;
  119. start = len;
  120. }
  121. for ( var i=start ; i<end ; i++ ) {
  122. out.push( i );
  123. }
  124. return out;
  125. };
  126. var _removeEmpty = function ( a )
  127. {
  128. var out = [];
  129. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  130. if ( a[i] ) {
  131. out.push( a[i] );
  132. }
  133. }
  134. return out;
  135. };
  136. var _stripHtml = function ( d ) {
  137. return d.replace( _re_html, '' );
  138. };
  139. var _unique = function ( src )
  140. {
  141. var
  142. out = [],
  143. val,
  144. i, ien=src.length,
  145. j, k=0;
  146. again: for ( i=0 ; i<ien ; i++ ) {
  147. val = src[i];
  148. for ( j=0 ; j<k ; j++ ) {
  149. if ( out[j] === val ) {
  150. continue again;
  151. }
  152. }
  153. out.push( val );
  154. k++;
  155. }
  156. return out;
  157. };
  158. function _fnHungarianMap ( o )
  159. {
  160. var
  161. hungarian = 'a aa ai ao as b fn i m o s ',
  162. match,
  163. newKey,
  164. map = {};
  165. $.each( o, function (key, val) {
  166. match = key.match(/^([^A-Z]+?)([A-Z])/);
  167. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  168. {
  169. newKey = key.replace( match[0], match[2].toLowerCase() );
  170. map[ newKey ] = key;
  171. if ( match[1] === 'o' )
  172. {
  173. _fnHungarianMap( o[key] );
  174. }
  175. }
  176. } );
  177. o._hungarianMap = map;
  178. }
  179. function _fnCamelToHungarian ( src, user, force )
  180. {
  181. if ( ! src._hungarianMap ) {
  182. _fnHungarianMap( src );
  183. }
  184. var hungarianKey;
  185. $.each( user, function (key, val) {
  186. hungarianKey = src._hungarianMap[ key ];
  187. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  188. {
  189. if ( hungarianKey.charAt(0) === 'o' )
  190. {
  191. if ( ! user[ hungarianKey ] ) {
  192. user[ hungarianKey ] = {};
  193. }
  194. $.extend( true, user[hungarianKey], user[key] );
  195. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  196. }
  197. else {
  198. user[hungarianKey] = user[ key ];
  199. }
  200. }
  201. } );
  202. }
  203. function _fnLanguageCompat( lang )
  204. {
  205. var defaults = DataTable.defaults.oLanguage;
  206. var zeroRecords = lang.sZeroRecords;
  207. if ( ! lang.sEmptyTable && zeroRecords &&
  208. defaults.sEmptyTable === "No data available in table" )
  209. {
  210. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  211. }
  212. if ( ! lang.sLoadingRecords && zeroRecords &&
  213. defaults.sLoadingRecords === "Loading..." )
  214. {
  215. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  216. }
  217. if ( lang.sInfoThousands ) {
  218. lang.sThousands = lang.sInfoThousands;
  219. }
  220. var decimal = lang.sDecimal;
  221. if ( decimal ) {
  222. _addNumericSort( decimal );
  223. }
  224. }
  225. var _fnCompatMap = function ( o, knew, old ) {
  226. if ( o[ knew ] !== undefined ) {
  227. o[ old ] = o[ knew ];
  228. }
  229. };
  230. function _fnCompatOpts ( init )
  231. {
  232. _fnCompatMap( init, 'ordering', 'bSort' );
  233. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  234. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  235. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  236. _fnCompatMap( init, 'order', 'aaSorting' );
  237. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  238. _fnCompatMap( init, 'paging', 'bPaginate' );
  239. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  240. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  241. _fnCompatMap( init, 'searching', 'bFilter' );
  242. if ( typeof init.sScrollX === 'boolean' ) {
  243. init.sScrollX = init.sScrollX ? '100%' : '';
  244. }
  245. if ( typeof init.scrollX === 'boolean' ) {
  246. init.scrollX = init.scrollX ? '100%' : '';
  247. }
  248. var searchCols = init.aoSearchCols;
  249. if ( searchCols ) {
  250. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  251. if ( searchCols[i] ) {
  252. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  253. }
  254. }
  255. }
  256. }
  257. function _fnCompatCols ( init )
  258. {
  259. _fnCompatMap( init, 'orderable', 'bSortable' );
  260. _fnCompatMap( init, 'orderData', 'aDataSort' );
  261. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  262. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  263. var dataSort = init.aDataSort;
  264. if ( dataSort && ! $.isArray( dataSort ) ) {
  265. init.aDataSort = [ dataSort ];
  266. }
  267. }
  268. function _fnBrowserDetect( settings )
  269. {
  270. if ( ! DataTable.__browser ) {
  271. var browser = {};
  272. DataTable.__browser = browser;
  273. var n = $('<div/>')
  274. .css( {
  275. position: 'fixed',
  276. top: 0,
  277. left: 0,
  278. height: 1,
  279. width: 1,
  280. overflow: 'hidden'
  281. } )
  282. .append(
  283. $('<div/>')
  284. .css( {
  285. position: 'absolute',
  286. top: 1,
  287. left: 1,
  288. width: 100,
  289. overflow: 'scroll'
  290. } )
  291. .append(
  292. $('<div/>')
  293. .css( {
  294. width: '100%',
  295. height: 10
  296. } )
  297. )
  298. )
  299. .appendTo( 'body' );
  300. var outer = n.children();
  301. var inner = outer.children();
  302. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  303. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  304. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  305. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  306. n.remove();
  307. }
  308. $.extend( settings.oBrowser, DataTable.__browser );
  309. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  310. }
  311. function _fnReduce ( that, fn, init, start, end, inc )
  312. {
  313. var
  314. i = start,
  315. value,
  316. isSet = false;
  317. if ( init !== undefined ) {
  318. value = init;
  319. isSet = true;
  320. }
  321. while ( i !== end ) {
  322. if ( ! that.hasOwnProperty(i) ) {
  323. continue;
  324. }
  325. value = isSet ?
  326. fn( value, that[i], i, that ) :
  327. that[i];
  328. isSet = true;
  329. i += inc;
  330. }
  331. return value;
  332. }
  333. function _fnAddColumn( oSettings, nTh )
  334. {
  335. var oDefaults = DataTable.defaults.column;
  336. var iCol = oSettings.aoColumns.length;
  337. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  338. "nTh": nTh ? nTh : document.createElement('th'),
  339. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  340. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  341. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  342. idx: iCol
  343. } );
  344. oSettings.aoColumns.push( oCol );
  345. var searchCols = oSettings.aoPreSearchCols;
  346. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  347. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  348. }
  349. function _fnColumnOptions( oSettings, iCol, oOptions )
  350. {
  351. var oCol = oSettings.aoColumns[ iCol ];
  352. var oClasses = oSettings.oClasses;
  353. var th = $(oCol.nTh);
  354. if ( ! oCol.sWidthOrig ) {
  355. oCol.sWidthOrig = th.attr('width') || null;
  356. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  357. if ( t ) {
  358. oCol.sWidthOrig = t[1];
  359. }
  360. }
  361. if ( oOptions !== undefined && oOptions !== null )
  362. {
  363. _fnCompatCols( oOptions );
  364. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  365. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  366. {
  367. oOptions.mData = oOptions.mDataProp;
  368. }
  369. if ( oOptions.sType )
  370. {
  371. oCol._sManualType = oOptions.sType;
  372. }
  373. if ( oOptions.className && ! oOptions.sClass )
  374. {
  375. oOptions.sClass = oOptions.className;
  376. }
  377. $.extend( oCol, oOptions );
  378. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  379. if ( oOptions.iDataSort !== undefined )
  380. {
  381. oCol.aDataSort = [ oOptions.iDataSort ];
  382. }
  383. _fnMap( oCol, oOptions, "aDataSort" );
  384. }
  385. var mDataSrc = oCol.mData;
  386. var mData = _fnGetObjectDataFn( mDataSrc );
  387. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  388. var attrTest = function( src ) {
  389. return typeof src === 'string' && src.indexOf('@') !== -1;
  390. };
  391. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  392. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  393. );
  394. oCol.fnGetData = function (rowData, type, meta) {
  395. var innerData = mData( rowData, type, undefined, meta );
  396. return mRender && type ?
  397. mRender( innerData, type, rowData, meta ) :
  398. innerData;
  399. };
  400. oCol.fnSetData = function ( rowData, val, meta ) {
  401. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  402. };
  403. if ( typeof mDataSrc !== 'number' ) {
  404. oSettings._rowReadObject = true;
  405. }
  406. if ( !oSettings.oFeatures.bSort )
  407. {
  408. oCol.bSortable = false;
  409. th.addClass( oClasses.sSortableNone );
  410. }
  411. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  412. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  413. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  414. {
  415. oCol.sSortingClass = oClasses.sSortableNone;
  416. oCol.sSortingClassJUI = "";
  417. }
  418. else if ( bAsc && !bDesc )
  419. {
  420. oCol.sSortingClass = oClasses.sSortableAsc;
  421. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  422. }
  423. else if ( !bAsc && bDesc )
  424. {
  425. oCol.sSortingClass = oClasses.sSortableDesc;
  426. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  427. }
  428. else
  429. {
  430. oCol.sSortingClass = oClasses.sSortable;
  431. oCol.sSortingClassJUI = oClasses.sSortJUI;
  432. }
  433. }
  434. function _fnAdjustColumnSizing ( settings )
  435. {
  436. if ( settings.oFeatures.bAutoWidth !== false )
  437. {
  438. var columns = settings.aoColumns;
  439. _fnCalculateColumnWidths( settings );
  440. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  441. {
  442. columns[i].nTh.style.width = columns[i].sWidth;
  443. }
  444. }
  445. var scroll = settings.oScroll;
  446. if ( scroll.sY !== '' || scroll.sX !== '')
  447. {
  448. _fnScrollDraw( settings );
  449. }
  450. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  451. }
  452. function _fnVisibleToColumnIndex( oSettings, iMatch )
  453. {
  454. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  455. return typeof aiVis[iMatch] === 'number' ?
  456. aiVis[iMatch] :
  457. null;
  458. }
  459. function _fnColumnIndexToVisible( oSettings, iMatch )
  460. {
  461. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  462. var iPos = $.inArray( iMatch, aiVis );
  463. return iPos !== -1 ? iPos : null;
  464. }
  465. function _fnVisbleColumns( oSettings )
  466. {
  467. return _fnGetColumns( oSettings, 'bVisible' ).length;
  468. }
  469. function _fnGetColumns( oSettings, sParam )
  470. {
  471. var a = [];
  472. $.map( oSettings.aoColumns, function(val, i) {
  473. if ( val[sParam] ) {
  474. a.push( i );
  475. }
  476. } );
  477. return a;
  478. }
  479. function _fnColumnTypes ( settings )
  480. {
  481. var columns = settings.aoColumns;
  482. var data = settings.aoData;
  483. var types = DataTable.ext.type.detect;
  484. var i, ien, j, jen, k, ken;
  485. var col, cell, detectedType, cache;
  486. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  487. col = columns[i];
  488. cache = [];
  489. if ( ! col.sType && col._sManualType ) {
  490. col.sType = col._sManualType;
  491. }
  492. else if ( ! col.sType ) {
  493. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  494. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  495. if ( cache[k] === undefined ) {
  496. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  497. }
  498. detectedType = types[j]( cache[k], settings );
  499. if ( ! detectedType && j !== types.length-1 ) {
  500. break;
  501. }
  502. if ( detectedType === 'html' ) {
  503. break;
  504. }
  505. }
  506. if ( detectedType ) {
  507. col.sType = detectedType;
  508. break;
  509. }
  510. }
  511. if ( ! col.sType ) {
  512. col.sType = 'string';
  513. }
  514. }
  515. }
  516. }
  517. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  518. {
  519. var i, iLen, j, jLen, k, kLen, def;
  520. var columns = oSettings.aoColumns;
  521. if ( aoColDefs )
  522. {
  523. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  524. {
  525. def = aoColDefs[i];
  526. var aTargets = def.targets !== undefined ?
  527. def.targets :
  528. def.aTargets;
  529. if ( ! $.isArray( aTargets ) )
  530. {
  531. aTargets = [ aTargets ];
  532. }
  533. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  534. {
  535. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  536. {
  537. while( columns.length <= aTargets[j] )
  538. {
  539. _fnAddColumn( oSettings );
  540. }
  541. fn( aTargets[j], def );
  542. }
  543. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  544. {
  545. fn( columns.length+aTargets[j], def );
  546. }
  547. else if ( typeof aTargets[j] === 'string' )
  548. {
  549. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  550. {
  551. if ( aTargets[j] == "_all" ||
  552. $(columns[k].nTh).hasClass( aTargets[j] ) )
  553. {
  554. fn( k, def );
  555. }
  556. }
  557. }
  558. }
  559. }
  560. }
  561. if ( aoCols )
  562. {
  563. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  564. {
  565. fn( i, aoCols[i] );
  566. }
  567. }
  568. }
  569. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  570. {
  571. var iRow = oSettings.aoData.length;
  572. var oData = $.extend( true, {}, DataTable.models.oRow, {
  573. src: nTr ? 'dom' : 'data',
  574. idx: iRow
  575. } );
  576. oData._aData = aDataIn;
  577. oSettings.aoData.push( oData );
  578. var nTd, sThisType;
  579. var columns = oSettings.aoColumns;
  580. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  581. {
  582. columns[i].sType = null;
  583. }
  584. oSettings.aiDisplayMaster.push( iRow );
  585. var id = oSettings.rowIdFn( aDataIn );
  586. if ( id !== undefined ) {
  587. oSettings.aIds[ id ] = oData;
  588. }
  589. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  590. {
  591. _fnCreateTr( oSettings, iRow, nTr, anTds );
  592. }
  593. return iRow;
  594. }
  595. function _fnAddTr( settings, trs )
  596. {
  597. var row;
  598. if ( ! (trs instanceof $) ) {
  599. trs = $(trs);
  600. }
  601. return trs.map( function (i, el) {
  602. row = _fnGetRowElements( settings, el );
  603. return _fnAddData( settings, row.data, el, row.cells );
  604. } );
  605. }
  606. function _fnNodeToDataIndex( oSettings, n )
  607. {
  608. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  609. }
  610. function _fnNodeToColumnIndex( oSettings, iRow, n )
  611. {
  612. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  613. }
  614. function _fnGetCellData( settings, rowIdx, colIdx, type )
  615. {
  616. var draw = settings.iDraw;
  617. var col = settings.aoColumns[colIdx];
  618. var rowData = settings.aoData[rowIdx]._aData;
  619. var defaultContent = col.sDefaultContent;
  620. var cellData = col.fnGetData( rowData, type, {
  621. settings: settings,
  622. row: rowIdx,
  623. col: colIdx
  624. } );
  625. if ( cellData === undefined ) {
  626. if ( settings.iDrawError != draw && defaultContent === null ) {
  627. _fnLog( settings, 0, "Requested unknown parameter "+
  628. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  629. " for row "+rowIdx, 4 );
  630. settings.iDrawError = draw;
  631. }
  632. return defaultContent;
  633. }
  634. if ( (cellData === rowData || cellData === null) && defaultContent !== null ) {
  635. cellData = defaultContent;
  636. }
  637. else if ( typeof cellData === 'function' ) {
  638. return cellData.call( rowData );
  639. }
  640. if ( cellData === null && type == 'display' ) {
  641. return '';
  642. }
  643. return cellData;
  644. }
  645. function _fnSetCellData( settings, rowIdx, colIdx, val )
  646. {
  647. var col = settings.aoColumns[colIdx];
  648. var rowData = settings.aoData[rowIdx]._aData;
  649. col.fnSetData( rowData, val, {
  650. settings: settings,
  651. row: rowIdx,
  652. col: colIdx
  653. } );
  654. }
  655. var __reArray = /\[.*?\]$/;
  656. var __reFn = /\(\)$/;
  657. function _fnSplitObjNotation( str )
  658. {
  659. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  660. return s.replace(/\\./g, '.');
  661. } );
  662. }
  663. function _fnGetObjectDataFn( mSource )
  664. {
  665. if ( $.isPlainObject( mSource ) )
  666. {
  667. var o = {};
  668. $.each( mSource, function (key, val) {
  669. if ( val ) {
  670. o[key] = _fnGetObjectDataFn( val );
  671. }
  672. } );
  673. return function (data, type, row, meta) {
  674. var t = o[type] || o._;
  675. return t !== undefined ?
  676. t(data, type, row, meta) :
  677. data;
  678. };
  679. }
  680. else if ( mSource === null )
  681. {
  682. return function (data) {
  683. return data;
  684. };
  685. }
  686. else if ( typeof mSource === 'function' )
  687. {
  688. return function (data, type, row, meta) {
  689. return mSource( data, type, row, meta );
  690. };
  691. }
  692. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  693. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  694. {
  695. var fetchData = function (data, type, src) {
  696. var arrayNotation, funcNotation, out, innerSrc;
  697. if ( src !== "" )
  698. {
  699. var a = _fnSplitObjNotation( src );
  700. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  701. {
  702. arrayNotation = a[i].match(__reArray);
  703. funcNotation = a[i].match(__reFn);
  704. if ( arrayNotation )
  705. {
  706. a[i] = a[i].replace(__reArray, '');
  707. if ( a[i] !== "" ) {
  708. data = data[ a[i] ];
  709. }
  710. out = [];
  711. a.splice( 0, i+1 );
  712. innerSrc = a.join('.');
  713. if ( $.isArray( data ) ) {
  714. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  715. out.push( fetchData( data[j], type, innerSrc ) );
  716. }
  717. }
  718. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  719. data = (join==="") ? out : out.join(join);
  720. break;
  721. }
  722. else if ( funcNotation )
  723. {
  724. a[i] = a[i].replace(__reFn, '');
  725. data = data[ a[i] ]();
  726. continue;
  727. }
  728. if ( data === null || data[ a[i] ] === undefined )
  729. {
  730. return undefined;
  731. }
  732. data = data[ a[i] ];
  733. }
  734. }
  735. return data;
  736. };
  737. return function (data, type) {
  738. return fetchData( data, type, mSource );
  739. };
  740. }
  741. else
  742. {
  743. return function (data, type) {
  744. return data[mSource];
  745. };
  746. }
  747. }
  748. function _fnSetObjectDataFn( mSource )
  749. {
  750. if ( $.isPlainObject( mSource ) )
  751. {
  752. return _fnSetObjectDataFn( mSource._ );
  753. }
  754. else if ( mSource === null )
  755. {
  756. return function () {};
  757. }
  758. else if ( typeof mSource === 'function' )
  759. {
  760. return function (data, val, meta) {
  761. mSource( data, 'set', val, meta );
  762. };
  763. }
  764. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  765. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  766. {
  767. var setData = function (data, val, src) {
  768. var a = _fnSplitObjNotation( src ), b;
  769. var aLast = a[a.length-1];
  770. var arrayNotation, funcNotation, o, innerSrc;
  771. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  772. {
  773. arrayNotation = a[i].match(__reArray);
  774. funcNotation = a[i].match(__reFn);
  775. if ( arrayNotation )
  776. {
  777. a[i] = a[i].replace(__reArray, '');
  778. data[ a[i] ] = [];
  779. b = a.slice();
  780. b.splice( 0, i+1 );
  781. innerSrc = b.join('.');
  782. if ( $.isArray( val ) )
  783. {
  784. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  785. {
  786. o = {};
  787. setData( o, val[j], innerSrc );
  788. data[ a[i] ].push( o );
  789. }
  790. }
  791. else
  792. {
  793. data[ a[i] ] = val;
  794. }
  795. return;
  796. }
  797. else if ( funcNotation )
  798. {
  799. a[i] = a[i].replace(__reFn, '');
  800. data = data[ a[i] ]( val );
  801. }
  802. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  803. {
  804. data[ a[i] ] = {};
  805. }
  806. data = data[ a[i] ];
  807. }
  808. if ( aLast.match(__reFn ) )
  809. {
  810. data = data[ aLast.replace(__reFn, '') ]( val );
  811. }
  812. else
  813. {
  814. data[ aLast.replace(__reArray, '') ] = val;
  815. }
  816. };
  817. return function (data, val) {
  818. return setData( data, val, mSource );
  819. };
  820. }
  821. else
  822. {
  823. return function (data, val) {
  824. data[mSource] = val;
  825. };
  826. }
  827. }
  828. function _fnGetDataMaster ( settings )
  829. {
  830. return _pluck( settings.aoData, '_aData' );
  831. }
  832. function _fnClearTable( settings )
  833. {
  834. settings.aoData.length = 0;
  835. settings.aiDisplayMaster.length = 0;
  836. settings.aiDisplay.length = 0;
  837. settings.aIds = {};
  838. }
  839. function _fnDeleteIndex( a, iTarget, splice )
  840. {
  841. var iTargetIndex = -1;
  842. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  843. {
  844. if ( a[i] == iTarget )
  845. {
  846. iTargetIndex = i;
  847. }
  848. else if ( a[i] > iTarget )
  849. {
  850. a[i]--;
  851. }
  852. }
  853. if ( iTargetIndex != -1 && splice === undefined )
  854. {
  855. a.splice( iTargetIndex, 1 );
  856. }
  857. }
  858. function _fnInvalidate( settings, rowIdx, src, colIdx )
  859. {
  860. var row = settings.aoData[ rowIdx ];
  861. var i, ien;
  862. var cellWrite = function ( cell, col ) {
  863. while ( cell.childNodes.length ) {
  864. cell.removeChild( cell.firstChild );
  865. }
  866. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  867. };
  868. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  869. row._aData = _fnGetRowElements(
  870. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  871. )
  872. .data;
  873. }
  874. else {
  875. var cells = row.anCells;
  876. if ( cells ) {
  877. if ( colIdx !== undefined ) {
  878. cellWrite( cells[colIdx], colIdx );
  879. }
  880. else {
  881. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  882. cellWrite( cells[i], i );
  883. }
  884. }
  885. }
  886. }
  887. row._aSortData = null;
  888. row._aFilterData = null;
  889. var cols = settings.aoColumns;
  890. if ( colIdx !== undefined ) {
  891. cols[ colIdx ].sType = null;
  892. }
  893. else {
  894. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  895. cols[i].sType = null;
  896. }
  897. _fnRowAttributes( settings, row );
  898. }
  899. }
  900. function _fnGetRowElements( settings, row, colIdx, d )
  901. {
  902. var
  903. tds = [],
  904. td = row.firstChild,
  905. name, col, o, i=0, contents,
  906. columns = settings.aoColumns,
  907. objectRead = settings._rowReadObject;
  908. d = d !== undefined ?
  909. d :
  910. objectRead ?
  911. {} :
  912. [];
  913. var attr = function ( str, td ) {
  914. if ( typeof str === 'string' ) {
  915. var idx = str.indexOf('@');
  916. if ( idx !== -1 ) {
  917. var attr = str.substring( idx+1 );
  918. var setter = _fnSetObjectDataFn( str );
  919. setter( d, td.getAttribute( attr ) );
  920. }
  921. }
  922. };
  923. var cellProcess = function ( cell ) {
  924. if ( colIdx === undefined || colIdx === i ) {
  925. col = columns[i];
  926. contents = $.trim(cell.innerHTML);
  927. if ( col && col._bAttrSrc ) {
  928. var setter = _fnSetObjectDataFn( col.mData._ );
  929. setter( d, contents );
  930. attr( col.mData.sort, cell );
  931. attr( col.mData.type, cell );
  932. attr( col.mData.filter, cell );
  933. }
  934. else {
  935. if ( objectRead ) {
  936. if ( ! col._setter ) {
  937. col._setter = _fnSetObjectDataFn( col.mData );
  938. }
  939. col._setter( d, contents );
  940. }
  941. else {
  942. d[i] = contents;
  943. }
  944. }
  945. }
  946. i++;
  947. };
  948. if ( td ) {
  949. while ( td ) {
  950. name = td.nodeName.toUpperCase();
  951. if ( name == "TD" || name == "TH" ) {
  952. cellProcess( td );
  953. tds.push( td );
  954. }
  955. td = td.nextSibling;
  956. }
  957. }
  958. else {
  959. tds = row.anCells;
  960. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  961. cellProcess( tds[j] );
  962. }
  963. }
  964. var rowNode = row.firstChild ? row : row.nTr;
  965. if ( rowNode ) {
  966. var id = rowNode.getAttribute( 'id' );
  967. if ( id ) {
  968. _fnSetObjectDataFn( settings.rowId )( d, id );
  969. }
  970. }
  971. return {
  972. data: d,
  973. cells: tds
  974. };
  975. }
  976. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  977. {
  978. var
  979. row = oSettings.aoData[iRow],
  980. rowData = row._aData,
  981. cells = [],
  982. nTr, nTd, oCol,
  983. i, iLen;
  984. if ( row.nTr === null )
  985. {
  986. nTr = nTrIn || document.createElement('tr');
  987. row.nTr = nTr;
  988. row.anCells = cells;
  989. nTr._DT_RowIndex = iRow;
  990. _fnRowAttributes( oSettings, row );
  991. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  992. {
  993. oCol = oSettings.aoColumns[i];
  994. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  995. cells.push( nTd );
  996. if ( !nTrIn || oCol.mRender || oCol.mData !== i )
  997. {
  998. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  999. }
  1000. if ( oCol.sClass )
  1001. {
  1002. nTd.className += ' '+oCol.sClass;
  1003. }
  1004. if ( oCol.bVisible && ! nTrIn )
  1005. {
  1006. nTr.appendChild( nTd );
  1007. }
  1008. else if ( ! oCol.bVisible && nTrIn )
  1009. {
  1010. nTd.parentNode.removeChild( nTd );
  1011. }
  1012. if ( oCol.fnCreatedCell )
  1013. {
  1014. oCol.fnCreatedCell.call( oSettings.oInstance,
  1015. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  1016. );
  1017. }
  1018. }
  1019. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  1020. }
  1021. row.nTr.setAttribute( 'role', 'row' );
  1022. }
  1023. function _fnRowAttributes( settings, row )
  1024. {
  1025. var tr = row.nTr;
  1026. var data = row._aData;
  1027. if ( tr ) {
  1028. var id = settings.rowIdFn( data );
  1029. if ( id ) {
  1030. tr.id = id;
  1031. }
  1032. if ( data.DT_RowClass ) {
  1033. var a = data.DT_RowClass.split(' ');
  1034. row.__rowc = row.__rowc ?
  1035. _unique( row.__rowc.concat( a ) ) :
  1036. a;
  1037. $(tr)
  1038. .removeClass( row.__rowc.join(' ') )
  1039. .addClass( data.DT_RowClass );
  1040. }
  1041. if ( data.DT_RowAttr ) {
  1042. $(tr).attr( data.DT_RowAttr );
  1043. }
  1044. if ( data.DT_RowData ) {
  1045. $(tr).data( data.DT_RowData );
  1046. }
  1047. }
  1048. }
  1049. function _fnBuildHead( oSettings )
  1050. {
  1051. var i, ien, cell, row, column;
  1052. var thead = oSettings.nTHead;
  1053. var tfoot = oSettings.nTFoot;
  1054. var createHeader = $('th, td', thead).length === 0;
  1055. var classes = oSettings.oClasses;
  1056. var columns = oSettings.aoColumns;
  1057. if ( createHeader ) {
  1058. row = $('<tr/>').appendTo( thead );
  1059. }
  1060. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1061. column = columns[i];
  1062. cell = $( column.nTh ).addClass( column.sClass );
  1063. if ( createHeader ) {
  1064. cell.appendTo( row );
  1065. }
  1066. if ( oSettings.oFeatures.bSort ) {
  1067. cell.addClass( column.sSortingClass );
  1068. if ( column.bSortable !== false ) {
  1069. cell
  1070. .attr( 'tabindex', oSettings.iTabIndex )
  1071. .attr( 'aria-controls', oSettings.sTableId );
  1072. _fnSortAttachListener( oSettings, column.nTh, i );
  1073. }
  1074. }
  1075. if ( column.sTitle != cell[0].innerHTML ) {
  1076. cell.html( column.sTitle );
  1077. }
  1078. _fnRenderer( oSettings, 'header' )(
  1079. oSettings, cell, column, classes
  1080. );
  1081. }
  1082. if ( createHeader ) {
  1083. _fnDetectHeader( oSettings.aoHeader, thead );
  1084. }
  1085. $(thead).find('>tr').attr('role', 'row');
  1086. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  1087. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  1088. if ( tfoot !== null ) {
  1089. var cells = oSettings.aoFooter[0];
  1090. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1091. column = columns[i];
  1092. column.nTf = cells[i].cell;
  1093. if ( column.sClass ) {
  1094. $(column.nTf).addClass( column.sClass );
  1095. }
  1096. }
  1097. }
  1098. }
  1099. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  1100. {
  1101. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  1102. var aoLocal = [];
  1103. var aApplied = [];
  1104. var iColumns = oSettings.aoColumns.length;
  1105. var iRowspan, iColspan;
  1106. if ( ! aoSource )
  1107. {
  1108. return;
  1109. }
  1110. if ( bIncludeHidden === undefined )
  1111. {
  1112. bIncludeHidden = false;
  1113. }
  1114. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  1115. {
  1116. aoLocal[i] = aoSource[i].slice();
  1117. aoLocal[i].nTr = aoSource[i].nTr;
  1118. for ( j=iColumns-1 ; j>=0 ; j-- )
  1119. {
  1120. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  1121. {
  1122. aoLocal[i].splice( j, 1 );
  1123. }
  1124. }
  1125. aApplied.push( [] );
  1126. }
  1127. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  1128. {
  1129. nLocalTr = aoLocal[i].nTr;
  1130. if ( nLocalTr )
  1131. {
  1132. while( (n = nLocalTr.firstChild) )
  1133. {
  1134. nLocalTr.removeChild( n );
  1135. }
  1136. }
  1137. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  1138. {
  1139. iRowspan = 1;
  1140. iColspan = 1;
  1141. if ( aApplied[i][j] === undefined )
  1142. {
  1143. nLocalTr.appendChild( aoLocal[i][j].cell );
  1144. aApplied[i][j] = 1;
  1145. while ( aoLocal[i+iRowspan] !== undefined &&
  1146. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  1147. {
  1148. aApplied[i+iRowspan][j] = 1;
  1149. iRowspan++;
  1150. }
  1151. while ( aoLocal[i][j+iColspan] !== undefined &&
  1152. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  1153. {
  1154. for ( k=0 ; k<iRowspan ; k++ )
  1155. {
  1156. aApplied[i+k][j+iColspan] = 1;
  1157. }
  1158. iColspan++;
  1159. }
  1160. $(aoLocal[i][j].cell)
  1161. .attr('rowspan', iRowspan)
  1162. .attr('colspan', iColspan);
  1163. }
  1164. }
  1165. }
  1166. }
  1167. function _fnDraw( oSettings )
  1168. {
  1169. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  1170. if ( $.inArray( false, aPreDraw ) !== -1 )
  1171. {
  1172. _fnProcessingDisplay( oSettings, false );
  1173. return;
  1174. }
  1175. var i, iLen, n;
  1176. var anRows = [];
  1177. var iRowCount = 0;
  1178. var asStripeClasses = oSettings.asStripeClasses;
  1179. var iStripes = asStripeClasses.length;
  1180. var iOpenRows = oSettings.aoOpenRows.length;
  1181. var oLang = oSettings.oLanguage;
  1182. var iInitDisplayStart = oSettings.iInitDisplayStart;
  1183. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  1184. var aiDisplay = oSettings.aiDisplay;
  1185. oSettings.bDrawing = true;
  1186. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  1187. {
  1188. oSettings._iDisplayStart = bServerSide ?
  1189. iInitDisplayStart :
  1190. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  1191. 0 :
  1192. iInitDisplayStart;
  1193. oSettings.iInitDisplayStart = -1;
  1194. }
  1195. var iDisplayStart = oSettings._iDisplayStart;
  1196. var iDisplayEnd = oSettings.fnDisplayEnd();
  1197. if ( oSettings.bDeferLoading )
  1198. {
  1199. oSettings.bDeferLoading = false;
  1200. oSettings.iDraw++;
  1201. _fnProcessingDisplay( oSettings, false );
  1202. }
  1203. else if ( !bServerSide )
  1204. {
  1205. oSettings.iDraw++;
  1206. }
  1207. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  1208. {
  1209. return;
  1210. }
  1211. if ( aiDisplay.length !== 0 )
  1212. {
  1213. var iStart = bServerSide ? 0 : iDisplayStart;
  1214. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  1215. for ( var j=iStart ; j<iEnd ; j++ )
  1216. {
  1217. var iDataIndex = aiDisplay[j];
  1218. var aoData = oSettings.aoData[ iDataIndex ];
  1219. if ( aoData.nTr === null )
  1220. {
  1221. _fnCreateTr( oSettings, iDataIndex );
  1222. }
  1223. var nRow = aoData.nTr;
  1224. if ( iStripes !== 0 )
  1225. {
  1226. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  1227. if ( aoData._sRowStripe != sStripe )
  1228. {
  1229. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  1230. aoData._sRowStripe = sStripe;
  1231. }
  1232. }
  1233. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  1234. [nRow, aoData._aData, iRowCount, j] );
  1235. anRows.push( nRow );
  1236. iRowCount++;
  1237. }
  1238. }
  1239. else
  1240. {
  1241. var sZero = oLang.sZeroRecords;
  1242. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  1243. {
  1244. sZero = oLang.sLoadingRecords;
  1245. }
  1246. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  1247. {
  1248. sZero = oLang.sEmptyTable;
  1249. }
  1250. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  1251. .append( $('<td />', {
  1252. 'valign': 'top',
  1253. 'colSpan': _fnVisbleColumns( oSettings ),
  1254. 'class': oSettings.oClasses.sRowEmpty
  1255. } ).html( sZero ) )[0];
  1256. }
  1257. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  1258. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1259. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  1260. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1261. var body = $(oSettings.nTBody);
  1262. body.children().detach();
  1263. body.append( $(anRows) );
  1264. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  1265. oSettings.bSorted = false;
  1266. oSettings.bFiltered = false;
  1267. oSettings.bDrawing = false;
  1268. }
  1269. function _fnReDraw( settings, holdPosition )
  1270. {
  1271. var
  1272. features = settings.oFeatures,
  1273. sort = features.bSort,
  1274. filter = features.bFilter;
  1275. if ( sort ) {
  1276. _fnSort( settings );
  1277. }
  1278. if ( filter ) {
  1279. _fnFilterComplete( settings, settings.oPreviousSearch );
  1280. }
  1281. else {
  1282. settings.aiDisplay = settings.aiDisplayMaster.slice();
  1283. }
  1284. if ( holdPosition !== true ) {
  1285. settings._iDisplayStart = 0;
  1286. }
  1287. settings._drawHold = holdPosition;
  1288. _fnDraw( settings );
  1289. settings._drawHold = false;
  1290. }
  1291. function _fnAddOptionsHtml ( oSettings )
  1292. {
  1293. var classes = oSettings.oClasses;
  1294. var table = $(oSettings.nTable);
  1295. var holding = $('<div/>').insertBefore( table );
  1296. var features = oSettings.oFeatures;
  1297. var insert = $('<div/>', {
  1298. id: oSettings.sTableId+'_wrapper',
  1299. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  1300. } );
  1301. oSettings.nHolding = holding[0];
  1302. oSettings.nTableWrapper = insert[0];
  1303. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  1304. var aDom = oSettings.sDom.split('');
  1305. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  1306. for ( var i=0 ; i<aDom.length ; i++ )
  1307. {
  1308. featureNode = null;
  1309. cOption = aDom[i];
  1310. if ( cOption == '<' )
  1311. {
  1312. nNewNode = $('<div/>')[0];
  1313. cNext = aDom[i+1];
  1314. if ( cNext == "'" || cNext == '"' )
  1315. {
  1316. sAttr = "";
  1317. j = 2;
  1318. while ( aDom[i+j] != cNext )
  1319. {
  1320. sAttr += aDom[i+j];
  1321. j++;
  1322. }
  1323. if ( sAttr == "H" )
  1324. {
  1325. sAttr = classes.sJUIHeader;
  1326. }
  1327. else if ( sAttr == "F" )
  1328. {
  1329. sAttr = classes.sJUIFooter;
  1330. }
  1331. if ( sAttr.indexOf('.') != -1 )
  1332. {
  1333. var aSplit = sAttr.split('.');
  1334. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  1335. nNewNode.className = aSplit[1];
  1336. }
  1337. else if ( sAttr.charAt(0) == "#" )
  1338. {
  1339. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  1340. }
  1341. else
  1342. {
  1343. nNewNode.className = sAttr;
  1344. }
  1345. i += j;
  1346. }
  1347. insert.append( nNewNode );
  1348. insert = $(nNewNode);
  1349. }
  1350. else if ( cOption == '>' )
  1351. {
  1352. insert = insert.parent();
  1353. }
  1354. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  1355. {
  1356. featureNode = _fnFeatureHtmlLength( oSettings );
  1357. }
  1358. else if ( cOption == 'f' && features.bFilter )
  1359. {
  1360. featureNode = _fnFeatureHtmlFilter( oSettings );
  1361. }
  1362. else if ( cOption == 'r' && features.bProcessing )
  1363. {
  1364. featureNode = _fnFeatureHtmlProcessing( oSettings );
  1365. }
  1366. else if ( cOption == 't' )
  1367. {
  1368. featureNode = _fnFeatureHtmlTable( oSettings );
  1369. }
  1370. else if ( cOption == 'i' && features.bInfo )
  1371. {
  1372. featureNode = _fnFeatureHtmlInfo( oSettings );
  1373. }
  1374. else if ( cOption == 'p' && features.bPaginate )
  1375. {
  1376. featureNode = _fnFeatureHtmlPaginate( oSettings );
  1377. }
  1378. else if ( DataTable.ext.feature.length !== 0 )
  1379. {
  1380. var aoFeatures = DataTable.ext.feature;
  1381. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  1382. {
  1383. if ( cOption == aoFeatures[k].cFeature )
  1384. {
  1385. featureNode = aoFeatures[k].fnInit( oSettings );
  1386. break;
  1387. }
  1388. }
  1389. }
  1390. if ( featureNode )
  1391. {
  1392. var aanFeatures = oSettings.aanFeatures;
  1393. if ( ! aanFeatures[cOption] )
  1394. {
  1395. aanFeatures[cOption] = [];
  1396. }
  1397. aanFeatures[cOption].push( featureNode );
  1398. insert.append( featureNode );
  1399. }
  1400. }
  1401. holding.replaceWith( insert );
  1402. oSettings.nHolding = null;
  1403. }
  1404. function _fnDetectHeader ( aLayout, nThead )
  1405. {
  1406. var nTrs = $(nThead).children('tr');
  1407. var nTr, nCell;
  1408. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  1409. var bUnique;
  1410. var fnShiftCol = function ( a, i, j ) {
  1411. var k = a[i];
  1412. while ( k[j] ) {
  1413. j++;
  1414. }
  1415. return j;
  1416. };
  1417. aLayout.splice( 0, aLayout.length );
  1418. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1419. {
  1420. aLayout.push( [] );
  1421. }
  1422. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1423. {
  1424. nTr = nTrs[i];
  1425. iColumn = 0;
  1426. nCell = nTr.firstChild;
  1427. while ( nCell ) {
  1428. if ( nCell.nodeName.toUpperCase() == "TD" ||
  1429. nCell.nodeName.toUpperCase() == "TH" )
  1430. {
  1431. iColspan = nCell.getAttribute('colspan') * 1;
  1432. iRowspan = nCell.getAttribute('rowspan') * 1;
  1433. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  1434. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  1435. iColShifted = fnShiftCol( aLayout, i, iColumn );
  1436. bUnique = iColspan === 1 ? true : false;
  1437. for ( l=0 ; l<iColspan ; l++ )
  1438. {
  1439. for ( k=0 ; k<iRowspan ; k++ )
  1440. {
  1441. aLayout[i+k][iColShifted+l] = {
  1442. "cell": nCell,
  1443. "unique": bUnique
  1444. };
  1445. aLayout[i+k].nTr = nTr;
  1446. }
  1447. }
  1448. }
  1449. nCell = nCell.nextSibling;
  1450. }
  1451. }
  1452. }
  1453. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  1454. {
  1455. var aReturn = [];
  1456. if ( !aLayout )
  1457. {
  1458. aLayout = oSettings.aoHeader;
  1459. if ( nHeader )
  1460. {
  1461. aLayout = [];
  1462. _fnDetectHeader( aLayout, nHeader );
  1463. }
  1464. }
  1465. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  1466. {
  1467. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  1468. {
  1469. if ( aLayout[i][j].unique &&
  1470. (!aReturn[j] || !oSettings.bSortCellsTop) )
  1471. {
  1472. aReturn[j] = aLayout[i][j].cell;
  1473. }
  1474. }
  1475. }
  1476. return aReturn;
  1477. }
  1478. function _fnBuildAjax( oSettings, data, fn )
  1479. {
  1480. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  1481. if ( data && $.isArray(data) ) {
  1482. var tmp = {};
  1483. var rbracket = /(.*?)\[\]$/;
  1484. $.each( data, function (key, val) {
  1485. var match = val.name.match(rbracket);
  1486. if ( match ) {
  1487. var name = match[0];
  1488. if ( ! tmp[ name ] ) {
  1489. tmp[ name ] = [];
  1490. }
  1491. tmp[ name ].push( val.value );
  1492. }
  1493. else {
  1494. tmp[val.name] = val.value;
  1495. }
  1496. } );
  1497. data = tmp;
  1498. }
  1499. var ajaxData;
  1500. var ajax = oSettings.ajax;
  1501. var instance = oSettings.oInstance;
  1502. var callback = function ( json ) {
  1503. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  1504. fn( json );
  1505. };
  1506. if ( $.isPlainObject( ajax ) && ajax.data )
  1507. {
  1508. ajaxData = ajax.data;
  1509. var newData = $.isFunction( ajaxData ) ?
  1510. ajaxData( data, oSettings ) :
  1511. ajaxData;
  1512. data = $.isFunction( ajaxData ) && newData ?
  1513. newData :
  1514. $.extend( true, data, newData );
  1515. delete ajax.data;
  1516. }
  1517. var baseAjax = {
  1518. "data": data,
  1519. "success": function (json) {
  1520. var error = json.error || json.sError;
  1521. if ( error ) {
  1522. _fnLog( oSettings, 0, error );
  1523. }
  1524. oSettings.json = json;
  1525. callback( json );
  1526. },
  1527. "dataType": "json",
  1528. "cache": false,
  1529. "type": oSettings.sServerMethod,
  1530. "error": function (xhr, error, thrown) {
  1531. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  1532. if ( $.inArray( true, ret ) === -1 ) {
  1533. if ( error == "parsererror" ) {
  1534. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  1535. }
  1536. else if ( xhr.readyState === 4 ) {
  1537. _fnLog( oSettings, 0, 'Ajax error', 7 );
  1538. }
  1539. }
  1540. _fnProcessingDisplay( oSettings, false );
  1541. }
  1542. };
  1543. oSettings.oAjaxData = data;
  1544. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  1545. if ( oSettings.fnServerData )
  1546. {
  1547. oSettings.fnServerData.call( instance,
  1548. oSettings.sAjaxSource,
  1549. $.map( data, function (val, key) {
  1550. return { name: key, value: val };
  1551. } ),
  1552. callback,
  1553. oSettings
  1554. );
  1555. }
  1556. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  1557. {
  1558. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  1559. url: ajax || oSettings.sAjaxSource
  1560. } ) );
  1561. }
  1562. else if ( $.isFunction( ajax ) )
  1563. {
  1564. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  1565. }
  1566. else
  1567. {
  1568. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  1569. ajax.data = ajaxData;
  1570. }
  1571. }
  1572. function _fnAjaxUpdate( settings )
  1573. {
  1574. if ( settings.bAjaxDataGet ) {
  1575. settings.iDraw++;
  1576. _fnProcessingDisplay( settings, true );
  1577. _fnBuildAjax(
  1578. settings,
  1579. _fnAjaxParameters( settings ),
  1580. function(json) {
  1581. _fnAjaxUpdateDraw( settings, json );
  1582. }
  1583. );
  1584. return false;
  1585. }
  1586. return true;
  1587. }
  1588. function _fnAjaxParameters( settings )
  1589. {
  1590. var
  1591. columns = settings.aoColumns,
  1592. columnCount = columns.length,
  1593. features = settings.oFeatures,
  1594. preSearch = settings.oPreviousSearch,
  1595. preColSearch = settings.aoPreSearchCols,
  1596. i, data = [], dataProp, column, columnSearch,
  1597. sort = _fnSortFlatten( settings ),
  1598. displayStart = settings._iDisplayStart,
  1599. displayLength = features.bPaginate !== false ?
  1600. settings._iDisplayLength :
  1601. -1;
  1602. var param = function ( name, value ) {
  1603. data.push( { 'name': name, 'value': value } );
  1604. };
  1605. param( 'sEcho', settings.iDraw );
  1606. param( 'iColumns', columnCount );
  1607. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  1608. param( 'iDisplayStart', displayStart );
  1609. param( 'iDisplayLength', displayLength );
  1610. var d = {
  1611. draw: settings.iDraw,
  1612. columns: [],
  1613. order: [],
  1614. start: displayStart,
  1615. length: displayLength,
  1616. search: {
  1617. value: preSearch.sSearch,
  1618. regex: preSearch.bRegex
  1619. }
  1620. };
  1621. for ( i=0 ; i<columnCount ; i++ ) {
  1622. column = columns[i];
  1623. columnSearch = preColSearch[i];
  1624. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  1625. d.columns.push( {
  1626. data: dataProp,
  1627. name: column.sName,
  1628. searchable: column.bSearchable,
  1629. orderable: column.bSortable,
  1630. search: {
  1631. value: columnSearch.sSearch,
  1632. regex: columnSearch.bRegex
  1633. }
  1634. } );
  1635. param( "mDataProp_"+i, dataProp );
  1636. if ( features.bFilter ) {
  1637. param( 'sSearch_'+i, columnSearch.sSearch );
  1638. param( 'bRegex_'+i, columnSearch.bRegex );
  1639. param( 'bSearchable_'+i, column.bSearchable );
  1640. }
  1641. if ( features.bSort ) {
  1642. param( 'bSortable_'+i, column.bSortable );
  1643. }
  1644. }
  1645. if ( features.bFilter ) {
  1646. param( 'sSearch', preSearch.sSearch );
  1647. param( 'bRegex', preSearch.bRegex );
  1648. }
  1649. if ( features.bSort ) {
  1650. $.each( sort, function ( i, val ) {
  1651. d.order.push( { column: val.col, dir: val.dir } );
  1652. param( 'iSortCol_'+i, val.col );
  1653. param( 'sSortDir_'+i, val.dir );
  1654. } );
  1655. param( 'iSortingCols', sort.length );
  1656. }
  1657. var legacy = DataTable.ext.legacy.ajax;
  1658. if ( legacy === null ) {
  1659. return settings.sAjaxSource ? data : d;
  1660. }
  1661. return legacy ? data : d;
  1662. }
  1663. function _fnAjaxUpdateDraw ( settings, json )
  1664. {
  1665. var compat = function ( old, modern ) {
  1666. return json[old] !== undefined ? json[old] : json[modern];
  1667. };
  1668. var data = _fnAjaxDataSrc( settings, json );
  1669. var draw = compat( 'sEcho', 'draw' );
  1670. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  1671. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  1672. if ( draw ) {
  1673. if ( draw*1 < settings.iDraw ) {
  1674. return;
  1675. }
  1676. settings.iDraw = draw * 1;
  1677. }
  1678. _fnClearTable( settings );
  1679. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  1680. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  1681. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  1682. _fnAddData( settings, data[i] );
  1683. }
  1684. settings.aiDisplay = settings.aiDisplayMaster.slice();
  1685. settings.bAjaxDataGet = false;
  1686. _fnDraw( settings );
  1687. if ( ! settings._bInitComplete ) {
  1688. _fnInitComplete( settings, json );
  1689. }
  1690. settings.bAjaxDataGet = true;
  1691. _fnProcessingDisplay( settings, false );
  1692. }
  1693. function _fnAjaxDataSrc ( oSettings, json )
  1694. {
  1695. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  1696. oSettings.ajax.dataSrc :
  1697. oSettings.sAjaxDataProp;
  1698. if ( dataSrc === 'data' ) {
  1699. return json.aaData || json[dataSrc];
  1700. }
  1701. return dataSrc !== "" ?
  1702. _fnGetObjectDataFn( dataSrc )( json ) :
  1703. json;
  1704. }
  1705. function _fnFeatureHtmlFilter ( settings )
  1706. {
  1707. var classes = settings.oClasses;
  1708. var tableId = settings.sTableId;
  1709. var language = settings.oLanguage;
  1710. var previousSearch = settings.oPreviousSearch;
  1711. var features = settings.aanFeatures;
  1712. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  1713. var str = language.sSearch;
  1714. str = str.match(/_INPUT_/) ?
  1715. str.replace('_INPUT_', input) :
  1716. str+input;
  1717. var filter = $('<div/>', {
  1718. 'id': ! features.f ? tableId+'_filter' : null,
  1719. 'class': classes.sFilter
  1720. } )
  1721. .append( $('<label/>' ).append( str ) );
  1722. var searchFn = function() {
  1723. var n = features.f;
  1724. var val = !this.value ? "" : this.value;
  1725. if ( val != previousSearch.sSearch ) {
  1726. _fnFilterComplete( settings, {
  1727. "sSearch": val,
  1728. "bRegex": previousSearch.bRegex,
  1729. "bSmart": previousSearch.bSmart ,
  1730. "bCaseInsensitive": previousSearch.bCaseInsensitive
  1731. } );
  1732. settings._iDisplayStart = 0;
  1733. _fnDraw( settings );
  1734. }
  1735. };
  1736. var searchDelay = settings.searchDelay !== null ?
  1737. settings.searchDelay :
  1738. _fnDataSource( settings ) === 'ssp' ?
  1739. 400 :
  1740. 0;
  1741. var jqFilter = $('input', filter)
  1742. .val( previousSearch.sSearch )
  1743. .attr( 'placeholder', language.sSearchPlaceholder )
  1744. .bind(
  1745. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  1746. searchDelay ?
  1747. _fnThrottle( searchFn, searchDelay ) :
  1748. searchFn
  1749. )
  1750. .bind( 'keypress.DT', function(e) {
  1751. if ( e.keyCode == 13 ) {
  1752. return false;
  1753. }
  1754. } )
  1755. .attr('aria-controls', tableId);
  1756. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  1757. if ( settings === s ) {
  1758. try {
  1759. if ( jqFilter[0] !== document.activeElement ) {
  1760. jqFilter.val( previousSearch.sSearch );
  1761. }
  1762. }
  1763. catch ( e ) {}
  1764. }
  1765. } );
  1766. return filter[0];
  1767. }
  1768. function _fnFilterComplete ( oSettings, oInput, iForce )
  1769. {
  1770. var oPrevSearch = oSettings.oPreviousSearch;
  1771. var aoPrevSearch = oSettings.aoPreSearchCols;
  1772. var fnSaveFilter = function ( oFilter ) {
  1773. oPrevSearch.sSearch = oFilter.sSearch;
  1774. oPrevSearch.bRegex = oFilter.bRegex;
  1775. oPrevSearch.bSmart = oFilter.bSmart;
  1776. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  1777. };
  1778. var fnRegex = function ( o ) {
  1779. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  1780. };
  1781. _fnColumnTypes( oSettings );
  1782. if ( _fnDataSource( oSettings ) != 'ssp' )
  1783. {
  1784. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  1785. fnSaveFilter( oInput );
  1786. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  1787. {
  1788. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  1789. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  1790. }
  1791. _fnFilterCustom( oSettings );
  1792. }
  1793. else
  1794. {
  1795. fnSaveFilter( oInput );
  1796. }
  1797. oSettings.bFiltered = true;
  1798. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  1799. }
  1800. function _fnFilterCustom( settings )
  1801. {
  1802. var filters = DataTable.ext.search;
  1803. var displayRows = settings.aiDisplay;
  1804. var row, rowIdx;
  1805. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  1806. var rows = [];
  1807. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  1808. rowIdx = displayRows[ j ];
  1809. row = settings.aoData[ rowIdx ];
  1810. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  1811. rows.push( rowIdx );
  1812. }
  1813. }
  1814. displayRows.length = 0;
  1815. $.merge( displayRows, rows );
  1816. }
  1817. }
  1818. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  1819. {
  1820. if ( searchStr === '' ) {
  1821. return;
  1822. }
  1823. var data;
  1824. var display = settings.aiDisplay;
  1825. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  1826. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  1827. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  1828. if ( ! rpSearch.test( data ) ) {
  1829. display.splice( i, 1 );
  1830. }
  1831. }
  1832. }
  1833. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  1834. {
  1835. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  1836. var prevSearch = settings.oPreviousSearch.sSearch;
  1837. var displayMaster = settings.aiDisplayMaster;
  1838. var display, invalidated, i;
  1839. if ( DataTable.ext.search.length !== 0 ) {
  1840. force = true;
  1841. }
  1842. invalidated = _fnFilterData( settings );
  1843. if ( input.length <= 0 ) {
  1844. settings.aiDisplay = displayMaster.slice();
  1845. }
  1846. else {
  1847. if ( invalidated ||
  1848. force ||
  1849. prevSearch.length > input.length ||
  1850. input.indexOf(prevSearch) !== 0 ||
  1851. settings.bSorted
  1852. ) {
  1853. settings.aiDisplay = displayMaster.slice();
  1854. }
  1855. display = settings.aiDisplay;
  1856. for ( i=display.length-1 ; i>=0 ; i-- ) {
  1857. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  1858. display.splice( i, 1 );
  1859. }
  1860. }
  1861. }
  1862. }
  1863. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  1864. {
  1865. search = regex ?
  1866. search :
  1867. _fnEscapeRegex( search );
  1868. if ( smart ) {
  1869. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  1870. if ( word.charAt(0) === '"' ) {
  1871. var m = word.match( /^"(.*)"$/ );
  1872. word = m ? m[1] : word;
  1873. }
  1874. return word.replace('"', '');
  1875. } );
  1876. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  1877. }
  1878. return new RegExp( search, caseInsensitive ? 'i' : '' );
  1879. }
  1880. function _fnEscapeRegex ( sVal )
  1881. {
  1882. return sVal.replace( _re_escape_regex, '\\$1' );
  1883. }
  1884. var __filter_div = $('<div>')[0];
  1885. var __filter_div_textContent = __filter_div.textContent !== undefined;
  1886. function _fnFilterData ( settings )
  1887. {
  1888. var columns = settings.aoColumns;
  1889. var column;
  1890. var i, j, ien, jen, filterData, cellData, row;
  1891. var fomatters = DataTable.ext.type.search;
  1892. var wasInvalidated = false;
  1893. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  1894. row = settings.aoData[i];
  1895. if ( ! row._aFilterData ) {
  1896. filterData = [];
  1897. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  1898. column = columns[j];
  1899. if ( column.bSearchable ) {
  1900. cellData = _fnGetCellData( settings, i, j, 'filter' );
  1901. if ( fomatters[ column.sType ] ) {
  1902. cellData = fomatters[ column.sType ]( cellData );
  1903. }
  1904. if ( cellData === null ) {
  1905. cellData = '';
  1906. }
  1907. if ( typeof cellData !== 'string' && cellData.toString ) {
  1908. cellData = cellData.toString();
  1909. }
  1910. }
  1911. else {
  1912. cellData = '';
  1913. }
  1914. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  1915. __filter_div.innerHTML = cellData;
  1916. cellData = __filter_div_textContent ?
  1917. __filter_div.textContent :
  1918. __filter_div.innerText;
  1919. }
  1920. if ( cellData.replace ) {
  1921. cellData = cellData.replace(/[\r\n]/g, '');
  1922. }
  1923. filterData.push( cellData );
  1924. }
  1925. row._aFilterData = filterData;
  1926. row._sFilterRow = filterData.join(' ');
  1927. wasInvalidated = true;
  1928. }
  1929. }
  1930. return wasInvalidated;
  1931. }
  1932. function _fnSearchToCamel ( obj )
  1933. {
  1934. return {
  1935. search: obj.sSearch,
  1936. smart: obj.bSmart,
  1937. regex: obj.bRegex,
  1938. caseInsensitive: obj.bCaseInsensitive
  1939. };
  1940. }
  1941. function _fnSearchToHung ( obj )
  1942. {
  1943. return {
  1944. sSearch: obj.search,
  1945. bSmart: obj.smart,
  1946. bRegex: obj.regex,
  1947. bCaseInsensitive: obj.caseInsensitive
  1948. };
  1949. }
  1950. function _fnFeatureHtmlInfo ( settings )
  1951. {
  1952. var
  1953. tid = settings.sTableId,
  1954. nodes = settings.aanFeatures.i,
  1955. n = $('<div/>', {
  1956. 'class': settings.oClasses.sInfo,
  1957. 'id': ! nodes ? tid+'_info' : null
  1958. } );
  1959. if ( ! nodes ) {
  1960. settings.aoDrawCallback.push( {
  1961. "fn": _fnUpdateInfo,
  1962. "sName": "information"
  1963. } );
  1964. n
  1965. .attr( 'role', 'status' )
  1966. .attr( 'aria-live', 'polite' );
  1967. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  1968. }
  1969. return n[0];
  1970. }
  1971. function _fnUpdateInfo ( settings )
  1972. {
  1973. var nodes = settings.aanFeatures.i;
  1974. if ( nodes.length === 0 ) {
  1975. return;
  1976. }
  1977. var
  1978. lang = settings.oLanguage,
  1979. start = settings._iDisplayStart+1,
  1980. end = settings.fnDisplayEnd(),
  1981. max = settings.fnRecordsTotal(),
  1982. total = settings.fnRecordsDisplay(),
  1983. out = total ?
  1984. lang.sInfo :
  1985. lang.sInfoEmpty;
  1986. if ( total !== max ) {
  1987. out += ' ' + lang.sInfoFiltered;
  1988. }
  1989. out += lang.sInfoPostFix;
  1990. out = _fnInfoMacros( settings, out );
  1991. var callback = lang.fnInfoCallback;
  1992. if ( callback !== null ) {
  1993. out = callback.call( settings.oInstance,
  1994. settings, start, end, max, total, out
  1995. );
  1996. }
  1997. $(nodes).html( out );
  1998. }
  1999. function _fnInfoMacros ( settings, str )
  2000. {
  2001. var
  2002. formatter = settings.fnFormatNumber,
  2003. start = settings._iDisplayStart+1,
  2004. len = settings._iDisplayLength,
  2005. vis = settings.fnRecordsDisplay(),
  2006. all = len === -1;
  2007. return str.
  2008. replace(/_START_/g, formatter.call( settings, start ) ).
  2009. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  2010. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  2011. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  2012. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  2013. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  2014. }
  2015. function _fnInitialise ( settings )
  2016. {
  2017. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  2018. var columns = settings.aoColumns, column;
  2019. var features = settings.oFeatures;
  2020. var deferLoading = settings.bDeferLoading;
  2021. if ( ! settings.bInitialised ) {
  2022. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  2023. return;
  2024. }
  2025. _fnAddOptionsHtml( settings );
  2026. _fnBuildHead( settings );
  2027. _fnDrawHead( settings, settings.aoHeader );
  2028. _fnDrawHead( settings, settings.aoFooter );
  2029. _fnProcessingDisplay( settings, true );
  2030. if ( features.bAutoWidth ) {
  2031. _fnCalculateColumnWidths( settings );
  2032. }
  2033. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  2034. column = columns[i];
  2035. if ( column.sWidth ) {
  2036. column.nTh.style.width = _fnStringToCss( column.sWidth );
  2037. }
  2038. }
  2039. _fnCallbackFire( settings, null, 'preInit', [settings] );
  2040. _fnReDraw( settings );
  2041. var dataSrc = _fnDataSource( settings );
  2042. if ( dataSrc != 'ssp' || deferLoading ) {
  2043. if ( dataSrc == 'ajax' ) {
  2044. _fnBuildAjax( settings, [], function(json) {
  2045. var aData = _fnAjaxDataSrc( settings, json );
  2046. for ( i=0 ; i<aData.length ; i++ ) {
  2047. _fnAddData( settings, aData[i] );
  2048. }
  2049. settings.iInitDisplayStart = iAjaxStart;
  2050. _fnReDraw( settings );
  2051. _fnProcessingDisplay( settings, false );
  2052. _fnInitComplete( settings, json );
  2053. }, settings );
  2054. }
  2055. else {
  2056. _fnProcessingDisplay( settings, false );
  2057. _fnInitComplete( settings );
  2058. }
  2059. }
  2060. }
  2061. function _fnInitComplete ( settings, json )
  2062. {
  2063. settings._bInitComplete = true;
  2064. if ( json || settings.oInit.aaData ) {
  2065. _fnAdjustColumnSizing( settings );
  2066. }
  2067. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  2068. }
  2069. function _fnLengthChange ( settings, val )
  2070. {
  2071. var len = parseInt( val, 10 );
  2072. settings._iDisplayLength = len;
  2073. _fnLengthOverflow( settings );
  2074. _fnCallbackFire( settings, null, 'length', [settings, len] );
  2075. }
  2076. function _fnFeatureHtmlLength ( settings )
  2077. {
  2078. var
  2079. classes = settings.oClasses,
  2080. tableId = settings.sTableId,
  2081. menu = settings.aLengthMenu,
  2082. d2 = $.isArray( menu[0] ),
  2083. lengths = d2 ? menu[0] : menu,
  2084. language = d2 ? menu[1] : menu;
  2085. var select = $('<select/>', {
  2086. 'name': tableId+'_length',
  2087. 'aria-controls': tableId,
  2088. 'class': classes.sLengthSelect
  2089. } );
  2090. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  2091. select[0][ i ] = new Option( language[i], lengths[i] );
  2092. }
  2093. var div = $('<div><label/></div>').addClass( classes.sLength );
  2094. if ( ! settings.aanFeatures.l ) {
  2095. div[0].id = tableId+'_length';
  2096. }
  2097. div.children().append(
  2098. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  2099. );
  2100. $('select', div)
  2101. .val( settings._iDisplayLength )
  2102. .bind( 'change.DT', function(e) {
  2103. _fnLengthChange( settings, $(this).val() );
  2104. _fnDraw( settings );
  2105. } );
  2106. $(settings.nTable).bind( 'length.dt.DT', function (e, s, len) {
  2107. if ( settings === s ) {
  2108. $('select', div).val( len );
  2109. }
  2110. } );
  2111. return div[0];
  2112. }
  2113. function _fnFeatureHtmlPaginate ( settings )
  2114. {
  2115. var
  2116. type = settings.sPaginationType,
  2117. plugin = DataTable.ext.pager[ type ],
  2118. modern = typeof plugin === 'function',
  2119. redraw = function( settings ) {
  2120. _fnDraw( settings );
  2121. },
  2122. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  2123. features = settings.aanFeatures;
  2124. if ( ! modern ) {
  2125. plugin.fnInit( settings, node, redraw );
  2126. }
  2127. if ( ! features.p )
  2128. {
  2129. node.id = settings.sTableId+'_paginate';
  2130. settings.aoDrawCallback.push( {
  2131. "fn": function( settings ) {
  2132. if ( modern ) {
  2133. var
  2134. start = settings._iDisplayStart,
  2135. len = settings._iDisplayLength,
  2136. visRecords = settings.fnRecordsDisplay(),
  2137. all = len === -1,
  2138. page = all ? 0 : Math.ceil( start / len ),
  2139. pages = all ? 1 : Math.ceil( visRecords / len ),
  2140. buttons = plugin(page, pages),
  2141. i, ien;
  2142. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  2143. _fnRenderer( settings, 'pageButton' )(
  2144. settings, features.p[i], i, buttons, page, pages
  2145. );
  2146. }
  2147. }
  2148. else {
  2149. plugin.fnUpdate( settings, redraw );
  2150. }
  2151. },
  2152. "sName": "pagination"
  2153. } );
  2154. }
  2155. return node;
  2156. }
  2157. function _fnPageChange ( settings, action, redraw )
  2158. {
  2159. var
  2160. start = settings._iDisplayStart,
  2161. len = settings._iDisplayLength,
  2162. records = settings.fnRecordsDisplay();
  2163. if ( records === 0 || len === -1 )
  2164. {
  2165. start = 0;
  2166. }
  2167. else if ( typeof action === "number" )
  2168. {
  2169. start = action * len;
  2170. if ( start > records )
  2171. {
  2172. start = 0;
  2173. }
  2174. }
  2175. else if ( action == "first" )
  2176. {
  2177. start = 0;
  2178. }
  2179. else if ( action == "previous" )
  2180. {
  2181. start = len >= 0 ?
  2182. start - len :
  2183. 0;
  2184. if ( start < 0 )
  2185. {
  2186. start = 0;
  2187. }
  2188. }
  2189. else if ( action == "next" )
  2190. {
  2191. if ( start + len < records )
  2192. {
  2193. start += len;
  2194. }
  2195. }
  2196. else if ( action == "last" )
  2197. {
  2198. start = Math.floor( (records-1) / len) * len;
  2199. }
  2200. else
  2201. {
  2202. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  2203. }
  2204. var changed = settings._iDisplayStart !== start;
  2205. settings._iDisplayStart = start;
  2206. if ( changed ) {
  2207. _fnCallbackFire( settings, null, 'page', [settings] );
  2208. if ( redraw ) {
  2209. _fnDraw( settings );
  2210. }
  2211. }
  2212. return changed;
  2213. }
  2214. function _fnFeatureHtmlProcessing ( settings )
  2215. {
  2216. return $('<div/>', {
  2217. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  2218. 'class': settings.oClasses.sProcessing
  2219. } )
  2220. .html( settings.oLanguage.sProcessing )
  2221. .insertBefore( settings.nTable )[0];
  2222. }
  2223. function _fnProcessingDisplay ( settings, show )
  2224. {
  2225. if ( settings.oFeatures.bProcessing ) {
  2226. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  2227. }
  2228. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  2229. }
  2230. function _fnFeatureHtmlTable ( settings )
  2231. {
  2232. var table = $(settings.nTable);
  2233. table.attr( 'role', 'grid' );
  2234. var scroll = settings.oScroll;
  2235. if ( scroll.sX === '' && scroll.sY === '' ) {
  2236. return settings.nTable;
  2237. }
  2238. var scrollX = scroll.sX;
  2239. var scrollY = scroll.sY;
  2240. var classes = settings.oClasses;
  2241. var caption = table.children('caption');
  2242. var captionSide = caption.length ? caption[0]._captionSide : null;
  2243. var headerClone = $( table[0].cloneNode(false) );
  2244. var footerClone = $( table[0].cloneNode(false) );
  2245. var footer = table.children('tfoot');
  2246. var _div = '<div/>';
  2247. var size = function ( s ) {
  2248. return !s ? null : _fnStringToCss( s );
  2249. };
  2250. if ( scroll.sX && table.attr('width') === '100%' ) {
  2251. table.removeAttr('width');
  2252. }
  2253. if ( ! footer.length ) {
  2254. footer = null;
  2255. }
  2256. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  2257. .append(
  2258. $(_div, { 'class': classes.sScrollHead } )
  2259. .css( {
  2260. overflow: 'hidden',
  2261. position: 'relative',
  2262. border: 0,
  2263. width: scrollX ? size(scrollX) : '100%'
  2264. } )
  2265. .append(
  2266. $(_div, { 'class': classes.sScrollHeadInner } )
  2267. .css( {
  2268. 'box-sizing': 'content-box',
  2269. width: scroll.sXInner || '100%'
  2270. } )
  2271. .append(
  2272. headerClone
  2273. .removeAttr('id')
  2274. .css( 'margin-left', 0 )
  2275. .append( captionSide === 'top' ? caption : null )
  2276. .append(
  2277. table.children('thead')
  2278. )
  2279. )
  2280. )
  2281. )
  2282. .append(
  2283. $(_div, { 'class': classes.sScrollBody } )
  2284. .css( {
  2285. position: 'relative',
  2286. overflow: 'auto',
  2287. width: size( scrollX )
  2288. } )
  2289. .append( table )
  2290. );
  2291. if ( footer ) {
  2292. scroller.append(
  2293. $(_div, { 'class': classes.sScrollFoot } )
  2294. .css( {
  2295. overflow: 'hidden',
  2296. border: 0,
  2297. width: scrollX ? size(scrollX) : '100%'
  2298. } )
  2299. .append(
  2300. $(_div, { 'class': classes.sScrollFootInner } )
  2301. .append(
  2302. footerClone
  2303. .removeAttr('id')
  2304. .css( 'margin-left', 0 )
  2305. .append( captionSide === 'bottom' ? caption : null )
  2306. .append(
  2307. table.children('tfoot')
  2308. )
  2309. )
  2310. )
  2311. );
  2312. }
  2313. var children = scroller.children();
  2314. var scrollHead = children[0];
  2315. var scrollBody = children[1];
  2316. var scrollFoot = footer ? children[2] : null;
  2317. if ( scrollX ) {
  2318. $(scrollBody).on( 'scroll.DT', function (e) {
  2319. var scrollLeft = this.scrollLeft;
  2320. scrollHead.scrollLeft = scrollLeft;
  2321. if ( footer ) {
  2322. scrollFoot.scrollLeft = scrollLeft;
  2323. }
  2324. } );
  2325. }
  2326. $(scrollBody).css(
  2327. scrollY && scroll.bCollapse ? 'max-height' : 'height',
  2328. scrollY
  2329. );
  2330. settings.nScrollHead = scrollHead;
  2331. settings.nScrollBody = scrollBody;
  2332. settings.nScrollFoot = scrollFoot;
  2333. settings.aoDrawCallback.push( {
  2334. "fn": _fnScrollDraw,
  2335. "sName": "scrolling"
  2336. } );
  2337. return scroller[0];
  2338. }
  2339. function _fnScrollDraw ( settings )
  2340. {
  2341. var
  2342. scroll = settings.oScroll,
  2343. scrollX = scroll.sX,
  2344. scrollXInner = scroll.sXInner,
  2345. scrollY = scroll.sY,
  2346. barWidth = scroll.iBarWidth,
  2347. divHeader = $(settings.nScrollHead),
  2348. divHeaderStyle = divHeader[0].style,
  2349. divHeaderInner = divHeader.children('div'),
  2350. divHeaderInnerStyle = divHeaderInner[0].style,
  2351. divHeaderTable = divHeaderInner.children('table'),
  2352. divBodyEl = settings.nScrollBody,
  2353. divBody = $(divBodyEl),
  2354. divBodyStyle = divBodyEl.style,
  2355. divFooter = $(settings.nScrollFoot),
  2356. divFooterInner = divFooter.children('div'),
  2357. divFooterTable = divFooterInner.children('table'),
  2358. header = $(settings.nTHead),
  2359. table = $(settings.nTable),
  2360. tableEl = table[0],
  2361. tableStyle = tableEl.style,
  2362. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  2363. browser = settings.oBrowser,
  2364. ie67 = browser.bScrollOversize,
  2365. headerTrgEls, footerTrgEls,
  2366. headerSrcEls, footerSrcEls,
  2367. headerCopy, footerCopy,
  2368. headerWidths=[], footerWidths=[],
  2369. headerContent=[],
  2370. idx, correction, sanityWidth,
  2371. zeroOut = function(nSizer) {
  2372. var style = nSizer.style;
  2373. style.paddingTop = "0";
  2374. style.paddingBottom = "0";
  2375. style.borderTopWidth = "0";
  2376. style.borderBottomWidth = "0";
  2377. style.height = 0;
  2378. };
  2379. table.children('thead, tfoot').remove();
  2380. headerCopy = header.clone().prependTo( table );
  2381. headerTrgEls = header.find('tr');
  2382. headerSrcEls = headerCopy.find('tr');
  2383. headerCopy.find('th, td').removeAttr('tabindex');
  2384. if ( footer ) {
  2385. footerCopy = footer.clone().prependTo( table );
  2386. footerTrgEls = footer.find('tr');
  2387. footerSrcEls = footerCopy.find('tr');
  2388. }
  2389. if ( ! scrollX )
  2390. {
  2391. divBodyStyle.width = '100%';
  2392. divHeader[0].style.width = '100%';
  2393. }
  2394. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  2395. idx = _fnVisibleToColumnIndex( settings, i );
  2396. el.style.width = settings.aoColumns[idx].sWidth;
  2397. } );
  2398. if ( footer ) {
  2399. _fnApplyToChildren( function(n) {
  2400. n.style.width = "";
  2401. }, footerSrcEls );
  2402. }
  2403. sanityWidth = table.outerWidth();
  2404. if ( scrollX === "" ) {
  2405. tableStyle.width = "100%";
  2406. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  2407. divBody.css('overflow-y') == "scroll")
  2408. ) {
  2409. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  2410. }
  2411. sanityWidth = table.outerWidth();
  2412. }
  2413. else if ( scrollXInner !== "" ) {
  2414. tableStyle.width = _fnStringToCss(scrollXInner);
  2415. sanityWidth = table.outerWidth();
  2416. }
  2417. _fnApplyToChildren( zeroOut, headerSrcEls );
  2418. _fnApplyToChildren( function(nSizer) {
  2419. headerContent.push( nSizer.innerHTML );
  2420. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  2421. }, headerSrcEls );
  2422. _fnApplyToChildren( function(nToSize, i) {
  2423. nToSize.style.width = headerWidths[i];
  2424. }, headerTrgEls );
  2425. $(headerSrcEls).height(0);
  2426. if ( footer )
  2427. {
  2428. _fnApplyToChildren( zeroOut, footerSrcEls );
  2429. _fnApplyToChildren( function(nSizer) {
  2430. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  2431. }, footerSrcEls );
  2432. _fnApplyToChildren( function(nToSize, i) {
  2433. nToSize.style.width = footerWidths[i];
  2434. }, footerTrgEls );
  2435. $(footerSrcEls).height(0);
  2436. }
  2437. _fnApplyToChildren( function(nSizer, i) {
  2438. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  2439. nSizer.style.width = headerWidths[i];
  2440. }, headerSrcEls );
  2441. if ( footer )
  2442. {
  2443. _fnApplyToChildren( function(nSizer, i) {
  2444. nSizer.innerHTML = "";
  2445. nSizer.style.width = footerWidths[i];
  2446. }, footerSrcEls );
  2447. }
  2448. if ( table.outerWidth() < sanityWidth )
  2449. {
  2450. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  2451. divBody.css('overflow-y') == "scroll")) ?
  2452. sanityWidth+barWidth :
  2453. sanityWidth;
  2454. if ( ie67 && (divBodyEl.scrollHeight >
  2455. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  2456. ) {
  2457. tableStyle.width = _fnStringToCss( correction-barWidth );
  2458. }
  2459. if ( scrollX === "" || scrollXInner !== "" ) {
  2460. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  2461. }
  2462. }
  2463. else
  2464. {
  2465. correction = '100%';
  2466. }
  2467. divBodyStyle.width = _fnStringToCss( correction );
  2468. divHeaderStyle.width = _fnStringToCss( correction );
  2469. if ( footer ) {
  2470. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  2471. }
  2472. if ( ! scrollY ) {
  2473. if ( ie67 ) {
  2474. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  2475. }
  2476. }
  2477. var iOuterWidth = table.outerWidth();
  2478. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  2479. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  2480. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  2481. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  2482. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  2483. if ( footer ) {
  2484. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  2485. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  2486. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  2487. }
  2488. divBody.scroll();
  2489. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  2490. divBodyEl.scrollTop = 0;
  2491. }
  2492. }
  2493. function _fnApplyToChildren( fn, an1, an2 )
  2494. {
  2495. var index=0, i=0, iLen=an1.length;
  2496. var nNode1, nNode2;
  2497. while ( i < iLen ) {
  2498. nNode1 = an1[i].firstChild;
  2499. nNode2 = an2 ? an2[i].firstChild : null;
  2500. while ( nNode1 ) {
  2501. if ( nNode1.nodeType === 1 ) {
  2502. if ( an2 ) {
  2503. fn( nNode1, nNode2, index );
  2504. }
  2505. else {
  2506. fn( nNode1, index );
  2507. }
  2508. index++;
  2509. }
  2510. nNode1 = nNode1.nextSibling;
  2511. nNode2 = an2 ? nNode2.nextSibling : null;
  2512. }
  2513. i++;
  2514. }
  2515. }
  2516. var __re_html_remove = /<.*?>/g;
  2517. function _fnCalculateColumnWidths ( oSettings )
  2518. {
  2519. var
  2520. table = oSettings.nTable,
  2521. columns = oSettings.aoColumns,
  2522. scroll = oSettings.oScroll,
  2523. scrollY = scroll.sY,
  2524. scrollX = scroll.sX,
  2525. scrollXInner = scroll.sXInner,
  2526. columnCount = columns.length,
  2527. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  2528. headerCells = $('th', oSettings.nTHead),
  2529. tableWidthAttr = table.getAttribute('width'),
  2530. tableContainer = table.parentNode,
  2531. userInputs = false,
  2532. i, column, columnIdx, width, outerWidth,
  2533. browser = oSettings.oBrowser,
  2534. ie67 = browser.bScrollOversize;
  2535. var styleWidth = table.style.width;
  2536. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  2537. tableWidthAttr = styleWidth;
  2538. }
  2539. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  2540. column = columns[ visibleColumns[i] ];
  2541. if ( column.sWidth !== null ) {
  2542. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  2543. userInputs = true;
  2544. }
  2545. }
  2546. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  2547. columnCount == _fnVisbleColumns( oSettings ) &&
  2548. columnCount == headerCells.length
  2549. ) {
  2550. for ( i=0 ; i<columnCount ; i++ ) {
  2551. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  2552. if ( colIdx !== null ) {
  2553. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  2554. }
  2555. }
  2556. }
  2557. else
  2558. {
  2559. var tmpTable = $(table).clone()
  2560. .css( 'visibility', 'hidden' )
  2561. .removeAttr( 'id' );
  2562. tmpTable.find('tbody tr').remove();
  2563. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  2564. tmpTable.find('thead, tfoot').remove();
  2565. tmpTable
  2566. .append( $(oSettings.nTHead).clone() )
  2567. .append( $(oSettings.nTFoot).clone() );
  2568. tmpTable.find('tfoot th, tfoot td').css('width', '');
  2569. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  2570. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  2571. column = columns[ visibleColumns[i] ];
  2572. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  2573. _fnStringToCss( column.sWidthOrig ) :
  2574. '';
  2575. }
  2576. if ( oSettings.aoData.length ) {
  2577. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  2578. columnIdx = visibleColumns[i];
  2579. column = columns[ columnIdx ];
  2580. $( _fnGetWidestNode( oSettings, columnIdx ) )
  2581. .clone( false )
  2582. .append( column.sContentPadding )
  2583. .appendTo( tr );
  2584. }
  2585. }
  2586. var holder = $('<div/>').css( scrollX || scrollY ?
  2587. {
  2588. position: 'absolute',
  2589. top: 0,
  2590. left: 0,
  2591. height: 1,
  2592. right: 0,
  2593. overflow: 'hidden'
  2594. } :
  2595. {}
  2596. )
  2597. .append( tmpTable )
  2598. .appendTo( tableContainer );
  2599. if ( scrollX && scrollXInner ) {
  2600. tmpTable.width( scrollXInner );
  2601. }
  2602. else if ( scrollX ) {
  2603. tmpTable.css( 'width', 'auto' );
  2604. if ( tmpTable.width() < tableContainer.clientWidth ) {
  2605. tmpTable.width( tableContainer.clientWidth );
  2606. }
  2607. }
  2608. else if ( scrollY ) {
  2609. tmpTable.width( tableContainer.clientWidth );
  2610. }
  2611. else if ( tableWidthAttr ) {
  2612. tmpTable.width( tableWidthAttr );
  2613. }
  2614. if ( scrollX )
  2615. {
  2616. var total = 0;
  2617. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  2618. column = columns[ visibleColumns[i] ];
  2619. outerWidth = browser.bBounding ?
  2620. headerCells[i].getBoundingClientRect().width :
  2621. $(headerCells[i]).outerWidth();
  2622. total += column.sWidthOrig === null ?
  2623. outerWidth :
  2624. parseInt( column.sWidth, 10 ) + outerWidth - $(headerCells[i]).width();
  2625. }
  2626. tmpTable.width( _fnStringToCss( total ) );
  2627. table.style.width = _fnStringToCss( total );
  2628. }
  2629. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  2630. column = columns[ visibleColumns[i] ];
  2631. width = $(headerCells[i]).width();
  2632. if ( width ) {
  2633. column.sWidth = _fnStringToCss( width );
  2634. }
  2635. }
  2636. table.style.width = _fnStringToCss( tmpTable.css('width') );
  2637. holder.remove();
  2638. }
  2639. if ( tableWidthAttr ) {
  2640. table.style.width = _fnStringToCss( tableWidthAttr );
  2641. }
  2642. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  2643. var bindResize = function () {
  2644. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  2645. _fnAdjustColumnSizing( oSettings );
  2646. } ) );
  2647. };
  2648. if ( ie67 ) {
  2649. setTimeout( bindResize, 1000 );
  2650. }
  2651. else {
  2652. bindResize();
  2653. }
  2654. oSettings._reszEvt = true;
  2655. }
  2656. }
  2657. function _fnThrottle( fn, freq ) {
  2658. var
  2659. frequency = freq !== undefined ? freq : 200,
  2660. last,
  2661. timer;
  2662. return function () {
  2663. var
  2664. that = this,
  2665. now = +new Date(),
  2666. args = arguments;
  2667. if ( last && now < last + frequency ) {
  2668. clearTimeout( timer );
  2669. timer = setTimeout( function () {
  2670. last = undefined;
  2671. fn.apply( that, args );
  2672. }, frequency );
  2673. }
  2674. else {
  2675. last = now;
  2676. fn.apply( that, args );
  2677. }
  2678. };
  2679. }
  2680. function _fnConvertToWidth ( width, parent )
  2681. {
  2682. if ( ! width ) {
  2683. return 0;
  2684. }
  2685. var n = $('<div/>')
  2686. .css( 'width', _fnStringToCss( width ) )
  2687. .appendTo( parent || document.body );
  2688. var val = n[0].offsetWidth;
  2689. n.remove();
  2690. return val;
  2691. }
  2692. function _fnGetWidestNode( settings, colIdx )
  2693. {
  2694. var idx = _fnGetMaxLenString( settings, colIdx );
  2695. if ( idx < 0 ) {
  2696. return null;
  2697. }
  2698. var data = settings.aoData[ idx ];
  2699. return ! data.nTr ?
  2700. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  2701. data.anCells[ colIdx ];
  2702. }
  2703. function _fnGetMaxLenString( settings, colIdx )
  2704. {
  2705. var s, max=-1, maxIdx = -1;
  2706. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  2707. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  2708. s = s.replace( __re_html_remove, '' );
  2709. if ( s.length > max ) {
  2710. max = s.length;
  2711. maxIdx = i;
  2712. }
  2713. }
  2714. return maxIdx;
  2715. }
  2716. function _fnStringToCss( s )
  2717. {
  2718. if ( s === null ) {
  2719. return '0px';
  2720. }
  2721. if ( typeof s == 'number' ) {
  2722. return s < 0 ?
  2723. '0px' :
  2724. s+'px';
  2725. }
  2726. return s.match(/\d$/) ?
  2727. s+'px' :
  2728. s;
  2729. }
  2730. function _fnSortFlatten ( settings )
  2731. {
  2732. var
  2733. i, iLen, k, kLen,
  2734. aSort = [],
  2735. aiOrig = [],
  2736. aoColumns = settings.aoColumns,
  2737. aDataSort, iCol, sType, srcCol,
  2738. fixed = settings.aaSortingFixed,
  2739. fixedObj = $.isPlainObject( fixed ),
  2740. nestedSort = [],
  2741. add = function ( a ) {
  2742. if ( a.length && ! $.isArray( a[0] ) ) {
  2743. nestedSort.push( a );
  2744. }
  2745. else {
  2746. $.merge( nestedSort, a );
  2747. }
  2748. };
  2749. if ( $.isArray( fixed ) ) {
  2750. add( fixed );
  2751. }
  2752. if ( fixedObj && fixed.pre ) {
  2753. add( fixed.pre );
  2754. }
  2755. add( settings.aaSorting );
  2756. if (fixedObj && fixed.post ) {
  2757. add( fixed.post );
  2758. }
  2759. for ( i=0 ; i<nestedSort.length ; i++ )
  2760. {
  2761. srcCol = nestedSort[i][0];
  2762. aDataSort = aoColumns[ srcCol ].aDataSort;
  2763. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  2764. {
  2765. iCol = aDataSort[k];
  2766. sType = aoColumns[ iCol ].sType || 'string';
  2767. if ( nestedSort[i]._idx === undefined ) {
  2768. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  2769. }
  2770. aSort.push( {
  2771. src: srcCol,
  2772. col: iCol,
  2773. dir: nestedSort[i][1],
  2774. index: nestedSort[i]._idx,
  2775. type: sType,
  2776. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  2777. } );
  2778. }
  2779. }
  2780. return aSort;
  2781. }
  2782. function _fnSort ( oSettings )
  2783. {
  2784. var
  2785. i, ien, iLen, j, jLen, k, kLen,
  2786. sDataType, nTh,
  2787. aiOrig = [],
  2788. oExtSort = DataTable.ext.type.order,
  2789. aoData = oSettings.aoData,
  2790. aoColumns = oSettings.aoColumns,
  2791. aDataSort, data, iCol, sType, oSort,
  2792. formatters = 0,
  2793. sortCol,
  2794. displayMaster = oSettings.aiDisplayMaster,
  2795. aSort;
  2796. _fnColumnTypes( oSettings );
  2797. aSort = _fnSortFlatten( oSettings );
  2798. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  2799. sortCol = aSort[i];
  2800. if ( sortCol.formatter ) {
  2801. formatters++;
  2802. }
  2803. _fnSortData( oSettings, sortCol.col );
  2804. }
  2805. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  2806. {
  2807. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  2808. aiOrig[ displayMaster[i] ] = i;
  2809. }
  2810. if ( formatters === aSort.length ) {
  2811. displayMaster.sort( function ( a, b ) {
  2812. var
  2813. x, y, k, test, sort,
  2814. len=aSort.length,
  2815. dataA = aoData[a]._aSortData,
  2816. dataB = aoData[b]._aSortData;
  2817. for ( k=0 ; k<len ; k++ ) {
  2818. sort = aSort[k];
  2819. x = dataA[ sort.col ];
  2820. y = dataB[ sort.col ];
  2821. test = x<y ? -1 : x>y ? 1 : 0;
  2822. if ( test !== 0 ) {
  2823. return sort.dir === 'asc' ? test : -test;
  2824. }
  2825. }
  2826. x = aiOrig[a];
  2827. y = aiOrig[b];
  2828. return x<y ? -1 : x>y ? 1 : 0;
  2829. } );
  2830. }
  2831. else {
  2832. displayMaster.sort( function ( a, b ) {
  2833. var
  2834. x, y, k, l, test, sort, fn,
  2835. len=aSort.length,
  2836. dataA = aoData[a]._aSortData,
  2837. dataB = aoData[b]._aSortData;
  2838. for ( k=0 ; k<len ; k++ ) {
  2839. sort = aSort[k];
  2840. x = dataA[ sort.col ];
  2841. y = dataB[ sort.col ];
  2842. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  2843. test = fn( x, y );
  2844. if ( test !== 0 ) {
  2845. return test;
  2846. }
  2847. }
  2848. x = aiOrig[a];
  2849. y = aiOrig[b];
  2850. return x<y ? -1 : x>y ? 1 : 0;
  2851. } );
  2852. }
  2853. }
  2854. oSettings.bSorted = true;
  2855. }
  2856. function _fnSortAria ( settings )
  2857. {
  2858. var label;
  2859. var nextSort;
  2860. var columns = settings.aoColumns;
  2861. var aSort = _fnSortFlatten( settings );
  2862. var oAria = settings.oLanguage.oAria;
  2863. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  2864. {
  2865. var col = columns[i];
  2866. var asSorting = col.asSorting;
  2867. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  2868. var th = col.nTh;
  2869. th.removeAttribute('aria-sort');
  2870. if ( col.bSortable ) {
  2871. if ( aSort.length > 0 && aSort[0].col == i ) {
  2872. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  2873. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  2874. }
  2875. else {
  2876. nextSort = asSorting[0];
  2877. }
  2878. label = sTitle + ( nextSort === "asc" ?
  2879. oAria.sSortAscending :
  2880. oAria.sSortDescending
  2881. );
  2882. }
  2883. else {
  2884. label = sTitle;
  2885. }
  2886. th.setAttribute('aria-label', label);
  2887. }
  2888. }
  2889. function _fnSortListener ( settings, colIdx, append, callback )
  2890. {
  2891. var col = settings.aoColumns[ colIdx ];
  2892. var sorting = settings.aaSorting;
  2893. var asSorting = col.asSorting;
  2894. var nextSortIdx;
  2895. var next = function ( a, overflow ) {
  2896. var idx = a._idx;
  2897. if ( idx === undefined ) {
  2898. idx = $.inArray( a[1], asSorting );
  2899. }
  2900. return idx+1 < asSorting.length ?
  2901. idx+1 :
  2902. overflow ?
  2903. null :
  2904. 0;
  2905. };
  2906. if ( typeof sorting[0] === 'number' ) {
  2907. sorting = settings.aaSorting = [ sorting ];
  2908. }
  2909. if ( append && settings.oFeatures.bSortMulti ) {
  2910. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  2911. if ( sortIdx !== -1 ) {
  2912. nextSortIdx = next( sorting[sortIdx], true );
  2913. if ( nextSortIdx === null && sorting.length === 1 ) {
  2914. nextSortIdx = 0;
  2915. }
  2916. if ( nextSortIdx === null ) {
  2917. sorting.splice( sortIdx, 1 );
  2918. }
  2919. else {
  2920. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  2921. sorting[sortIdx]._idx = nextSortIdx;
  2922. }
  2923. }
  2924. else {
  2925. sorting.push( [ colIdx, asSorting[0], 0 ] );
  2926. sorting[sorting.length-1]._idx = 0;
  2927. }
  2928. }
  2929. else if ( sorting.length && sorting[0][0] == colIdx ) {
  2930. nextSortIdx = next( sorting[0] );
  2931. sorting.length = 1;
  2932. sorting[0][1] = asSorting[ nextSortIdx ];
  2933. sorting[0]._idx = nextSortIdx;
  2934. }
  2935. else {
  2936. sorting.length = 0;
  2937. sorting.push( [ colIdx, asSorting[0] ] );
  2938. sorting[0]._idx = 0;
  2939. }
  2940. _fnReDraw( settings );
  2941. if ( typeof callback == 'function' ) {
  2942. callback( settings );
  2943. }
  2944. }
  2945. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  2946. {
  2947. var col = settings.aoColumns[ colIdx ];
  2948. _fnBindAction( attachTo, {}, function (e) {
  2949. if ( col.bSortable === false ) {
  2950. return;
  2951. }
  2952. if ( settings.oFeatures.bProcessing ) {
  2953. _fnProcessingDisplay( settings, true );
  2954. setTimeout( function() {
  2955. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  2956. if ( _fnDataSource( settings ) !== 'ssp' ) {
  2957. _fnProcessingDisplay( settings, false );
  2958. }
  2959. }, 0 );
  2960. }
  2961. else {
  2962. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  2963. }
  2964. } );
  2965. }
  2966. function _fnSortingClasses( settings )
  2967. {
  2968. var oldSort = settings.aLastSort;
  2969. var sortClass = settings.oClasses.sSortColumn;
  2970. var sort = _fnSortFlatten( settings );
  2971. var features = settings.oFeatures;
  2972. var i, ien, colIdx;
  2973. if ( features.bSort && features.bSortClasses ) {
  2974. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  2975. colIdx = oldSort[i].src;
  2976. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  2977. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  2978. }
  2979. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  2980. colIdx = sort[i].src;
  2981. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  2982. .addClass( sortClass + (i<2 ? i+1 : 3) );
  2983. }
  2984. }
  2985. settings.aLastSort = sort;
  2986. }
  2987. function _fnSortData( settings, idx )
  2988. {
  2989. var column = settings.aoColumns[ idx ];
  2990. var customSort = DataTable.ext.order[ column.sSortDataType ];
  2991. var customData;
  2992. if ( customSort ) {
  2993. customData = customSort.call( settings.oInstance, settings, idx,
  2994. _fnColumnIndexToVisible( settings, idx )
  2995. );
  2996. }
  2997. var row, cellData;
  2998. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  2999. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3000. row = settings.aoData[i];
  3001. if ( ! row._aSortData ) {
  3002. row._aSortData = [];
  3003. }
  3004. if ( ! row._aSortData[idx] || customSort ) {
  3005. cellData = customSort ?
  3006. customData[i] :
  3007. _fnGetCellData( settings, i, idx, 'sort' );
  3008. row._aSortData[ idx ] = formatter ?
  3009. formatter( cellData ) :
  3010. cellData;
  3011. }
  3012. }
  3013. }
  3014. function _fnSaveState ( settings )
  3015. {
  3016. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  3017. {
  3018. return;
  3019. }
  3020. var state = {
  3021. time: +new Date(),
  3022. start: settings._iDisplayStart,
  3023. length: settings._iDisplayLength,
  3024. order: $.extend( true, [], settings.aaSorting ),
  3025. search: _fnSearchToCamel( settings.oPreviousSearch ),
  3026. columns: $.map( settings.aoColumns, function ( col, i ) {
  3027. return {
  3028. visible: col.bVisible,
  3029. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  3030. };
  3031. } )
  3032. };
  3033. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  3034. settings.oSavedState = state;
  3035. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  3036. }
  3037. function _fnLoadState ( settings, oInit )
  3038. {
  3039. var i, ien;
  3040. var columns = settings.aoColumns;
  3041. if ( ! settings.oFeatures.bStateSave ) {
  3042. return;
  3043. }
  3044. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings );
  3045. if ( ! state || ! state.time ) {
  3046. return;
  3047. }
  3048. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state] );
  3049. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  3050. return;
  3051. }
  3052. var duration = settings.iStateDuration;
  3053. if ( duration > 0 && state.time < +new Date() - (duration*1000) ) {
  3054. return;
  3055. }
  3056. if ( columns.length !== state.columns.length ) {
  3057. return;
  3058. }
  3059. settings.oLoadedState = $.extend( true, {}, state );
  3060. if ( state.start !== undefined ) {
  3061. settings._iDisplayStart = state.start;
  3062. settings.iInitDisplayStart = state.start;
  3063. }
  3064. if ( state.length !== undefined ) {
  3065. settings._iDisplayLength = state.length;
  3066. }
  3067. if ( state.order !== undefined ) {
  3068. settings.aaSorting = [];
  3069. $.each( state.order, function ( i, col ) {
  3070. settings.aaSorting.push( col[0] >= columns.length ?
  3071. [ 0, col[1] ] :
  3072. col
  3073. );
  3074. } );
  3075. }
  3076. if ( state.search !== undefined ) {
  3077. $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) );
  3078. }
  3079. for ( i=0, ien=state.columns.length ; i<ien ; i++ ) {
  3080. var col = state.columns[i];
  3081. if ( col.visible !== undefined ) {
  3082. columns[i].bVisible = col.visible;
  3083. }
  3084. if ( col.search !== undefined ) {
  3085. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  3086. }
  3087. }
  3088. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, state] );
  3089. }
  3090. function _fnSettingsFromNode ( table )
  3091. {
  3092. var settings = DataTable.settings;
  3093. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  3094. return idx !== -1 ?
  3095. settings[ idx ] :
  3096. null;
  3097. }
  3098. function _fnLog( settings, level, msg, tn )
  3099. {
  3100. msg = 'DataTables warning: '+
  3101. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  3102. if ( tn ) {
  3103. msg += '. For more information about this error, please see '+tn;
  3104. }
  3105. if ( ! level ) {
  3106. var ext = DataTable.ext;
  3107. var type = ext.sErrMode || ext.errMode;
  3108. if ( settings ) {
  3109. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  3110. }
  3111. if ( type == 'alert' ) {
  3112. //alert( msg );
  3113. }
  3114. else if ( type == 'throw' ) {
  3115. throw new Error(msg);
  3116. }
  3117. else if ( typeof type == 'function' ) {
  3118. type( settings, tn, msg );
  3119. }
  3120. }
  3121. else if ( window.console && console.log ) {
  3122. console.log( msg );
  3123. }
  3124. }
  3125. function _fnMap( ret, src, name, mappedName )
  3126. {
  3127. if ( $.isArray( name ) ) {
  3128. $.each( name, function (i, val) {
  3129. if ( $.isArray( val ) ) {
  3130. _fnMap( ret, src, val[0], val[1] );
  3131. }
  3132. else {
  3133. _fnMap( ret, src, val );
  3134. }
  3135. } );
  3136. return;
  3137. }
  3138. if ( mappedName === undefined ) {
  3139. mappedName = name;
  3140. }
  3141. if ( src[name] !== undefined ) {
  3142. ret[mappedName] = src[name];
  3143. }
  3144. }
  3145. function _fnExtend( out, extender, breakRefs )
  3146. {
  3147. var val;
  3148. for ( var prop in extender ) {
  3149. if ( extender.hasOwnProperty(prop) ) {
  3150. val = extender[prop];
  3151. if ( $.isPlainObject( val ) ) {
  3152. if ( ! $.isPlainObject( out[prop] ) ) {
  3153. out[prop] = {};
  3154. }
  3155. $.extend( true, out[prop], val );
  3156. }
  3157. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  3158. out[prop] = val.slice();
  3159. }
  3160. else {
  3161. out[prop] = val;
  3162. }
  3163. }
  3164. }
  3165. return out;
  3166. }
  3167. function _fnBindAction( n, oData, fn )
  3168. {
  3169. $(n)
  3170. .bind( 'click.DT', oData, function (e) {
  3171. n.blur();
  3172. fn(e);
  3173. } )
  3174. .bind( 'keypress.DT', oData, function (e){
  3175. if ( e.which === 13 ) {
  3176. e.preventDefault();
  3177. fn(e);
  3178. }
  3179. } )
  3180. .bind( 'selectstart.DT', function () {
  3181. return false;
  3182. } );
  3183. }
  3184. function _fnCallbackReg( oSettings, sStore, fn, sName )
  3185. {
  3186. if ( fn )
  3187. {
  3188. oSettings[sStore].push( {
  3189. "fn": fn,
  3190. "sName": sName
  3191. } );
  3192. }
  3193. }
  3194. function _fnCallbackFire( settings, callbackArr, eventName, args )
  3195. {
  3196. var ret = [];
  3197. if ( callbackArr ) {
  3198. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  3199. return val.fn.apply( settings.oInstance, args );
  3200. } );
  3201. }
  3202. if ( eventName !== null ) {
  3203. var e = $.Event( eventName+'.dt' );
  3204. $(settings.nTable).trigger( e, args );
  3205. ret.push( e.result );
  3206. }
  3207. return ret;
  3208. }
  3209. function _fnLengthOverflow ( settings )
  3210. {
  3211. var
  3212. start = settings._iDisplayStart,
  3213. end = settings.fnDisplayEnd(),
  3214. len = settings._iDisplayLength;
  3215. if ( start >= end )
  3216. {
  3217. start = end - len;
  3218. }
  3219. start -= (start % len);
  3220. if ( len === -1 || start < 0 )
  3221. {
  3222. start = 0;
  3223. }
  3224. settings._iDisplayStart = start;
  3225. }
  3226. function _fnRenderer( settings, type )
  3227. {
  3228. var renderer = settings.renderer;
  3229. var host = DataTable.ext.renderer[type];
  3230. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  3231. return host[renderer[type]] || host._;
  3232. }
  3233. else if ( typeof renderer === 'string' ) {
  3234. return host[renderer] || host._;
  3235. }
  3236. return host._;
  3237. }
  3238. function _fnDataSource ( settings )
  3239. {
  3240. if ( settings.oFeatures.bServerSide ) {
  3241. return 'ssp';
  3242. }
  3243. else if ( settings.ajax || settings.sAjaxSource ) {
  3244. return 'ajax';
  3245. }
  3246. return 'dom';
  3247. }
  3248. DataTable = function( options )
  3249. {
  3250. this.$ = function ( sSelector, oOpts )
  3251. {
  3252. return this.api(true).$( sSelector, oOpts );
  3253. };
  3254. this._ = function ( sSelector, oOpts )
  3255. {
  3256. return this.api(true).rows( sSelector, oOpts ).data();
  3257. };
  3258. this.api = function ( traditional )
  3259. {
  3260. return traditional ?
  3261. new _Api(
  3262. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  3263. ) :
  3264. new _Api( this );
  3265. };
  3266. this.fnAddData = function( data, redraw )
  3267. {
  3268. var api = this.api( true );
  3269. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  3270. api.rows.add( data ) :
  3271. api.row.add( data );
  3272. if ( redraw === undefined || redraw ) {
  3273. api.draw();
  3274. }
  3275. return rows.flatten().toArray();
  3276. };
  3277. this.fnAdjustColumnSizing = function ( bRedraw )
  3278. {
  3279. var api = this.api( true ).columns.adjust();
  3280. var settings = api.settings()[0];
  3281. var scroll = settings.oScroll;
  3282. if ( bRedraw === undefined || bRedraw ) {
  3283. api.draw( false );
  3284. }
  3285. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  3286. _fnScrollDraw( settings );
  3287. }
  3288. };
  3289. this.fnClearTable = function( bRedraw )
  3290. {
  3291. var api = this.api( true ).clear();
  3292. if ( bRedraw === undefined || bRedraw ) {
  3293. api.draw();
  3294. }
  3295. };
  3296. this.fnClose = function( nTr )
  3297. {
  3298. this.api( true ).row( nTr ).child.hide();
  3299. };
  3300. this.fnDeleteRow = function( target, callback, redraw )
  3301. {
  3302. var api = this.api( true );
  3303. var rows = api.rows( target );
  3304. var settings = rows.settings()[0];
  3305. var data = settings.aoData[ rows[0][0] ];
  3306. rows.remove();
  3307. if ( callback ) {
  3308. callback.call( this, settings, data );
  3309. }
  3310. if ( redraw === undefined || redraw ) {
  3311. api.draw();
  3312. }
  3313. return data;
  3314. };
  3315. this.fnDestroy = function ( remove )
  3316. {
  3317. this.api( true ).destroy( remove );
  3318. };
  3319. this.fnDraw = function( complete )
  3320. {
  3321. this.api( true ).draw( complete );
  3322. };
  3323. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  3324. {
  3325. var api = this.api( true );
  3326. if ( iColumn === null || iColumn === undefined ) {
  3327. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  3328. }
  3329. else {
  3330. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  3331. }
  3332. api.draw();
  3333. };
  3334. this.fnGetData = function( src, col )
  3335. {
  3336. var api = this.api( true );
  3337. if ( src !== undefined ) {
  3338. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  3339. return col !== undefined || type == 'td' || type == 'th' ?
  3340. api.cell( src, col ).data() :
  3341. api.row( src ).data() || null;
  3342. }
  3343. return api.data().toArray();
  3344. };
  3345. this.fnGetNodes = function( iRow )
  3346. {
  3347. var api = this.api( true );
  3348. return iRow !== undefined ?
  3349. api.row( iRow ).node() :
  3350. api.rows().nodes().flatten().toArray();
  3351. };
  3352. this.fnGetPosition = function( node )
  3353. {
  3354. var api = this.api( true );
  3355. var nodeName = node.nodeName.toUpperCase();
  3356. if ( nodeName == 'TR' ) {
  3357. return api.row( node ).index();
  3358. }
  3359. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  3360. var cell = api.cell( node ).index();
  3361. return [
  3362. cell.row,
  3363. cell.columnVisible,
  3364. cell.column
  3365. ];
  3366. }
  3367. return null;
  3368. };
  3369. this.fnIsOpen = function( nTr )
  3370. {
  3371. return this.api( true ).row( nTr ).child.isShown();
  3372. };
  3373. this.fnOpen = function( nTr, mHtml, sClass )
  3374. {
  3375. return this.api( true )
  3376. .row( nTr )
  3377. .child( mHtml, sClass )
  3378. .show()
  3379. .child()[0];
  3380. };
  3381. this.fnPageChange = function ( mAction, bRedraw )
  3382. {
  3383. var api = this.api( true ).page( mAction );
  3384. if ( bRedraw === undefined || bRedraw ) {
  3385. api.draw(false);
  3386. }
  3387. };
  3388. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  3389. {
  3390. var api = this.api( true ).column( iCol ).visible( bShow );
  3391. if ( bRedraw === undefined || bRedraw ) {
  3392. api.columns.adjust().draw();
  3393. }
  3394. };
  3395. this.fnSettings = function()
  3396. {
  3397. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  3398. };
  3399. this.fnSort = function( aaSort )
  3400. {
  3401. this.api( true ).order( aaSort ).draw();
  3402. };
  3403. this.fnSortListener = function( nNode, iColumn, fnCallback )
  3404. {
  3405. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  3406. };
  3407. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  3408. {
  3409. var api = this.api( true );
  3410. if ( iColumn === undefined || iColumn === null ) {
  3411. api.row( mRow ).data( mData );
  3412. }
  3413. else {
  3414. api.cell( mRow, iColumn ).data( mData );
  3415. }
  3416. if ( bAction === undefined || bAction ) {
  3417. api.columns.adjust();
  3418. }
  3419. if ( bRedraw === undefined || bRedraw ) {
  3420. api.draw();
  3421. }
  3422. return 0;
  3423. };
  3424. this.fnVersionCheck = _ext.fnVersionCheck;
  3425. var _that = this;
  3426. var emptyInit = options === undefined;
  3427. var len = this.length;
  3428. if ( emptyInit ) {
  3429. options = {};
  3430. }
  3431. this.oApi = this.internal = _ext.internal;
  3432. for ( var fn in DataTable.ext.internal ) {
  3433. if ( fn ) {
  3434. this[fn] = _fnExternApiFunc(fn);
  3435. }
  3436. }
  3437. this.each(function() {
  3438. var o = {};
  3439. var oInit = len > 1 ?
  3440. _fnExtend( o, options, true ) :
  3441. options;
  3442. var i=0, iLen, j, jLen, k, kLen;
  3443. var sId = this.getAttribute( 'id' );
  3444. var bInitHandedOff = false;
  3445. var defaults = DataTable.defaults;
  3446. var $this = $(this);
  3447. if ( this.nodeName.toLowerCase() != 'table' )
  3448. {
  3449. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  3450. return;
  3451. }
  3452. _fnCompatOpts( defaults );
  3453. _fnCompatCols( defaults.column );
  3454. _fnCamelToHungarian( defaults, defaults, true );
  3455. _fnCamelToHungarian( defaults.column, defaults.column, true );
  3456. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ) );
  3457. var allSettings = DataTable.settings;
  3458. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  3459. {
  3460. var s = allSettings[i];
  3461. if ( s.nTable == this || s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this) )
  3462. {
  3463. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  3464. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  3465. if ( emptyInit || bRetrieve )
  3466. {
  3467. return s.oInstance;
  3468. }
  3469. else if ( bDestroy )
  3470. {
  3471. s.oInstance.fnDestroy();
  3472. break;
  3473. }
  3474. else
  3475. {
  3476. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  3477. return;
  3478. }
  3479. }
  3480. if ( s.sTableId == this.id )
  3481. {
  3482. allSettings.splice( i, 1 );
  3483. break;
  3484. }
  3485. }
  3486. if ( sId === null || sId === "" )
  3487. {
  3488. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  3489. this.id = sId;
  3490. }
  3491. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  3492. "sDestroyWidth": $this[0].style.width,
  3493. "sInstance": sId,
  3494. "sTableId": sId
  3495. } );
  3496. oSettings.nTable = this;
  3497. oSettings.oApi = _that.internal;
  3498. oSettings.oInit = oInit;
  3499. allSettings.push( oSettings );
  3500. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  3501. _fnCompatOpts( oInit );
  3502. if ( oInit.oLanguage )
  3503. {
  3504. _fnLanguageCompat( oInit.oLanguage );
  3505. }
  3506. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  3507. {
  3508. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  3509. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  3510. }
  3511. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  3512. _fnMap( oSettings.oFeatures, oInit, [
  3513. "bPaginate",
  3514. "bLengthChange",
  3515. "bFilter",
  3516. "bSort",
  3517. "bSortMulti",
  3518. "bInfo",
  3519. "bProcessing",
  3520. "bAutoWidth",
  3521. "bSortClasses",
  3522. "bServerSide",
  3523. "bDeferRender"
  3524. ] );
  3525. _fnMap( oSettings, oInit, [
  3526. "asStripeClasses",
  3527. "ajax",
  3528. "fnServerData",
  3529. "fnFormatNumber",
  3530. "sServerMethod",
  3531. "aaSorting",
  3532. "aaSortingFixed",
  3533. "aLengthMenu",
  3534. "sPaginationType",
  3535. "sAjaxSource",
  3536. "sAjaxDataProp",
  3537. "iStateDuration",
  3538. "sDom",
  3539. "bSortCellsTop",
  3540. "iTabIndex",
  3541. "fnStateLoadCallback",
  3542. "fnStateSaveCallback",
  3543. "renderer",
  3544. "searchDelay",
  3545. "rowId",
  3546. [ "iCookieDuration", "iStateDuration" ],
  3547. [ "oSearch", "oPreviousSearch" ],
  3548. [ "aoSearchCols", "aoPreSearchCols" ],
  3549. [ "iDisplayLength", "_iDisplayLength" ],
  3550. [ "bJQueryUI", "bJUI" ]
  3551. ] );
  3552. _fnMap( oSettings.oScroll, oInit, [
  3553. [ "sScrollX", "sX" ],
  3554. [ "sScrollXInner", "sXInner" ],
  3555. [ "sScrollY", "sY" ],
  3556. [ "bScrollCollapse", "bCollapse" ]
  3557. ] );
  3558. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  3559. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  3560. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  3561. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  3562. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  3563. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  3564. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  3565. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  3566. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  3567. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  3568. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  3569. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  3570. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  3571. _fnBrowserDetect( oSettings );
  3572. var oClasses = oSettings.oClasses;
  3573. if ( oInit.bJQueryUI )
  3574. {
  3575. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  3576. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  3577. {
  3578. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  3579. }
  3580. if ( ! oSettings.renderer ) {
  3581. oSettings.renderer = 'jqueryui';
  3582. }
  3583. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  3584. oSettings.renderer.header = 'jqueryui';
  3585. }
  3586. }
  3587. else
  3588. {
  3589. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  3590. }
  3591. $this.addClass( oClasses.sTable );
  3592. if ( oSettings.iInitDisplayStart === undefined )
  3593. {
  3594. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  3595. oSettings._iDisplayStart = oInit.iDisplayStart;
  3596. }
  3597. if ( oInit.iDeferLoading !== null )
  3598. {
  3599. oSettings.bDeferLoading = true;
  3600. var tmp = $.isArray( oInit.iDeferLoading );
  3601. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  3602. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  3603. }
  3604. var oLanguage = oSettings.oLanguage;
  3605. $.extend( true, oLanguage, oInit.oLanguage );
  3606. if ( oLanguage.sUrl !== "" )
  3607. {
  3608. $.ajax( {
  3609. dataType: 'json',
  3610. url: oLanguage.sUrl,
  3611. success: function ( json ) {
  3612. _fnLanguageCompat( json );
  3613. _fnCamelToHungarian( defaults.oLanguage, json );
  3614. $.extend( true, oLanguage, json );
  3615. _fnInitialise( oSettings );
  3616. },
  3617. error: function () {
  3618. _fnInitialise( oSettings );
  3619. }
  3620. } );
  3621. bInitHandedOff = true;
  3622. }
  3623. if ( oInit.asStripeClasses === null )
  3624. {
  3625. oSettings.asStripeClasses =[
  3626. oClasses.sStripeOdd,
  3627. oClasses.sStripeEven
  3628. ];
  3629. }
  3630. var stripeClasses = oSettings.asStripeClasses;
  3631. var rowOne = $this.children('tbody').find('tr').eq(0);
  3632. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  3633. return rowOne.hasClass(el);
  3634. } ) ) !== -1 ) {
  3635. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  3636. oSettings.asDestroyStripes = stripeClasses.slice();
  3637. }
  3638. var anThs = [];
  3639. var aoColumnsInit;
  3640. var nThead = this.getElementsByTagName('thead');
  3641. if ( nThead.length !== 0 )
  3642. {
  3643. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  3644. anThs = _fnGetUniqueThs( oSettings );
  3645. }
  3646. if ( oInit.aoColumns === null )
  3647. {
  3648. aoColumnsInit = [];
  3649. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  3650. {
  3651. aoColumnsInit.push( null );
  3652. }
  3653. }
  3654. else
  3655. {
  3656. aoColumnsInit = oInit.aoColumns;
  3657. }
  3658. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  3659. {
  3660. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  3661. }
  3662. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  3663. _fnColumnOptions( oSettings, iCol, oDef );
  3664. } );
  3665. if ( rowOne.length ) {
  3666. var a = function ( cell, name ) {
  3667. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  3668. };
  3669. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  3670. var col = oSettings.aoColumns[i];
  3671. if ( col.mData === i ) {
  3672. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  3673. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  3674. if ( sort !== null || filter !== null ) {
  3675. col.mData = {
  3676. _: i+'.display',
  3677. sort: sort !== null ? i+'.@data-'+sort : undefined,
  3678. type: sort !== null ? i+'.@data-'+sort : undefined,
  3679. filter: filter !== null ? i+'.@data-'+filter : undefined
  3680. };
  3681. _fnColumnOptions( oSettings, i );
  3682. }
  3683. }
  3684. } );
  3685. }
  3686. var features = oSettings.oFeatures;
  3687. if ( oInit.bStateSave )
  3688. {
  3689. features.bStateSave = true;
  3690. _fnLoadState( oSettings, oInit );
  3691. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  3692. }
  3693. if ( oInit.aaSorting === undefined )
  3694. {
  3695. var sorting = oSettings.aaSorting;
  3696. for ( i=0, iLen=sorting.length ; i<iLen ; i++ )
  3697. {
  3698. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  3699. }
  3700. }
  3701. _fnSortingClasses( oSettings );
  3702. if ( features.bSort )
  3703. {
  3704. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  3705. if ( oSettings.bSorted ) {
  3706. var aSort = _fnSortFlatten( oSettings );
  3707. var sortedColumns = {};
  3708. $.each( aSort, function (i, val) {
  3709. sortedColumns[ val.src ] = val.dir;
  3710. } );
  3711. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  3712. _fnSortAria( oSettings );
  3713. }
  3714. } );
  3715. }
  3716. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  3717. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  3718. _fnSortingClasses( oSettings );
  3719. }
  3720. }, 'sc' );
  3721. var captions = $this.children('caption').each( function () {
  3722. this._captionSide = $this.css('caption-side');
  3723. } );
  3724. var thead = $this.children('thead');
  3725. if ( thead.length === 0 )
  3726. {
  3727. thead = $('<thead/>').appendTo(this);
  3728. }
  3729. oSettings.nTHead = thead[0];
  3730. var tbody = $this.children('tbody');
  3731. if ( tbody.length === 0 )
  3732. {
  3733. tbody = $('<tbody/>').appendTo(this);
  3734. }
  3735. oSettings.nTBody = tbody[0];
  3736. var tfoot = $this.children('tfoot');
  3737. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  3738. {
  3739. tfoot = $('<tfoot/>').appendTo(this);
  3740. }
  3741. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  3742. $this.addClass( oClasses.sNoFooter );
  3743. }
  3744. else if ( tfoot.length > 0 ) {
  3745. oSettings.nTFoot = tfoot[0];
  3746. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  3747. }
  3748. if ( oInit.aaData )
  3749. {
  3750. for ( i=0 ; i<oInit.aaData.length ; i++ )
  3751. {
  3752. _fnAddData( oSettings, oInit.aaData[ i ] );
  3753. }
  3754. }
  3755. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  3756. {
  3757. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  3758. }
  3759. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  3760. oSettings.bInitialised = true;
  3761. if ( bInitHandedOff === false )
  3762. {
  3763. _fnInitialise( oSettings );
  3764. }
  3765. } );
  3766. _that = null;
  3767. return this;
  3768. };
  3769. var __apiStruct = [];
  3770. var __arrayProto = Array.prototype;
  3771. var _toSettings = function ( mixed )
  3772. {
  3773. var idx, jq;
  3774. var settings = DataTable.settings;
  3775. var tables = $.map( settings, function (el, i) {
  3776. return el.nTable;
  3777. } );
  3778. if ( ! mixed ) {
  3779. return [];
  3780. }
  3781. else if ( mixed.nTable && mixed.oApi ) {
  3782. return [ mixed ];
  3783. }
  3784. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  3785. idx = $.inArray( mixed, tables );
  3786. return idx !== -1 ? [ settings[idx] ] : null;
  3787. }
  3788. else if ( mixed && typeof mixed.settings === 'function' ) {
  3789. return mixed.settings().toArray();
  3790. }
  3791. else if ( typeof mixed === 'string' ) {
  3792. jq = $(mixed);
  3793. }
  3794. else if ( mixed instanceof $ ) {
  3795. jq = mixed;
  3796. }
  3797. if ( jq ) {
  3798. return jq.map( function(i) {
  3799. idx = $.inArray( this, tables );
  3800. return idx !== -1 ? settings[idx] : null;
  3801. } ).toArray();
  3802. }
  3803. };
  3804. _Api = function ( context, data )
  3805. {
  3806. if ( ! (this instanceof _Api) ) {
  3807. return new _Api( context, data );
  3808. }
  3809. var settings = [];
  3810. var ctxSettings = function ( o ) {
  3811. var a = _toSettings( o );
  3812. if ( a ) {
  3813. settings = settings.concat( a );
  3814. }
  3815. };
  3816. if ( $.isArray( context ) ) {
  3817. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  3818. ctxSettings( context[i] );
  3819. }
  3820. }
  3821. else {
  3822. ctxSettings( context );
  3823. }
  3824. this.context = _unique( settings );
  3825. if ( data ) {
  3826. $.merge( this, data );
  3827. }
  3828. this.selector = {
  3829. rows: null,
  3830. cols: null,
  3831. opts: null
  3832. };
  3833. _Api.extend( this, this, __apiStruct );
  3834. };
  3835. DataTable.Api = _Api;
  3836. $.extend( _Api.prototype, {
  3837. any: function ()
  3838. {
  3839. return this.count() !== 0;
  3840. },
  3841. concat: __arrayProto.concat,
  3842. context: [],
  3843. count: function ()
  3844. {
  3845. return this.flatten().length;
  3846. },
  3847. each: function ( fn )
  3848. {
  3849. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  3850. fn.call( this, this[i], i, this );
  3851. }
  3852. return this;
  3853. },
  3854. eq: function ( idx )
  3855. {
  3856. var ctx = this.context;
  3857. return ctx.length > idx ?
  3858. new _Api( ctx[idx], this[idx] ) :
  3859. null;
  3860. },
  3861. filter: function ( fn )
  3862. {
  3863. var a = [];
  3864. if ( __arrayProto.filter ) {
  3865. a = __arrayProto.filter.call( this, fn, this );
  3866. }
  3867. else {
  3868. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  3869. if ( fn.call( this, this[i], i, this ) ) {
  3870. a.push( this[i] );
  3871. }
  3872. }
  3873. }
  3874. return new _Api( this.context, a );
  3875. },
  3876. flatten: function ()
  3877. {
  3878. var a = [];
  3879. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  3880. },
  3881. join: __arrayProto.join,
  3882. indexOf: __arrayProto.indexOf || function (obj, start)
  3883. {
  3884. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  3885. if ( this[i] === obj ) {
  3886. return i;
  3887. }
  3888. }
  3889. return -1;
  3890. },
  3891. iterator: function ( flatten, type, fn, alwaysNew ) {
  3892. var
  3893. a = [], ret,
  3894. i, ien, j, jen,
  3895. context = this.context,
  3896. rows, items, item,
  3897. selector = this.selector;
  3898. if ( typeof flatten === 'string' ) {
  3899. alwaysNew = fn;
  3900. fn = type;
  3901. type = flatten;
  3902. flatten = false;
  3903. }
  3904. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  3905. var apiInst = new _Api( context[i] );
  3906. if ( type === 'table' ) {
  3907. ret = fn.call( apiInst, context[i], i );
  3908. if ( ret !== undefined ) {
  3909. a.push( ret );
  3910. }
  3911. }
  3912. else if ( type === 'columns' || type === 'rows' ) {
  3913. ret = fn.call( apiInst, context[i], this[i], i );
  3914. if ( ret !== undefined ) {
  3915. a.push( ret );
  3916. }
  3917. }
  3918. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  3919. items = this[i];
  3920. if ( type === 'column-rows' ) {
  3921. rows = _selector_row_indexes( context[i], selector.opts );
  3922. }
  3923. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  3924. item = items[j];
  3925. if ( type === 'cell' ) {
  3926. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  3927. }
  3928. else {
  3929. ret = fn.call( apiInst, context[i], item, i, j, rows );
  3930. }
  3931. if ( ret !== undefined ) {
  3932. a.push( ret );
  3933. }
  3934. }
  3935. }
  3936. }
  3937. if ( a.length || alwaysNew ) {
  3938. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  3939. var apiSelector = api.selector;
  3940. apiSelector.rows = selector.rows;
  3941. apiSelector.cols = selector.cols;
  3942. apiSelector.opts = selector.opts;
  3943. return api;
  3944. }
  3945. return this;
  3946. },
  3947. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  3948. {
  3949. return this.indexOf.apply( this.toArray.reverse(), arguments );
  3950. },
  3951. length: 0,
  3952. map: function ( fn )
  3953. {
  3954. var a = [];
  3955. if ( __arrayProto.map ) {
  3956. a = __arrayProto.map.call( this, fn, this );
  3957. }
  3958. else {
  3959. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  3960. a.push( fn.call( this, this[i], i ) );
  3961. }
  3962. }
  3963. return new _Api( this.context, a );
  3964. },
  3965. pluck: function ( prop )
  3966. {
  3967. return this.map( function ( el ) {
  3968. return el[ prop ];
  3969. } );
  3970. },
  3971. pop: __arrayProto.pop,
  3972. push: __arrayProto.push,
  3973. reduce: __arrayProto.reduce || function ( fn, init )
  3974. {
  3975. return _fnReduce( this, fn, init, 0, this.length, 1 );
  3976. },
  3977. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  3978. {
  3979. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  3980. },
  3981. reverse: __arrayProto.reverse,
  3982. selector: null,
  3983. shift: __arrayProto.shift,
  3984. sort: __arrayProto.sort,
  3985. splice: __arrayProto.splice,
  3986. toArray: function ()
  3987. {
  3988. return __arrayProto.slice.call( this );
  3989. },
  3990. to$: function ()
  3991. {
  3992. return $( this );
  3993. },
  3994. toJQuery: function ()
  3995. {
  3996. return $( this );
  3997. },
  3998. unique: function ()
  3999. {
  4000. return new _Api( this.context, _unique(this) );
  4001. },
  4002. unshift: __arrayProto.unshift
  4003. } );
  4004. _Api.extend = function ( scope, obj, ext )
  4005. {
  4006. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  4007. return;
  4008. }
  4009. var
  4010. i, ien,
  4011. j, jen,
  4012. struct, inner,
  4013. methodScoping = function ( scope, fn, struc ) {
  4014. return function () {
  4015. var ret = fn.apply( scope, arguments );
  4016. _Api.extend( ret, ret, struc.methodExt );
  4017. return ret;
  4018. };
  4019. };
  4020. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  4021. struct = ext[i];
  4022. obj[ struct.name ] = typeof struct.val === 'function' ?
  4023. methodScoping( scope, struct.val, struct ) :
  4024. $.isPlainObject( struct.val ) ?
  4025. {} :
  4026. struct.val;
  4027. obj[ struct.name ].__dt_wrapper = true;
  4028. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  4029. }
  4030. };
  4031. _Api.register = _api_register = function ( name, val )
  4032. {
  4033. if ( $.isArray( name ) ) {
  4034. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  4035. _Api.register( name[j], val );
  4036. }
  4037. return;
  4038. }
  4039. var
  4040. i, ien,
  4041. heir = name.split('.'),
  4042. struct = __apiStruct,
  4043. key, method;
  4044. var find = function ( src, name ) {
  4045. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  4046. if ( src[i].name === name ) {
  4047. return src[i];
  4048. }
  4049. }
  4050. return null;
  4051. };
  4052. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  4053. method = heir[i].indexOf('()') !== -1;
  4054. key = method ?
  4055. heir[i].replace('()', '') :
  4056. heir[i];
  4057. var src = find( struct, key );
  4058. if ( ! src ) {
  4059. src = {
  4060. name: key,
  4061. val: {},
  4062. methodExt: [],
  4063. propExt: []
  4064. };
  4065. struct.push( src );
  4066. }
  4067. if ( i === ien-1 ) {
  4068. src.val = val;
  4069. }
  4070. else {
  4071. struct = method ?
  4072. src.methodExt :
  4073. src.propExt;
  4074. }
  4075. }
  4076. };
  4077. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  4078. _Api.register( pluralName, val );
  4079. _Api.register( singularName, function () {
  4080. var ret = val.apply( this, arguments );
  4081. if ( ret === this ) {
  4082. return this;
  4083. }
  4084. else if ( ret instanceof _Api ) {
  4085. return ret.length ?
  4086. $.isArray( ret[0] ) ?
  4087. new _Api( ret.context, ret[0] ) :
  4088. ret[0] :
  4089. undefined;
  4090. }
  4091. return ret;
  4092. } );
  4093. };
  4094. var __table_selector = function ( selector, a )
  4095. {
  4096. if ( typeof selector === 'number' ) {
  4097. return [ a[ selector ] ];
  4098. }
  4099. var nodes = $.map( a, function (el, i) {
  4100. return el.nTable;
  4101. } );
  4102. return $(nodes)
  4103. .filter( selector )
  4104. .map( function (i) {
  4105. var idx = $.inArray( this, nodes );
  4106. return a[ idx ];
  4107. } )
  4108. .toArray();
  4109. };
  4110. _api_register( 'tables()', function ( selector ) {
  4111. return selector ?
  4112. new _Api( __table_selector( selector, this.context ) ) :
  4113. this;
  4114. } );
  4115. _api_register( 'table()', function ( selector ) {
  4116. var tables = this.tables( selector );
  4117. var ctx = tables.context;
  4118. return ctx.length ?
  4119. new _Api( ctx[0] ) :
  4120. tables;
  4121. } );
  4122. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  4123. return this.iterator( 'table', function ( ctx ) {
  4124. return ctx.nTable;
  4125. }, 1 );
  4126. } );
  4127. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  4128. return this.iterator( 'table', function ( ctx ) {
  4129. return ctx.nTBody;
  4130. }, 1 );
  4131. } );
  4132. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  4133. return this.iterator( 'table', function ( ctx ) {
  4134. return ctx.nTHead;
  4135. }, 1 );
  4136. } );
  4137. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  4138. return this.iterator( 'table', function ( ctx ) {
  4139. return ctx.nTFoot;
  4140. }, 1 );
  4141. } );
  4142. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  4143. return this.iterator( 'table', function ( ctx ) {
  4144. return ctx.nTableWrapper;
  4145. }, 1 );
  4146. } );
  4147. _api_register( 'draw()', function ( paging ) {
  4148. return this.iterator( 'table', function ( settings ) {
  4149. if ( paging === 'page' ) {
  4150. _fnDraw( settings );
  4151. }
  4152. else {
  4153. if ( typeof paging === 'string' ) {
  4154. paging = paging === 'full-hold' ?
  4155. false :
  4156. true;
  4157. }
  4158. _fnReDraw( settings, paging===false );
  4159. }
  4160. } );
  4161. } );
  4162. _api_register( 'page()', function ( action ) {
  4163. if ( action === undefined ) {
  4164. return this.page.info().page;
  4165. }
  4166. return this.iterator( 'table', function ( settings ) {
  4167. _fnPageChange( settings, action );
  4168. } );
  4169. } );
  4170. _api_register( 'page.info()', function ( action ) {
  4171. if ( this.context.length === 0 ) {
  4172. return undefined;
  4173. }
  4174. var
  4175. settings = this.context[0],
  4176. start = settings._iDisplayStart,
  4177. len = settings._iDisplayLength,
  4178. visRecords = settings.fnRecordsDisplay(),
  4179. all = len === -1;
  4180. return {
  4181. "page": all ? 0 : Math.floor( start / len ),
  4182. "pages": all ? 1 : Math.ceil( visRecords / len ),
  4183. "start": start,
  4184. "end": settings.fnDisplayEnd(),
  4185. "length": len,
  4186. "recordsTotal": settings.fnRecordsTotal(),
  4187. "recordsDisplay": visRecords,
  4188. "serverSide": _fnDataSource( settings ) === 'ssp'
  4189. };
  4190. } );
  4191. _api_register( 'page.len()', function ( len ) {
  4192. if ( len === undefined ) {
  4193. return this.context.length !== 0 ?
  4194. this.context[0]._iDisplayLength :
  4195. undefined;
  4196. }
  4197. return this.iterator( 'table', function ( settings ) {
  4198. _fnLengthChange( settings, len );
  4199. } );
  4200. } );
  4201. var __reload = function ( settings, holdPosition, callback ) {
  4202. if ( callback ) {
  4203. var api = new _Api( settings );
  4204. api.one( 'draw', function () {
  4205. callback( api.ajax.json() );
  4206. } );
  4207. }
  4208. if ( _fnDataSource( settings ) == 'ssp' ) {
  4209. _fnReDraw( settings, holdPosition );
  4210. }
  4211. else {
  4212. _fnProcessingDisplay( settings, true );
  4213. var xhr = settings.jqXHR;
  4214. if ( xhr && xhr.readyState !== 4 ) {
  4215. xhr.abort();
  4216. }
  4217. _fnBuildAjax( settings, [], function( json ) {
  4218. _fnClearTable( settings );
  4219. var data = _fnAjaxDataSrc( settings, json );
  4220. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  4221. _fnAddData( settings, data[i] );
  4222. }
  4223. _fnReDraw( settings, holdPosition );
  4224. _fnProcessingDisplay( settings, false );
  4225. } );
  4226. }
  4227. };
  4228. _api_register( 'ajax.json()', function () {
  4229. var ctx = this.context;
  4230. if ( ctx.length > 0 ) {
  4231. return ctx[0].json;
  4232. }
  4233. } );
  4234. _api_register( 'ajax.params()', function () {
  4235. var ctx = this.context;
  4236. if ( ctx.length > 0 ) {
  4237. return ctx[0].oAjaxData;
  4238. }
  4239. } );
  4240. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  4241. return this.iterator( 'table', function (settings) {
  4242. __reload( settings, resetPaging===false, callback );
  4243. } );
  4244. } );
  4245. _api_register( 'ajax.url()', function ( url ) {
  4246. var ctx = this.context;
  4247. if ( url === undefined ) {
  4248. if ( ctx.length === 0 ) {
  4249. return undefined;
  4250. }
  4251. ctx = ctx[0];
  4252. return ctx.ajax ?
  4253. $.isPlainObject( ctx.ajax ) ?
  4254. ctx.ajax.url :
  4255. ctx.ajax :
  4256. ctx.sAjaxSource;
  4257. }
  4258. return this.iterator( 'table', function ( settings ) {
  4259. if ( $.isPlainObject( settings.ajax ) ) {
  4260. settings.ajax.url = url;
  4261. }
  4262. else {
  4263. settings.ajax = url;
  4264. }
  4265. } );
  4266. } );
  4267. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  4268. return this.iterator( 'table', function ( ctx ) {
  4269. __reload( ctx, resetPaging===false, callback );
  4270. } );
  4271. } );
  4272. var _selector_run = function ( type, selector, selectFn, settings, opts )
  4273. {
  4274. var
  4275. out = [], res,
  4276. a, i, ien, j, jen,
  4277. selectorType = typeof selector;
  4278. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  4279. selector = [ selector ];
  4280. }
  4281. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  4282. a = selector[i] && selector[i].split ?
  4283. selector[i].split(',') :
  4284. [ selector[i] ];
  4285. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  4286. res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  4287. if ( res && res.length ) {
  4288. out = out.concat( res );
  4289. }
  4290. }
  4291. }
  4292. var ext = _ext.selector[ type ];
  4293. if ( ext.length ) {
  4294. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  4295. out = ext[i]( settings, opts, out );
  4296. }
  4297. }
  4298. return _unique( out );
  4299. };
  4300. var _selector_opts = function ( opts )
  4301. {
  4302. if ( ! opts ) {
  4303. opts = {};
  4304. }
  4305. if ( opts.filter && opts.search === undefined ) {
  4306. opts.search = opts.filter;
  4307. }
  4308. return $.extend( {
  4309. search: 'none',
  4310. order: 'current',
  4311. page: 'all'
  4312. }, opts );
  4313. };
  4314. var _selector_first = function ( inst )
  4315. {
  4316. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  4317. if ( inst[i].length > 0 ) {
  4318. inst[0] = inst[i];
  4319. inst[0].length = 1;
  4320. inst.length = 1;
  4321. inst.context = [ inst.context[i] ];
  4322. return inst;
  4323. }
  4324. }
  4325. inst.length = 0;
  4326. return inst;
  4327. };
  4328. var _selector_row_indexes = function ( settings, opts )
  4329. {
  4330. var
  4331. i, ien, tmp, a=[],
  4332. displayFiltered = settings.aiDisplay,
  4333. displayMaster = settings.aiDisplayMaster;
  4334. var
  4335. search = opts.search,
  4336. order = opts.order,
  4337. page = opts.page;
  4338. if ( _fnDataSource( settings ) == 'ssp' ) {
  4339. return search === 'removed' ?
  4340. [] :
  4341. _range( 0, displayMaster.length );
  4342. }
  4343. else if ( page == 'current' ) {
  4344. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  4345. a.push( displayFiltered[i] );
  4346. }
  4347. }
  4348. else if ( order == 'current' || order == 'applied' ) {
  4349. a = search == 'none' ?
  4350. displayMaster.slice() :
  4351. search == 'applied' ?
  4352. displayFiltered.slice() :
  4353. $.map( displayMaster, function (el, i) {
  4354. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  4355. } );
  4356. }
  4357. else if ( order == 'index' || order == 'original' ) {
  4358. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4359. if ( search == 'none' ) {
  4360. a.push( i );
  4361. }
  4362. else {
  4363. tmp = $.inArray( i, displayFiltered );
  4364. if ((tmp === -1 && search == 'removed') ||
  4365. (tmp >= 0 && search == 'applied') )
  4366. {
  4367. a.push( i );
  4368. }
  4369. }
  4370. }
  4371. }
  4372. return a;
  4373. };
  4374. var __row_selector = function ( settings, selector, opts )
  4375. {
  4376. var run = function ( sel ) {
  4377. var selInt = _intVal( sel );
  4378. var i, ien;
  4379. if ( selInt !== null && ! opts ) {
  4380. return [ selInt ];
  4381. }
  4382. var rows = _selector_row_indexes( settings, opts );
  4383. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  4384. return [ selInt ];
  4385. }
  4386. else if ( ! sel ) {
  4387. return rows;
  4388. }
  4389. if ( typeof sel === 'function' ) {
  4390. return $.map( rows, function (idx) {
  4391. var row = settings.aoData[ idx ];
  4392. return sel( idx, row._aData, row.nTr ) ? idx : null;
  4393. } );
  4394. }
  4395. var nodes = _removeEmpty(
  4396. _pluck_order( settings.aoData, rows, 'nTr' )
  4397. );
  4398. if ( sel.nodeName ) {
  4399. if ( $.inArray( sel, nodes ) !== -1 ) {
  4400. return [ sel._DT_RowIndex ];
  4401. }
  4402. }
  4403. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  4404. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  4405. if ( rowObj !== undefined ) {
  4406. return [ rowObj.idx ];
  4407. }
  4408. }
  4409. return $(nodes)
  4410. .filter( sel )
  4411. .map( function () {
  4412. return this._DT_RowIndex;
  4413. } )
  4414. .toArray();
  4415. };
  4416. return _selector_run( 'row', selector, run, settings, opts );
  4417. };
  4418. _api_register( 'rows()', function ( selector, opts ) {
  4419. if ( selector === undefined ) {
  4420. selector = '';
  4421. }
  4422. else if ( $.isPlainObject( selector ) ) {
  4423. opts = selector;
  4424. selector = '';
  4425. }
  4426. opts = _selector_opts( opts );
  4427. var inst = this.iterator( 'table', function ( settings ) {
  4428. return __row_selector( settings, selector, opts );
  4429. }, 1 );
  4430. inst.selector.rows = selector;
  4431. inst.selector.opts = opts;
  4432. return inst;
  4433. } );
  4434. _api_register( 'rows().nodes()', function () {
  4435. return this.iterator( 'row', function ( settings, row ) {
  4436. return settings.aoData[ row ].nTr || undefined;
  4437. }, 1 );
  4438. } );
  4439. _api_register( 'rows().data()', function () {
  4440. return this.iterator( true, 'rows', function ( settings, rows ) {
  4441. return _pluck_order( settings.aoData, rows, '_aData' );
  4442. }, 1 );
  4443. } );
  4444. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  4445. return this.iterator( 'row', function ( settings, row ) {
  4446. var r = settings.aoData[ row ];
  4447. return type === 'search' ? r._aFilterData : r._aSortData;
  4448. }, 1 );
  4449. } );
  4450. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  4451. return this.iterator( 'row', function ( settings, row ) {
  4452. _fnInvalidate( settings, row, src );
  4453. } );
  4454. } );
  4455. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  4456. return this.iterator( 'row', function ( settings, row ) {
  4457. return row;
  4458. }, 1 );
  4459. } );
  4460. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  4461. var a = [];
  4462. var context = this.context;
  4463. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  4464. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  4465. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  4466. a.push( (hash === true ? '#' : '' )+ id );
  4467. }
  4468. }
  4469. return new _Api( context, a );
  4470. } );
  4471. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  4472. var that = this;
  4473. this.iterator( 'row', function ( settings, row, thatIdx ) {
  4474. var data = settings.aoData;
  4475. var rowData = data[ row ];
  4476. data.splice( row, 1 );
  4477. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  4478. if ( data[i].nTr !== null ) {
  4479. data[i].nTr._DT_RowIndex = i;
  4480. }
  4481. }
  4482. _fnDeleteIndex( settings.aiDisplayMaster, row );
  4483. _fnDeleteIndex( settings.aiDisplay, row );
  4484. _fnDeleteIndex( that[ thatIdx ], row, false );
  4485. _fnLengthOverflow( settings );
  4486. var id = settings.rowIdFn( rowData._aData );
  4487. if ( id !== undefined ) {
  4488. delete settings.aIds[ id ];
  4489. }
  4490. } );
  4491. this.iterator( 'table', function ( settings ) {
  4492. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4493. settings.aoData[i].idx = i;
  4494. }
  4495. } );
  4496. return this;
  4497. } );
  4498. _api_register( 'rows.add()', function ( rows ) {
  4499. var newRows = this.iterator( 'table', function ( settings ) {
  4500. var row, i, ien;
  4501. var out = [];
  4502. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  4503. row = rows[i];
  4504. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  4505. out.push( _fnAddTr( settings, row )[0] );
  4506. }
  4507. else {
  4508. out.push( _fnAddData( settings, row ) );
  4509. }
  4510. }
  4511. return out;
  4512. }, 1 );
  4513. var modRows = this.rows( -1 );
  4514. modRows.pop();
  4515. $.merge( modRows, newRows );
  4516. return modRows;
  4517. } );
  4518. _api_register( 'row()', function ( selector, opts ) {
  4519. return _selector_first( this.rows( selector, opts ) );
  4520. } );
  4521. _api_register( 'row().data()', function ( data ) {
  4522. var ctx = this.context;
  4523. if ( data === undefined ) {
  4524. return ctx.length && this.length ?
  4525. ctx[0].aoData[ this[0] ]._aData :
  4526. undefined;
  4527. }
  4528. ctx[0].aoData[ this[0] ]._aData = data;
  4529. _fnInvalidate( ctx[0], this[0], 'data' );
  4530. return this;
  4531. } );
  4532. _api_register( 'row().node()', function () {
  4533. var ctx = this.context;
  4534. return ctx.length && this.length ?
  4535. ctx[0].aoData[ this[0] ].nTr || null :
  4536. null;
  4537. } );
  4538. _api_register( 'row.add()', function ( row ) {
  4539. if ( row instanceof $ && row.length ) {
  4540. row = row[0];
  4541. }
  4542. var rows = this.iterator( 'table', function ( settings ) {
  4543. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  4544. return _fnAddTr( settings, row )[0];
  4545. }
  4546. return _fnAddData( settings, row );
  4547. } );
  4548. return this.row( rows[0] );
  4549. } );
  4550. var __details_add = function ( ctx, row, data, klass )
  4551. {
  4552. var rows = [];
  4553. var addRow = function ( r, k ) {
  4554. if ( $.isArray( r ) || r instanceof $ ) {
  4555. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  4556. addRow( r[i], k );
  4557. }
  4558. return;
  4559. }
  4560. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  4561. rows.push( r );
  4562. }
  4563. else {
  4564. var created = $('<tr><td/></tr>').addClass( k );
  4565. $('td', created)
  4566. .addClass( k )
  4567. .html( r )
  4568. [0].colSpan = _fnVisbleColumns( ctx );
  4569. rows.push( created[0] );
  4570. }
  4571. };
  4572. addRow( data, klass );
  4573. if ( row._details ) {
  4574. row._details.remove();
  4575. }
  4576. row._details = $(rows);
  4577. if ( row._detailsShow ) {
  4578. row._details.insertAfter( row.nTr );
  4579. }
  4580. };
  4581. var __details_remove = function ( api, idx )
  4582. {
  4583. var ctx = api.context;
  4584. if ( ctx.length ) {
  4585. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  4586. if ( row && row._details ) {
  4587. row._details.remove();
  4588. row._detailsShow = undefined;
  4589. row._details = undefined;
  4590. }
  4591. }
  4592. };
  4593. var __details_display = function ( api, show ) {
  4594. var ctx = api.context;
  4595. if ( ctx.length && api.length ) {
  4596. var row = ctx[0].aoData[ api[0] ];
  4597. if ( row._details ) {
  4598. row._detailsShow = show;
  4599. if ( show ) {
  4600. row._details.insertAfter( row.nTr );
  4601. }
  4602. else {
  4603. row._details.detach();
  4604. }
  4605. __details_events( ctx[0] );
  4606. }
  4607. }
  4608. };
  4609. var __details_events = function ( settings )
  4610. {
  4611. var api = new _Api( settings );
  4612. var namespace = '.dt.DT_details';
  4613. var drawEvent = 'draw'+namespace;
  4614. var colvisEvent = 'column-visibility'+namespace;
  4615. var destroyEvent = 'destroy'+namespace;
  4616. var data = settings.aoData;
  4617. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  4618. if ( _pluck( data, '_details' ).length > 0 ) {
  4619. api.on( drawEvent, function ( e, ctx ) {
  4620. if ( settings !== ctx ) {
  4621. return;
  4622. }
  4623. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  4624. var row = data[ idx ];
  4625. if ( row._detailsShow ) {
  4626. row._details.insertAfter( row.nTr );
  4627. }
  4628. } );
  4629. } );
  4630. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  4631. if ( settings !== ctx ) {
  4632. return;
  4633. }
  4634. var row, visible = _fnVisbleColumns( ctx );
  4635. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  4636. row = data[i];
  4637. if ( row._details ) {
  4638. row._details.children('td[colspan]').attr('colspan', visible );
  4639. }
  4640. }
  4641. } );
  4642. api.on( destroyEvent, function ( e, ctx ) {
  4643. if ( settings !== ctx ) {
  4644. return;
  4645. }
  4646. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  4647. if ( data[i]._details ) {
  4648. __details_remove( api, i );
  4649. }
  4650. }
  4651. } );
  4652. }
  4653. };
  4654. var _emp = '';
  4655. var _child_obj = _emp+'row().child';
  4656. var _child_mth = _child_obj+'()';
  4657. _api_register( _child_mth, function ( data, klass ) {
  4658. var ctx = this.context;
  4659. if ( data === undefined ) {
  4660. return ctx.length && this.length ?
  4661. ctx[0].aoData[ this[0] ]._details :
  4662. undefined;
  4663. }
  4664. else if ( data === true ) {
  4665. this.child.show();
  4666. }
  4667. else if ( data === false ) {
  4668. __details_remove( this );
  4669. }
  4670. else if ( ctx.length && this.length ) {
  4671. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  4672. }
  4673. return this;
  4674. } );
  4675. _api_register( [
  4676. _child_obj+'.show()',
  4677. _child_mth+'.show()'
  4678. ], function ( show ) {
  4679. __details_display( this, true );
  4680. return this;
  4681. } );
  4682. _api_register( [
  4683. _child_obj+'.hide()',
  4684. _child_mth+'.hide()'
  4685. ], function () {
  4686. __details_display( this, false );
  4687. return this;
  4688. } );
  4689. _api_register( [
  4690. _child_obj+'.remove()',
  4691. _child_mth+'.remove()'
  4692. ], function () {
  4693. __details_remove( this );
  4694. return this;
  4695. } );
  4696. _api_register( _child_obj+'.isShown()', function () {
  4697. var ctx = this.context;
  4698. if ( ctx.length && this.length ) {
  4699. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  4700. }
  4701. return false;
  4702. } );
  4703. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  4704. var __columnData = function ( settings, column, r1, r2, rows ) {
  4705. var a = [];
  4706. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  4707. a.push( _fnGetCellData( settings, rows[row], column ) );
  4708. }
  4709. return a;
  4710. };
  4711. var __column_selector = function ( settings, selector, opts )
  4712. {
  4713. var
  4714. columns = settings.aoColumns,
  4715. names = _pluck( columns, 'sName' ),
  4716. nodes = _pluck( columns, 'nTh' );
  4717. var run = function ( s ) {
  4718. var selInt = _intVal( s );
  4719. if ( s === '' ) {
  4720. return _range( columns.length );
  4721. }
  4722. if ( selInt !== null ) {
  4723. return [ selInt >= 0 ?
  4724. selInt :
  4725. columns.length + selInt
  4726. ];
  4727. }
  4728. if ( typeof s === 'function' ) {
  4729. var rows = _selector_row_indexes( settings, opts );
  4730. return $.map( columns, function (col, idx) {
  4731. return s(
  4732. idx,
  4733. __columnData( settings, idx, 0, 0, rows ),
  4734. nodes[ idx ]
  4735. ) ? idx : null;
  4736. } );
  4737. }
  4738. var match = typeof s === 'string' ?
  4739. s.match( __re_column_selector ) :
  4740. '';
  4741. if ( match ) {
  4742. switch( match[2] ) {
  4743. case 'visIdx':
  4744. case 'visible':
  4745. var idx = parseInt( match[1], 10 );
  4746. if ( idx < 0 ) {
  4747. var visColumns = $.map( columns, function (col,i) {
  4748. return col.bVisible ? i : null;
  4749. } );
  4750. return [ visColumns[ visColumns.length + idx ] ];
  4751. }
  4752. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  4753. case 'name':
  4754. return $.map( names, function (name, i) {
  4755. return name === match[1] ? i : null;
  4756. } );
  4757. }
  4758. }
  4759. else {
  4760. return $( nodes )
  4761. .filter( s )
  4762. .map( function () {
  4763. return $.inArray( this, nodes );
  4764. } )
  4765. .toArray();
  4766. }
  4767. };
  4768. return _selector_run( 'column', selector, run, settings, opts );
  4769. };
  4770. var __setColumnVis = function ( settings, column, vis, recalc ) {
  4771. var
  4772. cols = settings.aoColumns,
  4773. col = cols[ column ],
  4774. data = settings.aoData,
  4775. row, cells, i, ien, tr;
  4776. if ( vis === undefined ) {
  4777. return col.bVisible;
  4778. }
  4779. if ( col.bVisible === vis ) {
  4780. return;
  4781. }
  4782. if ( vis ) {
  4783. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  4784. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  4785. tr = data[i].nTr;
  4786. cells = data[i].anCells;
  4787. if ( tr ) {
  4788. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  4789. }
  4790. }
  4791. }
  4792. else {
  4793. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  4794. }
  4795. col.bVisible = vis;
  4796. _fnDrawHead( settings, settings.aoHeader );
  4797. _fnDrawHead( settings, settings.aoFooter );
  4798. if ( recalc === undefined || recalc ) {
  4799. _fnAdjustColumnSizing( settings );
  4800. if ( settings.oScroll.sX || settings.oScroll.sY ) {
  4801. _fnScrollDraw( settings );
  4802. }
  4803. }
  4804. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis] );
  4805. _fnSaveState( settings );
  4806. };
  4807. _api_register( 'columns()', function ( selector, opts ) {
  4808. if ( selector === undefined ) {
  4809. selector = '';
  4810. }
  4811. else if ( $.isPlainObject( selector ) ) {
  4812. opts = selector;
  4813. selector = '';
  4814. }
  4815. opts = _selector_opts( opts );
  4816. var inst = this.iterator( 'table', function ( settings ) {
  4817. return __column_selector( settings, selector, opts );
  4818. }, 1 );
  4819. inst.selector.cols = selector;
  4820. inst.selector.opts = opts;
  4821. return inst;
  4822. } );
  4823. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  4824. return this.iterator( 'column', function ( settings, column ) {
  4825. return settings.aoColumns[column].nTh;
  4826. }, 1 );
  4827. } );
  4828. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  4829. return this.iterator( 'column', function ( settings, column ) {
  4830. return settings.aoColumns[column].nTf;
  4831. }, 1 );
  4832. } );
  4833. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  4834. return this.iterator( 'column-rows', __columnData, 1 );
  4835. } );
  4836. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  4837. return this.iterator( 'column', function ( settings, column ) {
  4838. return settings.aoColumns[column].mData;
  4839. }, 1 );
  4840. } );
  4841. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  4842. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  4843. return _pluck_order( settings.aoData, rows,
  4844. type === 'search' ? '_aFilterData' : '_aSortData', column
  4845. );
  4846. }, 1 );
  4847. } );
  4848. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  4849. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  4850. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  4851. }, 1 );
  4852. } );
  4853. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  4854. return this.iterator( 'column', function ( settings, column ) {
  4855. if ( vis === undefined ) {
  4856. return settings.aoColumns[ column ].bVisible;
  4857. }
  4858. __setColumnVis( settings, column, vis, calc );
  4859. } );
  4860. } );
  4861. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  4862. return this.iterator( 'column', function ( settings, column ) {
  4863. return type === 'visible' ?
  4864. _fnColumnIndexToVisible( settings, column ) :
  4865. column;
  4866. }, 1 );
  4867. } );
  4868. _api_register( 'columns.adjust()', function () {
  4869. return this.iterator( 'table', function ( settings ) {
  4870. _fnAdjustColumnSizing( settings );
  4871. }, 1 );
  4872. } );
  4873. _api_register( 'column.index()', function ( type, idx ) {
  4874. if ( this.context.length !== 0 ) {
  4875. var ctx = this.context[0];
  4876. if ( type === 'fromVisible' || type === 'toData' ) {
  4877. return _fnVisibleToColumnIndex( ctx, idx );
  4878. }
  4879. else if ( type === 'fromData' || type === 'toVisible' ) {
  4880. return _fnColumnIndexToVisible( ctx, idx );
  4881. }
  4882. }
  4883. } );
  4884. _api_register( 'column()', function ( selector, opts ) {
  4885. return _selector_first( this.columns( selector, opts ) );
  4886. } );
  4887. var __cell_selector = function ( settings, selector, opts )
  4888. {
  4889. var data = settings.aoData;
  4890. var rows = _selector_row_indexes( settings, opts );
  4891. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  4892. var allCells = $( [].concat.apply([], cells) );
  4893. var row;
  4894. var columns = settings.aoColumns.length;
  4895. var a, i, ien, j, o, host;
  4896. var run = function ( s ) {
  4897. var fnSelector = typeof s === 'function';
  4898. if ( s === null || s === undefined || fnSelector ) {
  4899. a = [];
  4900. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  4901. row = rows[i];
  4902. for ( j=0 ; j<columns ; j++ ) {
  4903. o = {
  4904. row: row,
  4905. column: j
  4906. };
  4907. if ( fnSelector ) {
  4908. host = data[ row ];
  4909. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  4910. a.push( o );
  4911. }
  4912. }
  4913. else {
  4914. a.push( o );
  4915. }
  4916. }
  4917. }
  4918. return a;
  4919. }
  4920. if ( $.isPlainObject( s ) ) {
  4921. return [s];
  4922. }
  4923. return allCells
  4924. .filter( s )
  4925. .map( function (i, el) {
  4926. if ( el.parentNode ) {
  4927. row = el.parentNode._DT_RowIndex;
  4928. }
  4929. else {
  4930. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  4931. if ( $.inArray( el, data[i].anCells ) !== -1 ) {
  4932. row = i;
  4933. break;
  4934. }
  4935. }
  4936. }
  4937. return {
  4938. row: row,
  4939. column: $.inArray( el, data[ row ].anCells )
  4940. };
  4941. } )
  4942. .toArray();
  4943. };
  4944. return _selector_run( 'cell', selector, run, settings, opts );
  4945. };
  4946. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  4947. if ( $.isPlainObject( rowSelector ) ) {
  4948. if ( rowSelector.row === undefined ) {
  4949. opts = rowSelector;
  4950. rowSelector = null;
  4951. }
  4952. else {
  4953. opts = columnSelector;
  4954. columnSelector = null;
  4955. }
  4956. }
  4957. if ( $.isPlainObject( columnSelector ) ) {
  4958. opts = columnSelector;
  4959. columnSelector = null;
  4960. }
  4961. if ( columnSelector === null || columnSelector === undefined ) {
  4962. return this.iterator( 'table', function ( settings ) {
  4963. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  4964. } );
  4965. }
  4966. var columns = this.columns( columnSelector, opts );
  4967. var rows = this.rows( rowSelector, opts );
  4968. var a, i, ien, j, jen;
  4969. var cells = this.iterator( 'table', function ( settings, idx ) {
  4970. a = [];
  4971. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  4972. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  4973. a.push( {
  4974. row: rows[idx][i],
  4975. column: columns[idx][j]
  4976. } );
  4977. }
  4978. }
  4979. return a;
  4980. }, 1 );
  4981. $.extend( cells.selector, {
  4982. cols: columnSelector,
  4983. rows: rowSelector,
  4984. opts: opts
  4985. } );
  4986. return cells;
  4987. } );
  4988. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  4989. return this.iterator( 'cell', function ( settings, row, column ) {
  4990. var cells = settings.aoData[ row ].anCells;
  4991. return cells ?
  4992. cells[ column ] :
  4993. undefined;
  4994. }, 1 );
  4995. } );
  4996. _api_register( 'cells().data()', function () {
  4997. return this.iterator( 'cell', function ( settings, row, column ) {
  4998. return _fnGetCellData( settings, row, column );
  4999. }, 1 );
  5000. } );
  5001. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  5002. type = type === 'search' ? '_aFilterData' : '_aSortData';
  5003. return this.iterator( 'cell', function ( settings, row, column ) {
  5004. return settings.aoData[ row ][ type ][ column ];
  5005. }, 1 );
  5006. } );
  5007. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  5008. return this.iterator( 'cell', function ( settings, row, column ) {
  5009. return _fnGetCellData( settings, row, column, type );
  5010. }, 1 );
  5011. } );
  5012. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  5013. return this.iterator( 'cell', function ( settings, row, column ) {
  5014. return {
  5015. row: row,
  5016. column: column,
  5017. columnVisible: _fnColumnIndexToVisible( settings, column )
  5018. };
  5019. }, 1 );
  5020. } );
  5021. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  5022. return this.iterator( 'cell', function ( settings, row, column ) {
  5023. _fnInvalidate( settings, row, src, column );
  5024. } );
  5025. } );
  5026. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  5027. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  5028. } );
  5029. _api_register( 'cell().data()', function ( data ) {
  5030. var ctx = this.context;
  5031. var cell = this[0];
  5032. if ( data === undefined ) {
  5033. return ctx.length && cell.length ?
  5034. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  5035. undefined;
  5036. }
  5037. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  5038. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  5039. return this;
  5040. } );
  5041. _api_register( 'order()', function ( order, dir ) {
  5042. var ctx = this.context;
  5043. if ( order === undefined ) {
  5044. return ctx.length !== 0 ?
  5045. ctx[0].aaSorting :
  5046. undefined;
  5047. }
  5048. if ( typeof order === 'number' ) {
  5049. order = [ [ order, dir ] ];
  5050. }
  5051. else if ( ! $.isArray( order[0] ) ) {
  5052. order = Array.prototype.slice.call( arguments );
  5053. }
  5054. return this.iterator( 'table', function ( settings ) {
  5055. settings.aaSorting = order.slice();
  5056. } );
  5057. } );
  5058. _api_register( 'order.listener()', function ( node, column, callback ) {
  5059. return this.iterator( 'table', function ( settings ) {
  5060. _fnSortAttachListener( settings, node, column, callback );
  5061. } );
  5062. } );
  5063. _api_register( 'order.fixed()', function ( set ) {
  5064. if ( ! set ) {
  5065. var ctx = this.context;
  5066. var fixed = ctx.length ?
  5067. ctx[0].aaSortingFixed :
  5068. undefined;
  5069. return $.isArray( fixed ) ?
  5070. { pre: fixed } :
  5071. fixed;
  5072. }
  5073. return this.iterator( 'table', function ( settings ) {
  5074. settings.aaSortingFixed = $.extend( true, {}, set );
  5075. } );
  5076. } );
  5077. _api_register( [
  5078. 'columns().order()',
  5079. 'column().order()'
  5080. ], function ( dir ) {
  5081. var that = this;
  5082. return this.iterator( 'table', function ( settings, i ) {
  5083. var sort = [];
  5084. $.each( that[i], function (j, col) {
  5085. sort.push( [ col, dir ] );
  5086. } );
  5087. settings.aaSorting = sort;
  5088. } );
  5089. } );
  5090. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  5091. var ctx = this.context;
  5092. if ( input === undefined ) {
  5093. return ctx.length !== 0 ?
  5094. ctx[0].oPreviousSearch.sSearch :
  5095. undefined;
  5096. }
  5097. return this.iterator( 'table', function ( settings ) {
  5098. if ( ! settings.oFeatures.bFilter ) {
  5099. return;
  5100. }
  5101. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  5102. "sSearch": input+"",
  5103. "bRegex": regex === null ? false : regex,
  5104. "bSmart": smart === null ? true : smart,
  5105. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  5106. } ), 1 );
  5107. } );
  5108. } );
  5109. _api_registerPlural(
  5110. 'columns().search()',
  5111. 'column().search()',
  5112. function ( input, regex, smart, caseInsen ) {
  5113. return this.iterator( 'column', function ( settings, column ) {
  5114. var preSearch = settings.aoPreSearchCols;
  5115. if ( input === undefined ) {
  5116. return preSearch[ column ].sSearch;
  5117. }
  5118. if ( ! settings.oFeatures.bFilter ) {
  5119. return;
  5120. }
  5121. $.extend( preSearch[ column ], {
  5122. "sSearch": input+"",
  5123. "bRegex": regex === null ? false : regex,
  5124. "bSmart": smart === null ? true : smart,
  5125. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  5126. } );
  5127. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  5128. } );
  5129. }
  5130. );
  5131. _api_register( 'state()', function () {
  5132. return this.context.length ?
  5133. this.context[0].oSavedState :
  5134. null;
  5135. } );
  5136. _api_register( 'state.clear()', function () {
  5137. return this.iterator( 'table', function ( settings ) {
  5138. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  5139. } );
  5140. } );
  5141. _api_register( 'state.loaded()', function () {
  5142. return this.context.length ?
  5143. this.context[0].oLoadedState :
  5144. null;
  5145. } );
  5146. _api_register( 'state.save()', function () {
  5147. return this.iterator( 'table', function ( settings ) {
  5148. _fnSaveState( settings );
  5149. } );
  5150. } );
  5151. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  5152. {
  5153. var aThis = DataTable.version.split('.');
  5154. var aThat = version.split('.');
  5155. var iThis, iThat;
  5156. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  5157. iThis = parseInt( aThis[i], 10 ) || 0;
  5158. iThat = parseInt( aThat[i], 10 ) || 0;
  5159. if (iThis === iThat) {
  5160. continue;
  5161. }
  5162. return iThis > iThat;
  5163. }
  5164. return true;
  5165. };
  5166. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  5167. {
  5168. var t = $(table).get(0);
  5169. var is = false;
  5170. $.each( DataTable.settings, function (i, o) {
  5171. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  5172. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  5173. if ( o.nTable === t || head === t || foot === t ) {
  5174. is = true;
  5175. }
  5176. } );
  5177. return is;
  5178. };
  5179. DataTable.tables = DataTable.fnTables = function ( visible )
  5180. {
  5181. var api = false;
  5182. if ( $.isPlainObject( visible ) ) {
  5183. api = visible.api;
  5184. visible = visible.visible;
  5185. }
  5186. var a = $.map( DataTable.settings, function (o) {
  5187. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  5188. return o.nTable;
  5189. }
  5190. } );
  5191. return api ?
  5192. new _Api( a ) :
  5193. a;
  5194. };
  5195. DataTable.util = {
  5196. throttle: _fnThrottle,
  5197. escapeRegex: _fnEscapeRegex
  5198. };
  5199. DataTable.camelToHungarian = _fnCamelToHungarian;
  5200. _api_register( '$()', function ( selector, opts ) {
  5201. var
  5202. rows = this.rows( opts ).nodes(),
  5203. jqRows = $(rows);
  5204. return $( [].concat(
  5205. jqRows.filter( selector ).toArray(),
  5206. jqRows.find( selector ).toArray()
  5207. ) );
  5208. } );
  5209. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  5210. _api_register( key+'()', function ( /* event, handler */ ) {
  5211. var args = Array.prototype.slice.call(arguments);
  5212. if ( ! args[0].match(/\.dt\b/) ) {
  5213. args[0] += '.dt';
  5214. }
  5215. var inst = $( this.tables().nodes() );
  5216. inst[key].apply( inst, args );
  5217. return this;
  5218. } );
  5219. } );
  5220. _api_register( 'clear()', function () {
  5221. return this.iterator( 'table', function ( settings ) {
  5222. _fnClearTable( settings );
  5223. } );
  5224. } );
  5225. _api_register( 'settings()', function () {
  5226. return new _Api( this.context, this.context );
  5227. } );
  5228. _api_register( 'init()', function () {
  5229. var ctx = this.context;
  5230. return ctx.length ? ctx[0].oInit : null;
  5231. } );
  5232. _api_register( 'data()', function () {
  5233. return this.iterator( 'table', function ( settings ) {
  5234. return _pluck( settings.aoData, '_aData' );
  5235. } ).flatten();
  5236. } );
  5237. _api_register( 'destroy()', function ( remove ) {
  5238. remove = remove || false;
  5239. return this.iterator( 'table', function ( settings ) {
  5240. var orig = settings.nTableWrapper.parentNode;
  5241. var classes = settings.oClasses;
  5242. var table = settings.nTable;
  5243. var tbody = settings.nTBody;
  5244. var thead = settings.nTHead;
  5245. var tfoot = settings.nTFoot;
  5246. var jqTable = $(table);
  5247. var jqTbody = $(tbody);
  5248. var jqWrapper = $(settings.nTableWrapper);
  5249. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  5250. var i, ien;
  5251. settings.bDestroying = true;
  5252. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  5253. if ( ! remove ) {
  5254. new _Api( settings ).columns().visible( true );
  5255. }
  5256. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  5257. $(window).unbind('.DT-'+settings.sInstance);
  5258. if ( table != thead.parentNode ) {
  5259. jqTable.children('thead').detach();
  5260. jqTable.append( thead );
  5261. }
  5262. if ( tfoot && table != tfoot.parentNode ) {
  5263. jqTable.children('tfoot').detach();
  5264. jqTable.append( tfoot );
  5265. }
  5266. settings.aaSorting = [];
  5267. settings.aaSortingFixed = [];
  5268. _fnSortingClasses( settings );
  5269. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  5270. $('th, td', thead).removeClass( classes.sSortable+' '+
  5271. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  5272. );
  5273. if ( settings.bJUI ) {
  5274. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  5275. $('th, td', thead).each( function () {
  5276. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  5277. $(this).append( wrapper.contents() );
  5278. wrapper.detach();
  5279. } );
  5280. }
  5281. jqTbody.children().detach();
  5282. jqTbody.append( rows );
  5283. var removedMethod = remove ? 'remove' : 'detach';
  5284. jqTable[ removedMethod ]();
  5285. jqWrapper[ removedMethod ]();
  5286. if ( ! remove && orig ) {
  5287. orig.insertBefore( table, settings.nTableReinsertBefore );
  5288. jqTable
  5289. .css( 'width', settings.sDestroyWidth )
  5290. .removeClass( classes.sTable );
  5291. ien = settings.asDestroyStripes.length;
  5292. if ( ien ) {
  5293. jqTbody.children().each( function (i) {
  5294. $(this).addClass( settings.asDestroyStripes[i % ien] );
  5295. } );
  5296. }
  5297. }
  5298. var idx = $.inArray( settings, DataTable.settings );
  5299. if ( idx !== -1 ) {
  5300. DataTable.settings.splice( idx, 1 );
  5301. }
  5302. } );
  5303. } );
  5304. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  5305. _api_register( type+'s().every()', function ( fn ) {
  5306. var opts = this.selector.opts;
  5307. var api = this;
  5308. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  5309. fn.call(
  5310. api[ type ](
  5311. arg1,
  5312. type==='cell' ? arg2 : opts,
  5313. type==='cell' ? opts : undefined
  5314. ),
  5315. arg1, arg2, arg3, arg4
  5316. );
  5317. } );
  5318. } );
  5319. } );
  5320. _api_register( 'i18n()', function ( token, def, plural ) {
  5321. var ctx = this.context[0];
  5322. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  5323. if ( resolved === undefined ) {
  5324. resolved = def;
  5325. }
  5326. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  5327. resolved = resolved[ plural ] !== undefined ?
  5328. resolved[ plural ] :
  5329. resolved._;
  5330. }
  5331. return resolved.replace( '%d', plural );
  5332. } );
  5333. DataTable.version = "1.10.10-dev";
  5334. DataTable.settings = [];
  5335. DataTable.models = {};
  5336. DataTable.models.oSearch = {
  5337. "bCaseInsensitive": true,
  5338. "sSearch": "",
  5339. "bRegex": false,
  5340. "bSmart": true
  5341. };
  5342. DataTable.models.oRow = {
  5343. "nTr": null,
  5344. "anCells": null,
  5345. "_aData": [],
  5346. "_aSortData": null,
  5347. "_aFilterData": null,
  5348. "_sFilterRow": null,
  5349. "_sRowStripe": "",
  5350. "src": null,
  5351. "idx": -1
  5352. };
  5353. DataTable.models.oColumn = {
  5354. "idx": null,
  5355. "aDataSort": null,
  5356. "asSorting": null,
  5357. "bSearchable": null,
  5358. "bSortable": null,
  5359. "bVisible": null,
  5360. "_sManualType": null,
  5361. "_bAttrSrc": false,
  5362. "fnCreatedCell": null,
  5363. "fnGetData": null,
  5364. "fnSetData": null,
  5365. "mData": null,
  5366. "mRender": null,
  5367. "nTh": null,
  5368. "nTf": null,
  5369. "sClass": null,
  5370. "sContentPadding": null,
  5371. "sDefaultContent": null,
  5372. "sName": null,
  5373. "sSortDataType": 'std',
  5374. "sSortingClass": null,
  5375. "sSortingClassJUI": null,
  5376. "sTitle": null,
  5377. "sType": null,
  5378. "sWidth": null,
  5379. "sWidthOrig": null
  5380. };
  5381. DataTable.defaults = {
  5382. "aaData": null,
  5383. "aaSorting": [[0,'asc']],
  5384. "aaSortingFixed": [],
  5385. "ajax": null,
  5386. "aLengthMenu": [ 10, 25, 50, 100 ],
  5387. "aoColumns": null,
  5388. "aoColumnDefs": null,
  5389. "aoSearchCols": [],
  5390. "asStripeClasses": null,
  5391. "bAutoWidth": true,
  5392. "bDeferRender": false,
  5393. "bDestroy": false,
  5394. "bFilter": false,
  5395. "bInfo": true,
  5396. "bJQueryUI": false,
  5397. "bLengthChange": true,
  5398. "bPaginate": true,
  5399. "bProcessing": false,
  5400. "bRetrieve": false,
  5401. "bScrollCollapse": false,
  5402. "bServerSide": false,
  5403. "bSort": false,
  5404. "bSortMulti": true,
  5405. "bSortCellsTop": false,
  5406. "bSortClasses": true,
  5407. "bStateSave": false,
  5408. "fnCreatedRow": null,
  5409. "fnDrawCallback": null,
  5410. "fnFooterCallback": null,
  5411. "fnFormatNumber": function ( toFormat ) {
  5412. return toFormat.toString().replace(
  5413. /\B(?=(\d{3})+(?!\d))/g,
  5414. this.oLanguage.sThousands
  5415. );
  5416. },
  5417. "fnHeaderCallback": null,
  5418. "fnInfoCallback": null,
  5419. "fnInitComplete": null,
  5420. "fnPreDrawCallback": null,
  5421. "fnRowCallback": null,
  5422. "fnServerData": null,
  5423. "fnServerParams": null,
  5424. "fnStateLoadCallback": function ( settings ) {
  5425. try {
  5426. return JSON.parse(
  5427. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  5428. 'DataTables_'+settings.sInstance+'_'+location.pathname
  5429. )
  5430. );
  5431. } catch (e) {}
  5432. },
  5433. "fnStateLoadParams": null,
  5434. "fnStateLoaded": null,
  5435. "fnStateSaveCallback": function ( settings, data ) {
  5436. try {
  5437. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  5438. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  5439. JSON.stringify( data )
  5440. );
  5441. } catch (e) {}
  5442. },
  5443. "fnStateSaveParams": null,
  5444. "iStateDuration": 7200,
  5445. "iDeferLoading": null,
  5446. "iDisplayLength": 10,
  5447. "iDisplayStart": 0,
  5448. "iTabIndex": 0,
  5449. "oClasses": {},
  5450. "oLanguage": {
  5451. "oAria": {
  5452. "sSortAscending": ": \u6fc0\u6d3b\u6392\u5e8f\u5217",
  5453. "sSortDescending": ": \u6fc0\u6d3b\u6392\u5e8f\u5217\u964d"
  5454. },
  5455. "oPaginate": {
  5456. "sFirst": "First",
  5457. "sLast": "Last",
  5458. "sNext": "\u4e0b\u4e00\u9875",
  5459. "sPrevious": "\u4e0a\u4e00\u9875"
  5460. },
  5461. "sEmptyTable": "\u6ca1\u6709\u53ef\u7528\u7684\u6570\u636e\u8868",
  5462. "sInfo": "\u663e\u793a _START_ \u5230 _END_ \u603b\u8ba1 _TOTAL_",
  5463. "sInfoEmpty": "\u663e\u793a 0 to 0 of 0 entries",
  5464. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  5465. "sInfoPostFix": "",
  5466. "sDecimal": "",
  5467. "sThousands": ",",
  5468. "sLengthMenu": "\u663e\u793a _MENU_ \u6761",
  5469. "sLoadingRecords": "\u6570\u636e\u8f7d\u5165\u4e2d...",
  5470. "sProcessing": "\u5904\u7406\u4e2d...",
  5471. "sSearch": "\u641c\u7d22:",
  5472. "sSearchPlaceholder": "",
  5473. "sUrl": "",
  5474. "sZeroRecords": "\u672a\u627e\u5230\u5339\u914d\u8bb0\u5f55"
  5475. },
  5476. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  5477. "sAjaxDataProp": "data",
  5478. "sAjaxSource": null,
  5479. "sDom": 't<"dataTables_footer_operate clearfix mt15"ilp>',
  5480. "searchDelay": null,
  5481. "sPaginationType": "simple_numbers",
  5482. "sScrollX": "",
  5483. "sScrollXInner": "",
  5484. "sScrollY": "",
  5485. "sServerMethod": "GET",
  5486. "renderer": null,
  5487. "rowId": "DT_RowId"
  5488. };
  5489. _fnHungarianMap( DataTable.defaults );
  5490. DataTable.defaults.column = {
  5491. "aDataSort": null,
  5492. "iDataSort": -1,
  5493. "asSorting": [ 'asc', 'desc' ],
  5494. "bSearchable": true,
  5495. "bSortable": true,
  5496. "bVisible": true,
  5497. "fnCreatedCell": null,
  5498. "mData": null,
  5499. "mRender": null,
  5500. "sCellType": "td",
  5501. "sClass": "",
  5502. "sContentPadding": "",
  5503. "sDefaultContent": null,
  5504. "sName": "",
  5505. "sSortDataType": "std",
  5506. "sTitle": null,
  5507. "sType": null,
  5508. "sWidth": null
  5509. };
  5510. _fnHungarianMap( DataTable.defaults.column );
  5511. DataTable.models.oSettings = {
  5512. "oFeatures": {
  5513. "bAutoWidth": null,
  5514. "bDeferRender": null,
  5515. "bFilter": null,
  5516. "bInfo": null,
  5517. "bLengthChange": null,
  5518. "bPaginate": null,
  5519. "bProcessing": null,
  5520. "bServerSide": null,
  5521. "bSort": null,
  5522. "bSortMulti": null,
  5523. "bSortClasses": null,
  5524. "bStateSave": null
  5525. },
  5526. "oScroll": {
  5527. "bCollapse": null,
  5528. "iBarWidth": 0,
  5529. "sX": null,
  5530. "sXInner": null,
  5531. "sY": null
  5532. },
  5533. "oLanguage": {
  5534. "fnInfoCallback": null
  5535. },
  5536. "oBrowser": {
  5537. "bScrollOversize": false,
  5538. "bScrollbarLeft": false,
  5539. "bBounding": false,
  5540. "barWidth": 0
  5541. },
  5542. "ajax": null,
  5543. "aanFeatures": [],
  5544. "aoData": [],
  5545. "aiDisplay": [],
  5546. "aiDisplayMaster": [],
  5547. "aIds": {},
  5548. "aoColumns": [],
  5549. "aoHeader": [],
  5550. "aoFooter": [],
  5551. "oPreviousSearch": {},
  5552. "aoPreSearchCols": [],
  5553. "aaSorting": null,
  5554. "aaSortingFixed": [],
  5555. "asStripeClasses": null,
  5556. "asDestroyStripes": [],
  5557. "sDestroyWidth": 0,
  5558. "aoRowCallback": [],
  5559. "aoHeaderCallback": [],
  5560. "aoFooterCallback": [],
  5561. "aoDrawCallback": [],
  5562. "aoRowCreatedCallback": [],
  5563. "aoPreDrawCallback": [],
  5564. "aoInitComplete": [],
  5565. "aoStateSaveParams": [],
  5566. "aoStateLoadParams": [],
  5567. "aoStateLoaded": [],
  5568. "sTableId": "",
  5569. "nTable": null,
  5570. "nTHead": null,
  5571. "nTFoot": null,
  5572. "nTBody": null,
  5573. "nTableWrapper": null,
  5574. "bDeferLoading": false,
  5575. "bInitialised": false,
  5576. "aoOpenRows": [],
  5577. "sDom": 'lfrp',
  5578. "searchDelay": null,
  5579. "sPaginationType": "two_button",
  5580. "iStateDuration": 0,
  5581. "aoStateSave": [],
  5582. "aoStateLoad": [],
  5583. "oSavedState": null,
  5584. "oLoadedState": null,
  5585. "sAjaxSource": null,
  5586. "sAjaxDataProp": null,
  5587. "bAjaxDataGet": true,
  5588. "jqXHR": null,
  5589. "json": undefined,
  5590. "oAjaxData": undefined,
  5591. "fnServerData": null,
  5592. "aoServerParams": [],
  5593. "sServerMethod": null,
  5594. "fnFormatNumber": null,
  5595. "aLengthMenu": null,
  5596. "iDraw": 0,
  5597. "bDrawing": false,
  5598. "iDrawError": -1,
  5599. "_iDisplayLength": 10,
  5600. "_iDisplayStart": 0,
  5601. "_iRecordsTotal": 0,
  5602. "_iRecordsDisplay": 0,
  5603. "bJUI": null,
  5604. "oClasses": {},
  5605. "bFiltered": false,
  5606. "bSorted": false,
  5607. "bSortCellsTop": null,
  5608. "oInit": null,
  5609. "aoDestroyCallback": [],
  5610. "fnRecordsTotal": function ()
  5611. {
  5612. return _fnDataSource( this ) == 'ssp' ?
  5613. this._iRecordsTotal * 1 :
  5614. this.aiDisplayMaster.length;
  5615. },
  5616. "fnRecordsDisplay": function ()
  5617. {
  5618. return _fnDataSource( this ) == 'ssp' ?
  5619. this._iRecordsDisplay * 1 :
  5620. this.aiDisplay.length;
  5621. },
  5622. "fnDisplayEnd": function ()
  5623. {
  5624. var
  5625. len = this._iDisplayLength,
  5626. start = this._iDisplayStart,
  5627. calc = start + len,
  5628. records = this.aiDisplay.length,
  5629. features = this.oFeatures,
  5630. paginate = features.bPaginate;
  5631. if ( features.bServerSide ) {
  5632. return paginate === false || len === -1 ?
  5633. start + records :
  5634. Math.min( start+len, this._iRecordsDisplay );
  5635. }
  5636. else {
  5637. return ! paginate || calc>records || len===-1 ?
  5638. records :
  5639. calc;
  5640. }
  5641. },
  5642. "oInstance": null,
  5643. "sInstance": null,
  5644. "iTabIndex": 0,
  5645. "nScrollHead": null,
  5646. "nScrollFoot": null,
  5647. "aLastSort": [],
  5648. "oPlugins": {},
  5649. "rowIdFn": null,
  5650. "rowId": null
  5651. };
  5652. DataTable.ext = _ext = {
  5653. buttons: {},
  5654. classes: {},
  5655. builder: "-source-",
  5656. errMode: "alert",
  5657. feature: [],
  5658. search: [],
  5659. selector: {
  5660. cell: [],
  5661. column: [],
  5662. row: []
  5663. },
  5664. internal: {},
  5665. legacy: {
  5666. ajax: null
  5667. },
  5668. pager: {},
  5669. renderer: {
  5670. pageButton: {},
  5671. header: {}
  5672. },
  5673. order: {},
  5674. type: {
  5675. detect: [],
  5676. search: {},
  5677. order: {}
  5678. },
  5679. _unique: 0,
  5680. fnVersionCheck: DataTable.fnVersionCheck,
  5681. iApiIndex: 0,
  5682. oJUIClasses: {},
  5683. sVersion: DataTable.version
  5684. };
  5685. $.extend( _ext, {
  5686. afnFiltering: _ext.search,
  5687. aTypes: _ext.type.detect,
  5688. ofnSearch: _ext.type.search,
  5689. oSort: _ext.type.order,
  5690. afnSortData: _ext.order,
  5691. aoFeatures: _ext.feature,
  5692. oApi: _ext.internal,
  5693. oStdClasses: _ext.classes,
  5694. oPagination: _ext.pager
  5695. } );
  5696. $.extend( DataTable.ext.classes, {
  5697. "sTable": "dataTable",
  5698. "sNoFooter": "no-footer",
  5699. "sPageButton": "paginate_button",
  5700. "sPageButtonActive": "current",
  5701. "sPageButtonDisabled": "disabled",
  5702. "sStripeOdd": "odd",
  5703. "sStripeEven": "even",
  5704. "sRowEmpty": "dataTables_empty",
  5705. "sWrapper": "dataTables_wrapper",
  5706. "sFilter": "dataTables_filter",
  5707. "sInfo": "dataTables_info",
  5708. "sPaging": "dataTables_paginate paging_",
  5709. "sLength": "dataTables_length",
  5710. "sProcessing": "dataTables_processing",
  5711. "sSortAsc": "sorting_asc",
  5712. "sSortDesc": "sorting_desc",
  5713. "sSortable": "sorting",
  5714. "sSortableAsc": "sorting_asc_disabled",
  5715. "sSortableDesc": "sorting_desc_disabled",
  5716. "sSortableNone": "sorting_disabled",
  5717. "sSortColumn": "sorting_",
  5718. "sFilterInput": "",
  5719. "sLengthSelect": "",
  5720. "sScrollWrapper": "dataTables_scroll",
  5721. "sScrollHead": "dataTables_scrollHead",
  5722. "sScrollHeadInner": "dataTables_scrollHeadInner",
  5723. "sScrollBody": "dataTables_scrollBody",
  5724. "sScrollFoot": "dataTables_scrollFoot",
  5725. "sScrollFootInner": "dataTables_scrollFootInner",
  5726. "sHeaderTH": "",
  5727. "sFooterTH": "",
  5728. "sSortJUIAsc": "",
  5729. "sSortJUIDesc": "",
  5730. "sSortJUI": "",
  5731. "sSortJUIAscAllowed": "",
  5732. "sSortJUIDescAllowed": "",
  5733. "sSortJUIWrapper": "",
  5734. "sSortIcon": "",
  5735. "sJUIHeader": "",
  5736. "sJUIFooter": ""
  5737. } );
  5738. (function() {
  5739. var _empty = '';
  5740. _empty = '';
  5741. var _stateDefault = _empty + 'ui-state-default';
  5742. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  5743. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  5744. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  5745. "sPageButton": "fg-button ui-button "+_stateDefault,
  5746. "sPageButtonActive": "ui-state-disabled",
  5747. "sPageButtonDisabled": "ui-state-disabled",
  5748. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  5749. "ui-buttonset-multi paging_",
  5750. "sSortAsc": _stateDefault+" sorting_asc",
  5751. "sSortDesc": _stateDefault+" sorting_desc",
  5752. "sSortable": _stateDefault+" sorting",
  5753. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  5754. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  5755. "sSortableNone": _stateDefault+" sorting_disabled",
  5756. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  5757. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  5758. "sSortJUI": _sortIcon+"carat-2-n-s",
  5759. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  5760. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  5761. "sSortJUIWrapper": "DataTables_sort_wrapper",
  5762. "sSortIcon": "DataTables_sort_icon",
  5763. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  5764. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  5765. "sHeaderTH": _stateDefault,
  5766. "sFooterTH": _stateDefault,
  5767. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  5768. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  5769. } );
  5770. }());
  5771. var extPagination = DataTable.ext.pager;
  5772. function _numbers ( page, pages ) {
  5773. var
  5774. numbers = [],
  5775. buttons = extPagination.numbers_length,
  5776. half = Math.floor( buttons / 2 ),
  5777. i = 1;
  5778. if ( pages <= buttons ) {
  5779. numbers = _range( 0, pages );
  5780. }
  5781. else if ( page <= half ) {
  5782. numbers = _range( 0, buttons-2 );
  5783. numbers.push( 'ellipsis' );
  5784. numbers.push( pages-1 );
  5785. }
  5786. else if ( page >= pages - 1 - half ) {
  5787. numbers = _range( pages-(buttons-2), pages );
  5788. numbers.splice( 0, 0, 'ellipsis' );
  5789. numbers.splice( 0, 0, 0 );
  5790. }
  5791. else {
  5792. numbers = _range( page-half+2, page+half-1 );
  5793. numbers.push( 'ellipsis' );
  5794. numbers.push( pages-1 );
  5795. numbers.splice( 0, 0, 'ellipsis' );
  5796. numbers.splice( 0, 0, 0 );
  5797. }
  5798. numbers.DT_el = 'span';
  5799. return numbers;
  5800. }
  5801. $.extend( extPagination, {
  5802. simple: function ( page, pages ) {
  5803. return [ 'previous', 'next' ];
  5804. },
  5805. full: function ( page, pages ) {
  5806. return [ 'first', 'previous', 'next', 'last' ];
  5807. },
  5808. numbers: function ( page, pages ) {
  5809. return [ _numbers(page, pages) ];
  5810. },
  5811. simple_numbers: function ( page, pages ) {
  5812. return [ 'previous', _numbers(page, pages), 'next' ];
  5813. },
  5814. full_numbers: function ( page, pages ) {
  5815. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  5816. },
  5817. _numbers: _numbers,
  5818. numbers_length: 7
  5819. } );
  5820. $.extend( true, DataTable.ext.renderer, {
  5821. pageButton: {
  5822. _: function ( settings, host, idx, buttons, page, pages ) {
  5823. var classes = settings.oClasses;
  5824. var lang = settings.oLanguage.oPaginate;
  5825. var btnDisplay, btnClass, counter=0;
  5826. var attach = function( container, buttons ) {
  5827. var i, ien, node, button;
  5828. var clickHandler = function ( e ) {
  5829. _fnPageChange( settings, e.data.action, true );
  5830. };
  5831. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  5832. button = buttons[i];
  5833. if ( $.isArray( button ) ) {
  5834. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  5835. .appendTo( container );
  5836. attach( inner, button );
  5837. }
  5838. else {
  5839. btnDisplay = null;
  5840. btnClass = '';
  5841. switch ( button ) {
  5842. case 'ellipsis':
  5843. container.append('<span class="ellipsis">&#x2026;</span>');
  5844. break;
  5845. case 'first':
  5846. btnDisplay = lang.sFirst;
  5847. btnClass = button + (page > 0 ?
  5848. '' : ' '+classes.sPageButtonDisabled);
  5849. break;
  5850. case 'previous':
  5851. btnDisplay = lang.sPrevious;
  5852. btnClass = button + (page > 0 ?
  5853. '' : ' '+classes.sPageButtonDisabled);
  5854. break;
  5855. case 'next':
  5856. btnDisplay = lang.sNext;
  5857. btnClass = button + (page < pages-1 ?
  5858. '' : ' '+classes.sPageButtonDisabled);
  5859. break;
  5860. case 'last':
  5861. btnDisplay = lang.sLast;
  5862. btnClass = button + (page < pages-1 ?
  5863. '' : ' '+classes.sPageButtonDisabled);
  5864. break;
  5865. default:
  5866. btnDisplay = button + 1;
  5867. btnClass = page === button ?
  5868. classes.sPageButtonActive : '';
  5869. break;
  5870. }
  5871. if ( btnDisplay !== null ) {
  5872. node = $('<a>', {
  5873. 'class': classes.sPageButton+' '+btnClass,
  5874. 'aria-controls': settings.sTableId,
  5875. 'data-dt-idx': counter,
  5876. 'tabindex': settings.iTabIndex,
  5877. 'id': idx === 0 && typeof button === 'string' ?
  5878. settings.sTableId +'_'+ button :
  5879. null
  5880. } )
  5881. .html( btnDisplay )
  5882. .appendTo( container );
  5883. _fnBindAction(
  5884. node, {action: button}, clickHandler
  5885. );
  5886. counter++;
  5887. }
  5888. }
  5889. }
  5890. };
  5891. var activeEl;
  5892. try {
  5893. activeEl = $(host).find(document.activeElement).data('dt-idx');
  5894. }
  5895. catch (e) {}
  5896. attach( $(host).empty(), buttons );
  5897. if ( activeEl ) {
  5898. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  5899. }
  5900. }
  5901. }
  5902. } );
  5903. $.extend( DataTable.ext.type.detect, [
  5904. function ( d, settings )
  5905. {
  5906. var decimal = settings.oLanguage.sDecimal;
  5907. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  5908. },
  5909. function ( d, settings )
  5910. {
  5911. if ( d && !(d instanceof Date) && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
  5912. return null;
  5913. }
  5914. var parsed = Date.parse(d);
  5915. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  5916. },
  5917. function ( d, settings )
  5918. {
  5919. var decimal = settings.oLanguage.sDecimal;
  5920. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  5921. },
  5922. function ( d, settings )
  5923. {
  5924. var decimal = settings.oLanguage.sDecimal;
  5925. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  5926. },
  5927. function ( d, settings )
  5928. {
  5929. var decimal = settings.oLanguage.sDecimal;
  5930. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  5931. },
  5932. function ( d, settings )
  5933. {
  5934. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  5935. 'html' : null;
  5936. }
  5937. ] );
  5938. $.extend( DataTable.ext.type.search, {
  5939. html: function ( data ) {
  5940. return _empty(data) ?
  5941. data :
  5942. typeof data === 'string' ?
  5943. data
  5944. .replace( _re_new_lines, " " )
  5945. .replace( _re_html, "" ) :
  5946. '';
  5947. },
  5948. string: function ( data ) {
  5949. return _empty(data) ?
  5950. data :
  5951. typeof data === 'string' ?
  5952. data.replace( _re_new_lines, " " ) :
  5953. data;
  5954. }
  5955. } );
  5956. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  5957. if ( d !== 0 && (!d || d === '-') ) {
  5958. return -Infinity;
  5959. }
  5960. if ( decimalPlace ) {
  5961. d = _numToDecimal( d, decimalPlace );
  5962. }
  5963. if ( d.replace ) {
  5964. if ( re1 ) {
  5965. d = d.replace( re1, '' );
  5966. }
  5967. if ( re2 ) {
  5968. d = d.replace( re2, '' );
  5969. }
  5970. }
  5971. return d * 1;
  5972. };
  5973. function _addNumericSort ( decimalPlace ) {
  5974. $.each(
  5975. {
  5976. "num": function ( d ) {
  5977. return __numericReplace( d, decimalPlace );
  5978. },
  5979. "num-fmt": function ( d ) {
  5980. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  5981. },
  5982. "html-num": function ( d ) {
  5983. return __numericReplace( d, decimalPlace, _re_html );
  5984. },
  5985. "html-num-fmt": function ( d ) {
  5986. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  5987. }
  5988. },
  5989. function ( key, fn ) {
  5990. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  5991. if ( key.match(/^html\-/) ) {
  5992. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  5993. }
  5994. }
  5995. );
  5996. }
  5997. $.extend( _ext.type.order, {
  5998. "date-pre": function ( d ) {
  5999. return Date.parse( d ) || 0;
  6000. },
  6001. "html-pre": function ( a ) {
  6002. return _empty(a) ?
  6003. '' :
  6004. a.replace ?
  6005. a.replace( /<.*?>/g, "" ).toLowerCase() :
  6006. a+'';
  6007. },
  6008. "string-pre": function ( a ) {
  6009. return _empty(a) ?
  6010. '' :
  6011. typeof a === 'string' ?
  6012. a.toLowerCase() :
  6013. ! a.toString ?
  6014. '' :
  6015. a.toString();
  6016. },
  6017. "string-asc": function ( x, y ) {
  6018. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  6019. },
  6020. "string-desc": function ( x, y ) {
  6021. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  6022. }
  6023. } );
  6024. _addNumericSort( '' );
  6025. $.extend( true, DataTable.ext.renderer, {
  6026. header: {
  6027. _: function ( settings, cell, column, classes ) {
  6028. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  6029. if ( settings !== ctx ) {
  6030. return;
  6031. }
  6032. var colIdx = column.idx;
  6033. cell
  6034. .removeClass(
  6035. column.sSortingClass +' '+
  6036. classes.sSortAsc +' '+
  6037. classes.sSortDesc
  6038. )
  6039. .addClass( columns[ colIdx ] == 'asc' ?
  6040. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  6041. classes.sSortDesc :
  6042. column.sSortingClass
  6043. );
  6044. } );
  6045. },
  6046. jqueryui: function ( settings, cell, column, classes ) {
  6047. $('<div/>')
  6048. .addClass( classes.sSortJUIWrapper )
  6049. .append( cell.contents() )
  6050. .append( $('<span/>')
  6051. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  6052. )
  6053. .appendTo( cell );
  6054. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  6055. if ( settings !== ctx ) {
  6056. return;
  6057. }
  6058. var colIdx = column.idx;
  6059. cell
  6060. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  6061. .addClass( columns[ colIdx ] == 'asc' ?
  6062. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  6063. classes.sSortDesc :
  6064. column.sSortingClass
  6065. );
  6066. cell
  6067. .find( 'span.'+classes.sSortIcon )
  6068. .removeClass(
  6069. classes.sSortJUIAsc +" "+
  6070. classes.sSortJUIDesc +" "+
  6071. classes.sSortJUI +" "+
  6072. classes.sSortJUIAscAllowed +" "+
  6073. classes.sSortJUIDescAllowed
  6074. )
  6075. .addClass( columns[ colIdx ] == 'asc' ?
  6076. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  6077. classes.sSortJUIDesc :
  6078. column.sSortingClassJUI
  6079. );
  6080. } );
  6081. }
  6082. }
  6083. } );
  6084. DataTable.render = {
  6085. number: function ( thousands, decimal, precision, prefix, postfix ) {
  6086. return {
  6087. display: function ( d ) {
  6088. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  6089. return d;
  6090. }
  6091. var negative = d < 0 ? '-' : '';
  6092. d = Math.abs( parseFloat( d ) );
  6093. var intPart = parseInt( d, 10 );
  6094. var floatPart = precision ?
  6095. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  6096. '';
  6097. return negative + (prefix||'') +
  6098. intPart.toString().replace(
  6099. /\B(?=(\d{3})+(?!\d))/g, thousands
  6100. ) +
  6101. floatPart +
  6102. (postfix||'');
  6103. }
  6104. };
  6105. }
  6106. };
  6107. function _fnExternApiFunc (fn)
  6108. {
  6109. return function() {
  6110. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  6111. Array.prototype.slice.call(arguments)
  6112. );
  6113. return DataTable.ext.internal[fn].apply( this, args );
  6114. };
  6115. }
  6116. $.extend( DataTable.ext.internal, {
  6117. _fnExternApiFunc: _fnExternApiFunc,
  6118. _fnBuildAjax: _fnBuildAjax,
  6119. _fnAjaxUpdate: _fnAjaxUpdate,
  6120. _fnAjaxParameters: _fnAjaxParameters,
  6121. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  6122. _fnAjaxDataSrc: _fnAjaxDataSrc,
  6123. _fnAddColumn: _fnAddColumn,
  6124. _fnColumnOptions: _fnColumnOptions,
  6125. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  6126. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  6127. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  6128. _fnVisbleColumns: _fnVisbleColumns,
  6129. _fnGetColumns: _fnGetColumns,
  6130. _fnColumnTypes: _fnColumnTypes,
  6131. _fnApplyColumnDefs: _fnApplyColumnDefs,
  6132. _fnHungarianMap: _fnHungarianMap,
  6133. _fnCamelToHungarian: _fnCamelToHungarian,
  6134. _fnLanguageCompat: _fnLanguageCompat,
  6135. _fnBrowserDetect: _fnBrowserDetect,
  6136. _fnAddData: _fnAddData,
  6137. _fnAddTr: _fnAddTr,
  6138. _fnNodeToDataIndex: _fnNodeToDataIndex,
  6139. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  6140. _fnGetCellData: _fnGetCellData,
  6141. _fnSetCellData: _fnSetCellData,
  6142. _fnSplitObjNotation: _fnSplitObjNotation,
  6143. _fnGetObjectDataFn: _fnGetObjectDataFn,
  6144. _fnSetObjectDataFn: _fnSetObjectDataFn,
  6145. _fnGetDataMaster: _fnGetDataMaster,
  6146. _fnClearTable: _fnClearTable,
  6147. _fnDeleteIndex: _fnDeleteIndex,
  6148. _fnInvalidate: _fnInvalidate,
  6149. _fnGetRowElements: _fnGetRowElements,
  6150. _fnCreateTr: _fnCreateTr,
  6151. _fnBuildHead: _fnBuildHead,
  6152. _fnDrawHead: _fnDrawHead,
  6153. _fnDraw: _fnDraw,
  6154. _fnReDraw: _fnReDraw,
  6155. _fnAddOptionsHtml: _fnAddOptionsHtml,
  6156. _fnDetectHeader: _fnDetectHeader,
  6157. _fnGetUniqueThs: _fnGetUniqueThs,
  6158. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  6159. _fnFilterComplete: _fnFilterComplete,
  6160. _fnFilterCustom: _fnFilterCustom,
  6161. _fnFilterColumn: _fnFilterColumn,
  6162. _fnFilter: _fnFilter,
  6163. _fnFilterCreateSearch: _fnFilterCreateSearch,
  6164. _fnEscapeRegex: _fnEscapeRegex,
  6165. _fnFilterData: _fnFilterData,
  6166. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  6167. _fnUpdateInfo: _fnUpdateInfo,
  6168. _fnInfoMacros: _fnInfoMacros,
  6169. _fnInitialise: _fnInitialise,
  6170. _fnInitComplete: _fnInitComplete,
  6171. _fnLengthChange: _fnLengthChange,
  6172. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  6173. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  6174. _fnPageChange: _fnPageChange,
  6175. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  6176. _fnProcessingDisplay: _fnProcessingDisplay,
  6177. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  6178. _fnScrollDraw: _fnScrollDraw,
  6179. _fnApplyToChildren: _fnApplyToChildren,
  6180. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  6181. _fnThrottle: _fnThrottle,
  6182. _fnConvertToWidth: _fnConvertToWidth,
  6183. _fnGetWidestNode: _fnGetWidestNode,
  6184. _fnGetMaxLenString: _fnGetMaxLenString,
  6185. _fnStringToCss: _fnStringToCss,
  6186. _fnSortFlatten: _fnSortFlatten,
  6187. _fnSort: _fnSort,
  6188. _fnSortAria: _fnSortAria,
  6189. _fnSortListener: _fnSortListener,
  6190. _fnSortAttachListener: _fnSortAttachListener,
  6191. _fnSortingClasses: _fnSortingClasses,
  6192. _fnSortData: _fnSortData,
  6193. _fnSaveState: _fnSaveState,
  6194. _fnLoadState: _fnLoadState,
  6195. _fnSettingsFromNode: _fnSettingsFromNode,
  6196. _fnLog: _fnLog,
  6197. _fnMap: _fnMap,
  6198. _fnBindAction: _fnBindAction,
  6199. _fnCallbackReg: _fnCallbackReg,
  6200. _fnCallbackFire: _fnCallbackFire,
  6201. _fnLengthOverflow: _fnLengthOverflow,
  6202. _fnRenderer: _fnRenderer,
  6203. _fnDataSource: _fnDataSource,
  6204. _fnRowAttributes: _fnRowAttributes,
  6205. _fnCalculateEnd: function () {}
  6206. } );
  6207. $.fn.dataTable = DataTable;
  6208. $.fn.dataTableSettings = DataTable.settings;
  6209. $.fn.dataTableExt = DataTable.ext;
  6210. $.fn.DataTable = function ( opts ) {
  6211. return $(this).dataTable( opts ).api();
  6212. };
  6213. $.each( DataTable, function ( prop, val ) {
  6214. $.fn.DataTable[ prop ] = val;
  6215. } );
  6216. return $.fn.dataTable;
  6217. }));
  6218. }(window, document));