5 var ZeroClipboard_TableTools = {
7 version:
"1.0.4-TableTools2",
14 if (typeof(thingy) ==
'string') {
15 thingy = document.getElementById(thingy);
17 if (!thingy.addClass) {
19 thingy.hide =
function() { this.style.display =
'none'; };
20 thingy.show =
function() { this.style.display =
''; };
21 thingy.addClass =
function(name) { this.removeClass(name); this.className +=
' ' + name; };
22 thingy.removeClass =
function(name) {
23 this.className = this.className.replace(
new RegExp(
"\\s*" + name +
"\\s*"),
" ").replace(/^\s+/,
'').replace(/\s+$/,
'');
25 thingy.hasClass =
function(name) {
26 return !!this.className.match(
new RegExp(
"\\s*" + name +
"\\s*") );
32 setMoviePath:
function(path) {
34 this.moviePath = path;
37 dispatch:
function(id, eventName, args) {
39 var client = this.clients[id];
41 client.receiveEvent(eventName, args);
45 register:
function(id, client) {
47 this.clients[id] = client;
50 getDOMObjectPosition:
function(obj) {
55 width: obj.width ? obj.width : obj.offsetWidth,
56 height: obj.height ? obj.height : obj.offsetHeight
59 if ( obj.style.width !==
"" ) {
60 info.width = obj.style.width.replace(
"px",
"");
63 if ( obj.style.height !==
"" ) {
64 info.height = obj.style.height.replace(
"px",
"");
68 info.left += obj.offsetLeft;
69 info.top += obj.offsetTop;
70 obj = obj.offsetParent;
76 Client:
function(elem) {
81 this.
id = ZeroClipboard_TableTools.nextId++;
82 this.movieId =
'ZeroClipboard_TableToolsMovie_' + this.id;
85 ZeroClipboard_TableTools.register(this.
id,
this);
94 ZeroClipboard_TableTools.Client.prototype = {
102 handCursorEnabled:
true,
107 glue:
function(elem, title) {
110 this.domElement = ZeroClipboard_TableTools.$(elem);
114 if (this.domElement.style.zIndex) {
115 zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
119 var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
122 this.div = document.createElement(
'div');
123 var style = this.div.style;
124 style.position =
'absolute';
127 style.width = (box.width) +
'px';
128 style.height = box.height +
'px';
129 style.zIndex = zIndex;
131 if ( typeof title !=
"undefined" && title !==
"" ) {
132 this.div.title = title;
134 if ( box.width !== 0 && box.height !== 0 ) {
139 if ( this.domElement ) {
140 this.domElement.appendChild(this.div);
141 this.div.innerHTML = this.getHTML( box.width, box.height ).replace(/&/g,
'&');
145 positionElement:
function() {
146 var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
147 var style = this.div.style;
149 style.position =
'absolute';
152 style.width = box.width +
'px';
153 style.height = box.height +
'px';
155 if ( box.width !== 0 && box.height !== 0 ) {
161 var flash = this.div.childNodes[0];
162 flash.width = box.width;
163 flash.height = box.height;
166 getHTML:
function(width, height) {
169 var flashvars =
'id=' + this.
id +
173 if (navigator.userAgent.match(/MSIE/)) {
175 var protocol = location.href.match(/^https/i) ?
'https://' :
'http://';
176 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>';
180 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" />';
188 this.div.style.left =
'-2000px';
197 destroy:
function() {
199 if (this.domElement && this.div) {
201 this.div.innerHTML =
'';
203 var body = document.getElementsByTagName(
'body')[0];
204 try { body.removeChild( this.div ); }
catch(e) {}
206 this.domElement = null;
211 reposition:
function(elem) {
215 this.domElement = ZeroClipboard_TableTools.$(elem);
216 if (!this.domElement) {
221 if (this.domElement && this.div) {
222 var box = ZeroClipboard_TableTools.getDOMObjectPosition(this.domElement);
223 var style = this.div.style;
224 style.left =
'' + box.left +
'px';
225 style.top =
'' + box.top +
'px';
229 clearText:
function() {
233 this.movie.clearText();
237 appendText:
function(newText) {
239 this.clipText += newText;
240 if (this.ready) { this.movie.appendText(newText) ;}
243 setText:
function(newText) {
245 this.clipText = newText;
246 if (this.ready) { this.movie.setText(newText) ;}
249 setCharSet:
function(charSet) {
251 this.charSet = charSet;
252 if (this.ready) { this.movie.setCharSet(charSet) ;}
255 setBomInc:
function(bomInc) {
257 this.incBom = bomInc;
258 if (this.ready) { this.movie.setBomInc(bomInc) ;}
261 setFileName:
function(newText) {
263 this.fileName = newText;
265 this.movie.setFileName(newText);
269 setAction:
function(newText) {
271 this.action = newText;
273 this.movie.setAction(newText);
277 addEventListener:
function(eventName, func) {
280 eventName = eventName.toString().toLowerCase().replace(/^on/,
'');
281 if (!this.handlers[eventName]) {
282 this.handlers[eventName] = [];
284 this.handlers[eventName].push(func);
287 setHandCursor:
function(enabled) {
289 this.handCursorEnabled = enabled;
291 this.movie.setHandCursor(enabled);
295 setCSSEffects:
function(enabled) {
297 this.cssEffects = !!enabled;
300 receiveEvent:
function(eventName, args) {
304 eventName = eventName.toString().toLowerCase().replace(/^on/,
'');
311 this.movie = document.getElementById(this.movieId);
314 setTimeout(
function() {
self.receiveEvent(
'load', null); }, 1 );
319 if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
321 setTimeout(
function() {
self.receiveEvent(
'load', null); }, 100 );
327 this.movie.clearText();
328 this.movie.appendText( this.clipText );
329 this.movie.setFileName( this.fileName );
330 this.movie.setAction( this.action );
331 this.movie.setCharSet( this.charSet );
332 this.movie.setBomInc( this.incBom );
333 this.movie.setHandCursor( this.handCursorEnabled );
337 if (this.domElement && this.cssEffects) {
339 if (this.recoverActive) {
340 this.domElement.addClass(
'active');
346 if (this.domElement && this.cssEffects) {
347 this.recoverActive =
false;
348 if (this.domElement.hasClass(
'active')) {
349 this.domElement.removeClass(
'active');
350 this.recoverActive =
true;
357 if (this.domElement && this.cssEffects) {
358 this.domElement.addClass(
'active');
363 if (this.domElement && this.cssEffects) {
364 this.domElement.removeClass(
'active');
365 this.recoverActive =
false;
370 if (this.handlers[eventName]) {
371 for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) {
372 var func = this.handlers[eventName][idx];
374 if (typeof(func) ==
'function') {
378 else if ((typeof(func) ==
'object') && (func.length == 2)) {
380 func[0][ func[1] ](
this, args);
382 else if (typeof(func) ==
'string') {
384 window[func](
this, args);
394 window.ZeroClipboard_TableTools = ZeroClipboard_TableTools;