jquery-datatables-rails 1.11.0 → 1.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jquery-datatables-rails.rb +0 -0
- data/lib/jquery/datatables/rails/engine.rb +0 -0
- data/lib/jquery/datatables/rails/version.rb +1 -1
- data/vendor/assets/images/dataTables/back_disabled.png +0 -0
- data/vendor/assets/images/dataTables/back_enabled.png +0 -0
- data/vendor/assets/images/dataTables/back_enabled_hover.png +0 -0
- data/vendor/assets/images/dataTables/extras/background.png +0 -0
- data/vendor/assets/images/dataTables/extras/collection.png +0 -0
- data/vendor/assets/images/dataTables/extras/collection_hover.png +0 -0
- data/vendor/assets/images/dataTables/extras/copy.png +0 -0
- data/vendor/assets/images/dataTables/extras/copy_hover.png +0 -0
- data/vendor/assets/images/dataTables/extras/csv.png +0 -0
- data/vendor/assets/images/dataTables/extras/csv_hover.png +0 -0
- data/vendor/assets/images/dataTables/extras/pdf.png +0 -0
- data/vendor/assets/images/dataTables/extras/pdf_hover.png +0 -0
- data/vendor/assets/images/dataTables/extras/print.png +0 -0
- data/vendor/assets/images/dataTables/extras/print_hover.png +0 -0
- data/vendor/assets/images/dataTables/extras/xls.png +0 -0
- data/vendor/assets/images/dataTables/extras/xls_hover.png +0 -0
- data/vendor/assets/images/dataTables/favicon.ico +0 -0
- data/vendor/assets/images/dataTables/forward_disabled.png +0 -0
- data/vendor/assets/images/dataTables/forward_enabled.png +0 -0
- data/vendor/assets/images/dataTables/forward_enabled_hover.png +0 -0
- data/vendor/assets/images/dataTables/sort_asc.png +0 -0
- data/vendor/assets/images/dataTables/sort_asc_disabled.png +0 -0
- data/vendor/assets/images/dataTables/sort_both.png +0 -0
- data/vendor/assets/images/dataTables/sort_desc.png +0 -0
- data/vendor/assets/images/dataTables/sort_desc_disabled.png +0 -0
- data/vendor/assets/javascripts/dataTables/extras/AutoFill.js +0 -0
- data/vendor/assets/javascripts/dataTables/extras/ColReorder.js +0 -0
- data/vendor/assets/javascripts/dataTables/extras/ColVis.js +0 -0
- data/vendor/assets/javascripts/dataTables/extras/FixedColumns.js +0 -0
- data/vendor/assets/javascripts/dataTables/extras/FixedHeader.js +0 -0
- data/vendor/assets/javascripts/dataTables/extras/KeyTable.js +0 -0
- data/vendor/assets/javascripts/dataTables/extras/Scroller.js +0 -0
- data/vendor/assets/javascripts/dataTables/extras/TableTools.js +320 -302
- data/vendor/assets/javascripts/dataTables/extras/TableTools.min.js +76 -0
- data/vendor/assets/javascripts/dataTables/extras/ZeroClipboard.js +2 -2
- data/vendor/assets/javascripts/dataTables/jquery.dataTables.api.fnFilterOnReturn.js +1 -1
- data/vendor/assets/javascripts/dataTables/jquery.dataTables.api.fnGetColumnData.js +0 -0
- data/vendor/assets/javascripts/dataTables/jquery.dataTables.api.fnReloadAjax.js +0 -0
- data/vendor/assets/javascripts/dataTables/jquery.dataTables.api.fnSetFilteringDelay.js +32 -0
- data/vendor/assets/javascripts/dataTables/jquery.dataTables.bootstrap.js +0 -0
- data/vendor/assets/javascripts/dataTables/jquery.dataTables.js +0 -0
- data/vendor/assets/javascripts/dataTables/jquery.dataTables.sorting.numbersHtml.js +0 -0
- data/vendor/assets/javascripts/dataTables/jquery.dataTables.typeDetection.numbersHtml.js +0 -0
- data/vendor/assets/media/dataTables/extras/as3/ZeroClipboard.as +221 -0
- data/vendor/assets/media/dataTables/extras/as3/ZeroClipboardPdf.as +310 -0
- data/vendor/assets/media/dataTables/extras/as3/lib/AlivePDF.swc +0 -0
- data/vendor/assets/media/dataTables/extras/swf/copy_csv_xls.swf +0 -0
- data/vendor/assets/media/dataTables/extras/swf/copy_csv_xls_pdf.swf +0 -0
- data/vendor/assets/stylesheets/dataTables/extras/TableTools.css +314 -0
- data/vendor/assets/stylesheets/dataTables/extras/TableTools_JUI.css +185 -0
- data/vendor/assets/stylesheets/dataTables/jquery.dataTables.bootstrap.css.scss +0 -0
- data/vendor/assets/stylesheets/dataTables/jquery.dataTables.css.scss +11 -11
- data/vendor/assets/stylesheets/dataTables/src/demo_page.css +0 -0
- data/vendor/assets/stylesheets/dataTables/src/demo_table.css +11 -11
- data/vendor/assets/stylesheets/dataTables/src/demo_table_jui.css +17 -9
- data/vendor/assets/stylesheets/dataTables/src/jquery.dataTables_themeroller.css +6 -6
- metadata +25 -10
- data/.gitignore +0 -7
- data/Gemfile +0 -4
- data/LICENSE +0 -20
- data/Rakefile +0 -1
- data/Readme.md +0 -88
- data/jquery-datatables-rails.gemspec +0 -20
@@ -0,0 +1,76 @@
|
|
1
|
+
// Simple Set Clipboard System
|
2
|
+
// Author: Joseph Huckaby
|
3
|
+
var ZeroClipboard_TableTools={version:"1.0.4-TableTools2",clients:{},moviePath:"",nextId:1,$:function(a){"string"==typeof a&&(a=document.getElementById(a));a.addClass||(a.hide=function(){this.style.display="none"},a.show=function(){this.style.display=""},a.addClass=function(a){this.removeClass(a);this.className+=" "+a},a.removeClass=function(a){this.className=this.className.replace(RegExp("\\s*"+a+"\\s*")," ").replace(/^\s+/,"").replace(/\s+$/,"")},a.hasClass=function(a){return!!this.className.match(RegExp("\\s*"+
|
4
|
+
a+"\\s*"))});return a},setMoviePath:function(a){this.moviePath=a},dispatch:function(a,b,c){(a=this.clients[a])&&a.receiveEvent(b,c)},register:function(a,b){this.clients[a]=b},getDOMObjectPosition:function(a){var b={left:0,top:0,width:a.width?a.width:a.offsetWidth,height:a.height?a.height:a.offsetHeight};""!=a.style.width&&(b.width=a.style.width.replace("px",""));""!=a.style.height&&(b.height=a.style.height.replace("px",""));for(;a;)b.left+=a.offsetLeft,b.top+=a.offsetTop,a=a.offsetParent;return b},
|
5
|
+
Client:function(a){this.handlers={};this.id=ZeroClipboard_TableTools.nextId++;this.movieId="ZeroClipboard_TableToolsMovie_"+this.id;ZeroClipboard_TableTools.register(this.id,this);a&&this.glue(a)}};
|
6
|
+
ZeroClipboard_TableTools.Client.prototype={id:0,ready:!1,movie:null,clipText:"",fileName:"",action:"copy",handCursorEnabled:!0,cssEffects:!0,handlers:null,sized:!1,glue:function(a,b){this.domElement=ZeroClipboard_TableTools.$(a);var c=99;this.domElement.style.zIndex&&(c=parseInt(this.domElement.style.zIndex)+1);var d=ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);this.div=document.createElement("div");var e=this.div.style;e.position="absolute";e.left="0px";e.top="0px";e.width=d.width+
|
7
|
+
"px";e.height=d.height+"px";e.zIndex=c;"undefined"!=typeof b&&""!=b&&(this.div.title=b);0!=d.width&&0!=d.height&&(this.sized=!0);this.domElement&&(this.domElement.appendChild(this.div),this.div.innerHTML=this.getHTML(d.width,d.height))},positionElement:function(){var a=ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement),b=this.div.style;b.position="absolute";b.width=a.width+"px";b.height=a.height+"px";0!=a.width&&0!=a.height&&(this.sized=!0,b=this.div.childNodes[0],b.width=a.width,b.height=
|
8
|
+
a.height)},getHTML:function(a,b){var c="",d="id="+this.id+"&width="+a+"&height="+b;if(navigator.userAgent.match(/MSIE/))var e=location.href.match(/^https/i)?"https://":"http://",c=c+('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="'+e+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="'+a+'" height="'+b+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+
|
9
|
+
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="'+d+'"/><param name="wmode" value="transparent"/></object>');else c+='<embed id="'+this.movieId+'" src="'+ZeroClipboard_TableTools.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+a+'" height="'+b+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+
|
10
|
+
d+'" wmode="transparent" />';return c},hide:function(){this.div&&(this.div.style.left="-2000px")},show:function(){this.reposition()},destroy:function(){if(this.domElement&&this.div){this.hide();this.div.innerHTML="";var a=document.getElementsByTagName("body")[0];try{a.removeChild(this.div)}catch(b){}this.div=this.domElement=null}},reposition:function(a){a&&((this.domElement=ZeroClipboard_TableTools.$(a))||this.hide());if(this.domElement&&this.div){var a=ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement),
|
11
|
+
b=this.div.style;b.left=""+a.left+"px";b.top=""+a.top+"px"}},clearText:function(){this.clipText="";this.ready&&this.movie.clearText()},appendText:function(a){this.clipText+=a;this.ready&&this.movie.appendText(a)},setText:function(a){this.clipText=a;this.ready&&this.movie.setText(a)},setCharSet:function(a){this.charSet=a;this.ready&&this.movie.setCharSet(a)},setBomInc:function(a){this.incBom=a;this.ready&&this.movie.setBomInc(a)},setFileName:function(a){this.fileName=a;this.ready&&this.movie.setFileName(a)},
|
12
|
+
setAction:function(a){this.action=a;this.ready&&this.movie.setAction(a)},addEventListener:function(a,b){a=a.toString().toLowerCase().replace(/^on/,"");this.handlers[a]||(this.handlers[a]=[]);this.handlers[a].push(b)},setHandCursor:function(a){this.handCursorEnabled=a;this.ready&&this.movie.setHandCursor(a)},setCSSEffects:function(a){this.cssEffects=!!a},receiveEvent:function(a,b){a=a.toString().toLowerCase().replace(/^on/,"");switch(a){case "load":this.movie=document.getElementById(this.movieId);
|
13
|
+
if(!this.movie){var c=this;setTimeout(function(){c.receiveEvent("load",null)},1);return}if(!this.ready&&navigator.userAgent.match(/Firefox/)&&navigator.userAgent.match(/Windows/)){c=this;setTimeout(function(){c.receiveEvent("load",null)},100);this.ready=!0;return}this.ready=!0;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);
|
14
|
+
break;case "mouseover":this.domElement&&this.cssEffects&&this.recoverActive&&this.domElement.addClass("active");break;case "mouseout":this.domElement&&this.cssEffects&&(this.recoverActive=!1,this.domElement.hasClass("active")&&(this.domElement.removeClass("active"),this.recoverActive=!0));break;case "mousedown":this.domElement&&this.cssEffects&&this.domElement.addClass("active");break;case "mouseup":this.domElement&&this.cssEffects&&(this.domElement.removeClass("active"),this.recoverActive=!1)}if(this.handlers[a])for(var d=
|
15
|
+
0,e=this.handlers[a].length;d<e;d++){var f=this.handlers[a][d];if("function"==typeof f)f(this,b);else if("object"==typeof f&&2==f.length)f[0][f[1]](this,b);else if("string"==typeof f)window[f](this,b)}}};
|
16
|
+
|
17
|
+
|
18
|
+
/*
|
19
|
+
* File: TableTools.min.js
|
20
|
+
* Version: 2.1.3
|
21
|
+
* Author: Allan Jardine (www.sprymedia.co.uk)
|
22
|
+
*
|
23
|
+
* Copyright 2009-2012 Allan Jardine, all rights reserved.
|
24
|
+
*
|
25
|
+
* This source file is free software, under either the GPL v2 license or a
|
26
|
+
* BSD (3 point) style license, as supplied with this software.
|
27
|
+
*
|
28
|
+
* This source file is distributed in the hope that it will be useful, but
|
29
|
+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
30
|
+
* or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
|
31
|
+
*/
|
32
|
+
var TableTools;
|
33
|
+
(function(e,m,f){TableTools=function(a,b){!this instanceof TableTools&&alert("Warning: TableTools must be initialised with the keyword 'new'");this.s={that:this,dt:a.fnSettings(),print:{saveStart:-1,saveLength:-1,saveScroll:-1,funcEnd:function(){}},buttonCounter:0,select:{type:"",selected:[],preRowSelect:null,postSelected:null,postDeselected:null,all:!1,selectedClass:""},custom:{},swfPath:"",buttonSet:[],master:!1,tags:{}};this.dom={container:null,table:null,print:{hidden:[],message:null},collection:{collection:null,
|
34
|
+
background:null}};this.classes=e.extend(!0,{},TableTools.classes);this.s.dt.bJUI&&e.extend(!0,this.classes,TableTools.classes_themeroller);this.fnSettings=function(){return this.s};"undefined"==typeof b&&(b={});this._fnConstruct(b);return this};TableTools.prototype={fnGetSelected:function(){var a=[],b=this.s.dt.aoData,c,d;c=0;for(d=b.length;c<d;c++)b[c]._DTTT_selected&&a.push(b[c].nTr);return a},fnGetSelectedData:function(){var a=[],b=this.s.dt.aoData,c,d;c=0;for(d=b.length;c<d;c++)b[c]._DTTT_selected&&
|
35
|
+
a.push(this.s.dt.oInstance.fnGetData(c));return a},fnIsSelected:function(a){a=this.s.dt.oInstance.fnGetPosition(a);return!0===this.s.dt.aoData[a]._DTTT_selected?!0:!1},fnSelectAll:function(a){var b=this._fnGetMasterSettings();this._fnRowSelect(!0===a?b.dt.aiDisplay:b.dt.aoData)},fnSelectNone:function(a){var b=this._fnGetMasterSettings();this._fnRowDeselect(!0===a?b.dt.aiDisplay:b.dt.aoData)},fnSelect:function(a){"single"==this.s.select.type?(this.fnSelectNone(),this._fnRowSelect(a)):"multi"==this.s.select.type&&
|
36
|
+
this._fnRowSelect(a)},fnDeselect:function(a){this._fnRowDeselect(a)},fnGetTitle:function(a){var b="";"undefined"!=typeof a.sTitle&&""!==a.sTitle?b=a.sTitle:(a=f.getElementsByTagName("title"),0<a.length&&(b=a[0].innerHTML));return 4>"\u00a1".toString().length?b.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g,""):b.replace(/[^a-zA-Z0-9_\.,\-_ !\(\)]/g,"")},fnCalcColRatios:function(a){var b=this.s.dt.aoColumns,a=this._fnColumnTargets(a.mColumns),c=[],d=0,e=0,h,f;h=0;for(f=a.length;h<f;h++)a[h]&&(d=
|
37
|
+
b[h].nTh.offsetWidth,e+=d,c.push(d));h=0;for(f=c.length;h<f;h++)c[h]/=e;return c.join("\t")},fnGetTableData:function(a){if(this.s.dt)return this._fnGetDataTablesData(a)},fnSetText:function(a,b){this._fnFlashSetText(a,b)},fnResizeButtons:function(){for(var a in ZeroClipboard_TableTools.clients)if(a){var b=ZeroClipboard_TableTools.clients[a];"undefined"!=typeof b.domElement&&b.domElement.parentNode&&b.positionElement()}},fnResizeRequired:function(){for(var a in ZeroClipboard_TableTools.clients)if(a){var b=
|
38
|
+
ZeroClipboard_TableTools.clients[a];if("undefined"!=typeof b.domElement&&b.domElement.parentNode==this.dom.container&&!1===b.sized)return!0}return!1},fnPrint:function(a,b){void 0===b&&(b={});void 0===a||a?this._fnPrintStart(b):this._fnPrintEnd()},fnInfo:function(a,b){var c=f.createElement("div");c.className=this.classes.print.info;c.innerHTML=a;f.body.appendChild(c);setTimeout(function(){e(c).fadeOut("normal",function(){f.body.removeChild(c)})},b)},_fnConstruct:function(a){var b=this;this._fnCustomiseSettings(a);
|
39
|
+
this.dom.container=f.createElement(this.s.tags.container);this.dom.container.className=this.classes.container;"none"!=this.s.select.type&&this._fnRowSelectConfig();this._fnButtonDefinations(this.s.buttonSet,this.dom.container);this.s.dt.aoDestroyCallback.push({sName:"TableTools",fn:function(){b.dom.container.innerHTML=""}})},_fnCustomiseSettings:function(a){"undefined"==typeof this.s.dt._TableToolsInit&&(this.s.master=!0,this.s.dt._TableToolsInit=!0);this.dom.table=this.s.dt.nTable;this.s.custom=
|
40
|
+
e.extend({},TableTools.DEFAULTS,a);this.s.swfPath=this.s.custom.sSwfPath;"undefined"!=typeof ZeroClipboard_TableTools&&(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;this.s.custom.sSelectedClass&&(this.classes.select.row=this.s.custom.sSelectedClass);this.s.tags=this.s.custom.oTags;
|
41
|
+
this.s.buttonSet=this.s.custom.aButtons},_fnButtonDefinations:function(a,b){for(var c,d=0,g=a.length;d<g;d++){if("string"==typeof a[d]){if("undefined"==typeof TableTools.BUTTONS[a[d]]){alert("TableTools: Warning - unknown button type: "+a[d]);continue}c=e.extend({},TableTools.BUTTONS[a[d]],!0)}else{if("undefined"==typeof TableTools.BUTTONS[a[d].sExtends]){alert("TableTools: Warning - unknown button type: "+a[d].sExtends);continue}c=e.extend({},TableTools.BUTTONS[a[d].sExtends],!0);c=e.extend(c,a[d],
|
42
|
+
!0)}b.appendChild(this._fnCreateButton(c,e(b).hasClass(this.classes.collection.container)))}},_fnCreateButton:function(a,b){var c=this._fnButtonBase(a,b);a.sAction.match(/flash/)?this._fnFlashConfig(c,a):"text"==a.sAction?this._fnTextConfig(c,a):"div"==a.sAction?this._fnTextConfig(c,a):"collection"==a.sAction&&(this._fnTextConfig(c,a),this._fnCollectionConfig(c,a));return c},_fnButtonBase:function(a,b){var c,d,e;b?(c="default"!==a.sTag?a.sTag:this.s.tags.collection.button,d="default"!==a.sLinerTag?
|
43
|
+
a.sLiner:this.s.tags.collection.liner,e=this.classes.collection.buttons.normal):(c="default"!==a.sTag?a.sTag:this.s.tags.button,d="default"!==a.sLinerTag?a.sLiner:this.s.tags.liner,e=this.classes.buttons.normal);c=f.createElement(c);d=f.createElement(d);var h=this._fnGetMasterSettings();c.className=e+" "+a.sButtonClass;c.setAttribute("id","ToolTables_"+this.s.dt.sInstance+"_"+h.buttonCounter);c.appendChild(d);d.innerHTML=a.sButtonText;h.buttonCounter++;return c},_fnGetMasterSettings:function(){if(this.s.master)return this.s;
|
44
|
+
for(var a=TableTools._aInstances,b=0,c=a.length;b<c;b++)if(this.dom.table==a[b].s.dt.nTable)return a[b].s},_fnCollectionConfig:function(a,b){var c=f.createElement(this.s.tags.collection.container);c.style.display="none";c.className=this.classes.collection.container;b._collection=c;f.body.appendChild(c);this._fnButtonDefinations(b.aButtons,c)},_fnCollectionShow:function(a,b){var c=this,d=e(a).offset(),g=b._collection,h=d.left,d=d.top+e(a).outerHeight(),p=e(m).height(),j=e(f).height(),k=e(m).width(),
|
45
|
+
n=e(f).width();g.style.position="absolute";g.style.left=h+"px";g.style.top=d+"px";g.style.display="block";e(g).css("opacity",0);var l=f.createElement("div");l.style.position="absolute";l.style.left="0px";l.style.top="0px";l.style.height=(p>j?p:j)+"px";l.style.width=(k>n?k:n)+"px";l.className=this.classes.collection.background;e(l).css("opacity",0);f.body.appendChild(l);f.body.appendChild(g);p=e(g).outerWidth();k=e(g).outerHeight();h+p>n&&(g.style.left=n-p+"px");d+k>j&&(g.style.top=d-k-e(a).outerHeight()+
|
46
|
+
"px");this.dom.collection.collection=g;this.dom.collection.background=l;setTimeout(function(){e(g).animate({opacity:1},500);e(l).animate({opacity:0.25},500)},10);this.fnResizeButtons();e(l).click(function(){c._fnCollectionHide.call(c,null,null)})},_fnCollectionHide:function(a,b){!(null!==b&&"collection"==b.sExtends)&&null!==this.dom.collection.collection&&(e(this.dom.collection.collection).animate({opacity:0},500,function(){this.style.display="none"}),e(this.dom.collection.background).animate({opacity:0},
|
47
|
+
500,function(){this.parentNode.removeChild(this)}),this.dom.collection.collection=null,this.dom.collection.background=null)},_fnRowSelectConfig:function(){if(this.s.master){var a=this,b=this.s.dt;e(b.nTable).addClass(this.classes.select.table);e("tr",b.nTBody).live("click",function(c){if(this.parentNode==b.nTBody&&null!==b.oInstance.fnGetData(this)&&(null===a.s.select.preRowSelect||a.s.select.preRowSelect.call(a,c)))a.fnIsSelected(this)?a._fnRowDeselect(this):"single"==a.s.select.type?(a.fnSelectNone(),
|
48
|
+
a._fnRowSelect(this)):"multi"==a.s.select.type&&a._fnRowSelect(this)});b.oApi._fnCallbackReg(b,"aoRowCreatedCallback",function(c,d,g){b.aoData[g]._DTTT_selected&&e(c).addClass(a.classes.select.row)},"TableTools-SelectAll")}},_fnRowSelect:function(a){for(var a=this._fnSelectData(a),b=0===a.length?null:a[0].nTr,c=0,d=a.length;c<d;c++)a[c]._DTTT_selected=!0,a[c].nTr&&e(a[c].nTr).addClass(this.classes.select.row);null!==this.s.select.postSelected&&this.s.select.postSelected.call(this,b);TableTools._fnEventDispatch(this,
|
49
|
+
"select",b)},_fnRowDeselect:function(a){for(var a=this._fnSelectData(a),b=0===a.length?null:a[0].nTr,c=0,d=a.length;c<d;c++)a[c].nTr&&a[c]._DTTT_selected&&e(a[c].nTr).removeClass(this.classes.select.row),a[c]._DTTT_selected=!1;null!==this.s.select.postDeselected&&this.s.select.postDeselected.call(this,b);TableTools._fnEventDispatch(this,"select",b)},_fnSelectData:function(a){var b=[],c,d,e;if(a.nodeName)c=this.s.dt.oInstance.fnGetPosition(a),b.push(this.s.dt.aoData[c]);else if("undefined"!==typeof a.length){d=
|
50
|
+
0;for(e=a.length;d<e;d++)a[d].nodeName?(c=this.s.dt.oInstance.fnGetPosition(a[d]),b.push(this.s.dt.aoData[c])):"number"===typeof a[d]?b.push(this.s.dt.aoData[a[d]]):b.push(a[d])}else b.push(a);return b},_fnTextConfig:function(a,b){var c=this;null!==b.fnInit&&b.fnInit.call(this,a,b);""!==b.sToolTip&&(a.title=b.sToolTip);e(a).hover(function(){b.fnMouseover!==null&&b.fnMouseover.call(this,a,b,null)},function(){b.fnMouseout!==null&&b.fnMouseout.call(this,a,b,null)});null!==b.fnSelect&&TableTools._fnEventListen(this,
|
51
|
+
"select",function(d){b.fnSelect.call(c,a,b,d)});e(a).click(function(){b.fnClick!==null&&b.fnClick.call(c,a,b,null);b.fnComplete!==null&&b.fnComplete.call(c,a,b,null,null);c._fnCollectionHide(a,b)})},_fnFlashConfig:function(a,b){var c=this,d=new ZeroClipboard_TableTools.Client;null!==b.fnInit&&b.fnInit.call(this,a,b);d.setHandCursor(!0);"flash_save"==b.sAction?(d.setAction("save"),d.setCharSet("utf16le"==b.sCharSet?"UTF16LE":"UTF8"),d.setBomInc(b.bBomInc),d.setFileName(b.sFileName.replace("*",this.fnGetTitle(b)))):
|
52
|
+
"flash_pdf"==b.sAction?(d.setAction("pdf"),d.setFileName(b.sFileName.replace("*",this.fnGetTitle(b)))):d.setAction("copy");d.addEventListener("mouseOver",function(){b.fnMouseover!==null&&b.fnMouseover.call(c,a,b,d)});d.addEventListener("mouseOut",function(){b.fnMouseout!==null&&b.fnMouseout.call(c,a,b,d)});d.addEventListener("mouseDown",function(){b.fnClick!==null&&b.fnClick.call(c,a,b,d)});d.addEventListener("complete",function(e,h){b.fnComplete!==null&&b.fnComplete.call(c,a,b,d,h);c._fnCollectionHide(a,
|
53
|
+
b)});this._fnFlashGlue(d,a,b.sToolTip)},_fnFlashGlue:function(a,b,c){var d=this,e=b.getAttribute("id");f.getElementById(e)?a.glue(b,c):setTimeout(function(){d._fnFlashGlue(a,b,c)},100)},_fnFlashSetText:function(a,b){var c=this._fnChunkData(b,8192);a.clearText();for(var d=0,e=c.length;d<e;d++)a.appendText(c[d])},_fnColumnTargets:function(a){var b=[],c=this.s.dt;if("object"==typeof a){i=0;for(iLen=c.aoColumns.length;i<iLen;i++)b.push(!1);i=0;for(iLen=a.length;i<iLen;i++)b[a[i]]=!0}else if("visible"==
|
54
|
+
a){i=0;for(iLen=c.aoColumns.length;i<iLen;i++)b.push(c.aoColumns[i].bVisible?!0:!1)}else if("hidden"==a){i=0;for(iLen=c.aoColumns.length;i<iLen;i++)b.push(c.aoColumns[i].bVisible?!1:!0)}else if("sortable"==a){i=0;for(iLen=c.aoColumns.length;i<iLen;i++)b.push(c.aoColumns[i].bSortable?!0:!1)}else{i=0;for(iLen=c.aoColumns.length;i<iLen;i++)b.push(!0)}return b},_fnNewline:function(a){return"auto"==a.sNewLine?navigator.userAgent.match(/Windows/)?"\r\n":"\n":a.sNewLine},_fnGetDataTablesData:function(a){var b,
|
55
|
+
c,d,g,h,f=[],j="",k=this.s.dt,n,l=RegExp(a.sFieldBoundary,"g"),m=this._fnColumnTargets(a.mColumns);d="undefined"!=typeof a.bSelectedOnly?a.bSelectedOnly:!1;if(a.bHeader){h=[];b=0;for(c=k.aoColumns.length;b<c;b++)m[b]&&(j=k.aoColumns[b].sTitle.replace(/\n/g," ").replace(/<.*?>/g,"").replace(/^\s+|\s+$/g,""),j=this._fnHtmlDecode(j),h.push(this._fnBoundData(j,a.sFieldBoundary,l)));f.push(h.join(a.sFieldSeperator))}var o=k.aiDisplay;g=this.fnGetSelected();if("none"!==this.s.select.type&&d&&0!==g.length){o=
|
56
|
+
[];b=0;for(c=g.length;b<c;b++)o.push(k.oInstance.fnGetPosition(g[b]))}d=0;for(g=o.length;d<g;d++){n=k.aoData[o[d]].nTr;h=[];b=0;for(c=k.aoColumns.length;b<c;b++)m[b]&&(j=k.oApi._fnGetCellData(k,o[d],b,"display"),a.fnCellRender?j=a.fnCellRender(j,b,n,o[d])+"":"string"==typeof j?(j=j.replace(/\n/g," "),j=j.replace(/<img.*?\s+alt\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s>]+)).*?>/gi,"$1$2$3"),j=j.replace(/<.*?>/g,"")):j+="",j=j.replace(/^\s+/,"").replace(/\s+$/,""),j=this._fnHtmlDecode(j),h.push(this._fnBoundData(j,
|
57
|
+
a.sFieldBoundary,l)));f.push(h.join(a.sFieldSeperator));a.bOpenRows&&(b=e.grep(k.aoOpenRows,function(a){return a.nParent===n}),1===b.length&&(j=this._fnBoundData(e("td",b[0].nTr).html(),a.sFieldBoundary,l),f.push(j)))}if(a.bFooter&&null!==k.nTFoot){h=[];b=0;for(c=k.aoColumns.length;b<c;b++)m[b]&&null!==k.aoColumns[b].nTf&&(j=k.aoColumns[b].nTf.innerHTML.replace(/\n/g," ").replace(/<.*?>/g,""),j=this._fnHtmlDecode(j),h.push(this._fnBoundData(j,a.sFieldBoundary,l)));f.push(h.join(a.sFieldSeperator))}return _sLastData=
|
58
|
+
f.join(this._fnNewline(a))},_fnBoundData:function(a,b,c){return""===b?a:b+a.replace(c,b+b)+b},_fnChunkData:function(a,b){for(var c=[],d=a.length,e=0;e<d;e+=b)e+b<d?c.push(a.substring(e,e+b)):c.push(a.substring(e,d));return c},_fnHtmlDecode:function(a){if(-1==a.indexOf("&"))return a;var a=this._fnChunkData(a,2048),b=f.createElement("div"),c,d,e,h="";c=0;for(d=a.length;c<d;c++)e=a[c].lastIndexOf("&"),-1!=e&&(8<=a[c].length&&e>a[c].length-8)&&(a[c].substr(e),a[c]=a[c].substr(0,e)),b.innerHTML=a[c],h+=
|
59
|
+
b.childNodes[0].nodeValue;return h},_fnPrintStart:function(a){var b=this,c=this.s.dt;this._fnPrintHideNodes(c.nTable);this.s.print.saveStart=c._iDisplayStart;this.s.print.saveLength=c._iDisplayLength;a.bShowAll&&(c._iDisplayStart=0,c._iDisplayLength=-1,c.oApi._fnCalculateEnd(c),c.oApi._fnDraw(c));(""!==c.oScroll.sX||""!==c.oScroll.sY)&&this._fnPrintScrollStart(c);var c=c.aanFeatures,d;for(d in c)if("i"!=d&&"t"!=d&&1==d.length)for(var g=0,h=c[d].length;g<h;g++)this.dom.print.hidden.push({node:c[d][g],
|
60
|
+
display:"block"}),c[d][g].style.display="none";e(f.body).addClass(this.classes.print.body);""!==a.sInfo&&this.fnInfo(a.sInfo,3E3);a.sMessage&&(this.dom.print.message=f.createElement("div"),this.dom.print.message.className=this.classes.print.message,this.dom.print.message.innerHTML=a.sMessage,f.body.insertBefore(this.dom.print.message,f.body.childNodes[0]));this.s.print.saveScroll=e(m).scrollTop();m.scrollTo(0,0);e(f).bind("keydown.DTTT",function(a){if(a.keyCode==27){a.preventDefault();b._fnPrintEnd.call(b,
|
61
|
+
a)}})},_fnPrintEnd:function(){var a=this.s.dt,b=this.s.print,c=this.dom.print;this._fnPrintShowNodes();(""!==a.oScroll.sX||""!==a.oScroll.sY)&&this._fnPrintScrollEnd();m.scrollTo(0,b.saveScroll);null!==c.message&&(f.body.removeChild(c.message),c.message=null);e(f.body).removeClass("DTTT_Print");a._iDisplayStart=b.saveStart;a._iDisplayLength=b.saveLength;a.oApi._fnCalculateEnd(a);a.oApi._fnDraw(a);e(f).unbind("keydown.DTTT")},_fnPrintScrollStart:function(){var a=this.s.dt;a.nScrollHead.getElementsByTagName("div")[0].getElementsByTagName("table");
|
62
|
+
var b=a.nTable.parentNode,c=a.nTable.getElementsByTagName("thead");0<c.length&&a.nTable.removeChild(c[0]);null!==a.nTFoot&&(c=a.nTable.getElementsByTagName("tfoot"),0<c.length&&a.nTable.removeChild(c[0]));c=a.nTHead.cloneNode(!0);a.nTable.insertBefore(c,a.nTable.childNodes[0]);null!==a.nTFoot&&(c=a.nTFoot.cloneNode(!0),a.nTable.insertBefore(c,a.nTable.childNodes[1]));""!==a.oScroll.sX&&(a.nTable.style.width=e(a.nTable).outerWidth()+"px",b.style.width=e(a.nTable).outerWidth()+"px",b.style.overflow=
|
63
|
+
"visible");""!==a.oScroll.sY&&(b.style.height=e(a.nTable).outerHeight()+"px",b.style.overflow="visible")},_fnPrintScrollEnd:function(){var a=this.s.dt,b=a.nTable.parentNode;""!==a.oScroll.sX&&(b.style.width=a.oApi._fnStringToCss(a.oScroll.sX),b.style.overflow="auto");""!==a.oScroll.sY&&(b.style.height=a.oApi._fnStringToCss(a.oScroll.sY),b.style.overflow="auto")},_fnPrintShowNodes:function(){for(var a=this.dom.print.hidden,b=0,c=a.length;b<c;b++)a[b].node.style.display=a[b].display;a.splice(0,a.length)},
|
64
|
+
_fnPrintHideNodes:function(a){for(var b=this.dom.print.hidden,c=a.parentNode,d=c.childNodes,g=0,h=d.length;g<h;g++)if(d[g]!=a&&1==d[g].nodeType){var f=e(d[g]).css("display");"none"!=f&&(b.push({node:d[g],display:f}),d[g].style.display="none")}"BODY"!=c.nodeName&&this._fnPrintHideNodes(c)}};TableTools._aInstances=[];TableTools._aListeners=[];TableTools.fnGetMasters=function(){for(var a=[],b=0,c=TableTools._aInstances.length;b<c;b++)TableTools._aInstances[b].s.master&&a.push(TableTools._aInstances[b]);
|
65
|
+
return a};TableTools.fnGetInstance=function(a){"object"!=typeof a&&(a=f.getElementById(a));for(var b=0,c=TableTools._aInstances.length;b<c;b++)if(TableTools._aInstances[b].s.master&&TableTools._aInstances[b].dom.table==a)return TableTools._aInstances[b];return null};TableTools._fnEventListen=function(a,b,c){TableTools._aListeners.push({that:a,type:b,fn:c})};TableTools._fnEventDispatch=function(a,b,c){for(var d=TableTools._aListeners,e=0,f=d.length;e<f;e++)a.dom.table==d[e].that.dom.table&&d[e].type==
|
66
|
+
b&&d[e].fn(c)};TableTools.buttonBase={sAction:"text",sTag:"default",sLinerTag:"default",sButtonClass:"DTTT_button_text",sButtonText:"Button text",sTitle:"",sToolTip:"",sCharSet:"utf8",bBomInc:!1,sFileName:"*.csv",sFieldBoundary:"",sFieldSeperator:"\t",sNewLine:"auto",mColumns:"all",bHeader:!0,bFooter:!0,bOpenRows:!1,bSelectedOnly:!1,fnMouseover:null,fnMouseout:null,fnClick:null,fnSelect:null,fnComplete:null,fnInit:null,fnCellRender:null};TableTools.BUTTONS={csv:e.extend({},TableTools.buttonBase,{sAction:"flash_save",
|
67
|
+
sButtonClass:"DTTT_button_csv",sButtonText:"CSV",sFieldBoundary:'"',sFieldSeperator:",",fnClick:function(a,b,c){this.fnSetText(c,this.fnGetTableData(b))}}),xls:e.extend({},TableTools.buttonBase,{sAction:"flash_save",sCharSet:"utf16le",bBomInc:!0,sButtonClass:"DTTT_button_xls",sButtonText:"Excel",fnClick:function(a,b,c){this.fnSetText(c,this.fnGetTableData(b))}}),copy:e.extend({},TableTools.buttonBase,{sAction:"flash_copy",sButtonClass:"DTTT_button_copy",sButtonText:"Copy",fnClick:function(a,b,c){this.fnSetText(c,
|
68
|
+
this.fnGetTableData(b))},fnComplete:function(a,b,c,d){a=d.split("\n").length;a=null===this.s.dt.nTFoot?a-1:a-2;this.fnInfo("<h6>Table copied</h6><p>Copied "+a+" row"+(1==a?"":"s")+" to the clipboard.</p>",1500)}}),pdf:e.extend({},TableTools.buttonBase,{sAction:"flash_pdf",sNewLine:"\n",sFileName:"*.pdf",sButtonClass:"DTTT_button_pdf",sButtonText:"PDF",sPdfOrientation:"portrait",sPdfSize:"A4",sPdfMessage:"",fnClick:function(a,b,c){this.fnSetText(c,"title:"+this.fnGetTitle(b)+"\nmessage:"+b.sPdfMessage+
|
69
|
+
"\ncolWidth:"+this.fnCalcColRatios(b)+"\norientation:"+b.sPdfOrientation+"\nsize:"+b.sPdfSize+"\n--/TableToolsOpts--\n"+this.fnGetTableData(b))}}),print:e.extend({},TableTools.buttonBase,{sInfo:"<h6>Print view</h6><p>Please use your browser's print function to print this table. Press escape when finished.",sMessage:null,bShowAll:!0,sToolTip:"View print view",sButtonClass:"DTTT_button_print",sButtonText:"Print",fnClick:function(a,b){this.fnPrint(!0,b)}}),text:e.extend({},TableTools.buttonBase),select:e.extend({},
|
70
|
+
TableTools.buttonBase,{sButtonText:"Select button",fnSelect:function(a){0!==this.fnGetSelected().length?e(a).removeClass(this.classes.buttons.disabled):e(a).addClass(this.classes.buttons.disabled)},fnInit:function(a){e(a).addClass(this.classes.buttons.disabled)}}),select_single:e.extend({},TableTools.buttonBase,{sButtonText:"Select button",fnSelect:function(a){1==this.fnGetSelected().length?e(a).removeClass(this.classes.buttons.disabled):e(a).addClass(this.classes.buttons.disabled)},fnInit:function(a){e(a).addClass(this.classes.buttons.disabled)}}),
|
71
|
+
select_all:e.extend({},TableTools.buttonBase,{sButtonText:"Select all",fnClick:function(){this.fnSelectAll()},fnSelect:function(a){this.fnGetSelected().length==this.s.dt.fnRecordsDisplay()?e(a).addClass(this.classes.buttons.disabled):e(a).removeClass(this.classes.buttons.disabled)}}),select_none:e.extend({},TableTools.buttonBase,{sButtonText:"Deselect all",fnClick:function(){this.fnSelectNone()},fnSelect:function(a){0!==this.fnGetSelected().length?e(a).removeClass(this.classes.buttons.disabled):e(a).addClass(this.classes.buttons.disabled)},
|
72
|
+
fnInit:function(a){e(a).addClass(this.classes.buttons.disabled)}}),ajax:e.extend({},TableTools.buttonBase,{sAjaxUrl:"/xhr.php",sButtonText:"Ajax button",fnClick:function(a,b){var c=this.fnGetTableData(b);e.ajax({url:b.sAjaxUrl,data:[{name:"tableData",value:c}],success:b.fnAjaxComplete,dataType:"json",type:"POST",cache:!1,error:function(){alert("Error detected when sending table data to server")}})},fnAjaxComplete:function(){alert("Ajax complete")}}),div:e.extend({},TableTools.buttonBase,{sAction:"div",
|
73
|
+
sTag:"div",sButtonClass:"DTTT_nonbutton",sButtonText:"Text button"}),collection:e.extend({},TableTools.buttonBase,{sAction:"collection",sButtonClass:"DTTT_button_collection",sButtonText:"Collection",fnClick:function(a,b){this._fnCollectionShow(a,b)}})};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",
|
74
|
+
row:"DTTT_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:"media/swf/copy_csv_xls_pdf.swf",sRowSelect:"none",sSelectedClass:null,fnPreRowSelect:null,fnRowSelected:null,fnRowDeselected:null,aButtons:["copy","csv",
|
75
|
+
"xls","pdf","print"],oTags:{container:"div",button:"a",liner:"span",collection:{container:"div",button:"a",liner:"span"}}};TableTools.prototype.CLASS="TableTools";TableTools.VERSION="2.1.3";TableTools.prototype.VERSION=TableTools.VERSION;"function"==typeof e.fn.dataTable&&"function"==typeof e.fn.dataTableExt.fnVersionCheck&&e.fn.dataTableExt.fnVersionCheck("1.9.0")?e.fn.dataTableExt.aoFeatures.push({fnInit:function(a){a=new TableTools(a.oInstance,"undefined"!=typeof a.oInit.oTableTools?a.oInit.oTableTools:
|
76
|
+
{});TableTools._aInstances.push(a);return a.dom.container},cFeature:"T",sFeature:"TableTools"}):alert("Warning: TableTools 2 requires DataTables 1.9.0 or newer - www.datatables.net/download");e.fn.DataTable.TableTools=TableTools})(jQuery,window,document);
|
@@ -140,8 +140,8 @@ ZeroClipboard_TableTools.Client.prototype = {
|
|
140
140
|
var style = this.div.style;
|
141
141
|
|
142
142
|
style.position = 'absolute';
|
143
|
-
style.left = (this.domElement.offsetLeft)+'px';
|
144
|
-
style.top = this.domElement.offsetTop+'px';
|
143
|
+
//style.left = (this.domElement.offsetLeft)+'px';
|
144
|
+
//style.top = this.domElement.offsetTop+'px';
|
145
145
|
style.width = box.width + 'px';
|
146
146
|
style.height = box.height + 'px';
|
147
147
|
|
File without changes
|
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) {
|
2
|
+
var _that = this;
|
3
|
+
|
4
|
+
if ( iDelay === undefined ) {
|
5
|
+
iDelay = 250;
|
6
|
+
}
|
7
|
+
|
8
|
+
this.each( function ( i ) {
|
9
|
+
$.fn.dataTableExt.iApiIndex = i;
|
10
|
+
var
|
11
|
+
$this = this,
|
12
|
+
oTimerId = null,
|
13
|
+
sPreviousSearch = null,
|
14
|
+
anControl = $( 'input', _that.fnSettings().aanFeatures.f );
|
15
|
+
|
16
|
+
anControl.unbind( 'keyup' ).bind( 'keyup', function() {
|
17
|
+
var $$this = $this;
|
18
|
+
|
19
|
+
if (sPreviousSearch === null || sPreviousSearch != anControl.val()) {
|
20
|
+
window.clearTimeout(oTimerId);
|
21
|
+
sPreviousSearch = anControl.val();
|
22
|
+
oTimerId = window.setTimeout(function() {
|
23
|
+
$.fn.dataTableExt.iApiIndex = i;
|
24
|
+
_that.fnFilter( anControl.val() );
|
25
|
+
}, iDelay);
|
26
|
+
}
|
27
|
+
});
|
28
|
+
|
29
|
+
return this;
|
30
|
+
} );
|
31
|
+
return this;
|
32
|
+
};
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,221 @@
|
|
1
|
+
/* Compile using: mxmlc --target-player=10.0.0 ZeroClipboard.as */
|
2
|
+
package {
|
3
|
+
import flash.display.Stage;
|
4
|
+
import flash.display.Sprite;
|
5
|
+
import flash.display.LoaderInfo;
|
6
|
+
import flash.display.StageScaleMode;
|
7
|
+
import flash.events.*;
|
8
|
+
import flash.display.StageAlign;
|
9
|
+
import flash.display.StageScaleMode;
|
10
|
+
import flash.external.ExternalInterface;
|
11
|
+
import flash.system.Security;
|
12
|
+
import flash.utils.*;
|
13
|
+
import flash.system.System;
|
14
|
+
import flash.net.FileReference;
|
15
|
+
import flash.net.FileFilter;
|
16
|
+
|
17
|
+
public class ZeroClipboard extends Sprite {
|
18
|
+
|
19
|
+
private var domId:String = '';
|
20
|
+
private var button:Sprite;
|
21
|
+
private var clipText:String = 'blank';
|
22
|
+
private var fileName:String = '';
|
23
|
+
private var action:String = 'copy';
|
24
|
+
private var incBom:Boolean = true;
|
25
|
+
private var charSet:String = 'utf8';
|
26
|
+
|
27
|
+
|
28
|
+
public function ZeroClipboard() {
|
29
|
+
// constructor, setup event listeners and external interfaces
|
30
|
+
stage.scaleMode = StageScaleMode.EXACT_FIT;
|
31
|
+
flash.system.Security.allowDomain("*");
|
32
|
+
|
33
|
+
// import flashvars
|
34
|
+
var flashvars:Object = LoaderInfo( this.root.loaderInfo ).parameters;
|
35
|
+
domId = flashvars.id;
|
36
|
+
|
37
|
+
// invisible button covers entire stage
|
38
|
+
button = new Sprite();
|
39
|
+
button.buttonMode = true;
|
40
|
+
button.useHandCursor = true;
|
41
|
+
button.graphics.beginFill(0x00FF00);
|
42
|
+
button.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
|
43
|
+
button.alpha = 0.0;
|
44
|
+
addChild(button);
|
45
|
+
|
46
|
+
button.addEventListener(MouseEvent.CLICK, clickHandler);
|
47
|
+
button.addEventListener(MouseEvent.MOUSE_OVER, function(event:Event):void {
|
48
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseOver', null );
|
49
|
+
} );
|
50
|
+
button.addEventListener(MouseEvent.MOUSE_OUT, function(event:Event):void {
|
51
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseOut', null );
|
52
|
+
} );
|
53
|
+
button.addEventListener(MouseEvent.MOUSE_DOWN, function(event:Event):void {
|
54
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseDown', null );
|
55
|
+
} );
|
56
|
+
button.addEventListener(MouseEvent.MOUSE_UP, function(event:Event):void {
|
57
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseUp', null );
|
58
|
+
} );
|
59
|
+
|
60
|
+
// External functions - readd whenever the stage is made active for IE
|
61
|
+
addCallbacks();
|
62
|
+
stage.addEventListener(Event.ACTIVATE, addCallbacks);
|
63
|
+
|
64
|
+
// signal to the browser that we are ready
|
65
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'load', null );
|
66
|
+
}
|
67
|
+
|
68
|
+
public function addCallbacks (evt:Event = null):void {
|
69
|
+
ExternalInterface.addCallback("setHandCursor", setHandCursor);
|
70
|
+
ExternalInterface.addCallback("clearText", clearText);
|
71
|
+
ExternalInterface.addCallback("setText", setText);
|
72
|
+
ExternalInterface.addCallback("appendText", appendText);
|
73
|
+
ExternalInterface.addCallback("setFileName", setFileName);
|
74
|
+
ExternalInterface.addCallback("setAction", setAction);
|
75
|
+
ExternalInterface.addCallback("setCharSet", setCharSet);
|
76
|
+
ExternalInterface.addCallback("setBomInc", setBomInc);
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
public function setCharSet(newCharSet:String):void {
|
81
|
+
if ( newCharSet == 'UTF16LE' ) {
|
82
|
+
charSet = newCharSet;
|
83
|
+
} else {
|
84
|
+
charSet = 'UTF8';
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
public function setBomInc(newBomInc:Boolean):void {
|
89
|
+
incBom = newBomInc;
|
90
|
+
}
|
91
|
+
|
92
|
+
public function clearText():void {
|
93
|
+
clipText = '';
|
94
|
+
}
|
95
|
+
|
96
|
+
public function appendText(newText:String):void {
|
97
|
+
clipText += newText;
|
98
|
+
}
|
99
|
+
|
100
|
+
public function setText(newText:String):void {
|
101
|
+
clipText = newText;
|
102
|
+
}
|
103
|
+
|
104
|
+
public function setFileName(newFileName:String):void {
|
105
|
+
fileName = newFileName;
|
106
|
+
}
|
107
|
+
|
108
|
+
public function setAction(newAction:String):void {
|
109
|
+
action = newAction;
|
110
|
+
}
|
111
|
+
|
112
|
+
public function setHandCursor(enabled:Boolean):void {
|
113
|
+
// control whether the hand cursor is shown on rollover (true)
|
114
|
+
// or the default arrow cursor (false)
|
115
|
+
button.useHandCursor = enabled;
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
private function clickHandler(event:Event):void {
|
120
|
+
var fileRef:FileReference = new FileReference();
|
121
|
+
fileRef.addEventListener(Event.COMPLETE, saveComplete);
|
122
|
+
|
123
|
+
if ( action == "save" ) {
|
124
|
+
/* Save as a file */
|
125
|
+
if ( charSet == 'UTF16LE' ) {
|
126
|
+
fileRef.save( strToUTF16LE(clipText), fileName );
|
127
|
+
} else {
|
128
|
+
fileRef.save( strToUTF8(clipText), fileName );
|
129
|
+
}
|
130
|
+
} else if ( action == "pdf" ) {
|
131
|
+
fileRef.save( "This instance of ZeroClipboard is not configured for PDF export. "+
|
132
|
+
"Please use the PDF export version.", fileName+".txt" );
|
133
|
+
} else {
|
134
|
+
/* Copy the text to the clipboard. Note charset and BOM have no effect here */
|
135
|
+
System.setClipboard( clipText );
|
136
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'complete', clipText );
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
|
141
|
+
private function saveComplete(event:Event):void {
|
142
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'complete', clipText );
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
private function getProp( prop:String, opts:Array ):String
|
147
|
+
{
|
148
|
+
var i:int, iLen:int;
|
149
|
+
for ( i=0, iLen=opts.length ; i<iLen ; i++ )
|
150
|
+
{
|
151
|
+
if ( opts[i].indexOf( prop+":" ) != -1 )
|
152
|
+
{
|
153
|
+
return opts[i].replace( prop+":", "" );
|
154
|
+
}
|
155
|
+
}
|
156
|
+
return "";
|
157
|
+
}
|
158
|
+
|
159
|
+
|
160
|
+
/*
|
161
|
+
* Function: strToUTF8
|
162
|
+
* Purpose: Convert a string to the output utf-8
|
163
|
+
* Returns: ByteArray
|
164
|
+
* Inputs: String
|
165
|
+
*/
|
166
|
+
private function strToUTF8( str:String ):ByteArray {
|
167
|
+
var utf8:ByteArray = new ByteArray();
|
168
|
+
|
169
|
+
/* BOM first */
|
170
|
+
if ( incBom ) {
|
171
|
+
utf8.writeByte( 0xEF );
|
172
|
+
utf8.writeByte( 0xBB );
|
173
|
+
utf8.writeByte( 0xBF );
|
174
|
+
}
|
175
|
+
utf8.writeUTFBytes( str );
|
176
|
+
|
177
|
+
return utf8;
|
178
|
+
}
|
179
|
+
|
180
|
+
|
181
|
+
/*
|
182
|
+
* Function: strToUTF16LE
|
183
|
+
* Purpose: Convert a string to the output utf-16
|
184
|
+
* Returns: ByteArray
|
185
|
+
* Inputs: String
|
186
|
+
* Notes: The fact that this function is needed is a little annoying. Basically, strings in
|
187
|
+
* AS3 are UTF-16 (with surrogate pairs and everything), but characters which take up less
|
188
|
+
* than 8 bytes appear to be stored as only 8 bytes. This function effective adds the
|
189
|
+
* padding required, and the BOM
|
190
|
+
*/
|
191
|
+
private function strToUTF16LE( str:String ):ByteArray {
|
192
|
+
var utf16:ByteArray = new ByteArray();
|
193
|
+
var iChar:uint;
|
194
|
+
var i:uint=0, iLen:uint = str.length;
|
195
|
+
|
196
|
+
/* BOM first */
|
197
|
+
if ( incBom ) {
|
198
|
+
utf16.writeByte( 0xFF );
|
199
|
+
utf16.writeByte( 0xFE );
|
200
|
+
}
|
201
|
+
|
202
|
+
while ( i < iLen ) {
|
203
|
+
iChar = str.charCodeAt(i);
|
204
|
+
|
205
|
+
if ( iChar < 0xFF ) {
|
206
|
+
/* one byte char */
|
207
|
+
utf16.writeByte( iChar );
|
208
|
+
utf16.writeByte( 0 );
|
209
|
+
} else {
|
210
|
+
/* two byte char */
|
211
|
+
utf16.writeByte( iChar & 0x00FF );
|
212
|
+
utf16.writeByte( iChar >> 8 );
|
213
|
+
}
|
214
|
+
|
215
|
+
i++;
|
216
|
+
}
|
217
|
+
|
218
|
+
return utf16;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
@@ -0,0 +1,310 @@
|
|
1
|
+
/* Compile using: mxmlc --target-player=10.0.0 -static-link-runtime-shared-libraries=true -library-path+=lib ZeroClipboardPdf.as */
|
2
|
+
package {
|
3
|
+
import flash.display.Stage;
|
4
|
+
import flash.display.Sprite;
|
5
|
+
import flash.display.LoaderInfo;
|
6
|
+
import flash.display.StageScaleMode;
|
7
|
+
import flash.events.*;
|
8
|
+
import flash.display.StageAlign;
|
9
|
+
import flash.display.StageScaleMode;
|
10
|
+
import flash.external.ExternalInterface;
|
11
|
+
import flash.system.Security;
|
12
|
+
import flash.utils.*;
|
13
|
+
import flash.system.System;
|
14
|
+
import flash.net.FileReference;
|
15
|
+
import flash.net.FileFilter;
|
16
|
+
|
17
|
+
/* PDF imports */
|
18
|
+
import org.alivepdf.pdf.PDF;
|
19
|
+
import org.alivepdf.data.Grid;
|
20
|
+
import org.alivepdf.data.GridColumn;
|
21
|
+
import org.alivepdf.layout.Orientation;
|
22
|
+
import org.alivepdf.layout.Size;
|
23
|
+
import org.alivepdf.layout.Unit;
|
24
|
+
import org.alivepdf.display.Display;
|
25
|
+
import org.alivepdf.saving.Method;
|
26
|
+
import org.alivepdf.fonts.FontFamily;
|
27
|
+
import org.alivepdf.fonts.Style;
|
28
|
+
import org.alivepdf.fonts.CoreFont;
|
29
|
+
import org.alivepdf.colors.RGBColor;
|
30
|
+
|
31
|
+
public class ZeroClipboard extends Sprite {
|
32
|
+
|
33
|
+
private var domId:String = '';
|
34
|
+
private var button:Sprite;
|
35
|
+
private var clipText:String = 'blank';
|
36
|
+
private var fileName:String = '';
|
37
|
+
private var action:String = 'copy';
|
38
|
+
private var incBom:Boolean = true;
|
39
|
+
private var charSet:String = 'utf8';
|
40
|
+
|
41
|
+
|
42
|
+
public function ZeroClipboard() {
|
43
|
+
// constructor, setup event listeners and external interfaces
|
44
|
+
stage.scaleMode = StageScaleMode.EXACT_FIT;
|
45
|
+
flash.system.Security.allowDomain("*");
|
46
|
+
|
47
|
+
// import flashvars
|
48
|
+
var flashvars:Object = LoaderInfo( this.root.loaderInfo ).parameters;
|
49
|
+
domId = flashvars.id;
|
50
|
+
|
51
|
+
// invisible button covers entire stage
|
52
|
+
button = new Sprite();
|
53
|
+
button.buttonMode = true;
|
54
|
+
button.useHandCursor = true;
|
55
|
+
button.graphics.beginFill(0x00FF00);
|
56
|
+
button.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
|
57
|
+
button.alpha = 0.0;
|
58
|
+
addChild(button);
|
59
|
+
|
60
|
+
button.addEventListener(MouseEvent.CLICK, function(event:Event):void {
|
61
|
+
clickHandler(event);
|
62
|
+
} );
|
63
|
+
button.addEventListener(MouseEvent.MOUSE_OVER, function(event:Event):void {
|
64
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseOver', null );
|
65
|
+
} );
|
66
|
+
button.addEventListener(MouseEvent.MOUSE_OUT, function(event:Event):void {
|
67
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseOut', null );
|
68
|
+
} );
|
69
|
+
button.addEventListener(MouseEvent.MOUSE_DOWN, function(event:Event):void {
|
70
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseDown', null );
|
71
|
+
} );
|
72
|
+
button.addEventListener(MouseEvent.MOUSE_UP, function(event:Event):void {
|
73
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'mouseUp', null );
|
74
|
+
} );
|
75
|
+
|
76
|
+
// External functions - readd whenever the stage is made active for IE
|
77
|
+
addCallbacks();
|
78
|
+
stage.addEventListener(Event.ACTIVATE, addCallbacks);
|
79
|
+
|
80
|
+
// signal to the browser that we are ready
|
81
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'load', null );
|
82
|
+
}
|
83
|
+
|
84
|
+
public function addCallbacks (evt:Event = null):void {
|
85
|
+
ExternalInterface.addCallback("setHandCursor", setHandCursor);
|
86
|
+
ExternalInterface.addCallback("clearText", clearText);
|
87
|
+
ExternalInterface.addCallback("setText", setText);
|
88
|
+
ExternalInterface.addCallback("appendText", appendText);
|
89
|
+
ExternalInterface.addCallback("setFileName", setFileName);
|
90
|
+
ExternalInterface.addCallback("setAction", setAction);
|
91
|
+
ExternalInterface.addCallback("setCharSet", setCharSet);
|
92
|
+
ExternalInterface.addCallback("setBomInc", setBomInc);
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
public function setCharSet(newCharSet:String):void {
|
97
|
+
if ( newCharSet == 'UTF16LE' ) {
|
98
|
+
charSet = newCharSet;
|
99
|
+
} else {
|
100
|
+
charSet = 'UTF8';
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
public function setBomInc(newBomInc:Boolean):void {
|
105
|
+
incBom = newBomInc;
|
106
|
+
}
|
107
|
+
|
108
|
+
public function clearText():void {
|
109
|
+
clipText = '';
|
110
|
+
}
|
111
|
+
|
112
|
+
public function appendText(newText:String):void {
|
113
|
+
clipText += newText;
|
114
|
+
}
|
115
|
+
|
116
|
+
public function setText(newText:String):void {
|
117
|
+
clipText = newText;
|
118
|
+
}
|
119
|
+
|
120
|
+
public function setFileName(newFileName:String):void {
|
121
|
+
fileName = newFileName;
|
122
|
+
}
|
123
|
+
|
124
|
+
public function setAction(newAction:String):void {
|
125
|
+
action = newAction;
|
126
|
+
}
|
127
|
+
|
128
|
+
public function setHandCursor(enabled:Boolean):void {
|
129
|
+
// control whether the hand cursor is shown on rollover (true)
|
130
|
+
// or the default arrow cursor (false)
|
131
|
+
button.useHandCursor = enabled;
|
132
|
+
}
|
133
|
+
|
134
|
+
|
135
|
+
private function clickHandler(event:Event):void {
|
136
|
+
var fileRef:FileReference = new FileReference();
|
137
|
+
fileRef.addEventListener(Event.COMPLETE, saveComplete);
|
138
|
+
|
139
|
+
if ( action == "save" ) {
|
140
|
+
/* Save as a file */
|
141
|
+
if ( charSet == 'UTF16LE' ) {
|
142
|
+
fileRef.save( strToUTF16LE(clipText), fileName );
|
143
|
+
} else {
|
144
|
+
fileRef.save( strToUTF8(clipText), fileName );
|
145
|
+
}
|
146
|
+
} else if ( action == "pdf" ) {
|
147
|
+
/* Save as a PDF */
|
148
|
+
var pdf:PDF = configPdf();
|
149
|
+
fileRef.save( pdf.save( Method.LOCAL ), fileName );
|
150
|
+
} else {
|
151
|
+
/* Copy the text to the clipboard. Note charset and BOM have no effect here */
|
152
|
+
System.setClipboard( clipText );
|
153
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'complete', clipText );
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
private function saveComplete(event:Event):void {
|
159
|
+
ExternalInterface.call( 'ZeroClipboard_TableTools.dispatch', domId, 'complete', clipText );
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
private function getProp( prop:String, opts:Array ):String
|
164
|
+
{
|
165
|
+
var i:int, iLen:int;
|
166
|
+
for ( i=0, iLen=opts.length ; i<iLen ; i++ )
|
167
|
+
{
|
168
|
+
if ( opts[i].indexOf( prop+":" ) != -1 )
|
169
|
+
{
|
170
|
+
return opts[i].replace( prop+":", "" );
|
171
|
+
}
|
172
|
+
}
|
173
|
+
return "";
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
private function configPdf():PDF
|
178
|
+
{
|
179
|
+
var
|
180
|
+
pdf:PDF,
|
181
|
+
i:int, iLen:int,
|
182
|
+
splitText:Array = clipText.split("--/TableToolsOpts--\n"),
|
183
|
+
opts:Array = splitText[0].split("\n"),
|
184
|
+
dataIn:Array = splitText[1].split("\n"),
|
185
|
+
aColRatio:Array = getProp( 'colWidth', opts ).split('\t'),
|
186
|
+
title:String = getProp( 'title', opts ),
|
187
|
+
message:String = getProp( 'message', opts ),
|
188
|
+
orientation:String = getProp( 'orientation', opts ),
|
189
|
+
size:String = getProp( 'size', opts ),
|
190
|
+
iPageWidth:int = 0,
|
191
|
+
dataOut:Array = [],
|
192
|
+
columns:Array = [],
|
193
|
+
headers:Array,
|
194
|
+
y:int = 0;
|
195
|
+
|
196
|
+
/* Create the PDF */
|
197
|
+
pdf = new PDF( Orientation[orientation.toUpperCase()], Unit.MM, Size[size.toUpperCase()] );
|
198
|
+
pdf.setDisplayMode( Display.FULL_WIDTH );
|
199
|
+
pdf.addPage();
|
200
|
+
iPageWidth = pdf.getCurrentPage().w-20;
|
201
|
+
pdf.textStyle( new RGBColor(0), 1 );
|
202
|
+
|
203
|
+
/* Add the title / message if there is one */
|
204
|
+
pdf.setFont( new CoreFont(FontFamily.HELVETICA), 14 );
|
205
|
+
if ( title != "" )
|
206
|
+
{
|
207
|
+
pdf.writeText(11, title+"\n");
|
208
|
+
}
|
209
|
+
|
210
|
+
pdf.setFont( new CoreFont(FontFamily.HELVETICA), 11 );
|
211
|
+
if ( message != "" )
|
212
|
+
{
|
213
|
+
pdf.writeText(11, message+"\n");
|
214
|
+
}
|
215
|
+
|
216
|
+
/* Data setup. Split up the headers, and then construct the columns */
|
217
|
+
for ( i=0, iLen=dataIn.length ; i<iLen ; i++ )
|
218
|
+
{
|
219
|
+
if ( dataIn[i] != "" )
|
220
|
+
{
|
221
|
+
dataOut.push( dataIn[i].split("\t") );
|
222
|
+
}
|
223
|
+
}
|
224
|
+
headers = dataOut.shift();
|
225
|
+
|
226
|
+
for ( i=0, iLen=headers.length ; i<iLen ; i++ )
|
227
|
+
{
|
228
|
+
columns.push( new GridColumn( " \n"+headers[i]+"\n ", i.toString(), aColRatio[i]*iPageWidth, 'C' ) );
|
229
|
+
}
|
230
|
+
|
231
|
+
var grid:Grid = new Grid(
|
232
|
+
dataOut, /* 1. data */
|
233
|
+
iPageWidth, /* 2. width */
|
234
|
+
100, /* 3. height */
|
235
|
+
new RGBColor (0xE0E0E0), /* 4. headerColor */
|
236
|
+
new RGBColor (0xFFFFFF), /* 5. backgroundColor */
|
237
|
+
true, /* 6. alternateRowColor */
|
238
|
+
new RGBColor ( 0x0 ), /* 7. borderColor */
|
239
|
+
.1, /* 8. border alpha */
|
240
|
+
null, /* 9. joins */
|
241
|
+
columns /* 10. columns */
|
242
|
+
);
|
243
|
+
|
244
|
+
pdf.addGrid( grid, 0, y );
|
245
|
+
return pdf;
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
/*
|
250
|
+
* Function: strToUTF8
|
251
|
+
* Purpose: Convert a string to the output utf-8
|
252
|
+
* Returns: ByteArray
|
253
|
+
* Inputs: String
|
254
|
+
*/
|
255
|
+
private function strToUTF8( str:String ):ByteArray {
|
256
|
+
var utf8:ByteArray = new ByteArray();
|
257
|
+
|
258
|
+
/* BOM first */
|
259
|
+
if ( incBom ) {
|
260
|
+
utf8.writeByte( 0xEF );
|
261
|
+
utf8.writeByte( 0xBB );
|
262
|
+
utf8.writeByte( 0xBF );
|
263
|
+
}
|
264
|
+
utf8.writeUTFBytes( str );
|
265
|
+
|
266
|
+
return utf8;
|
267
|
+
}
|
268
|
+
|
269
|
+
|
270
|
+
/*
|
271
|
+
* Function: strToUTF16LE
|
272
|
+
* Purpose: Convert a string to the output utf-16
|
273
|
+
* Returns: ByteArray
|
274
|
+
* Inputs: String
|
275
|
+
* Notes: The fact that this function is needed is a little annoying. Basically, strings in
|
276
|
+
* AS3 are UTF-16 (with surrogate pairs and everything), but characters which take up less
|
277
|
+
* than 8 bytes appear to be stored as only 8 bytes. This function effective adds the
|
278
|
+
* padding required, and the BOM
|
279
|
+
*/
|
280
|
+
private function strToUTF16LE( str:String ):ByteArray {
|
281
|
+
var utf16:ByteArray = new ByteArray();
|
282
|
+
var iChar:uint;
|
283
|
+
var i:uint=0, iLen:uint = str.length;
|
284
|
+
|
285
|
+
/* BOM first */
|
286
|
+
if ( incBom ) {
|
287
|
+
utf16.writeByte( 0xFF );
|
288
|
+
utf16.writeByte( 0xFE );
|
289
|
+
}
|
290
|
+
|
291
|
+
while ( i < iLen ) {
|
292
|
+
iChar = str.charCodeAt(i);
|
293
|
+
|
294
|
+
if ( iChar < 0xFF ) {
|
295
|
+
/* one byte char */
|
296
|
+
utf16.writeByte( iChar );
|
297
|
+
utf16.writeByte( 0 );
|
298
|
+
} else {
|
299
|
+
/* two byte char */
|
300
|
+
utf16.writeByte( iChar & 0x00FF );
|
301
|
+
utf16.writeByte( iChar >> 8 );
|
302
|
+
}
|
303
|
+
|
304
|
+
i++;
|
305
|
+
}
|
306
|
+
|
307
|
+
return utf16;
|
308
|
+
}
|
309
|
+
}
|
310
|
+
}
|