[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 YUI.add('yui2-uploader', function(Y) { 2 var YAHOO = Y.YUI2; 3 /* 4 Copyright (c) 2011, Yahoo! Inc. All rights reserved. 5 Code licensed under the BSD License: 6 http://developer.yahoo.com/yui/license.html 7 version: 2.9.0 8 */ 9 /*extern ActiveXObject, __flash_unloadHandler, __flash_savedUnloadHandler */ 10 /*! 11 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/ 12 * 13 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License: 14 * http://www.opensource.org/licenses/mit-license.php 15 * @namespace YAHOO 16 */ 17 18 YAHOO.namespace("deconcept"); 19 20 YAHOO.deconcept = YAHOO.deconcept || {}; 21 22 if(typeof YAHOO.deconcept.util == "undefined" || !YAHOO.deconcept.util) 23 { 24 YAHOO.deconcept.util = {}; 25 } 26 27 if(typeof YAHOO.deconcept.SWFObjectUtil == "undefined" || !YAHOO.deconcept.SWFObjectUtil) 28 { 29 YAHOO.deconcept.SWFObjectUtil = {}; 30 } 31 32 YAHOO.deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) 33 { 34 if(!document.getElementById) { return; } 35 this.DETECT_KEY = detectKey ? detectKey : 'detectflash'; 36 this.skipDetect = YAHOO.deconcept.util.getRequestParameter(this.DETECT_KEY); 37 this.params = {}; 38 this.variables = {}; 39 this.attributes = []; 40 if(swf) { this.setAttribute('swf', swf); } 41 if(id) { this.setAttribute('id', id); } 42 if(w) { this.setAttribute('width', w); } 43 if(h) { this.setAttribute('height', h); } 44 if(ver) { this.setAttribute('version', new YAHOO.deconcept.PlayerVersion(ver.toString().split("."))); } 45 this.installedVer = YAHOO.deconcept.SWFObjectUtil.getPlayerVersion(); 46 if (!window.opera && document.all && this.installedVer.major > 7) 47 { 48 // only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE 49 YAHOO.deconcept.SWFObject.doPrepUnload = true; 50 } 51 if(c) 52 { 53 this.addParam('bgcolor', c); 54 } 55 var q = quality ? quality : 'high'; 56 this.addParam('quality', q); 57 this.setAttribute('useExpressInstall', false); 58 this.setAttribute('doExpressInstall', false); 59 var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location; 60 this.setAttribute('xiRedirectUrl', xir); 61 this.setAttribute('redirectUrl', ''); 62 if(redirectUrl) 63 { 64 this.setAttribute('redirectUrl', redirectUrl); 65 } 66 }; 67 68 YAHOO.deconcept.SWFObject.prototype = 69 { 70 useExpressInstall: function(path) 71 { 72 this.xiSWFPath = !path ? "expressinstall.swf" : path; 73 this.setAttribute('useExpressInstall', true); 74 }, 75 setAttribute: function(name, value){ 76 this.attributes[name] = value; 77 }, 78 getAttribute: function(name){ 79 return this.attributes[name]; 80 }, 81 addParam: function(name, value){ 82 this.params[name] = value; 83 }, 84 getParams: function(){ 85 return this.params; 86 }, 87 addVariable: function(name, value){ 88 this.variables[name] = value; 89 }, 90 getVariable: function(name){ 91 return this.variables[name]; 92 }, 93 getVariables: function(){ 94 return this.variables; 95 }, 96 getVariablePairs: function(){ 97 var variablePairs = []; 98 var key; 99 var variables = this.getVariables(); 100 for(key in variables) 101 { 102 if(variables.hasOwnProperty(key)) 103 { 104 variablePairs[variablePairs.length] = YAHOO.lang.escapeHTML(key || '') +"="+ YAHOO.lang.escapeHTML(encodeURIComponent(variables[key] || '')); 105 } 106 } 107 return variablePairs; 108 }, 109 getSWFHTML: function() { 110 var swfNode = ""; 111 var params = {}; 112 var key = ""; 113 var pairs = ""; 114 if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture 115 if (this.getAttribute("doExpressInstall")) { 116 this.addVariable("MMplayerType", "PlugIn"); 117 this.setAttribute('swf', this.xiSWFPath); 118 } 119 swfNode = '<embed type="application/x-shockwave-flash" src="'+ YAHOO.lang.escapeHTML(this.getAttribute('swf') || '') +'" width="'+ YAHOO.lang.escapeHTML(this.getAttribute('width') || '') +'" height="'+ YAHOO.lang.escapeHTML(this.getAttribute('height') || '') +'" style="'+ YAHOO.lang.escapeHTML(this.getAttribute('style') || '') +'"'; 120 swfNode += ' id="'+ YAHOO.lang.escapeHTML(this.getAttribute('id') || '') +'" name="'+ YAHOO.lang.escapeHTML(this.getAttribute('id') || '') +'" '; 121 params = this.getParams(); 122 for(key in params) 123 { 124 if(params.hasOwnProperty(key)) 125 { 126 swfNode += YAHOO.lang.escapeHTML(key || '') +'="'+ YAHOO.lang.escapeHTML(params[key] || '') +'" '; 127 } 128 } 129 pairs = this.getVariablePairs().join("&"); 130 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; } 131 swfNode += '/>'; 132 } else { // PC IE 133 if (this.getAttribute("doExpressInstall")) { 134 this.addVariable("MMplayerType", "ActiveX"); 135 this.setAttribute('swf', this.xiSWFPath); 136 } 137 swfNode = '<object id="'+ YAHOO.lang.escapeHTML(this.getAttribute('id') || '') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ YAHOO.lang.escapeHTML(this.getAttribute('width') || '') +'" height="'+ YAHOO.lang.escapeHTML(this.getAttribute('height') || '') +'" style="'+ YAHOO.lang.escapeHTML(this.getAttribute('style') || '') +'">'; 138 swfNode += '<param name="movie" value="'+ YAHOO.lang.escapeHTML(this.getAttribute('swf') || '') +'" />'; 139 params = this.getParams(); 140 for(key in params) 141 { 142 if(params.hasOwnProperty(key)) 143 { 144 swfNode += '<param name="'+ YAHOO.lang.escapeHTML(key || '') +'" value="'+ YAHOO.lang.escapeHTML(params[key] || '') +'" />'; 145 } 146 } 147 pairs = this.getVariablePairs().join("&"); 148 if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';} 149 swfNode += "</object>"; 150 } 151 return swfNode; 152 }, 153 write: function(elementId) 154 { 155 if(this.getAttribute('useExpressInstall')) { 156 // check to see if we need to do an express install 157 var expressInstallReqVer = new YAHOO.deconcept.PlayerVersion([6,0,65]); 158 if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) { 159 this.setAttribute('doExpressInstall', true); 160 this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl'))); 161 document.title = document.title.slice(0, 47) + " - Flash Player Installation"; 162 this.addVariable("MMdoctitle", document.title); 163 } 164 } 165 if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))) 166 { 167 var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId; 168 n.innerHTML = this.getSWFHTML(); 169 return true; 170 } 171 else 172 { 173 if(this.getAttribute('redirectUrl') !== "") 174 { 175 document.location.replace(this.getAttribute('redirectUrl')); 176 } 177 } 178 return false; 179 } 180 }; 181 182 /* ---- detection functions ---- */ 183 YAHOO.deconcept.SWFObjectUtil.getPlayerVersion = function() 184 { 185 var axo = null; 186 var PlayerVersion = new YAHOO.deconcept.PlayerVersion([0,0,0]); 187 if(navigator.plugins && navigator.mimeTypes.length) 188 { 189 var x = navigator.plugins["Shockwave Flash"]; 190 if(x && x.description) 191 { 192 PlayerVersion = new YAHOO.deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")); 193 } 194 } 195 else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) 196 { // if Windows CE 197 var counter = 3; 198 while(axo) 199 { 200 try 201 { 202 counter++; 203 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter); 204 // document.write("player v: "+ counter); 205 PlayerVersion = new YAHOO.deconcept.PlayerVersion([counter,0,0]); 206 } 207 catch(e) 208 { 209 axo = null; 210 } 211 } 212 } 213 else 214 { // Win IE (non mobile) 215 // do minor version lookup in IE, but avoid fp6 crashing issues 216 // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 217 try 218 { 219 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); 220 } 221 catch(e) 222 { 223 try 224 { 225 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); 226 PlayerVersion = new YAHOO.deconcept.PlayerVersion([6,0,21]); 227 axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code) 228 } 229 catch(e) 230 { 231 if(PlayerVersion.major == 6) 232 { 233 return PlayerVersion; 234 } 235 } 236 try 237 { 238 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); 239 } 240 catch(e) {} 241 } 242 243 if(axo !== null) 244 { 245 PlayerVersion = new YAHOO.deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(",")); 246 } 247 } 248 return PlayerVersion; 249 }; 250 251 YAHOO.deconcept.PlayerVersion = function(arrVersion) 252 { 253 this.major = arrVersion[0] !== null ? parseInt(arrVersion[0], 0) : 0; 254 this.minor = arrVersion[1] !== null ? parseInt(arrVersion[1], 0) : 0; 255 this.rev = arrVersion[2] !== null ? parseInt(arrVersion[2], 0) : 0; 256 }; 257 258 YAHOO.deconcept.PlayerVersion.prototype.versionIsValid = function(fv) 259 { 260 if(this.major < fv.major) 261 { 262 return false; 263 } 264 if(this.major > fv.major) 265 { 266 return true; 267 } 268 if(this.minor < fv.minor) 269 { 270 return false; 271 } 272 if(this.minor > fv.minor) 273 { 274 return true; 275 } 276 if(this.rev < fv.rev) 277 { 278 return false; 279 } 280 return true; 281 }; 282 283 /* ---- get value of query string param ---- */ 284 YAHOO.deconcept.util = 285 { 286 getRequestParameter: function(param) 287 { 288 var q = document.location.search || document.location.hash; 289 if(param === null) { return q; } 290 if(q) 291 { 292 var pairs = q.substring(1).split("&"); 293 for(var i=0; i < pairs.length; i++) 294 { 295 if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) 296 { 297 return pairs[i].substring((pairs[i].indexOf("=") + 1)); 298 } 299 } 300 } 301 return ""; 302 } 303 }; 304 305 /* fix for video streaming bug */ 306 YAHOO.deconcept.SWFObjectUtil.cleanupSWFs = function() 307 { 308 var objects = document.getElementsByTagName("OBJECT"); 309 for(var i = objects.length - 1; i >= 0; i--) 310 { 311 objects[i].style.display = 'none'; 312 for(var x in objects[i]) 313 { 314 if(typeof objects[i][x] == 'function') 315 { 316 objects[i][x] = function(){}; 317 } 318 } 319 } 320 }; 321 322 // fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/ 323 if(YAHOO.deconcept.SWFObject.doPrepUnload) 324 { 325 if(!YAHOO.deconcept.unloadSet) 326 { 327 YAHOO.deconcept.SWFObjectUtil.prepUnload = function() 328 { 329 __flash_unloadHandler = function(){}; 330 __flash_savedUnloadHandler = function(){}; 331 window.attachEvent("onunload", YAHOO.deconcept.SWFObjectUtil.cleanupSWFs); 332 }; 333 window.attachEvent("onbeforeunload", YAHOO.deconcept.SWFObjectUtil.prepUnload); 334 YAHOO.deconcept.unloadSet = true; 335 } 336 } 337 338 /* add document.getElementById if needed (mobile IE < 5) */ 339 if(!document.getElementById && document.all) 340 { 341 document.getElementById = function(id) { return document.all[id]; }; 342 } 343 /** 344 * Wraps Flash embedding functionality and allows communication with SWF through 345 * attributes. 346 * 347 * @namespace YAHOO.widget 348 * @class FlashAdapter 349 * @uses YAHOO.util.AttributeProvider 350 */ 351 YAHOO.widget.FlashAdapter = function(swfURL, containerID, attributes, buttonSkin) 352 { 353 354 this._queue = this._queue || []; 355 this._events = this._events || {}; 356 this._configs = this._configs || {}; 357 attributes = attributes || {}; 358 359 //the Flash Player external interface code from Adobe doesn't play nicely 360 //with the default value, yui-gen, in IE 361 this._id = attributes.id = attributes.id || YAHOO.util.Dom.generateId(null, "yuigen"); 362 attributes.version = attributes.version || "9.0.45"; 363 attributes.backgroundColor = attributes.backgroundColor || "#ffffff"; 364 365 //we can't use the initial attributes right away 366 //so save them for once the SWF finishes loading 367 this._attributes = attributes; 368 369 this._swfURL = swfURL; 370 this._containerID = containerID; 371 372 //embed the SWF file in the page 373 this._embedSWF(this._swfURL, this._containerID, attributes.id, attributes.version, 374 attributes.backgroundColor, attributes.expressInstall, attributes.wmode, buttonSkin); 375 376 /** 377 * Fires when the SWF is initialized and communication is possible. 378 * @event contentReady 379 */ 380 //Fix for iframe cross-domain issue with FF2x 381 try 382 { 383 this.createEvent("contentReady"); 384 } 385 catch(e){} 386 }; 387 388 YAHOO.widget.FlashAdapter.owners = YAHOO.widget.FlashAdapter.owners || {}; 389 390 YAHOO.extend(YAHOO.widget.FlashAdapter, YAHOO.util.AttributeProvider, 391 { 392 /** 393 * The URL of the SWF file. 394 * @property _swfURL 395 * @type String 396 * @private 397 */ 398 _swfURL: null, 399 400 /** 401 * The ID of the containing DIV. 402 * @property _containerID 403 * @type String 404 * @private 405 */ 406 _containerID: null, 407 408 /** 409 * A reference to the embedded SWF file. 410 * @property _swf 411 * @private 412 */ 413 _swf: null, 414 415 /** 416 * The id of this instance. 417 * @property _id 418 * @type String 419 * @private 420 */ 421 _id: null, 422 423 /** 424 * Indicates whether the SWF has been initialized and is ready 425 * to communicate with JavaScript 426 * @property _initialized 427 * @type Boolean 428 * @private 429 */ 430 _initialized: false, 431 432 /** 433 * The initializing attributes are stored here until the SWF is ready. 434 * @property _attributes 435 * @type Object 436 * @private 437 */ 438 _attributes: null, //the intializing attributes 439 440 /** 441 * Public accessor to the unique name of the FlashAdapter instance. 442 * 443 * @method toString 444 * @return {String} Unique name of the FlashAdapter instance. 445 */ 446 toString: function() 447 { 448 return "FlashAdapter " + this._id; 449 }, 450 451 /** 452 * Nulls out the entire FlashAdapter instance and related objects and removes attached 453 * event listeners and clears out DOM elements inside the container. After calling 454 * this method, the instance reference should be expliclitly nulled by implementer, 455 * as in myChart = null. Use with caution! 456 * 457 * @method destroy 458 */ 459 destroy: function() 460 { 461 //kill the Flash Player instance 462 if(this._swf) 463 { 464 var container = YAHOO.util.Dom.get(this._containerID); 465 container.removeChild(this._swf); 466 } 467 468 var instanceName = this._id; 469 470 //null out properties 471 for(var prop in this) 472 { 473 if(YAHOO.lang.hasOwnProperty(this, prop)) 474 { 475 this[prop] = null; 476 } 477 } 478 479 }, 480 481 /** 482 * Embeds the SWF in the page and associates it with this instance. 483 * 484 * @method _embedSWF 485 * @private 486 */ 487 _embedSWF: function(swfURL, containerID, swfID, version, backgroundColor, expressInstall, wmode, buttonSkin) 488 { 489 //standard SWFObject embed 490 var swfObj = new YAHOO.deconcept.SWFObject(swfURL, swfID, "100%", "100%", version, backgroundColor); 491 492 if(expressInstall) 493 { 494 swfObj.useExpressInstall(expressInstall); 495 } 496 497 //make sure we can communicate with ExternalInterface 498 swfObj.addParam("allowScriptAccess", "always"); 499 500 if(wmode) 501 { 502 swfObj.addParam("wmode", wmode); 503 } 504 505 swfObj.addParam("menu", "false"); 506 507 //again, a useful ExternalInterface trick 508 swfObj.addVariable("allowedDomain", document.location.hostname); 509 510 //tell the SWF which HTML element it is in 511 swfObj.addVariable("YUISwfId", swfID); 512 513 // set the name of the function to call when the swf has an event 514 swfObj.addVariable("YUIBridgeCallback", "YAHOO.widget.FlashAdapter.eventHandler"); 515 if (buttonSkin) { 516 swfObj.addVariable("buttonSkin", buttonSkin); 517 } 518 var container = YAHOO.util.Dom.get(containerID); 519 var result = swfObj.write(container); 520 if(result) 521 { 522 this._swf = YAHOO.util.Dom.get(swfID); 523 YAHOO.widget.FlashAdapter.owners[swfID] = this; 524 } 525 else 526 { 527 } 528 }, 529 530 /** 531 * Handles or re-dispatches events received from the SWF. 532 * 533 * @method _eventHandler 534 * @private 535 */ 536 _eventHandler: function(event) 537 { 538 var type = event.type; 539 switch(type) 540 { 541 case "swfReady": 542 this._loadHandler(); 543 return; 544 case "log": 545 return; 546 } 547 548 549 //be sure to return after your case or the event will automatically fire! 550 this.fireEvent(type, event); 551 }, 552 553 /** 554 * Called when the SWF has been initialized. 555 * 556 * @method _loadHandler 557 * @private 558 */ 559 _loadHandler: function() 560 { 561 this._initialized = false; 562 this._initAttributes(this._attributes); 563 this.setAttributes(this._attributes, true); 564 565 this._initialized = true; 566 this.fireEvent("contentReady"); 567 }, 568 569 set: function(name, value) 570 { 571 //save all the attributes in case the swf reloads 572 //so that we can pass them in again 573 this._attributes[name] = value; 574 YAHOO.widget.FlashAdapter.superclass.set.call(this, name, value); 575 }, 576 577 /** 578 * Initializes the attributes. 579 * 580 * @method _initAttributes 581 * @private 582 */ 583 _initAttributes: function(attributes) 584 { 585 //should be overridden if other attributes need to be set up 586 587 /** 588 * @attribute wmode 589 * @description Sets the window mode of the Flash Player control. May be 590 * "window", "opaque", or "transparent". Only available in the constructor 591 * because it may not be set after Flash Player has been embedded in the page. 592 * @type String 593 */ 594 595 /** 596 * @attribute expressInstall 597 * @description URL pointing to a SWF file that handles Flash Player's express 598 * install feature. Only available in the constructor because it may not be 599 * set after Flash Player has been embedded in the page. 600 * @type String 601 */ 602 603 /** 604 * @attribute version 605 * @description Minimum required version for the SWF file. Only available in the constructor because it may not be 606 * set after Flash Player has been embedded in the page. 607 * @type String 608 */ 609 610 /** 611 * @attribute backgroundColor 612 * @description The background color of the SWF. Only available in the constructor because it may not be 613 * set after Flash Player has been embedded in the page. 614 * @type String 615 */ 616 617 /** 618 * @attribute altText 619 * @description The alternative text to provide for screen readers and other assistive technology. 620 * @type String 621 */ 622 this.getAttributeConfig("altText", 623 { 624 method: this._getAltText 625 }); 626 this.setAttributeConfig("altText", 627 { 628 method: this._setAltText 629 }); 630 631 /** 632 * @attribute swfURL 633 * @description Absolute or relative URL to the SWF displayed by the FlashAdapter. Only available in the constructor because it may not be 634 * set after Flash Player has been embedded in the page. 635 * @type String 636 */ 637 this.getAttributeConfig("swfURL", 638 { 639 method: this._getSWFURL 640 }); 641 }, 642 643 /** 644 * Getter for swfURL attribute. 645 * 646 * @method _getSWFURL 647 * @private 648 */ 649 _getSWFURL: function() 650 { 651 return this._swfURL; 652 }, 653 654 /** 655 * Getter for altText attribute. 656 * 657 * @method _getAltText 658 * @private 659 */ 660 _getAltText: function() 661 { 662 return this._swf.getAltText(); 663 }, 664 665 /** 666 * Setter for altText attribute. 667 * 668 * @method _setAltText 669 * @private 670 */ 671 _setAltText: function(value) 672 { 673 return this._swf.setAltText(value); 674 } 675 }); 676 677 678 /** 679 * Receives event messages from SWF and passes them to the correct instance 680 * of FlashAdapter. 681 * 682 * @method YAHOO.widget.FlashAdapter.eventHandler 683 * @static 684 * @private 685 */ 686 YAHOO.widget.FlashAdapter.eventHandler = function(elementID, event) 687 { 688 689 if(!YAHOO.widget.FlashAdapter.owners[elementID]) 690 { 691 //fix for ie: if owner doesn't exist yet, try again in a moment 692 setTimeout(function() { YAHOO.widget.FlashAdapter.eventHandler( elementID, event ); }, 0); 693 } 694 else 695 { 696 YAHOO.widget.FlashAdapter.owners[elementID]._eventHandler(event); 697 } 698 }; 699 700 /** 701 * The number of proxy functions that have been created. 702 * @static 703 * @private 704 */ 705 YAHOO.widget.FlashAdapter.proxyFunctionCount = 0; 706 707 /** 708 * Creates a globally accessible function that wraps a function reference. 709 * Returns the proxy function's name as a string for use by the SWF through 710 * ExternalInterface. 711 * 712 * @method YAHOO.widget.FlashAdapter.createProxyFunction 713 * @static 714 * @private 715 */ 716 YAHOO.widget.FlashAdapter.createProxyFunction = function(func) 717 { 718 var index = YAHOO.widget.FlashAdapter.proxyFunctionCount; 719 YAHOO.widget.FlashAdapter["proxyFunction" + index] = function() 720 { 721 return func.apply(null, arguments); 722 }; 723 YAHOO.widget.FlashAdapter.proxyFunctionCount++; 724 return "YAHOO.widget.FlashAdapter.proxyFunction" + index.toString(); 725 }; 726 727 /** 728 * Removes a function created with createProxyFunction() 729 * 730 * @method YAHOO.widget.FlashAdapter.removeProxyFunction 731 * @static 732 * @private 733 */ 734 YAHOO.widget.FlashAdapter.removeProxyFunction = function(funcName) 735 { 736 //quick error check 737 if(!funcName || funcName.indexOf("YAHOO.widget.FlashAdapter.proxyFunction") < 0) 738 { 739 return; 740 } 741 742 funcName = funcName.substr(26); 743 YAHOO.widget.FlashAdapter[funcName] = null; 744 }; 745 /** 746 * The YUI Uploader Control 747 * @module uploader 748 * @description <p>YUI Uploader provides file upload functionality that goes beyond the basic browser-based methods. 749 * Specifically, the YUI Uploader allows for: 750 * <ol> 751 * <li> Multiple file selection in a single "Open File" dialog.</li> 752 * <li> File extension filters to facilitate the user's selection.</li> 753 * <li> Progress tracking for file uploads.</li> 754 * <li> A range of file metadata: filename, size, date created, date modified, and author.</li> 755 * <li> A set of events dispatched on various aspects of the file upload process: file selection, upload progress, upload completion, etc.</li> 756 * <li> Inclusion of additional data in the file upload POST request.</li> 757 * <li> Faster file upload on broadband connections due to the modified SEND buffer size.</li> 758 * <li> Same-page server response upon completion of the file upload.</li> 759 * </ol> 760 * </p> 761 * @title Uploader 762 * @namespace YAHOO.widget 763 * @requires yahoo, dom, element, event 764 */ 765 /** 766 * Uploader class for the YUI Uploader component. 767 * 768 * @namespace YAHOO.widget 769 * @class Uploader 770 * @uses YAHOO.widget.FlashAdapter 771 * @constructor 772 * @param containerId {HTMLElement} Container element for the Flash Player instance. 773 * @param buttonSkin {String} [optional]. If defined, the uploader is 774 * rendered as a button. This parameter must provide the URL of a button 775 * skin sprite image. Acceptable types are: jpg, gif, png and swf. The 776 * sprite is divided evenly into four sections along its height (e.g., if 777 * the sprite is 200 px tall, it's divided into four sections 50px each). 778 * Each section is used as a skin for a specific state of the button: top 779 * section is "up", second section is "over", third section is "down", and 780 * fourth section is "disabled". 781 * If the parameter is not supplied, the uploader is rendered transparent, 782 * and it's the developer's responsibility to create a visible UI below it. 783 * @param forceTransparent {Boolean} This parameter, if true, forces the Flash 784 * UI to be rendered with wmode set to "transparent". This behavior is useful 785 * in conjunction with non-rectangular button skins with PNG transparency. 786 * The parameter is false by default, and ignored if no buttonSkin is defined. 787 */ 788 YAHOO.widget.Uploader = function(containerId, buttonSkin, forceTransparent) 789 { 790 var newWMode = "window"; 791 792 if (!(buttonSkin) || (buttonSkin && forceTransparent)) { 793 newWMode = "transparent"; 794 } 795 796 797 YAHOO.widget.Uploader.superclass.constructor.call(this, YAHOO.widget.Uploader.SWFURL, containerId, {wmode:newWMode}, buttonSkin); 798 799 /** 800 * Fires when the mouse is pressed over the Uploader. 801 * Only fires when the Uploader UI is enabled and 802 * the render type is 'transparent'. 803 * 804 * @event mouseDown 805 * @param event.type {String} The event type 806 */ 807 this.createEvent("mouseDown"); 808 809 /** 810 * Fires when the mouse is released over the Uploader. 811 * Only fires when the Uploader UI is enabled and 812 * the render type is 'transparent'. 813 * 814 * @event mouseUp 815 * @param event.type {String} The event type 816 */ 817 this.createEvent("mouseUp"); 818 819 /** 820 * Fires when the mouse rolls over the Uploader. 821 * 822 * @event rollOver 823 * @param event.type {String} The event type 824 */ 825 this.createEvent("rollOver"); 826 827 /** 828 * Fires when the mouse rolls out of the Uploader. 829 * 830 * @event rollOut 831 * @param event.type {String} The event type 832 */ 833 this.createEvent("rollOut"); 834 835 /** 836 * Fires when the uploader is clicked. 837 * 838 * @event click 839 * @param event.type {String} The event type 840 */ 841 this.createEvent("click"); 842 843 /** 844 * Fires when the user has finished selecting files in the "Open File" dialog. 845 * 846 * @event fileSelect 847 * @param event.type {String} The event type 848 * @param event.fileList {Object} A dictionary of objects with file information 849 * @param event.fileList[].size {Number} File size in bytes for a specific file in fileList 850 * @param event.fileList[].cDate {Date} Creation date for a specific file in fileList 851 * @param event.fileList[].mDate {Date} Modification date for a specific file in fileList 852 * @param event.fileList[].name {String} File name for a specific file in fileList 853 * @param event.fileList[].id {String} Unique file id of a specific file in fileList 854 */ 855 this.createEvent("fileSelect"); 856 857 /** 858 * Fires when an upload of a specific file has started. 859 * 860 * @event uploadStart 861 * @param event.type {String} The event type 862 * @param event.id {String} The id of the file that's started to upload 863 */ 864 this.createEvent("uploadStart"); 865 866 /** 867 * Fires when new information about the upload progress for a specific file is available. 868 * 869 * @event uploadProgress 870 * @param event.type {String} The event type 871 * @param event.id {String} The id of the file with which the upload progress data is associated 872 * @param bytesLoaded {Number} The number of bytes of the file uploaded so far 873 * @param bytesTotal {Number} The total size of the file 874 */ 875 this.createEvent("uploadProgress"); 876 877 /** 878 * Fires when an upload for a specific file is cancelled. 879 * 880 * @event uploadCancel 881 * @param event.type {String} The event type 882 * @param event.id {String} The id of the file with which the upload has been cancelled. 883 */ 884 this.createEvent("uploadCancel"); 885 886 /** 887 * Fires when an upload for a specific file is complete. 888 * 889 * @event uploadComplete 890 * @param event.type {String} The event type 891 * @param event.id {String} The id of the file for which the upload has been completed. 892 */ 893 this.createEvent("uploadComplete"); 894 895 /** 896 * Fires when the server sends data in response to a completed upload. 897 * 898 * @event uploadCompleteData 899 * @param event.type {String} The event type 900 * @param event.id {String} The id of the file for which the upload has been completed. 901 * @param event.data {String} The raw data returned by the server in response to the upload. 902 */ 903 this.createEvent("uploadCompleteData"); 904 905 /** 906 * Fires when an upload error occurs. 907 * 908 * @event uploadError 909 * @param event.type {String} The event type 910 * @param event.id {String} The id of the file that was being uploaded when the error has occurred. 911 * @param event.status {String} The status message associated with the error. 912 */ 913 this.createEvent("uploadError"); 914 } 915 916 /** 917 * Location of the Uploader SWF 918 * 919 * @property Chart.SWFURL 920 * @private 921 * @static 922 * @final 923 * @default "assets/uploader.swf" 924 */ 925 YAHOO.widget.Uploader.SWFURL = "assets/uploader.swf"; 926 927 YAHOO.extend(YAHOO.widget.Uploader, YAHOO.widget.FlashAdapter, 928 { 929 /** 930 * Starts the upload of the file specified by fileID to the location specified by uploadScriptPath. 931 * 932 * @param fileID {String} The id of the file to start uploading. 933 * @param uploadScriptPath {String} The URL of the upload location. 934 * @param method {String} Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default. 935 * @param vars {Object} The object containing variables to be sent in the same request as the file upload. 936 * @param fieldName {String} The name of the variable in the POST request containing the file data. "Filedata" by default. 937 * </code> 938 */ 939 upload: function(fileID, uploadScriptPath, method, vars, fieldName) 940 { 941 this._swf.upload(fileID, uploadScriptPath, method, vars, fieldName); 942 }, 943 944 /** 945 * Starts the upload of the files specified by fileIDs, or adds them to a currently running queue. The upload queue is automatically managed. 946 * 947 * @param fileIDs {Array} The ids of the files to start uploading. 948 * @param uploadScriptPath {String} The URL of the upload location. 949 * @param method {String} Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default. 950 * @param vars {Object} The object containing variables to be sent in the same request as the file upload. 951 * @param fieldName {String} The name of the variable in the POST request containing the file data. "Filedata" by default. 952 * </code> 953 */ 954 uploadThese: function(fileIDs, uploadScriptPath, method, vars, fieldName) 955 { 956 this._swf.uploadThese(fileIDs, uploadScriptPath, method, vars, fieldName); 957 }, 958 959 /** 960 * Starts uploading all files in the queue. If this function is called, the upload queue is automatically managed. 961 * 962 * @param uploadScriptPath {String} The URL of the upload location. 963 * @param method {String} Either "GET" or "POST", specifying how the variables accompanying the file upload POST request should be submitted. "GET" by default. 964 * @param vars {Object} The object containing variables to be sent in the same request as the file upload. 965 * @param fieldName {String} The name of the variable in the POST request containing the file data. "Filedata" by default. 966 * </code> 967 */ 968 uploadAll: function(uploadScriptPath, method, vars, fieldName) 969 { 970 this._swf.uploadAll(uploadScriptPath, method, vars, fieldName); 971 }, 972 973 /** 974 * Cancels the upload of a specified file. If no file id is specified, all ongoing uploads are cancelled. 975 * 976 * @param fileID {String} The ID of the file whose upload should be cancelled. 977 */ 978 cancel: function(fileID) 979 { 980 this._swf.cancel(fileID); 981 }, 982 983 /** 984 * Clears the list of files queued for upload. 985 * 986 */ 987 clearFileList: function() 988 { 989 this._swf.clearFileList(); 990 }, 991 992 /** 993 * Removes the specified file from the upload queue. 994 * 995 * @param fileID {String} The id of the file to remove from the upload queue. 996 */ 997 removeFile: function (fileID) 998 { 999 this._swf.removeFile(fileID); 1000 }, 1001 1002 /** 1003 * Turns the logging functionality on. 1004 * Uses Flash internal trace logging, as well as YUI Logger, if available. 1005 * 1006 * @param allowLogging {Boolean} If true, logs are output; otherwise, no logs are produced. 1007 */ 1008 setAllowLogging: function (allowLogging) 1009 { 1010 this._swf.setAllowLogging(allowLogging); 1011 }, 1012 1013 /** 1014 * Sets the number of simultaneous uploads when using uploadAll() 1015 * The minimum value is 1, and maximum value is 5. The default value is 2. 1016 * 1017 * @param simUploadLimit {int} Number of simultaneous uploads, between 1 and 5. 1018 */ 1019 setSimUploadLimit : function (simUploadLimit) 1020 { 1021 this._swf.setSimUploadLimit(simUploadLimit); 1022 }, 1023 1024 /** 1025 * Sets the flag allowing users to select multiple files for the upload. 1026 * 1027 * @param allowMultipleFiles {Boolean} If true, multiple files can be selected. False by default. 1028 */ 1029 setAllowMultipleFiles : function (allowMultipleFiles) 1030 { 1031 this._swf.setAllowMultipleFiles(allowMultipleFiles); 1032 }, 1033 1034 /** 1035 * Sets the file filters for the "Browse" dialog. 1036 * 1037 * @param newFilterArray An array of sets of key-value pairs of the form 1038 * {extensions: extensionString, description: descriptionString, [optional]macType: macTypeString} 1039 * The extensions string is a semicolon-delimited list of elements of the form "*.xxx", 1040 * e.g. "*.jpg;*.gif;*.png". 1041 */ 1042 setFileFilters : function (fileFilters) 1043 { 1044 this._swf.setFileFilters(fileFilters); 1045 }, 1046 1047 /** 1048 * Enables the mouse events on the Uploader. 1049 * If the uploader is being rendered as a button, 1050 * then the button's skin is set to "up" 1051 * (first section of the button skin sprite). 1052 * 1053 */ 1054 enable : function () 1055 { 1056 this._swf.enable(); 1057 }, 1058 1059 /** 1060 * Disables the mouse events on the Uploader. 1061 * If the uploader is being rendered as a button, 1062 * then the button's skin is set to "disabled" 1063 * (fourth section of the button skin sprite). 1064 * 1065 */ 1066 disable : function () 1067 { 1068 this._swf.disable(); 1069 } 1070 }); 1071 YAHOO.register("uploader", YAHOO.widget.Uploader, {version: "2.9.0", build: "2800"}); 1072 1073 }, '2.9.0' ,{"requires": ["yui2-yahoo", "yui2-dom", "yui2-event", "yui2-element"]});
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |