12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230 |
- var TableTools;
- (function(window, document, undefined) {
- var factory = function( $, DataTable ) {
- "use strict";
- var ZeroClipboard_TableTools = {
- version: "1.0.4-TableTools2",
- clients: {},
- moviePath: '',
- nextId: 1,
- $: function(thingy) {
-
- if (typeof(thingy) == 'string') {
- thingy = document.getElementById(thingy);
- }
- if (!thingy.addClass) {
-
- thingy.hide = function() { this.style.display = 'none'; };
- thingy.show = function() { this.style.display = ''; };
- thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
- thingy.removeClass = function(name) {
- this.className = this.className.replace( new RegExp("\\s*" + name + "\\s*"), " ").replace(/^\s+/, '').replace(/\s+$/, '');
- };
- thingy.hasClass = function(name) {
- return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
- };
- }
- return thingy;
- },
- setMoviePath: function(path) {
-
- this.moviePath = path;
- },
- dispatch: function(id, eventName, args) {
-
- var client = this.clients[id];
- if (client) {
- client.receiveEvent(eventName, args);
- }
- },
- register: function(id, client) {
-
- this.clients[id] = client;
- },
- getDOMObjectPosition: function(obj) {
-
- var info = {
- left: 0,
- top: 0,
- width: obj.width ? obj.width : obj.offsetWidth,
- height: obj.height ? obj.height : obj.offsetHeight
- };
- if ( obj.style.width !== "" ) {
- info.width = obj.style.width.replace("px","");
- }
- if ( obj.style.height !== "" ) {
- info.height = obj.style.height.replace("px","");
- }
- while (obj) {
- info.left += obj.offsetLeft;
- info.top += obj.offsetTop;
- obj = obj.offsetParent;
- }
- return info;
- },
- Client: function(elem) {
-
- this.handlers = {};
-
- this.id = ZeroClipboard_TableTools.nextId++;
- this.movieId = 'ZeroClipboard_TableToolsMovie_' + this.id;
-
- ZeroClipboard_TableTools.register(this.id, this);
-
- if (elem) {
- this.glue(elem);
- }
- }
- };
- ZeroClipboard_TableTools.Client.prototype = {
- id: 0,
- ready: false,
- movie: null,
- clipText: '',
- fileName: '',
- action: 'copy',
- handCursorEnabled: true,
- cssEffects: true,
- handlers: null,
- sized: false,
- glue: function(elem, title) {
-
-
- this.domElement = ZeroClipboard_TableTools.$(elem);
-
- var zIndex = 99;
- if (this.domElement.style.zIndex) {
- zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
- }
-
- var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
-
- this.div = document.createElement('div');
- var style = this.div.style;
- style.position = 'absolute';
- style.left = '0px';
- style.top = '0px';
- style.width = (box.width) + 'px';
- style.height = box.height + 'px';
- style.zIndex = zIndex;
- if ( typeof title != "undefined" && title !== "" ) {
- this.div.title = title;
- }
- if ( box.width !== 0 && box.height !== 0 ) {
- this.sized = true;
- }
-
- if ( this.domElement ) {
- this.domElement.appendChild(this.div);
- this.div.innerHTML = this.getHTML( box.width, box.height ).replace(/&/g, '&');
- }
- },
- positionElement: function() {
- var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
- var style = this.div.style;
- style.position = 'absolute';
-
-
- style.width = box.width + 'px';
- style.height = box.height + 'px';
- if ( box.width !== 0 && box.height !== 0 ) {
- this.sized = true;
- } else {
- return;
- }
- var flash = this.div.childNodes[0];
- flash.width = box.width;
- flash.height = box.height;
- },
- getHTML: function(width, height) {
-
- var html = '';
- var flashvars = 'id=' + this.id +
- '&width=' + width +
- '&height=' + height;
- if (navigator.userAgent.match(/MSIE/)) {
-
- var protocol = location.href.match(/^https/i) ? 'https://' : 'http://';
- html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+protocol+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="'+width+'" height="'+height+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard_TableTools.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><param name="wmode" value="transparent"/></object>';
- }
- else {
-
- html += '<embed id="'+this.movieId+'" src="'+ZeroClipboard_TableTools.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" wmode="transparent" />';
- }
- return html;
- },
- hide: function() {
-
- if (this.div) {
- this.div.style.left = '-2000px';
- }
- },
- show: function() {
-
- this.reposition();
- },
- destroy: function() {
-
- if (this.domElement && this.div) {
- this.hide();
- this.div.innerHTML = '';
- var body = document.getElementsByTagName('body')[0];
- try { body.removeChild( this.div ); } catch(e) {}
- this.domElement = null;
- this.div = null;
- }
- },
- reposition: function(elem) {
-
-
- if (elem) {
- this.domElement = ZeroClipboard_TableTools.$(elem);
- if (!this.domElement) {
- this.hide();
- }
- }
- if (this.domElement && this.div) {
- var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
- var style = this.div.style;
- style.left = '' + box.left + 'px';
- style.top = '' + box.top + 'px';
- }
- },
- clearText: function() {
-
- this.clipText = '';
- if (this.ready) {
- this.movie.clearText();
- }
- },
- appendText: function(newText) {
-
- this.clipText += newText;
- if (this.ready) { this.movie.appendText(newText) ;}
- },
- setText: function(newText) {
-
- this.clipText = newText;
- if (this.ready) { this.movie.setText(newText) ;}
- },
- setCharSet: function(charSet) {
-
- this.charSet = charSet;
- if (this.ready) { this.movie.setCharSet(charSet) ;}
- },
- setBomInc: function(bomInc) {
-
- this.incBom = bomInc;
- if (this.ready) { this.movie.setBomInc(bomInc) ;}
- },
- setFileName: function(newText) {
-
- this.fileName = newText;
- if (this.ready) {
- this.movie.setFileName(newText);
- }
- },
- setAction: function(newText) {
-
- this.action = newText;
- if (this.ready) {
- this.movie.setAction(newText);
- }
- },
- addEventListener: function(eventName, func) {
-
-
- eventName = eventName.toString().toLowerCase().replace(/^on/, '');
- if (!this.handlers[eventName]) {
- this.handlers[eventName] = [];
- }
- this.handlers[eventName].push(func);
- },
- setHandCursor: function(enabled) {
-
- this.handCursorEnabled = enabled;
- if (this.ready) {
- this.movie.setHandCursor(enabled);
- }
- },
- setCSSEffects: function(enabled) {
-
- this.cssEffects = !!enabled;
- },
- receiveEvent: function(eventName, args) {
- var self;
-
- eventName = eventName.toString().toLowerCase().replace(/^on/, '');
-
- switch (eventName) {
- case 'load':
-
-
- this.movie = document.getElementById(this.movieId);
- if (!this.movie) {
- self = this;
- setTimeout( function() { self.receiveEvent('load', null); }, 1 );
- return;
- }
-
- if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
- self = this;
- setTimeout( function() { self.receiveEvent('load', null); }, 100 );
- this.ready = true;
- return;
- }
- this.ready = true;
- this.movie.clearText();
- this.movie.appendText( this.clipText );
- this.movie.setFileName( this.fileName );
- this.movie.setAction( this.action );
- this.movie.setCharSet( this.charSet );
- this.movie.setBomInc( this.incBom );
- this.movie.setHandCursor( this.handCursorEnabled );
- break;
- case 'mouseover':
- if (this.domElement && this.cssEffects) {
-
- if (this.recoverActive) {
- this.domElement.addClass('active');
- }
- }
- break;
- case 'mouseout':
- if (this.domElement && this.cssEffects) {
- this.recoverActive = false;
- if (this.domElement.hasClass('active')) {
- this.domElement.removeClass('active');
- this.recoverActive = true;
- }
-
- }
- break;
- case 'mousedown':
- if (this.domElement && this.cssEffects) {
- this.domElement.addClass('active');
- }
- break;
- case 'mouseup':
- if (this.domElement && this.cssEffects) {
- this.domElement.removeClass('active');
- this.recoverActive = false;
- }
- break;
- }
- if (this.handlers[eventName]) {
- for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
- var func = this.handlers[eventName][idx];
- if (typeof(func) == 'function') {
-
- func(this, args);
- }
- else if ((typeof(func) == 'object') && (func.length == 2)) {
-
- func[0][ func[1] ](this, args);
- }
- else if (typeof(func) == 'string') {
-
- window[func](this, args);
- }
- }
- }
- }
- };
- window.ZeroClipboard_TableTools = ZeroClipboard_TableTools;
- (function($, window, document) {
- TableTools = function( oDT, oOpts )
- {
-
- if ( ! this instanceof TableTools )
- {
- alert( "Warning: TableTools must be initialised with the keyword 'new'" );
- }
-
-
- var dtSettings = $.fn.dataTable.Api ?
- new $.fn.dataTable.Api( oDT ).settings()[0] :
- oDT.fnSettings();
-
-
- this.s = {
-
- "that": this,
-
- "dt": dtSettings,
-
- "print": {
-
- "saveStart": -1,
-
- "saveLength": -1,
-
- "saveScroll": -1,
-
- "funcEnd": function () {}
- },
-
- "buttonCounter": 0,
-
- "select": {
-
- "type": "",
-
- "selected": [],
-
- "preRowSelect": null,
-
- "postSelected": null,
-
- "postDeselected": null,
-
- "all": false,
-
- "selectedClass": ""
- },
-
- "custom": {},
-
- "swfPath": "",
-
- "buttonSet": [],
-
- "master": false,
-
- "tags": {}
- };
-
- this.dom = {
-
- "container": null,
-
- "table": null,
-
- "print": {
-
- "hidden": [],
-
- "message": null
- },
-
- "collection": {
-
- "collection": null,
-
- "background": null
- }
- };
-
- this.classes = $.extend( true, {}, TableTools.classes );
- if ( this.s.dt.bJUI )
- {
- $.extend( true, this.classes, TableTools.classes_themeroller );
- }
-
-
- this.fnSettings = function () {
- return this.s;
- };
-
- if ( typeof oOpts == 'undefined' )
- {
- oOpts = {};
- }
- TableTools._aInstances.push( this );
- this._fnConstruct( oOpts );
- return this;
- };
- TableTools.prototype = {
-
-
- "fnGetSelected": function ( filtered )
- {
- var
- out = [],
- data = this.s.dt.aoData,
- displayed = this.s.dt.aiDisplay,
- i, iLen;
- if ( filtered )
- {
-
- for ( i=0, iLen=displayed.length ; i<iLen ; i++ )
- {
- if ( data[ displayed[i] ]._DTTT_selected )
- {
- out.push( data[ displayed[i] ].nTr );
- }
- }
- }
- else
- {
-
- for ( i=0, iLen=data.length ; i<iLen ; i++ )
- {
- if ( data[i]._DTTT_selected )
- {
- out.push( data[i].nTr );
- }
- }
- }
- return out;
- },
-
- "fnGetSelectedData": function ()
- {
- var out = [];
- var data=this.s.dt.aoData;
- var i, iLen;
- for ( i=0, iLen=data.length ; i<iLen ; i++ )
- {
- if ( data[i]._DTTT_selected )
- {
- out.push( this.s.dt.oInstance.fnGetData(i) );
- }
- }
- return out;
- },
-
- "fnGetSelectedIndexes": function ( filtered )
- {
- var
- out = [],
- data = this.s.dt.aoData,
- displayed = this.s.dt.aiDisplay,
- i, iLen;
- if ( filtered )
- {
-
- for ( i=0, iLen=displayed.length ; i<iLen ; i++ )
- {
- if ( data[ displayed[i] ]._DTTT_selected )
- {
- out.push( displayed[i] );
- }
- }
- }
- else
- {
-
- for ( i=0, iLen=data.length ; i<iLen ; i++ )
- {
- if ( data[i]._DTTT_selected )
- {
- out.push( i );
- }
- }
- }
- return out;
- },
-
- "fnIsSelected": function ( n )
- {
- var pos = this.s.dt.oInstance.fnGetPosition( n );
- return (this.s.dt.aoData[pos]._DTTT_selected===true) ? true : false;
- },
-
- "fnSelectAll": function ( filtered )
- {
- this._fnRowSelect( filtered ?
- this.s.dt.aiDisplay :
- this.s.dt.aoData
- );
- },
-
- "fnSelectNone": function ( filtered )
- {
- this._fnRowDeselect( this.fnGetSelectedIndexes(filtered) );
- },
-
- "fnSelect": function ( n )
- {
- if ( this.s.select.type == "single" )
- {
- this.fnSelectNone();
- this._fnRowSelect( n );
- }
- else
- {
- this._fnRowSelect( n );
- }
- },
-
- "fnDeselect": function ( n )
- {
- this._fnRowDeselect( n );
- },
-
- "fnGetTitle": function( oConfig )
- {
- var sTitle = "";
- if ( typeof oConfig.sTitle != 'undefined' && oConfig.sTitle !== "" ) {
- sTitle = oConfig.sTitle;
- } else {
- var anTitle = document.getElementsByTagName('title');
- if ( anTitle.length > 0 )
- {
- sTitle = anTitle[0].innerHTML;
- }
- }
-
- if ( "\u00A1".toString().length < 4 ) {
- return sTitle.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g, "");
- } else {
- return sTitle.replace(/[^a-zA-Z0-9_\.,\-_ !\(\)]/g, "");
- }
- },
-
- "fnCalcColRatios": function ( oConfig )
- {
- var
- aoCols = this.s.dt.aoColumns,
- aColumnsInc = this._fnColumnTargets( oConfig.mColumns ),
- aColWidths = [],
- iWidth = 0, iTotal = 0, i, iLen;
- for ( i=0, iLen=aColumnsInc.length ; i<iLen ; i++ )
- {
- if ( aColumnsInc[i] )
- {
- iWidth = aoCols[i].nTh.offsetWidth;
- iTotal += iWidth;
- aColWidths.push( iWidth );
- }
- }
- for ( i=0, iLen=aColWidths.length ; i<iLen ; i++ )
- {
- aColWidths[i] = aColWidths[i] / iTotal;
- }
- return aColWidths.join('\t');
- },
-
- "fnGetTableData": function ( oConfig )
- {
-
- if ( this.s.dt )
- {
- return this._fnGetDataTablesData( oConfig );
- }
- },
-
- "fnSetText": function ( clip, text )
- {
- this._fnFlashSetText( clip, text );
- },
-
- "fnResizeButtons": function ()
- {
- for ( var cli in ZeroClipboard_TableTools.clients )
- {
- if ( cli )
- {
- var client = ZeroClipboard_TableTools.clients[cli];
- if ( typeof client.domElement != 'undefined' &&
- client.domElement.parentNode )
- {
- client.positionElement();
- }
- }
- }
- },
-
- "fnResizeRequired": function ()
- {
- for ( var cli in ZeroClipboard_TableTools.clients )
- {
- if ( cli )
- {
- var client = ZeroClipboard_TableTools.clients[cli];
- if ( typeof client.domElement != 'undefined' &&
- client.domElement.parentNode == this.dom.container &&
- client.sized === false )
- {
- return true;
- }
- }
- }
- return false;
- },
-
- "fnPrint": function ( bView, oConfig )
- {
- if ( oConfig === undefined )
- {
- oConfig = {};
- }
- if ( bView === undefined || bView )
- {
- this._fnPrintStart( oConfig );
- }
- else
- {
- this._fnPrintEnd();
- }
- },
-
- "fnInfo": function ( message, time ) {
- var info = $('<div/>')
- .addClass( this.classes.print.info )
- .html( message )
- .appendTo( 'body' );
- setTimeout( function() {
- info.fadeOut( "normal", function() {
- info.remove();
- } );
- }, time );
- },
-
- "fnContainer": function () {
- return this.dom.container;
- },
-
-
- "_fnConstruct": function ( oOpts )
- {
- var that = this;
- this._fnCustomiseSettings( oOpts );
-
- this.dom.container = document.createElement( this.s.tags.container );
- this.dom.container.className = this.classes.container;
-
- if ( this.s.select.type != 'none' )
- {
- this._fnRowSelectConfig();
- }
-
- this._fnButtonDefinations( this.s.buttonSet, this.dom.container );
-
- this.s.dt.aoDestroyCallback.push( {
- "sName": "TableTools",
- "fn": function () {
- $(that.s.dt.nTBody)
- .off( 'click.DTTT_Select', that.s.custom.sRowSelector )
- .off( 'mousedown.DTTT_Select', 'tr' )
- .off( 'mouseup.DTTT_Select', 'tr' );
- $(that.dom.container).empty();
-
- var idx = $.inArray( that, TableTools._aInstances );
- if ( idx !== -1 ) {
- TableTools._aInstances.splice( idx, 1 );
- }
- }
- } );
- },
-
- "_fnCustomiseSettings": function ( oOpts )
- {
-
- if ( typeof this.s.dt._TableToolsInit == 'undefined' )
- {
- this.s.master = true;
- this.s.dt._TableToolsInit = true;
- }
-
- this.dom.table = this.s.dt.nTable;
-
- this.s.custom = $.extend( {}, TableTools.DEFAULTS, oOpts );
-
- this.s.swfPath = this.s.custom.sSwfPath;
- if ( typeof ZeroClipboard_TableTools != 'undefined' )
- {
- ZeroClipboard_TableTools.moviePath = this.s.swfPath;
- }
-
- this.s.select.type = this.s.custom.sRowSelect;
- this.s.select.preRowSelect = this.s.custom.fnPreRowSelect;
- this.s.select.postSelected = this.s.custom.fnRowSelected;
- this.s.select.postDeselected = this.s.custom.fnRowDeselected;
-
- if ( this.s.custom.sSelectedClass )
- {
- this.classes.select.row = this.s.custom.sSelectedClass;
- }
- this.s.tags = this.s.custom.oTags;
-
- this.s.buttonSet = this.s.custom.aButtons;
- },
-
- "_fnButtonDefinations": function ( buttonSet, wrapper )
- {
- var buttonDef;
- for ( var i=0, iLen=buttonSet.length ; i<iLen ; i++ )
- {
- if ( typeof buttonSet[i] == "string" )
- {
- if ( typeof TableTools.BUTTONS[ buttonSet[i] ] == 'undefined' )
- {
- alert( "TableTools: Warning - unknown button type: "+buttonSet[i] );
- continue;
- }
- buttonDef = $.extend( {}, TableTools.BUTTONS[ buttonSet[i] ], true );
- }
- else
- {
- if ( typeof TableTools.BUTTONS[ buttonSet[i].sExtends ] == 'undefined' )
- {
- alert( "TableTools: Warning - unknown button type: "+buttonSet[i].sExtends );
- continue;
- }
- var o = $.extend( {}, TableTools.BUTTONS[ buttonSet[i].sExtends ], true );
- buttonDef = $.extend( o, buttonSet[i], true );
- }
- var button = this._fnCreateButton(
- buttonDef,
- $(wrapper).hasClass(this.classes.collection.container)
- );
- if ( button ) {
- wrapper.appendChild( button );
- }
- }
- },
-
- "_fnCreateButton": function ( oConfig, bCollectionButton )
- {
- var nButton = this._fnButtonBase( oConfig, bCollectionButton );
- if ( oConfig.sAction.match(/flash/) )
- {
- if ( ! this._fnHasFlash() ) {
- return false;
- }
- this._fnFlashConfig( nButton, oConfig );
- }
- else if ( oConfig.sAction == "text" )
- {
- this._fnTextConfig( nButton, oConfig );
- }
- else if ( oConfig.sAction == "div" )
- {
- this._fnTextConfig( nButton, oConfig );
- }
- else if ( oConfig.sAction == "collection" )
- {
- this._fnTextConfig( nButton, oConfig );
- this._fnCollectionConfig( nButton, oConfig );
- }
- if ( this.s.dt.iTabIndex !== -1 ) {
- $(nButton)
- .attr( 'tabindex', this.s.dt.iTabIndex )
- .attr( 'aria-controls', this.s.dt.sTableId )
- .on( 'keyup.DTTT', function (e) {
-
-
-
- if ( e.keyCode === 13 ) {
- e.stopPropagation();
- $(this).trigger( 'click' );
- }
- } )
- .on( 'mousedown.DTTT', function (e) {
-
-
-
-
-
-
- if ( ! oConfig.sAction.match(/flash/) ) {
- e.preventDefault();
- }
- } );
- }
- return nButton;
- },
-
- "_fnButtonBase": function ( o, bCollectionButton )
- {
- var sTag, sLiner, sClass;
- if ( bCollectionButton )
- {
- sTag = o.sTag && o.sTag !== "default" ? o.sTag : this.s.tags.collection.button;
- sLiner = o.sLinerTag && o.sLinerTag !== "default" ? o.sLiner : this.s.tags.collection.liner;
- sClass = this.classes.collection.buttons.normal;
- }
- else
- {
- sTag = o.sTag && o.sTag !== "default" ? o.sTag : this.s.tags.button;
- sLiner = o.sLinerTag && o.sLinerTag !== "default" ? o.sLiner : this.s.tags.liner;
- sClass = this.classes.buttons.normal;
- }
- var
- nButton = document.createElement( sTag ),
- nSpan = document.createElement( sLiner ),
- masterS = this._fnGetMasterSettings();
- nButton.className = sClass+" "+o.sButtonClass;
- nButton.setAttribute('id', "ToolTables_"+this.s.dt.sInstance+"_"+masterS.buttonCounter );
- nButton.appendChild( nSpan );
- nSpan.innerHTML = o.sButtonText;
- masterS.buttonCounter++;
- return nButton;
- },
-
- "_fnGetMasterSettings": function ()
- {
- if ( this.s.master )
- {
- return this.s;
- }
- else
- {
-
- var instances = TableTools._aInstances;
- for ( var i=0, iLen=instances.length ; i<iLen ; i++ )
- {
- if ( this.dom.table == instances[i].s.dt.nTable )
- {
- return instances[i].s;
- }
- }
- }
- },
-
-
- "_fnCollectionConfig": function ( nButton, oConfig )
- {
- var nHidden = document.createElement( this.s.tags.collection.container );
- nHidden.style.display = "none";
- nHidden.className = this.classes.collection.container;
- oConfig._collection = nHidden;
- document.body.appendChild( nHidden );
- this._fnButtonDefinations( oConfig.aButtons, nHidden );
- },
-
- "_fnCollectionShow": function ( nButton, oConfig )
- {
- var
- that = this,
- oPos = $(nButton).offset(),
- nHidden = oConfig._collection,
- iDivX = oPos.left,
- iDivY = oPos.top + $(nButton).outerHeight(),
- iWinHeight = $(window).height(), iDocHeight = $(document).height(),
- iWinWidth = $(window).width(), iDocWidth = $(document).width();
- nHidden.style.position = "absolute";
- nHidden.style.left = iDivX+"px";
- nHidden.style.top = iDivY+"px";
- nHidden.style.display = "block";
- $(nHidden).css('opacity',0);
- var nBackground = document.createElement('div');
- nBackground.style.position = "absolute";
- nBackground.style.left = "0px";
- nBackground.style.top = "0px";
- nBackground.style.height = ((iWinHeight>iDocHeight)? iWinHeight : iDocHeight) +"px";
- nBackground.style.width = ((iWinWidth>iDocWidth)? iWinWidth : iDocWidth) +"px";
- nBackground.className = this.classes.collection.background;
- $(nBackground).css('opacity',0);
- document.body.appendChild( nBackground );
- document.body.appendChild( nHidden );
-
- var iDivWidth = $(nHidden).outerWidth();
- var iDivHeight = $(nHidden).outerHeight();
- if ( iDivX + iDivWidth > iDocWidth )
- {
- nHidden.style.left = (iDocWidth-iDivWidth)+"px";
- }
- if ( iDivY + iDivHeight > iDocHeight )
- {
- nHidden.style.top = (iDivY-iDivHeight-$(nButton).outerHeight())+"px";
- }
- this.dom.collection.collection = nHidden;
- this.dom.collection.background = nBackground;
-
- setTimeout( function () {
- $(nHidden).animate({"opacity": 1}, 500);
- $(nBackground).animate({"opacity": 0.25}, 500);
- }, 10 );
-
- this.fnResizeButtons();
-
- $(nBackground).click( function () {
- that._fnCollectionHide.call( that, null, null );
- } );
- },
-
- "_fnCollectionHide": function ( nButton, oConfig )
- {
- if ( oConfig !== null && oConfig.sExtends == 'collection' )
- {
- return;
- }
- if ( this.dom.collection.collection !== null )
- {
- $(this.dom.collection.collection).animate({"opacity": 0}, 500, function (e) {
- this.style.display = "none";
- } );
- $(this.dom.collection.background).animate({"opacity": 0}, 500, function (e) {
- this.parentNode.removeChild( this );
- } );
- this.dom.collection.collection = null;
- this.dom.collection.background = null;
- }
- },
-
-
- "_fnRowSelectConfig": function ()
- {
- if ( this.s.master )
- {
- var
- that = this,
- i, iLen,
- dt = this.s.dt,
- aoOpenRows = this.s.dt.aoOpenRows;
- $(dt.nTable).addClass( this.classes.select.table );
-
-
-
- if ( this.s.select.type === 'os' ) {
- $(dt.nTBody).on( 'mousedown.DTTT_Select', 'tr', function(e) {
- if ( e.shiftKey ) {
- $(dt.nTBody)
- .css( '-moz-user-select', 'none' )
- .one('selectstart.DTTT_Select', 'tr', function () {
- return false;
- } );
- }
- } );
- $(dt.nTBody).on( 'mouseup.DTTT_Select', 'tr', function(e) {
- $(dt.nTBody).css( '-moz-user-select', '' );
- } );
- }
-
- $(dt.nTBody).on( 'click.DTTT_Select', this.s.custom.sRowSelector, function(e) {
- var row = this.nodeName.toLowerCase() === 'tr' ?
- this :
- $(this).parents('tr')[0];
- var select = that.s.select;
- var pos = that.s.dt.oInstance.fnGetPosition( row );
-
- if ( row.parentNode != dt.nTBody ) {
- return;
- }
-
- if ( dt.oInstance.fnGetData(row) === null ) {
- return;
- }
-
-
- if ( select.type == 'os' ) {
- if ( e.ctrlKey || e.metaKey ) {
-
- if ( that.fnIsSelected( row ) ) {
- that._fnRowDeselect( row, e );
- }
- else {
- that._fnRowSelect( row, e );
- }
- }
- else if ( e.shiftKey ) {
-
-
- var rowIdxs = that.s.dt.aiDisplay.slice();
- var idx1 = $.inArray( select.lastRow, rowIdxs );
- var idx2 = $.inArray( pos, rowIdxs );
- if ( that.fnGetSelected().length === 0 || idx1 === -1 ) {
-
-
- rowIdxs.splice( $.inArray( pos, rowIdxs )+1, rowIdxs.length );
- }
- else {
-
- if ( idx1 > idx2 ) {
- var tmp = idx2;
- idx2 = idx1;
- idx1 = tmp;
- }
- rowIdxs.splice( idx2+1, rowIdxs.length );
- rowIdxs.splice( 0, idx1 );
- }
- if ( ! that.fnIsSelected( row ) ) {
-
- that._fnRowSelect( rowIdxs, e );
- }
- else {
-
- rowIdxs.splice( $.inArray( pos, rowIdxs ), 1 );
- that._fnRowDeselect( rowIdxs, e );
- }
- }
- else {
-
-
- if ( that.fnIsSelected( row ) && that.fnGetSelected().length === 1 ) {
- that._fnRowDeselect( row, e );
- }
- else {
- that.fnSelectNone();
- that._fnRowSelect( row, e );
- }
- }
- }
- else if ( that.fnIsSelected( row ) ) {
- that._fnRowDeselect( row, e );
- }
- else if ( select.type == "single" ) {
- that.fnSelectNone();
- that._fnRowSelect( row, e );
- }
- else if ( select.type == "multi" ) {
- that._fnRowSelect( row, e );
- }
- select.lastRow = pos;
- } );
-
-
-
- dt.oApi._fnCallbackReg( dt, 'aoRowCreatedCallback', function (tr, data, index) {
- if ( dt.aoData[index]._DTTT_selected ) {
- $(tr).addClass( that.classes.select.row );
- }
- }, 'TableTools-SelectAll' );
- }
- },
-
- "_fnRowSelect": function ( src, e )
- {
- var
- that = this,
- data = this._fnSelectData( src ),
- firstTr = data.length===0 ? null : data[0].nTr,
- anSelected = [],
- i, len;
-
- for ( i=0, len=data.length ; i<len ; i++ )
- {
- if ( data[i].nTr )
- {
- anSelected.push( data[i].nTr );
- }
- }
-
- if ( this.s.select.preRowSelect !== null && !this.s.select.preRowSelect.call(this, e, anSelected, true) )
- {
- return;
- }
-
- for ( i=0, len=data.length ; i<len ; i++ )
- {
- data[i]._DTTT_selected = true;
- if ( data[i].nTr )
- {
- $(data[i].nTr).addClass( that.classes.select.row );
- }
- }
-
- if ( this.s.select.postSelected !== null )
- {
- this.s.select.postSelected.call( this, anSelected );
- }
- TableTools._fnEventDispatch( this, 'select', anSelected, true );
- },
-
- "_fnRowDeselect": function ( src, e )
- {
- var
- that = this,
- data = this._fnSelectData( src ),
- firstTr = data.length===0 ? null : data[0].nTr,
- anDeselectedTrs = [],
- i, len;
-
- for ( i=0, len=data.length ; i<len ; i++ )
- {
- if ( data[i].nTr )
- {
- anDeselectedTrs.push( data[i].nTr );
- }
- }
-
- if ( this.s.select.preRowSelect !== null && !this.s.select.preRowSelect.call(this, e, anDeselectedTrs, false) )
- {
- return;
- }
-
- for ( i=0, len=data.length ; i<len ; i++ )
- {
- data[i]._DTTT_selected = false;
- if ( data[i].nTr )
- {
- $(data[i].nTr).removeClass( that.classes.select.row );
- }
- }
-
- if ( this.s.select.postDeselected !== null )
- {
- this.s.select.postDeselected.call( this, anDeselectedTrs );
- }
- TableTools._fnEventDispatch( this, 'select', anDeselectedTrs, false );
- },
-
- "_fnSelectData": function ( src )
- {
- var out = [], pos, i, iLen;
- if ( src.nodeName )
- {
-
- pos = this.s.dt.oInstance.fnGetPosition( src );
- out.push( this.s.dt.aoData[pos] );
- }
- else if ( typeof src.length !== 'undefined' )
- {
-
- for ( i=0, iLen=src.length ; i<iLen ; i++ )
- {
- if ( src[i].nodeName )
- {
- pos = this.s.dt.oInstance.fnGetPosition( src[i] );
- out.push( this.s.dt.aoData[pos] );
- }
- else if ( typeof src[i] === 'number' )
- {
- out.push( this.s.dt.aoData[ src[i] ] );
- }
- else
- {
- out.push( src[i] );
- }
- }
- return out;
- }
- else if ( typeof src === 'number' )
- {
- out.push(this.s.dt.aoData[src]);
- }
- else
- {
-
- out.push( src );
- }
- return out;
- },
-
-
- "_fnTextConfig": function ( nButton, oConfig )
- {
- var that = this;
- if ( oConfig.fnInit !== null )
- {
- oConfig.fnInit.call( this, nButton, oConfig );
- }
- if ( oConfig.sToolTip !== "" )
- {
- nButton.title = oConfig.sToolTip;
- }
- $(nButton).hover( function () {
- if ( oConfig.fnMouseover !== null )
- {
- oConfig.fnMouseover.call( this, nButton, oConfig, null );
- }
- }, function () {
- if ( oConfig.fnMouseout !== null )
- {
- oConfig.fnMouseout.call( this, nButton, oConfig, null );
- }
- } );
- if ( oConfig.fnSelect !== null )
- {
- TableTools._fnEventListen( this, 'select', function (n) {
- oConfig.fnSelect.call( that, nButton, oConfig, n );
- } );
- }
- $(nButton).click( function (e) {
-
- if ( oConfig.fnClick !== null )
- {
- oConfig.fnClick.call( that, nButton, oConfig, null, e );
- }
-
- if ( oConfig.fnComplete !== null )
- {
- oConfig.fnComplete.call( that, nButton, oConfig, null, null );
- }
- that._fnCollectionHide( nButton, oConfig );
- } );
- },
-
-
-
- "_fnHasFlash": function ()
- {
- try {
- var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
- if (fo) {
- return true;
- }
- }
- catch (e) {
- if (
- navigator.mimeTypes &&
- navigator.mimeTypes['application/x-shockwave-flash'] !== undefined &&
- navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin
- ) {
- return true;
- }
- }
- return false;
- },
-
- "_fnFlashConfig": function ( nButton, oConfig )
- {
- var that = this;
- var flash = new ZeroClipboard_TableTools.Client();
- if ( oConfig.fnInit !== null )
- {
- oConfig.fnInit.call( this, nButton, oConfig );
- }
- flash.setHandCursor( true );
- if ( oConfig.sAction == "flash_save" )
- {
- flash.setAction( 'save' );
- flash.setCharSet( (oConfig.sCharSet=="utf16le") ? 'UTF16LE' : 'UTF8' );
- flash.setBomInc( oConfig.bBomInc );
- flash.setFileName( oConfig.sFileName.replace('*', this.fnGetTitle(oConfig)) );
- }
- else if ( oConfig.sAction == "flash_pdf" )
- {
- flash.setAction( 'pdf' );
- flash.setFileName( oConfig.sFileName.replace('*', this.fnGetTitle(oConfig)) );
- }
- else
- {
- flash.setAction( 'copy' );
- }
- flash.addEventListener('mouseOver', function(client) {
- if ( oConfig.fnMouseover !== null )
- {
- oConfig.fnMouseover.call( that, nButton, oConfig, flash );
- }
- } );
- flash.addEventListener('mouseOut', function(client) {
- if ( oConfig.fnMouseout !== null )
- {
- oConfig.fnMouseout.call( that, nButton, oConfig, flash );
- }
- } );
- flash.addEventListener('mouseDown', function(client) {
- if ( oConfig.fnClick !== null )
- {
- oConfig.fnClick.call( that, nButton, oConfig, flash );
- }
- } );
- flash.addEventListener('complete', function (client, text) {
- if ( oConfig.fnComplete !== null )
- {
- oConfig.fnComplete.call( that, nButton, oConfig, flash, text );
- }
- that._fnCollectionHide( nButton, oConfig );
- } );
- if ( oConfig.fnSelect !== null )
- {
- TableTools._fnEventListen( this, 'select', function (n) {
- oConfig.fnSelect.call( that, nButton, oConfig, n );
- } );
- }
- this._fnFlashGlue( flash, nButton, oConfig.sToolTip );
- },
-
- "_fnFlashGlue": function ( flash, node, text )
- {
- var that = this;
- var id = node.getAttribute('id');
- if ( document.getElementById(id) )
- {
- flash.glue( node, text );
- }
- else
- {
- setTimeout( function () {
- that._fnFlashGlue( flash, node, text );
- }, 100 );
- }
- },
-
- "_fnFlashSetText": function ( clip, sData )
- {
- var asData = this._fnChunkData( sData, 8192 );
- clip.clearText();
- for ( var i=0, iLen=asData.length ; i<iLen ; i++ )
- {
- clip.appendText( asData[i] );
- }
- },
-
-
- "_fnColumnTargets": function ( mColumns )
- {
- var aColumns = [];
- var dt = this.s.dt;
- var i, iLen;
- var columns = dt.aoColumns;
- var columnCount = columns.length;
- if ( typeof mColumns == "function" )
- {
- var a = mColumns.call( this, dt );
- for ( i=0, iLen=columnCount ; i<iLen ; i++ )
- {
- aColumns.push( $.inArray( i, a ) !== -1 ? true : false );
- }
- }
- else if ( typeof mColumns == "object" )
- {
- for ( i=0, iLen=columnCount ; i<iLen ; i++ )
- {
- aColumns.push( false );
- }
- for ( i=0, iLen=mColumns.length ; i<iLen ; i++ )
- {
- aColumns[ mColumns[i] ] = true;
- }
- }
- else if ( mColumns == "visible" )
- {
- for ( i=0, iLen=columnCount ; i<iLen ; i++ )
- {
- aColumns.push( columns[i].bVisible ? true : false );
- }
- }
- else if ( mColumns == "hidden" )
- {
- for ( i=0, iLen=columnCount ; i<iLen ; i++ )
- {
- aColumns.push( columns[i].bVisible ? false : true );
- }
- }
- else if ( mColumns == "sortable" )
- {
- for ( i=0, iLen=columnCount ; i<iLen ; i++ )
- {
- aColumns.push( columns[i].bSortable ? true : false );
- }
- }
- else
- {
- for ( i=0, iLen=columnCount ; i<iLen ; i++ )
- {
- aColumns.push( true );
- }
- }
- return aColumns;
- },
-
- "_fnNewline": function ( oConfig )
- {
- if ( oConfig.sNewLine == "auto" )
- {
- return navigator.userAgent.match(/Windows/) ? "\r\n" : "\n";
- }
- else
- {
- return oConfig.sNewLine;
- }
- },
-
- "_fnGetDataTablesData": function ( oConfig )
- {
- var i, iLen, j, jLen;
- var aRow, aData=[], sLoopData='', arr;
- var dt = this.s.dt, tr, child;
- var regex = new RegExp(oConfig.sFieldBoundary, "g");
- var aColumnsInc = this._fnColumnTargets( oConfig.mColumns );
- var bSelectedOnly = (typeof oConfig.bSelectedOnly != 'undefined') ? oConfig.bSelectedOnly : false;
-
- if ( oConfig.bHeader )
- {
- aRow = [];
- for ( i=0, iLen=dt.aoColumns.length ; i<iLen ; i++ )
- {
- if ( aColumnsInc[i] )
- {
- sLoopData = dt.aoColumns[i].sTitle.replace(/\n/g," ").replace( /<.*?>/g, "" ).replace(/^\s+|\s+$/g,"");
- sLoopData = this._fnHtmlDecode( sLoopData );
- aRow.push( this._fnBoundData( sLoopData, oConfig.sFieldBoundary, regex ) );
- }
- }
- aData.push( aRow.join(oConfig.sFieldSeperator) );
- }
- bSelectedOnly = true;
-
- var aDataIndex;
- var aSelected = this.fnGetSelectedIndexes();
- bSelectedOnly = this.s.select.type !== "none" && bSelectedOnly && aSelected.length !== 0;
- if ( bSelectedOnly ) {
-
- aDataIndex = aSelected;
- }
- else if ( DataTable.Api ) {
-
- aDataIndex = new DataTable.Api( dt )
- .rows( oConfig.oSelectorOpts )
- .indexes()
- .flatten()
- .toArray();
- }
- else {
-
- aDataIndex = dt.oInstance
- .$('tr', oConfig.oSelectorOpts)
- .map( function (id, row) {
- return dt.oInstance.fnGetPosition( row );
- } )
- .get();
- }
- for ( j=0, jLen=aDataIndex.length ; j<jLen ; j++ )
- {
- tr = dt.aoData[ aDataIndex[j] ].nTr;
- aRow = [];
-
- for ( i=0, iLen=dt.aoColumns.length ; i<iLen ; i++ )
- {
- if ( aColumnsInc[i] )
- {
-
- var mTypeData = dt.oApi._fnGetCellData( dt, aDataIndex[j], i, 'display' );
- if ( oConfig.fnCellRender )
- {
- sLoopData = oConfig.fnCellRender( mTypeData, i, tr, aDataIndex[j] )+"";
- }
- else if ( typeof mTypeData == "string" )
- {
-
- sLoopData = mTypeData.replace(/\n/g," ");
- sLoopData =
- sLoopData.replace(/<img.*?\s+alt\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s>]+)).*?>/gi,
- '$1$2$3');
- sLoopData = sLoopData.replace( /<.*?>/g, "" );
- }
- else
- {
- sLoopData = mTypeData+"";
- }
-
- sLoopData = sLoopData.replace(/^\s+/, '').replace(/\s+$/, '');
- sLoopData = this._fnHtmlDecode( sLoopData );
-
- aRow.push( this._fnBoundData( sLoopData, oConfig.sFieldBoundary, regex ) );
- }
- }
- aData.push( aRow.join(oConfig.sFieldSeperator) );
-
- if ( oConfig.bOpenRows )
- {
- arr = $.grep(dt.aoOpenRows, function(o) { return o.nParent === tr; });
- if ( arr.length === 1 )
- {
- sLoopData = this._fnBoundData( $('td', arr[0].nTr).html(), oConfig.sFieldBoundary, regex );
- aData.push( sLoopData );
- }
- }
- }
-
- if ( oConfig.bFooter && dt.nTFoot !== null )
- {
- aRow = [];
- for ( i=0, iLen=dt.aoColumns.length ; i<iLen ; i++ )
- {
- if ( aColumnsInc[i] && dt.aoColumns[i].nTf !== null )
- {
- sLoopData = dt.aoColumns[i].nTf.innerHTML.replace(/\n/g," ").replace( /<.*?>/g, "" );
- sLoopData = this._fnHtmlDecode( sLoopData );
- aRow.push( this._fnBoundData( sLoopData, oConfig.sFieldBoundary, regex ) );
- }
- }
- aData.push( aRow.join(oConfig.sFieldSeperator) );
- }
- var _sLastData = aData.join( this._fnNewline(oConfig) );
- return _sLastData;
- },
-
- "_fnBoundData": function ( sData, sBoundary, regex )
- {
- if ( sBoundary === "" )
- {
- return sData;
- }
- else
- {
- return sBoundary + sData.replace(regex, sBoundary+sBoundary) + sBoundary;
- }
- },
-
- "_fnChunkData": function ( sData, iSize )
- {
- var asReturn = [];
- var iStrlen = sData.length;
- for ( var i=0 ; i<iStrlen ; i+=iSize )
- {
- if ( i+iSize < iStrlen )
- {
- asReturn.push( sData.substring( i, i+iSize ) );
- }
- else
- {
- asReturn.push( sData.substring( i, iStrlen ) );
- }
- }
- return asReturn;
- },
-
- "_fnHtmlDecode": function ( sData )
- {
- if ( sData.indexOf('&') === -1 )
- {
- return sData;
- }
- var n = document.createElement('div');
- return sData.replace( /&([^\s]*?);/g, function( match, match2 ) {
- if ( match.substr(1, 1) === '#' )
- {
- return String.fromCharCode( Number(match2.substr(1)) );
- }
- else
- {
- n.innerHTML = match;
- return n.childNodes[0].nodeValue;
- }
- } );
- },
-
-
- "_fnPrintStart": function ( oConfig )
- {
- var that = this;
- var oSetDT = this.s.dt;
-
- this._fnPrintHideNodes( oSetDT.nTable );
-
- this.s.print.saveStart = oSetDT._iDisplayStart;
- this.s.print.saveLength = oSetDT._iDisplayLength;
- if ( oConfig.bShowAll )
- {
- oSetDT._iDisplayStart = 0;
- oSetDT._iDisplayLength = -1;
- if ( oSetDT.oApi._fnCalculateEnd ) {
- oSetDT.oApi._fnCalculateEnd( oSetDT );
- }
- oSetDT.oApi._fnDraw( oSetDT );
- }
-
- if ( oSetDT.oScroll.sX !== "" || oSetDT.oScroll.sY !== "" )
- {
- this._fnPrintScrollStart( oSetDT );
-
-
- $(this.s.dt.nTable).bind('draw.DTTT_Print', function () {
- that._fnPrintScrollStart( oSetDT );
- } );
- }
-
- var anFeature = oSetDT.aanFeatures;
- for ( var cFeature in anFeature )
- {
- if ( cFeature != 'i' && cFeature != 't' && cFeature.length == 1 )
- {
- for ( var i=0, iLen=anFeature[cFeature].length ; i<iLen ; i++ )
- {
- this.dom.print.hidden.push( {
- "node": anFeature[cFeature][i],
- "display": "block"
- } );
- anFeature[cFeature][i].style.display = "none";
- }
- }
- }
-
- $(document.body).addClass( this.classes.print.body );
-
- if ( oConfig.sInfo !== "" )
- {
- this.fnInfo( oConfig.sInfo, 3000 );
- }
-
- if ( oConfig.sMessage )
- {
- $('<div/>')
- .addClass( this.classes.print.message )
- .html( oConfig.sMessage )
- .prependTo( 'body' );
- }
-
- this.s.print.saveScroll = $(window).scrollTop();
- window.scrollTo( 0, 0 );
-
- $(document).bind( "keydown.DTTT", function(e) {
-
- if ( e.keyCode == 27 )
- {
- e.preventDefault();
- that._fnPrintEnd.call( that, e );
- }
- } );
- },
-
- "_fnPrintEnd": function ( e )
- {
- var that = this;
- var oSetDT = this.s.dt;
- var oSetPrint = this.s.print;
- var oDomPrint = this.dom.print;
-
- this._fnPrintShowNodes();
-
- if ( oSetDT.oScroll.sX !== "" || oSetDT.oScroll.sY !== "" )
- {
- $(this.s.dt.nTable).unbind('draw.DTTT_Print');
- this._fnPrintScrollEnd();
- }
-
- window.scrollTo( 0, oSetPrint.saveScroll );
-
- $('div.'+this.classes.print.message).remove();
-
- $(document.body).removeClass( 'DTTT_Print' );
-
- oSetDT._iDisplayStart = oSetPrint.saveStart;
- oSetDT._iDisplayLength = oSetPrint.saveLength;
- if ( oSetDT.oApi._fnCalculateEnd ) {
- oSetDT.oApi._fnCalculateEnd( oSetDT );
- }
- oSetDT.oApi._fnDraw( oSetDT );
- $(document).unbind( "keydown.DTTT" );
- },
-
- "_fnPrintScrollStart": function ()
- {
- var
- oSetDT = this.s.dt,
- nScrollHeadInner = oSetDT.nScrollHead.getElementsByTagName('div')[0],
- nScrollHeadTable = nScrollHeadInner.getElementsByTagName('table')[0],
- nScrollBody = oSetDT.nTable.parentNode,
- nTheadSize, nTfootSize;
-
- nTheadSize = oSetDT.nTable.getElementsByTagName('thead');
- if ( nTheadSize.length > 0 )
- {
- oSetDT.nTable.removeChild( nTheadSize[0] );
- }
- if ( oSetDT.nTFoot !== null )
- {
- nTfootSize = oSetDT.nTable.getElementsByTagName('tfoot');
- if ( nTfootSize.length > 0 )
- {
- oSetDT.nTable.removeChild( nTfootSize[0] );
- }
- }
- nTheadSize = oSetDT.nTHead.cloneNode(true);
- oSetDT.nTable.insertBefore( nTheadSize, oSetDT.nTable.childNodes[0] );
- if ( oSetDT.nTFoot !== null )
- {
- nTfootSize = oSetDT.nTFoot.cloneNode(true);
- oSetDT.nTable.insertBefore( nTfootSize, oSetDT.nTable.childNodes[1] );
- }
-
- if ( oSetDT.oScroll.sX !== "" )
- {
- oSetDT.nTable.style.width = $(oSetDT.nTable).outerWidth()+"px";
- nScrollBody.style.width = $(oSetDT.nTable).outerWidth()+"px";
- nScrollBody.style.overflow = "visible";
- }
- if ( oSetDT.oScroll.sY !== "" )
- {
- nScrollBody.style.height = $(oSetDT.nTable).outerHeight()+"px";
- nScrollBody.style.overflow = "visible";
- }
- },
-
- "_fnPrintScrollEnd": function ()
- {
- var
- oSetDT = this.s.dt,
- nScrollBody = oSetDT.nTable.parentNode;
- if ( oSetDT.oScroll.sX !== "" )
- {
- nScrollBody.style.width = oSetDT.oApi._fnStringToCss( oSetDT.oScroll.sX );
- nScrollBody.style.overflow = "auto";
- }
- if ( oSetDT.oScroll.sY !== "" )
- {
- nScrollBody.style.height = oSetDT.oApi._fnStringToCss( oSetDT.oScroll.sY );
- nScrollBody.style.overflow = "auto";
- }
- },
-
- "_fnPrintShowNodes": function ( )
- {
- var anHidden = this.dom.print.hidden;
- for ( var i=0, iLen=anHidden.length ; i<iLen ; i++ )
- {
- anHidden[i].node.style.display = anHidden[i].display;
- }
- anHidden.splice( 0, anHidden.length );
- },
-
- "_fnPrintHideNodes": function ( nNode )
- {
- var anHidden = this.dom.print.hidden;
- var nParent = nNode.parentNode;
- var nChildren = nParent.childNodes;
- for ( var i=0, iLen=nChildren.length ; i<iLen ; i++ )
- {
- if ( nChildren[i] != nNode && nChildren[i].nodeType == 1 )
- {
-
- var sDisplay = $(nChildren[i]).css("display");
- if ( sDisplay != "none" )
- {
-
- anHidden.push( {
- "node": nChildren[i],
- "display": sDisplay
- } );
- nChildren[i].style.display = "none";
- }
- }
- }
- if ( nParent.nodeName.toUpperCase() != "BODY" )
- {
- this._fnPrintHideNodes( nParent );
- }
- }
- };
- TableTools._aInstances = [];
- TableTools._aListeners = [];
- TableTools.fnGetMasters = function ()
- {
- var a = [];
- for ( var i=0, iLen=TableTools._aInstances.length ; i<iLen ; i++ )
- {
- if ( TableTools._aInstances[i].s.master )
- {
- a.push( TableTools._aInstances[i] );
- }
- }
- return a;
- };
- TableTools.fnGetInstance = function ( node )
- {
- if ( typeof node != 'object' )
- {
- node = document.getElementById(node);
- }
- for ( var i=0, iLen=TableTools._aInstances.length ; i<iLen ; i++ )
- {
- if ( TableTools._aInstances[i].s.master && TableTools._aInstances[i].dom.table == node )
- {
- return TableTools._aInstances[i];
- }
- }
- return null;
- };
- TableTools._fnEventListen = function ( that, type, fn )
- {
- TableTools._aListeners.push( {
- "that": that,
- "type": type,
- "fn": fn
- } );
- };
- TableTools._fnEventDispatch = function ( that, type, node, selected )
- {
- var listeners = TableTools._aListeners;
- for ( var i=0, iLen=listeners.length ; i<iLen ; i++ )
- {
- if ( that.dom.table == listeners[i].that.dom.table && listeners[i].type == type )
- {
- listeners[i].fn( node, selected );
- }
- }
- };
- TableTools.buttonBase = {
-
- "sAction": "text",
- "sTag": "default",
- "sLinerTag": "default",
- "sButtonClass": "DTTT_button_text",
- "sButtonText": "Button text",
- "sTitle": "",
- "sToolTip": "",
-
- "sCharSet": "utf8",
- "bBomInc": false,
- "sFileName": "*.csv",
- "sFieldBoundary": "",
- "sFieldSeperator": "\t",
- "sNewLine": "auto",
- "mColumns": "all",
- "bHeader": true,
- "bFooter": true,
- "bOpenRows": false,
- "bSelectedOnly": false,
- "oSelectorOpts": undefined,
-
- "fnMouseover": null,
- "fnMouseout": null,
- "fnClick": null,
- "fnSelect": null,
- "fnComplete": null,
- "fnInit": null,
- "fnCellRender": null
- };
- TableTools.BUTTONS = {
- "csv": $.extend( {}, TableTools.buttonBase, {
- "sAction": "flash_save",
- "sButtonClass": "DTTT_button_csv",
- "sButtonText": "CSV",
- "sFieldBoundary": '"',
- "sFieldSeperator": ",",
- "fnClick": function( nButton, oConfig, flash ) {
- this.fnSetText( flash, this.fnGetTableData(oConfig) );
- }
- } ),
- "xls": $.extend( {}, TableTools.buttonBase, {
- "sAction": "flash_save",
- "sCharSet": "utf16le",
- "bBomInc": true,
- "sButtonClass": "DTTT_button_xls",
- "sButtonText": "Excel",
- "fnClick": function( nButton, oConfig, flash ) {
- this.fnSetText( flash, this.fnGetTableData(oConfig) );
- }
- } ),
- "copy": $.extend( {}, TableTools.buttonBase, {
- "sAction": "flash_copy",
- "sButtonClass": "DTTT_button_copy",
- "sButtonText": "Copy",
- "fnClick": function( nButton, oConfig, flash ) {
- this.fnSetText( flash, this.fnGetTableData(oConfig) );
- },
- "fnComplete": function(nButton, oConfig, flash, text) {
- var lines = text.split('\n').length;
- if (oConfig.bHeader) lines--;
- if (this.s.dt.nTFoot !== null && oConfig.bFooter) lines--;
- var plural = (lines==1) ? "" : "s";
- this.fnInfo( '<h6>Table copied</h6>'+
- '<p>Copied '+lines+' row'+plural+' to the clipboard.</p>',
- 1500
- );
- }
- } ),
- "pdf": $.extend( {}, TableTools.buttonBase, {
- "sAction": "flash_pdf",
- "sNewLine": "\n",
- "sFileName": "*.pdf",
- "sButtonClass": "DTTT_button_pdf",
- "sButtonText": "PDF",
- "sPdfOrientation": "portrait",
- "sPdfSize": "A4",
- "sPdfMessage": "",
- "fnClick": function( nButton, oConfig, flash ) {
- this.fnSetText( flash,
- "title:"+ this.fnGetTitle(oConfig) +"\n"+
- "message:"+ oConfig.sPdfMessage +"\n"+
- "colWidth:"+ this.fnCalcColRatios(oConfig) +"\n"+
- "orientation:"+ oConfig.sPdfOrientation +"\n"+
- "size:"+ oConfig.sPdfSize +"\n"+
- "--/TableToolsOpts--\n" +
- this.fnGetTableData(oConfig)
- );
- }
- } ),
- "print": $.extend( {}, TableTools.buttonBase, {
- "sInfo": "<h6>Print view</h6><p>Please use your browser's print function to "+
- "print this table. Press escape when finished.</p>",
- "sMessage": null,
- "bShowAll": true,
- "sToolTip": "View print view",
- "sButtonClass": "DTTT_button_print",
- "sButtonText": "Print",
- "fnClick": function ( nButton, oConfig ) {
- this.fnPrint( true, oConfig );
- }
- } ),
- "text": $.extend( {}, TableTools.buttonBase ),
- "select": $.extend( {}, TableTools.buttonBase, {
- "sButtonText": "Select button",
- "fnSelect": function( nButton, oConfig ) {
- if ( this.fnGetSelected().length !== 0 ) {
- $(nButton).removeClass( this.classes.buttons.disabled );
- } else {
- $(nButton).addClass( this.classes.buttons.disabled );
- }
- },
- "fnInit": function( nButton, oConfig ) {
- $(nButton).addClass( this.classes.buttons.disabled );
- }
- } ),
- "select_single": $.extend( {}, TableTools.buttonBase, {
- "sButtonText": "Select button",
- "fnSelect": function( nButton, oConfig ) {
- var iSelected = this.fnGetSelected().length;
- if ( iSelected == 1 ) {
- $(nButton).removeClass( this.classes.buttons.disabled );
- } else {
- $(nButton).addClass( this.classes.buttons.disabled );
- }
- },
- "fnInit": function( nButton, oConfig ) {
- $(nButton).addClass( this.classes.buttons.disabled );
- }
- } ),
- "select_all": $.extend( {}, TableTools.buttonBase, {
- "sButtonText": "Select all",
- "fnClick": function( nButton, oConfig ) {
- this.fnSelectAll();
- },
- "fnSelect": function( nButton, oConfig ) {
- if ( this.fnGetSelected().length == this.s.dt.fnRecordsDisplay() ) {
- $(nButton).addClass( this.classes.buttons.disabled );
- } else {
- $(nButton).removeClass( this.classes.buttons.disabled );
- }
- }
- } ),
- "select_none": $.extend( {}, TableTools.buttonBase, {
- "sButtonText": "Deselect all",
- "fnClick": function( nButton, oConfig ) {
- this.fnSelectNone();
- },
- "fnSelect": function( nButton, oConfig ) {
- if ( this.fnGetSelected().length !== 0 ) {
- $(nButton).removeClass( this.classes.buttons.disabled );
- } else {
- $(nButton).addClass( this.classes.buttons.disabled );
- }
- },
- "fnInit": function( nButton, oConfig ) {
- $(nButton).addClass( this.classes.buttons.disabled );
- }
- } ),
- "ajax": $.extend( {}, TableTools.buttonBase, {
- "sAjaxUrl": "/xhr.php",
- "sButtonText": "Ajax button",
- "fnClick": function( nButton, oConfig ) {
- var sData = this.fnGetTableData(oConfig);
- $.ajax( {
- "url": oConfig.sAjaxUrl,
- "data": [
- { "name": "tableData", "value": sData }
- ],
- "success": oConfig.fnAjaxComplete,
- "dataType": "json",
- "type": "POST",
- "cache": false,
- "error": function () {
- alert( "Error detected when sending table data to server" );
- }
- } );
- },
- "fnAjaxComplete": function( json ) {
- alert( 'Ajax complete' );
- }
- } ),
- "div": $.extend( {}, TableTools.buttonBase, {
- "sAction": "div",
- "sTag": "div",
- "sButtonClass": "DTTT_nonbutton",
- "sButtonText": "Text button"
- } ),
- "collection": $.extend( {}, TableTools.buttonBase, {
- "sAction": "collection",
- "sButtonClass": "DTTT_button_collection",
- "sButtonText": "Collection",
- "fnClick": function( nButton, oConfig ) {
- this._fnCollectionShow(nButton, oConfig);
- }
- } )
- };
- TableTools.buttons = TableTools.BUTTONS;
- TableTools.classes = {
- "container": "DTTT_container",
- "buttons": {
- "normal": "DTTT_button",
- "disabled": "DTTT_disabled"
- },
- "collection": {
- "container": "DTTT_collection",
- "background": "DTTT_collection_background",
- "buttons": {
- "normal": "DTTT_button",
- "disabled": "DTTT_disabled"
- }
- },
- "select": {
- "table": "DTTT_selectable",
- "row": "DTTT_selected selected"
- },
- "print": {
- "body": "DTTT_Print",
- "info": "DTTT_print_info",
- "message": "DTTT_PrintMessage"
- }
- };
- TableTools.classes_themeroller = {
- "container": "DTTT_container ui-buttonset ui-buttonset-multi",
- "buttons": {
- "normal": "DTTT_button ui-button ui-state-default"
- },
- "collection": {
- "container": "DTTT_collection ui-buttonset ui-buttonset-multi"
- }
- };
- TableTools.DEFAULTS = {
- "sSwfPath": "../swf/copy_csv_xls_pdf.swf",
- "sRowSelect": "none",
- "sRowSelector": "tr",
- "sSelectedClass": null,
- "fnPreRowSelect": null,
- "fnRowSelected": null,
- "fnRowDeselected": null,
- "aButtons": [ "copy", "csv", "xls", "pdf", "print" ],
- "oTags": {
- "container": "div",
- "button": "a",
-
- "liner": "span",
- "collection": {
- "container": "div",
- "button": "a",
- "liner": "span"
- }
- }
- };
- TableTools.defaults = TableTools.DEFAULTS;
- TableTools.prototype.CLASS = "TableTools";
- TableTools.version = "2.2.4";
- if ( $.fn.dataTable.Api ) {
- $.fn.dataTable.Api.register( 'tabletools()', function () {
- var tt = null;
- if ( this.context.length > 0 ) {
- tt = TableTools.fnGetInstance( this.context[0].nTable );
- }
- return tt;
- } );
- }
- if ( typeof $.fn.dataTable == "function" &&
- typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
- $.fn.dataTableExt.fnVersionCheck('1.9.0') )
- {
- $.fn.dataTableExt.aoFeatures.push( {
- "fnInit": function( oDTSettings ) {
- var init = oDTSettings.oInit;
- var opts = init ?
- init.tableTools || init.oTableTools || {} :
- {};
- return new TableTools( oDTSettings.oInstance, opts ).dom.container;
- },
- "cFeature": "T",
- "sFeature": "TableTools"
- } );
- }
- else
- {
- alert( "Warning: TableTools requires DataTables 1.9.0 or newer - www.datatables.net/download");
- }
- $.fn.DataTable.TableTools = TableTools;
- })(jQuery, window, document);
- if ( typeof $.fn.dataTable == "function" &&
- typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
- $.fn.dataTableExt.fnVersionCheck('1.9.0') )
- {
- $.fn.dataTableExt.aoFeatures.push( {
- "fnInit": function( oDTSettings ) {
- var oOpts = typeof oDTSettings.oInit.oTableTools != 'undefined' ?
- oDTSettings.oInit.oTableTools : {};
- var oTT = new TableTools( oDTSettings.oInstance, oOpts );
- TableTools._aInstances.push( oTT );
- return oTT.dom.container;
- },
- "cFeature": "T",
- "sFeature": "TableTools"
- } );
- }
- else
- {
- alert( "Warning: TableTools 2 requires DataTables 1.9.0 or newer - www.datatables.net/download");
- }
- $.fn.dataTable.TableTools = TableTools;
- $.fn.DataTable.TableTools = TableTools;
- return TableTools;
- };
- if ( typeof define === 'function' && define.amd ) {
- define( ['jquery', 'datatables'], factory );
- }
- else if ( typeof exports === 'object' ) {
-
- factory( require('jquery'), require('datatables') );
- }
- else if ( jQuery && !jQuery.fn.dataTable.TableTools ) {
-
- factory( jQuery, jQuery.fn.dataTable );
- }
- })(window, document);
|