3 Copyright (c) 2012 Reactive Apps, Ronnie Garcia
\r
4 Released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
\r
6 SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
\r
7 mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
\r
8 SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilzén and Mammon Media and is released under the MIT License:
\r
9 http://www.opensource.org/licenses/mit-license.php
\r
10 SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
\r
11 http://www.opensource.org/licenses/mit-license.php
\r
13 SWFObject v2.2 <http://code.google.com/p/swfobject/>
\r
14 is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
\r
17 var swfobject = function () {
\r
18 var aq = "undefined",
\r
20 ab = "Shockwave Flash",
\r
21 X = "ShockwaveFlash.ShockwaveFlash",
\r
22 aE = "application/x-shockwave-flash",
\r
23 ac = "SWFObjectExprInst",
\r
24 ax = "onreadystatechange",
\r
33 aJ, ad, ap, at, ak = false,
\r
37 var a = typeof aL.getElementById != aq && typeof aL.getElementsByTagName != aq && typeof aL.createElement != aq,
\r
38 e = aB.userAgent.toLowerCase(),
\r
39 c = aB.platform.toLowerCase(),
\r
40 h = c ? /win/.test(c) : /win/.test(e),
\r
41 j = c ? /mac/.test(c) : /mac/.test(e),
\r
42 g = /webkit/.test(e) ? parseFloat(e.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false,
\r
46 if (typeof aB.plugins != aq && typeof aB.plugins[ab] == aD) {
\r
47 k = aB.plugins[ab].description;
\r
48 if (k && !(typeof aB.mimeTypes != aq && aB.mimeTypes[aE] && !aB.mimeTypes[aE].enabledPlugin)) {
\r
51 k = k.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
\r
52 f[0] = parseInt(k.replace(/^(.*)\..*$/, "$1"), 10);
\r
53 f[1] = parseInt(k.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
\r
54 f[2] = /[a-zA-Z]/.test(k) ? parseInt(k.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
\r
57 if (typeof af.ActiveXObject != aq) {
\r
59 var i = new ActiveXObject(X);
\r
61 k = i.GetVariable("$version");
\r
64 k = k.split(" ")[1].split(",");
\r
65 f = [parseInt(k[0], 10), parseInt(k[1], 10), parseInt(k[2], 10)];
\r
84 if ((typeof aL.readyState != aq && aL.readyState == "complete") || (typeof aL.readyState == aq && (aL.getElementsByTagName("body")[0] || aL.body))) {
\r
88 if (typeof aL.addEventListener != aq) {
\r
89 aL.addEventListener("DOMContentLoaded", aP, false);
\r
91 if (ah.ie && ah.win) {
\r
92 aL.attachEvent(ax, function () {
\r
93 if (aL.readyState == "complete") {
\r
94 aL.detachEvent(ax, arguments.callee);
\r
104 aL.documentElement.doScroll("left");
\r
106 setTimeout(arguments.callee, 0);
\r
118 if (!/loaded|complete/.test(aL.readyState)) {
\r
119 setTimeout(arguments.callee, 0);
\r
134 var b = aL.getElementsByTagName("body")[0].appendChild(ar("span"));
\r
135 b.parentNode.removeChild(b);
\r
141 for (var c = 0; c < d; c++) {
\r
153 if (typeof af.addEventListener != aq) {
\r
154 af.addEventListener("load", a, false);
\r
156 if (typeof aL.addEventListener != aq) {
\r
157 aL.addEventListener("load", a, false);
\r
159 if (typeof af.attachEvent != aq) {
\r
160 aM(af, "onload", a);
\r
162 if (typeof af.onload == "function") {
\r
164 af.onload = function () {
\r
183 var d = aL.getElementsByTagName("body")[0];
\r
185 b.setAttribute("type", aE);
\r
186 var a = d.appendChild(b);
\r
190 if (typeof a.GetVariable != aq) {
\r
191 var e = a.GetVariable("$version");
\r
193 e = e.split(" ")[1].split(",");
\r
194 ah.pv = [parseInt(e[0], 10), parseInt(e[1], 10), parseInt(e[2], 10)];
\r
199 setTimeout(arguments.callee, 10);
\r
214 for (var h = 0; h < g; h++) {
\r
216 var l = aG[h].callbackFn;
\r
221 if (ah.pv[0] > 0) {
\r
224 if (ao(aG[h].swfVersion) && !(ah.wk && ah.wk < 312)) {
\r
232 if (aG[h].expressInstall && au()) {
\r
234 e.data = aG[h].expressInstall;
\r
235 e.width = i.getAttribute("width") || "0";
\r
236 e.height = i.getAttribute("height") || "0";
\r
237 if (i.getAttribute("class")) {
\r
238 e.styleclass = i.getAttribute("class");
\r
240 if (i.getAttribute("align")) {
\r
241 e.align = i.getAttribute("align");
\r
244 var d = i.getElementsByTagName("param");
\r
246 for (var j = 0; j < k; j++) {
\r
247 if (d[j].getAttribute("name").toLowerCase() != "movie") {
\r
248 f[d[j].getAttribute("name")] = d[j].getAttribute("value");
\r
264 if (b && typeof b.SetVariable != aq) {
\r
277 if (c && c.nodeName == "OBJECT") {
\r
278 if (typeof c.SetVariable != aq) {
\r
281 var a = c.getElementsByTagName(aD)[0];
\r
290 return !aU && ao("6.0.65") && (ah.win || ah.mac) && !(ah.wk && ah.wk < 312);
\r
292 function ae(f, d, h, e) {
\r
301 if (a.nodeName == "OBJECT") {
\r
309 if (typeof f.width == aq || (!/%$/.test(f.width) && parseInt(f.width, 10) < 310)) {
\r
312 if (typeof f.height == aq || (!/%$/.test(f.height) && parseInt(f.height, 10) < 137)) {
\r
315 aL.title = aL.title.slice(0, 47) + " - Flash Player Installation";
\r
316 var b = ah.ie && ah.win ? "ActiveX" : "PlugIn",
\r
317 c = "MMredirectURL=" + af.location.toString().replace(/&/g, "%26") + "&MMplayerType=" + b + "&MMdoctitle=" + aL.title;
\r
318 if (typeof d.flashvars != aq) {
\r
319 d.flashvars += "&" + c;
\r
323 if (ah.ie && ah.win && a.readyState != 4) {
\r
325 h += "SWFObjectNew";
\r
326 g.setAttribute("id", h);
\r
327 a.parentNode.insertBefore(g, a);
\r
328 a.style.display = "none";
\r
330 if (a.readyState == 4) {
\r
331 a.parentNode.removeChild(a);
\r
333 setTimeout(arguments.callee, 10);
\r
341 if (ah.ie && ah.win && a.readyState != 4) {
\r
343 a.parentNode.insertBefore(b, a);
\r
344 b.parentNode.replaceChild(aO(a), b);
\r
345 a.style.display = "none";
\r
347 if (a.readyState == 4) {
\r
348 a.parentNode.removeChild(a);
\r
350 setTimeout(arguments.callee, 10);
\r
354 a.parentNode.replaceChild(aO(a), a);
\r
359 if (ah.win && ah.ie) {
\r
360 d.innerHTML = b.innerHTML;
\r
362 var e = b.getElementsByTagName(aD)[0];
\r
364 var a = e.childNodes;
\r
367 for (var c = 0; c < f; c++) {
\r
368 if (!(a[c].nodeType == 1 && a[c].nodeName == "PARAM") && !(a[c].nodeType == 8)) {
\r
369 d.appendChild(a[c].cloneNode(true));
\r
377 function aA(e, g, c) {
\r
379 if (ah.wk && ah.wk < 312) {
\r
383 if (typeof e.id == aq) {
\r
386 if (ah.ie && ah.win) {
\r
389 if (e[i] != Object.prototype[i]) {
\r
390 if (i.toLowerCase() == "data") {
\r
393 if (i.toLowerCase() == "styleclass") {
\r
394 f += ' class="' + e[i] + '"';
\r
396 if (i.toLowerCase() != "classid") {
\r
397 f += " " + i + '="' + e[i] + '"';
\r
405 if (g[j] != Object.prototype[j]) {
\r
406 h += '<param name="' + j + '" value="' + g[j] + '" />';
\r
409 a.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + f + ">" + h + "</object>";
\r
410 ag[ag.length] = e.id;
\r
414 b.setAttribute("type", aE);
\r
416 if (e[k] != Object.prototype[k]) {
\r
417 if (k.toLowerCase() == "styleclass") {
\r
418 b.setAttribute("class", e[k]);
\r
420 if (k.toLowerCase() != "classid") {
\r
421 b.setAttribute(k, e[k]);
\r
427 if (g[l] != Object.prototype[l] && l.toLowerCase() != "movie") {
\r
431 a.parentNode.replaceChild(b, a);
\r
437 function aQ(b, d, c) {
\r
438 var a = ar("param");
\r
439 a.setAttribute("name", d);
\r
440 a.setAttribute("value", c);
\r
445 if (b && b.nodeName == "OBJECT") {
\r
446 if (ah.ie && ah.win) {
\r
447 b.style.display = "none";
\r
449 if (b.readyState == 4) {
\r
452 setTimeout(arguments.callee, 10);
\r
456 b.parentNode.removeChild(b);
\r
464 if (typeof b[c] == "function") {
\r
468 b.parentNode.removeChild(b);
\r
474 c = aL.getElementById(a);
\r
479 return aL.createElement(a);
\r
481 function aM(a, c, b) {
\r
482 a.attachEvent(c, b);
\r
483 al[al.length] = [a, c, b];
\r
488 c[0] = parseInt(c[0], 10);
\r
489 c[1] = parseInt(c[1], 10) || 0;
\r
490 c[2] = parseInt(c[2], 10) || 0;
\r
491 return (b[0] > c[0] || (b[0] == c[0] && b[1] > c[1]) || (b[0] == c[0] && b[1] == c[1] && b[2] >= c[2])) ? true : false;
\r
493 function az(b, f, a, c) {
\r
494 if (ah.ie && ah.mac) {
\r
497 var e = aL.getElementsByTagName("head")[0];
\r
501 var g = (a && typeof a == "string") ? a : "screen";
\r
506 if (!aH || an != g) {
\r
507 var d = ar("style");
\r
508 d.setAttribute("type", "text/css");
\r
509 d.setAttribute("media", g);
\r
510 aH = e.appendChild(d);
\r
511 if (ah.ie && ah.win && typeof aL.styleSheets != aq && aL.styleSheets.length > 0) {
\r
512 aH = aL.styleSheets[aL.styleSheets.length - 1];
\r
516 if (ah.ie && ah.win) {
\r
517 if (aH && typeof aH.addRule == aD) {
\r
521 if (aH && typeof aL.createTextNode != aq) {
\r
522 aH.appendChild(aL.createTextNode(b + " {" + f + "}"));
\r
526 function ay(a, c) {
\r
530 var b = c ? "visible" : "hidden";
\r
532 aS(a).style.visibility = b;
\r
534 az("#" + a, "visibility:" + b);
\r
538 var a = /[\\\"<>\.;]/;
\r
539 var c = a.exec(b) != null;
\r
540 return c && typeof encodeURIComponent != aq ? encodeURIComponent(b) : b;
\r
542 var aR = function () {
\r
543 if (ah.ie && ah.win) {
\r
544 window.attachEvent("onunload", function () {
\r
546 for (var b = 0; b < a; b++) {
\r
547 al[b][0].detachEvent(al[b][1], al[b][2]);
\r
550 for (var c = 0; c < d; c++) {
\r
553 for (var e in ah) {
\r
557 for (var f in swfobject) {
\r
558 swfobject[f] = null;
\r
565 registerObject: function (a, e, c, b) {
\r
566 if (ah.w3 && a && e) {
\r
570 d.expressInstall = c;
\r
583 getObjectById: function (a) {
\r
588 embedSWF: function (k, e, h, f, c, a, b, i, g, j) {
\r
593 if (ah.w3 && !(ah.wk && ah.wk < 312) && k && e && h && f && c) {
\r
599 if (g && typeof g === aD) {
\r
608 if (i && typeof i === aD) {
\r
613 if (b && typeof b === aD) {
\r
615 if (typeof n.flashvars != aq) {
\r
616 n.flashvars += "&" + l + "=" + b[l];
\r
618 n.flashvars = l + "=" + b[l];
\r
623 var m = aA(q, n, e);
\r
648 switchOffAutoHideShow: function () {
\r
652 getFlashPlayerVersion: function () {
\r
659 hasFlashPlayerVersion: ao,
\r
660 createSWF: function (a, b, c) {
\r
662 return aA(a, b, c);
\r
667 showExpressInstall: function (b, a, d, c) {
\r
668 if (ah.w3 && au()) {
\r
672 removeSWF: function (a) {
\r
677 createCSS: function (b, a, c, d) {
\r
682 addDomLoadEvent: aj,
\r
684 getQueryParamValue: function (b) {
\r
685 var a = aL.location.search || aL.location.hash;
\r
687 if (/\?/.test(a)) {
\r
688 a = a.split("?")[1];
\r
693 var c = a.split("&");
\r
694 for (var d = 0; d < c.length; d++) {
\r
695 if (c[d].substring(0, c[d].indexOf("=")) == b) {
\r
696 return ai(c[d].substring((c[d].indexOf("=") + 1)));
\r
702 expressInstallCallback: function () {
\r
706 a.parentNode.replaceChild(aJ, a);
\r
709 if (ah.ie && ah.win) {
\r
710 aJ.style.display = "block";
\r
723 if (SWFUpload == undefined) {
\r
724 SWFUpload = function (b) {
\r
725 this.initSWFUpload(b);
\r
728 SWFUpload.prototype.initSWFUpload = function (c) {
\r
730 this.customSettings = {};
\r
732 this.eventQueue = [];
\r
733 this.movieName = "SWFUpload_" + SWFUpload.movieCount++;
\r
734 this.movieElement = null;
\r
735 SWFUpload.instances[this.movieName] = this;
\r
736 this.initSettings();
\r
738 this.displayDebugInfo();
\r
740 delete SWFUpload.instances[this.movieName];
\r
744 SWFUpload.instances = {};
\r
745 SWFUpload.movieCount = 0;
\r
746 SWFUpload.version = "2.2.0 2009-03-25";
\r
747 SWFUpload.QUEUE_ERROR = {
\r
748 QUEUE_LIMIT_EXCEEDED: -100,
\r
749 FILE_EXCEEDS_SIZE_LIMIT: -110,
\r
750 ZERO_BYTE_FILE: -120,
\r
751 INVALID_FILETYPE: -130
\r
753 SWFUpload.UPLOAD_ERROR = {
\r
755 MISSING_UPLOAD_URL: -210,
\r
757 SECURITY_ERROR: -230,
\r
758 UPLOAD_LIMIT_EXCEEDED: -240,
\r
759 UPLOAD_FAILED: -250,
\r
760 SPECIFIED_FILE_ID_NOT_FOUND: -260,
\r
761 FILE_VALIDATION_FAILED: -270,
\r
762 FILE_CANCELLED: -280,
\r
763 UPLOAD_STOPPED: -290
\r
765 SWFUpload.FILE_STATUS = {
\r
772 SWFUpload.BUTTON_ACTION = {
\r
774 SELECT_FILES: -110,
\r
777 SWFUpload.CURSOR = {
\r
781 SWFUpload.WINDOW_MODE = {
\r
783 TRANSPARENT: "transparent",
\r
786 SWFUpload.completeURL = function (e) {
\r
787 if (typeof(e) !== "string" || e.match(/^https?:\/\//i) || e.match(/^\//)) {
\r
790 var f = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
\r
791 var d = window.location.pathname.lastIndexOf("/");
\r
795 path = window.location.pathname.substr(0, d) + "/";
\r
799 SWFUpload.prototype.initSettings = function () {
\r
800 this.ensureDefault = function (c, d) {
\r
801 this.settings[c] = (this.settings[c] == undefined) ? d : this.settings[c];
\r
803 this.ensureDefault("upload_url", "");
\r
804 this.ensureDefault("preserve_relative_urls", false);
\r
805 this.ensureDefault("file_post_name", "Filedata");
\r
806 this.ensureDefault("post_params", {});
\r
807 this.ensureDefault("use_query_string", false);
\r
808 this.ensureDefault("requeue_on_error", false);
\r
809 this.ensureDefault("http_success", []);
\r
810 this.ensureDefault("assume_success_timeout", 0);
\r
811 this.ensureDefault("file_types", "*.*");
\r
812 this.ensureDefault("file_types_description", "All Files");
\r
813 this.ensureDefault("file_size_limit", 0);
\r
814 this.ensureDefault("file_upload_limit", 0);
\r
815 this.ensureDefault("file_queue_limit", 0);
\r
816 this.ensureDefault("flash_url", "swfupload.swf");
\r
817 this.ensureDefault("prevent_swf_caching", true);
\r
818 this.ensureDefault("button_image_url", "");
\r
819 this.ensureDefault("button_width", 1);
\r
820 this.ensureDefault("button_height", 1);
\r
821 this.ensureDefault("button_text", "");
\r
822 this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
\r
823 this.ensureDefault("button_text_top_padding", 0);
\r
824 this.ensureDefault("button_text_left_padding", 0);
\r
825 this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
\r
826 this.ensureDefault("button_disabled", false);
\r
827 this.ensureDefault("button_placeholder_id", "");
\r
828 this.ensureDefault("button_placeholder", null);
\r
829 this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
\r
830 this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
\r
831 this.ensureDefault("debug", false);
\r
832 this.settings.debug_enabled = this.settings.debug;
\r
833 this.settings.return_upload_start_handler = this.returnUploadStart;
\r
834 this.ensureDefault("swfupload_loaded_handler", null);
\r
835 this.ensureDefault("file_dialog_start_handler", null);
\r
836 this.ensureDefault("file_queued_handler", null);
\r
837 this.ensureDefault("file_queue_error_handler", null);
\r
838 this.ensureDefault("file_dialog_complete_handler", null);
\r
839 this.ensureDefault("upload_start_handler", null);
\r
840 this.ensureDefault("upload_progress_handler", null);
\r
841 this.ensureDefault("upload_error_handler", null);
\r
842 this.ensureDefault("upload_success_handler", null);
\r
843 this.ensureDefault("upload_complete_handler", null);
\r
844 this.ensureDefault("debug_handler", this.debugMessage);
\r
845 this.ensureDefault("custom_settings", {});
\r
846 this.customSettings = this.settings.custom_settings;
\r
847 if ( !! this.settings.prevent_swf_caching) {
\r
848 this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
\r
850 if (!this.settings.preserve_relative_urls) {
\r
851 this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
\r
852 this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
\r
854 delete this.ensureDefault;
\r
856 SWFUpload.prototype.loadFlash = function () {
\r
858 if (document.getElementById(this.movieName) !== null) {
\r
859 throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
\r
861 d = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
\r
862 if (d == undefined) {
\r
863 throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
\r
865 c = document.createElement("div");
\r
866 c.innerHTML = this.getFlashHTML();
\r
867 d.parentNode.replaceChild(c.firstChild, d);
\r
868 if (window[this.movieName] == undefined) {
\r
869 window[this.movieName] = this.getMovieElement();
\r
872 SWFUpload.prototype.getFlashHTML = function () {
\r
873 return ['<object id="', this.movieName, '" type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">', '<param name="wmode" value="', this.settings.button_window_mode, '" />', '<param name="movie" value="', this.settings.flash_url, '" />', '<param name="quality" value="high" />', '<param name="menu" value="false" />', '<param name="allowScriptAccess" value="always" />', '<param name="flashvars" value="' + this.getFlashVars() + '" />', "</object>"].join("");
\r
875 SWFUpload.prototype.getFlashVars = function () {
\r
876 var c = this.buildParamString();
\r
877 var d = this.settings.http_success.join(",");
\r
878 return ["movieName=", encodeURIComponent(this.movieName), "&uploadURL=", encodeURIComponent(this.settings.upload_url), "&useQueryString=", encodeURIComponent(this.settings.use_query_string), "&requeueOnError=", encodeURIComponent(this.settings.requeue_on_error), "&httpSuccess=", encodeURIComponent(d), "&assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout), "&params=", encodeURIComponent(c), "&filePostName=", encodeURIComponent(this.settings.file_post_name), "&fileTypes=", encodeURIComponent(this.settings.file_types), "&fileTypesDescription=", encodeURIComponent(this.settings.file_types_description), "&fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit), "&fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit), "&fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit), "&debugEnabled=", encodeURIComponent(this.settings.debug_enabled), "&buttonImageURL=", encodeURIComponent(this.settings.button_image_url), "&buttonWidth=", encodeURIComponent(this.settings.button_width), "&buttonHeight=", encodeURIComponent(this.settings.button_height), "&buttonText=", encodeURIComponent(this.settings.button_text), "&buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding), "&buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding), "&buttonTextStyle=", encodeURIComponent(this.settings.button_text_style), "&buttonAction=", encodeURIComponent(this.settings.button_action), "&buttonDisabled=", encodeURIComponent(this.settings.button_disabled), "&buttonCursor=", encodeURIComponent(this.settings.button_cursor)].join("");
\r
880 SWFUpload.prototype.getMovieElement = function () {
\r
881 if (this.movieElement == undefined) {
\r
882 this.movieElement = document.getElementById(this.movieName);
\r
884 if (this.movieElement === null) {
\r
885 throw "Could not find Flash element";
\r
887 return this.movieElement;
\r
889 SWFUpload.prototype.buildParamString = function () {
\r
890 var f = this.settings.post_params;
\r
892 if (typeof(f) === "object") {
\r
894 if (f.hasOwnProperty(e)) {
\r
895 d.push(encodeURIComponent(e.toString()) + "=" + encodeURIComponent(f[e].toString()));
\r
899 return d.join("&");
\r
901 SWFUpload.prototype.destroy = function () {
\r
903 this.cancelUpload(null, false);
\r
905 g = this.getMovieElement();
\r
906 if (g && typeof(g.CallFunction) === "unknown") {
\r
909 if (typeof(g[j]) === "function") {
\r
915 g.parentNode.removeChild(g);
\r
918 window[this.movieName] = null;
\r
919 SWFUpload.instances[this.movieName] = null;
\r
920 delete SWFUpload.instances[this.movieName];
\r
921 this.movieElement = null;
\r
922 this.settings = null;
\r
923 this.customSettings = null;
\r
924 this.eventQueue = null;
\r
925 this.movieName = null;
\r
931 SWFUpload.prototype.displayDebugInfo = function () {
\r
932 this.debug(["---SWFUpload Instance Info---\n", "Version: ", SWFUpload.version, "\n", "Movie Name: ", this.movieName, "\n", "Settings:\n", "\t", "upload_url: ", this.settings.upload_url, "\n", "\t", "flash_url: ", this.settings.flash_url, "\n", "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n", "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n", "\t", "http_success: ", this.settings.http_success.join(", "), "\n", "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n", "\t", "file_post_name: ", this.settings.file_post_name, "\n", "\t", "post_params: ", this.settings.post_params.toString(), "\n", "\t", "file_types: ", this.settings.file_types, "\n", "\t", "file_types_description: ", this.settings.file_types_description, "\n", "\t", "file_size_limit: ", this.settings.file_size_limit, "\n", "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n", "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n", "\t", "debug: ", this.settings.debug.toString(), "\n", "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n", "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n", "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n", "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n", "\t", "button_width: ", this.settings.button_width.toString(), "\n", "\t", "button_height: ", this.settings.button_height.toString(), "\n", "\t", "button_text: ", this.settings.button_text.toString(), "\n", "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n", "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n", "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n", "\t", "button_action: ", this.settings.button_action.toString(), "\n", "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n", "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n", "Event Handlers:\n", "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n", "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n", "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n", "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n", "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n", "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n", "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n", "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n", "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n", "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"].join(""));
\r
934 SWFUpload.prototype.addSetting = function (d, f, e) {
\r
935 if (f == undefined) {
\r
936 return (this.settings[d] = e);
\r
938 return (this.settings[d] = f);
\r
941 SWFUpload.prototype.getSetting = function (b) {
\r
942 if (this.settings[b] != undefined) {
\r
943 return this.settings[b];
\r
947 SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
\r
948 argumentArray = argumentArray || [];
\r
949 var movieElement = this.getMovieElement();
\r
950 var returnValue, returnString;
\r
952 returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + "</invoke>");
\r
953 returnValue = eval(returnString);
\r
955 throw "Call to " + functionName + " failed";
\r
957 if (returnValue != undefined && typeof returnValue.post === "object") {
\r
958 returnValue = this.unescapeFilePostParams(returnValue);
\r
960 return returnValue;
\r
962 SWFUpload.prototype.selectFile = function () {
\r
963 this.callFlash("SelectFile");
\r
965 SWFUpload.prototype.selectFiles = function () {
\r
966 this.callFlash("SelectFiles");
\r
968 SWFUpload.prototype.startUpload = function (b) {
\r
969 this.callFlash("StartUpload", [b]);
\r
971 SWFUpload.prototype.cancelUpload = function (d, c) {
\r
975 this.callFlash("CancelUpload", [d, c]);
\r
977 SWFUpload.prototype.stopUpload = function () {
\r
978 this.callFlash("StopUpload");
\r
980 SWFUpload.prototype.getStats = function () {
\r
981 return this.callFlash("GetStats");
\r
983 SWFUpload.prototype.setStats = function (b) {
\r
984 this.callFlash("SetStats", [b]);
\r
986 SWFUpload.prototype.getFile = function (b) {
\r
987 if (typeof(b) === "number") {
\r
988 return this.callFlash("GetFileByIndex", [b]);
\r
990 return this.callFlash("GetFile", [b]);
\r
993 SWFUpload.prototype.addFileParam = function (e, d, f) {
\r
994 return this.callFlash("AddFileParam", [e, d, f]);
\r
996 SWFUpload.prototype.removeFileParam = function (d, c) {
\r
997 this.callFlash("RemoveFileParam", [d, c]);
\r
999 SWFUpload.prototype.setUploadURL = function (b) {
\r
1000 this.settings.upload_url = b.toString();
\r
1001 this.callFlash("SetUploadURL", [b]);
\r
1003 SWFUpload.prototype.setPostParams = function (b) {
\r
1004 this.settings.post_params = b;
\r
1005 this.callFlash("SetPostParams", [b]);
\r
1007 SWFUpload.prototype.addPostParam = function (d, c) {
\r
1008 this.settings.post_params[d] = c;
\r
1009 this.callFlash("SetPostParams", [this.settings.post_params]);
\r
1011 SWFUpload.prototype.removePostParam = function (b) {
\r
1012 delete this.settings.post_params[b];
\r
1013 this.callFlash("SetPostParams", [this.settings.post_params]);
\r
1015 SWFUpload.prototype.setFileTypes = function (d, c) {
\r
1016 this.settings.file_types = d;
\r
1017 this.settings.file_types_description = c;
\r
1018 this.callFlash("SetFileTypes", [d, c]);
\r
1020 SWFUpload.prototype.setFileSizeLimit = function (b) {
\r
1021 this.settings.file_size_limit = b;
\r
1022 this.callFlash("SetFileSizeLimit", [b]);
\r
1024 SWFUpload.prototype.setFileUploadLimit = function (b) {
\r
1025 this.settings.file_upload_limit = b;
\r
1026 this.callFlash("SetFileUploadLimit", [b]);
\r
1028 SWFUpload.prototype.setFileQueueLimit = function (b) {
\r
1029 this.settings.file_queue_limit = b;
\r
1030 this.callFlash("SetFileQueueLimit", [b]);
\r
1032 SWFUpload.prototype.setFilePostName = function (b) {
\r
1033 this.settings.file_post_name = b;
\r
1034 this.callFlash("SetFilePostName", [b]);
\r
1036 SWFUpload.prototype.setUseQueryString = function (b) {
\r
1037 this.settings.use_query_string = b;
\r
1038 this.callFlash("SetUseQueryString", [b]);
\r
1040 SWFUpload.prototype.setRequeueOnError = function (b) {
\r
1041 this.settings.requeue_on_error = b;
\r
1042 this.callFlash("SetRequeueOnError", [b]);
\r
1044 SWFUpload.prototype.setHTTPSuccess = function (b) {
\r
1045 if (typeof b === "string") {
\r
1046 b = b.replace(" ", "").split(",");
\r
1048 this.settings.http_success = b;
\r
1049 this.callFlash("SetHTTPSuccess", [b]);
\r
1051 SWFUpload.prototype.setAssumeSuccessTimeout = function (b) {
\r
1052 this.settings.assume_success_timeout = b;
\r
1053 this.callFlash("SetAssumeSuccessTimeout", [b]);
\r
1055 SWFUpload.prototype.setDebugEnabled = function (b) {
\r
1056 this.settings.debug_enabled = b;
\r
1057 this.callFlash("SetDebugEnabled", [b]);
\r
1059 SWFUpload.prototype.setButtonImageURL = function (b) {
\r
1060 if (b == undefined) {
\r
1063 this.settings.button_image_url = b;
\r
1064 this.callFlash("SetButtonImageURL", [b]);
\r
1066 SWFUpload.prototype.setButtonDimensions = function (f, e) {
\r
1067 this.settings.button_width = f;
\r
1068 this.settings.button_height = e;
\r
1069 var d = this.getMovieElement();
\r
1070 if (d != undefined) {
\r
1071 d.style.width = f + "px";
\r
1072 d.style.height = e + "px";
\r
1074 this.callFlash("SetButtonDimensions", [f, e]);
\r
1076 SWFUpload.prototype.setButtonText = function (b) {
\r
1077 this.settings.button_text = b;
\r
1078 this.callFlash("SetButtonText", [b]);
\r
1080 SWFUpload.prototype.setButtonTextPadding = function (c, d) {
\r
1081 this.settings.button_text_top_padding = d;
\r
1082 this.settings.button_text_left_padding = c;
\r
1083 this.callFlash("SetButtonTextPadding", [c, d]);
\r
1085 SWFUpload.prototype.setButtonTextStyle = function (b) {
\r
1086 this.settings.button_text_style = b;
\r
1087 this.callFlash("SetButtonTextStyle", [b]);
\r
1089 SWFUpload.prototype.setButtonDisabled = function (b) {
\r
1090 this.settings.button_disabled = b;
\r
1091 this.callFlash("SetButtonDisabled", [b]);
\r
1093 SWFUpload.prototype.setButtonAction = function (b) {
\r
1094 this.settings.button_action = b;
\r
1095 this.callFlash("SetButtonAction", [b]);
\r
1097 SWFUpload.prototype.setButtonCursor = function (b) {
\r
1098 this.settings.button_cursor = b;
\r
1099 this.callFlash("SetButtonCursor", [b]);
\r
1101 SWFUpload.prototype.queueEvent = function (d, f) {
\r
1102 if (f == undefined) {
\r
1105 if (!(f instanceof Array)) {
\r
1110 if (typeof this.settings[d] === "function") {
\r
1111 this.eventQueue.push(function () {
\r
1112 this.settings[d].apply(this, f);
\r
1114 setTimeout(function () {
\r
1115 e.executeNextEvent();
\r
1118 if (this.settings[d] !== null) {
\r
1119 throw "Event handler " + d + " is unknown or is not a function";
\r
1123 SWFUpload.prototype.executeNextEvent = function () {
\r
1124 var b = this.eventQueue ? this.eventQueue.shift() : null;
\r
1125 if (typeof(b) === "function") {
\r
1129 SWFUpload.prototype.unescapeFilePostParams = function (l) {
\r
1130 var j = /[$]([0-9a-f]{4})/i;
\r
1133 if (l != undefined) {
\r
1134 for (var h in l.post) {
\r
1135 if (l.post.hasOwnProperty(h)) {
\r
1138 while ((g = j.exec(k)) !== null) {
\r
1139 k = k.replace(g[0], String.fromCharCode(parseInt("0x" + g[1], 16)));
\r
1148 SWFUpload.prototype.testExternalInterface = function () {
\r
1150 return this.callFlash("TestExternalInterface");
\r
1155 SWFUpload.prototype.flashReady = function () {
\r
1156 var b = this.getMovieElement();
\r
1158 this.debug("Flash called back ready but the flash movie can't be found.");
\r
1162 this.queueEvent("swfupload_loaded_handler");
\r
1164 SWFUpload.prototype.cleanUp = function (f) {
\r
1166 if (this.movieElement && typeof(f.CallFunction) === "unknown") {
\r
1167 this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
\r
1168 for (var h in f) {
\r
1170 if (typeof(f[h]) === "function") {
\r
1177 window.__flash__removeCallback = function (c, b) {
\r
1185 SWFUpload.prototype.fileDialogStart = function () {
\r
1186 this.queueEvent("file_dialog_start_handler");
\r
1188 SWFUpload.prototype.fileQueued = function (b) {
\r
1189 b = this.unescapeFilePostParams(b);
\r
1190 this.queueEvent("file_queued_handler", b);
\r
1192 SWFUpload.prototype.fileQueueError = function (e, f, d) {
\r
1193 e = this.unescapeFilePostParams(e);
\r
1194 this.queueEvent("file_queue_error_handler", [e, f, d]);
\r
1196 SWFUpload.prototype.fileDialogComplete = function (d, f, e) {
\r
1197 this.queueEvent("file_dialog_complete_handler", [d, f, e]);
\r
1199 SWFUpload.prototype.uploadStart = function (b) {
\r
1200 b = this.unescapeFilePostParams(b);
\r
1201 this.queueEvent("return_upload_start_handler", b);
\r
1203 SWFUpload.prototype.returnUploadStart = function (d) {
\r
1205 if (typeof this.settings.upload_start_handler === "function") {
\r
1206 d = this.unescapeFilePostParams(d);
\r
1207 c = this.settings.upload_start_handler.call(this, d);
\r
1209 if (this.settings.upload_start_handler != undefined) {
\r
1210 throw "upload_start_handler must be a function";
\r
1213 if (c === undefined) {
\r
1217 this.callFlash("ReturnUploadStart", [c]);
\r
1219 SWFUpload.prototype.uploadProgress = function (e, f, d) {
\r
1220 e = this.unescapeFilePostParams(e);
\r
1221 this.queueEvent("upload_progress_handler", [e, f, d]);
\r
1223 SWFUpload.prototype.uploadError = function (e, f, d) {
\r
1224 e = this.unescapeFilePostParams(e);
\r
1225 this.queueEvent("upload_error_handler", [e, f, d]);
\r
1227 SWFUpload.prototype.uploadSuccess = function (d, e, f) {
\r
1228 d = this.unescapeFilePostParams(d);
\r
1229 this.queueEvent("upload_success_handler", [d, e, f]);
\r
1231 SWFUpload.prototype.uploadComplete = function (b) {
\r
1232 b = this.unescapeFilePostParams(b);
\r
1233 this.queueEvent("upload_complete_handler", b);
\r
1235 SWFUpload.prototype.debug = function (b) {
\r
1236 this.queueEvent("debug_handler", b);
\r
1238 SWFUpload.prototype.debugMessage = function (h) {
\r
1239 if (this.settings.debug) {
\r
1241 if (typeof h === "object" && typeof h.name === "string" && typeof h.message === "string") {
\r
1242 for (var e in h) {
\r
1243 if (h.hasOwnProperty(e)) {
\r
1244 g.push(e + ": " + h[e]);
\r
1247 f = g.join("\n") || "";
\r
1248 g = f.split("\n");
\r
1249 f = "EXCEPTION: " + g.join("\nEXCEPTION: ");
\r
1250 SWFUpload.Console.writeLine(f);
\r
1252 SWFUpload.Console.writeLine(h);
\r
1256 SWFUpload.Console = {};
\r
1257 SWFUpload.Console.writeLine = function (g) {
\r
1260 e = document.getElementById("SWFUpload_Console");
\r
1262 f = document.createElement("form");
\r
1263 document.getElementsByTagName("body")[0].appendChild(f);
\r
1264 e = document.createElement("textarea");
\r
1265 e.id = "SWFUpload_Console";
\r
1266 e.style.fontFamily = "monospace";
\r
1267 e.setAttribute("wrap", "off");
\r
1269 e.style.overflow = "auto";
\r
1270 e.style.width = "700px";
\r
1271 e.style.height = "350px";
\r
1272 e.style.margin = "5px";
\r
1275 e.value += g + "\n";
\r
1276 e.scrollTop = e.scrollHeight - e.clientHeight;
\r
1278 alert("Exception: " + h.name + " Message: " + h.message);
\r
1283 init: function (d, e) {
\r
1284 return this.each(function () {
\r
1286 var m = n.clone();
\r
1287 var j = c.extend({
\r
1289 swf: "uploadify.swf",
\r
1290 uploader: "uploadify.php",
\r
1293 buttonCursor: "hand",
\r
1294 buttonImage: null,
\r
1295 buttonText: "SELECT FILES",
\r
1296 checkExisting: false,
\r
1298 fileObjName: "Filedata",
\r
1300 fileTypeDesc: "All Files",
\r
1301 fileTypeExts: "*.*",
\r
1306 preventCaching: true,
\r
1307 progressData: "percentage",
\r
1309 queueSizeLimit: 999,
\r
1310 removeCompleted: true,
\r
1312 requeueErrors: false,
\r
1313 successTimeout: 30,
\r
1316 overrideEvents: []
\r
1319 assume_success_timeout: j.successTimeout,
\r
1320 button_placeholder_id: j.id,
\r
1321 button_width: j.width,
\r
1322 button_height: j.height,
\r
1323 button_text: null,
\r
1324 button_text_style: null,
\r
1325 button_text_top_padding: 0,
\r
1326 button_text_left_padding: 0,
\r
1327 button_action: (j.multi ? SWFUpload.BUTTON_ACTION.SELECT_FILES : SWFUpload.BUTTON_ACTION.SELECT_FILE),
\r
1328 button_disabled: false,
\r
1329 button_cursor: (j.buttonCursor == "arrow" ? SWFUpload.CURSOR.ARROW : SWFUpload.CURSOR.HAND),
\r
1330 button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
\r
1332 requeue_on_error: j.requeueErrors,
\r
1333 file_post_name: j.fileObjName,
\r
1334 file_size_limit: j.fileSizeLimit,
\r
1335 file_types: j.fileTypeExts,
\r
1336 file_types_description: j.fileTypeDesc,
\r
1337 file_queue_limit: j.queueSizeLimit,
\r
1338 file_upload_limit: j.uploadLimit,
\r
1340 prevent_swf_caching: j.preventCaching,
\r
1341 post_params: j.formData,
\r
1342 upload_url: j.uploader,
\r
1343 use_query_string: (j.method == "get"),
\r
1344 file_dialog_complete_handler: a.onDialogClose,
\r
1345 file_dialog_start_handler: a.onDialogOpen,
\r
1346 file_queued_handler: a.onSelect,
\r
1347 file_queue_error_handler: a.onSelectError,
\r
1348 swfupload_loaded_handler: j.onSWFReady,
\r
1349 upload_complete_handler: a.onUploadComplete,
\r
1350 upload_error_handler: a.onUploadError,
\r
1351 upload_progress_handler: a.onUploadProgress,
\r
1352 upload_start_handler: a.onUploadStart,
\r
1353 upload_success_handler: a.onUploadSuccess
\r
1356 g = c.extend(g, e);
\r
1358 g = c.extend(g, j);
\r
1359 var o = swfobject.getFlashPlayerVersion();
\r
1360 var h = (o.major >= 9);
\r
1362 window["uploadify_" + j.id] = new SWFUpload(g);
\r
1363 var i = window["uploadify_" + j.id];
\r
1364 n.data("uploadify", i);
\r
1365 var l = c("<div />", {
\r
1367 "class": "uploadify",
\r
1369 height: j.height + "px",
\r
1370 width: j.width + "px"
\r
1373 c("#" + i.movieName).wrap(l);
\r
1374 l = c("#" + j.id);
\r
1375 l.data("uploadify", i);
\r
1376 var f = c("<div />", {
\r
1377 id: j.id + "-button",
\r
1378 "class": "uploadify-button " + j.buttonClass
\r
1380 if (j.buttonImage) {
\r
1382 "background-image": "url('" + j.buttonImage + "')",
\r
1383 "text-indent": "-9999px"
\r
1386 f.html('<span class="uploadify-button-text">' + j.buttonText + "</span>").css({
\r
1387 height: j.height + "px",
\r
1388 "line-height": j.height + "px",
\r
1389 width: j.width + "px"
\r
1392 c("#" + i.movieName).css({
\r
1393 position: "absolute",
\r
1397 var k = c("<div />", {
\r
1398 id: j.id + "-queue",
\r
1399 "class": "uploadify-queue"
\r
1402 i.settings.queueID = j.id + "-queue";
\r
1403 i.settings.defaultQueue = true;
\r
1410 filesCancelled: 0,
\r
1412 uploadsSuccessful: 0,
\r
1413 uploadsErrored: 0,
\r
1418 queueBytesUploaded: 0,
\r
1420 errorMsg: "Some files were not added to the queue:"
\r
1427 j.onInit.call(n, i);
\r
1430 if (j.onFallback) {
\r
1431 j.onFallback.call(n);
\r
1436 cancel: function (d, f) {
\r
1437 var e = arguments;
\r
1438 this.each(function () {
\r
1440 i = l.data("uploadify"),
\r
1444 if (e[0] == "*") {
\r
1445 var g = i.queueData.queueLength;
\r
1446 c("#" + j.queueID).find(".uploadify-queue-item").each(function () {
\r
1448 if (e[1] === true) {
\r
1449 i.cancelUpload(c(this).attr("id"), false);
\r
1451 i.cancelUpload(c(this).attr("id"));
\r
1453 c(this).find(".data").removeClass("data").html(" - Cancelled");
\r
1454 c(this).find(".uploadify-progress-bar").remove();
\r
1455 c(this).delay(1000 + 100 * h).fadeOut(500, function () {
\r
1459 i.queueData.queueSize = 0;
\r
1460 i.queueData.queueLength = 0;
\r
1461 if (j.onClearQueue) {
\r
1462 j.onClearQueue.call(l, g);
\r
1465 for (var m = 0; m < e.length; m++) {
\r
1466 i.cancelUpload(e[m]);
\r
1467 c("#" + e[m]).find(".data").removeClass("data").html(" - Cancelled");
\r
1468 c("#" + e[m]).find(".uploadify-progress-bar").remove();
\r
1469 c("#" + e[m]).delay(1000 + 100 * m).fadeOut(500, function () {
\r
1475 var k = c("#" + j.queueID).find(".uploadify-queue-item").get(0);
\r
1477 i.cancelUpload($item.attr("id"));
\r
1478 $item.find(".data").removeClass("data").html(" - Cancelled");
\r
1479 $item.find(".uploadify-progress-bar").remove();
\r
1480 $item.delay(1000).fadeOut(500, function () {
\r
1486 destroy: function () {
\r
1487 this.each(function () {
\r
1489 d = f.data("uploadify"),
\r
1492 if (e.defaultQueue) {
\r
1493 c("#" + e.queueID).remove();
\r
1495 c("#" + e.id).replaceWith(d.original);
\r
1496 if (e.onDestroy) {
\r
1497 e.onDestroy.call(this);
\r
1502 disable: function (d) {
\r
1503 this.each(function () {
\r
1505 e = g.data("uploadify"),
\r
1508 e.button.addClass("disabled");
\r
1509 if (f.onDisable) {
\r
1510 f.onDisable.call(this);
\r
1513 e.button.removeClass("disabled");
\r
1515 f.onEnable.call(this);
\r
1518 e.setButtonDisabled(d);
\r
1521 settings: function (e, g, h) {
\r
1522 var d = arguments;
\r
1524 this.each(function () {
\r
1526 i = k.data("uploadify"),
\r
1528 if (typeof(d[0]) == "object") {
\r
1529 for (var l in g) {
\r
1533 if (d.length === 1) {
\r
1538 i.setUploadURL(g);
\r
1542 g = c.extend(j.formData, g);
\r
1544 i.setPostParams(j.formData);
\r
1548 i.setUseQueryString(true);
\r
1550 i.setUseQueryString(false);
\r
1553 case "fileObjName":
\r
1554 i.setFilePostName(g);
\r
1556 case "fileTypeExts":
\r
1557 i.setFileTypes(g, j.fileTypeDesc);
\r
1559 case "fileTypeDesc":
\r
1560 i.setFileTypes(j.fileTypeExts, g);
\r
1562 case "fileSizeLimit":
\r
1563 i.setFileSizeLimit(g);
\r
1565 case "uploadLimit":
\r
1566 i.setFileUploadLimit(g);
\r
1568 case "queueSizeLimit":
\r
1569 i.setFileQueueLimit(g);
\r
1571 case "buttonImage":
\r
1572 i.button.css("background-image", settingValue);
\r
1574 case "buttonCursor":
\r
1575 if (g == "arrow") {
\r
1576 i.setButtonCursor(SWFUpload.CURSOR.ARROW);
\r
1578 i.setButtonCursor(SWFUpload.CURSOR.HAND);
\r
1581 case "buttonText":
\r
1582 c("#" + j.id + "-button").find(".uploadify-button-text").html(g);
\r
1585 i.setButtonDimensions(g, j.height);
\r
1588 i.setButtonDimensions(j.width, g);
\r
1592 i.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILES);
\r
1594 i.setButtonAction(SWFUpload.BUTTON_ACTION.SELECT_FILE);
\r
1601 if (d.length === 1) {
\r
1605 stop: function () {
\r
1606 this.each(function () {
\r
1608 d = e.data("uploadify");
\r
1609 d.queueData.averageSpeed = 0;
\r
1610 d.queueData.uploadSize = 0;
\r
1611 d.queueData.bytesUploaded = 0;
\r
1612 d.queueData.uploadQueue = [];
\r
1616 upload: function () {
\r
1617 var d = arguments;
\r
1618 this.each(function () {
\r
1620 e = f.data("uploadify");
\r
1621 e.queueData.averageSpeed = 0;
\r
1622 e.queueData.uploadSize = 0;
\r
1623 e.queueData.bytesUploaded = 0;
\r
1624 e.queueData.uploadQueue = [];
\r
1626 if (d[0] == "*") {
\r
1627 e.queueData.uploadSize = e.queueData.queueSize;
\r
1628 e.queueData.uploadQueue.push("*");
\r
1631 for (var g = 0; g < d.length; g++) {
\r
1632 e.queueData.uploadSize += e.queueData.files[d[g]].size;
\r
1633 e.queueData.uploadQueue.push(d[g]);
\r
1635 e.startUpload(e.queueData.uploadQueue.shift());
\r
1644 onDialogOpen: function () {
\r
1645 var d = this.settings;
\r
1646 this.queueData.errorMsg = "Some files were not added to the queue:";
\r
1647 this.queueData.filesReplaced = 0;
\r
1648 this.queueData.filesCancelled = 0;
\r
1649 if (d.onDialogOpen) {
\r
1650 d.onDialogOpen.call(this);
\r
1653 onDialogClose: function (d, f, g) {
\r
1654 var e = this.settings;
\r
1655 this.queueData.filesErrored = d - f;
\r
1656 this.queueData.filesSelected = d;
\r
1657 this.queueData.filesQueued = f - this.queueData.filesCancelled;
\r
1658 this.queueData.queueLength = g;
\r
1659 if (c.inArray("onDialogClose", e.overrideEvents) < 0) {
\r
1660 if (this.queueData.filesErrored > 0) {
\r
1661 alert(this.queueData.errorMsg);
\r
1664 if (e.onDialogClose) {
\r
1665 e.onDialogClose.call(this, this.queueData);
\r
1668 c("#" + e.id).uploadify("upload", "*");
\r
1671 onSelect: function (g) {
\r
1672 var h = this.settings;
\r
1674 for (var f in this.queueData.files) {
\r
1675 e = this.queueData.files[f];
\r
1676 if (e.uploaded != true && e.name == g.name) {
\r
1677 var d = confirm('The file named "' + g.name + '" is already in the queue.\nDo you want to replace the existing item in the queue?');
\r
1679 this.cancelUpload(g.id);
\r
1680 this.queueData.filesCancelled++;
\r
1683 c("#" + e.id).remove();
\r
1684 this.cancelUpload(e.id);
\r
1685 this.queueData.filesReplaced++;
\r
1689 var i = Math.round(g.size / 1024);
\r
1692 i = Math.round(i / 1000);
\r
1695 var k = i.toString().split(".");
\r
1697 if (k.length > 1) {
\r
1698 i += "." + k[1].substr(0, 2);
\r
1702 if (j.length > 25) {
\r
1703 j = j.substr(0, 25) + "...";
\r
1705 if (c.inArray("onSelect", h.overrideEvents) < 0) {
\r
1706 c("#" + h.queueID).append('<div id="' + g.id + '" class="uploadify-queue-item"> <div class="cancel"> <a href="javascript:$(\'#' + h.id + "').uploadify('cancel', '" + g.id + '\')">X</a> </div> <span class="fileName">' + j + " (" + i + ')</span><span class="data"></span> <div class="uploadify-progress"> <div class="uploadify-progress-bar"><!--Progress Bar--></div> </div> </div>');
\r
1708 this.queueData.queueSize += g.size;
\r
1709 this.queueData.files[g.id] = g;
\r
1711 h.onSelect.apply(this, arguments);
\r
1714 onSelectError: function (d, g, f) {
\r
1715 var e = this.settings;
\r
1716 if (c.inArray("onSelectError", e.overrideEvents) < 0) {
\r
1718 case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
\r
1719 if (e.queueSizeLimit > f) {
\r
1720 this.queueData.errorMsg += "\nThe number of files selected exceeds the remaining upload limit (" + f + ").";
\r
1722 this.queueData.errorMsg += "\nThe number of files selected exceeds the queue size limit (" + e.queueSizeLimit + ").";
\r
1725 case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
\r
1726 this.queueData.errorMsg += '\nThe file "' + d.name + '" exceeds the size limit (' + e.fileSizeLimit + ").";
\r
1728 case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
\r
1729 this.queueData.errorMsg += '\nThe file "' + d.name + '" is empty.';
\r
1731 case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
\r
1732 this.queueData.errorMsg += '\nThe file "' + d.name + '" is not an accepted file type (' + e.fileTypeDesc + ").";
\r
1736 if (g != SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
\r
1737 delete this.queueData.files[d.id];
\r
1739 if (e.onSelectError) {
\r
1740 e.onSelectError.apply(this, arguments);
\r
1743 onQueueComplete: function () {
\r
1744 if (this.settings.onQueueComplete) {
\r
1745 this.settings.onQueueComplete.call(this, this.settings.queueData);
\r
1748 onUploadComplete: function (f) {
\r
1749 var g = this.settings,
\r
1751 var e = this.getStats();
\r
1752 this.queueData.queueLength = e.files_queued;
\r
1753 if (this.queueData.uploadQueue[0] == "*") {
\r
1754 if (this.queueData.queueLength > 0) {
\r
1755 this.startUpload();
\r
1757 this.queueData.uploadQueue = [];
\r
1758 if (g.onQueueComplete) {
\r
1759 g.onQueueComplete.call(this, this.queueData);
\r
1763 if (this.queueData.uploadQueue.length > 0) {
\r
1764 this.startUpload(this.queueData.uploadQueue.shift());
\r
1766 this.queueData.uploadQueue = [];
\r
1767 if (g.onQueueComplete) {
\r
1768 g.onQueueComplete.call(this, this.queueData);
\r
1772 if (c.inArray("onUploadComplete", g.overrideEvents) < 0) {
\r
1773 if (g.removeCompleted) {
\r
1774 switch (f.filestatus) {
\r
1775 case SWFUpload.FILE_STATUS.COMPLETE:
\r
1776 setTimeout(function () {
\r
1777 if (c("#" + f.id)) {
\r
1778 d.queueData.queueSize -= f.size;
\r
1779 d.queueData.queueLength -= 1;
\r
1780 delete d.queueData.files[f.id];
\r
1781 c("#" + f.id).fadeOut(500, function () {
\r
1785 }, g.removeTimeout * 1000);
\r
1787 case SWFUpload.FILE_STATUS.ERROR:
\r
1788 if (!g.requeueErrors) {
\r
1789 setTimeout(function () {
\r
1790 if (c("#" + f.id)) {
\r
1791 d.queueData.queueSize -= f.size;
\r
1792 d.queueData.queueLength -= 1;
\r
1793 delete d.queueData.files[f.id];
\r
1794 c("#" + f.id).fadeOut(500, function () {
\r
1798 }, g.removeTimeout * 1000);
\r
1803 f.uploaded = true;
\r
1806 if (g.onUploadComplete) {
\r
1807 g.onUploadComplete.call(this, f);
\r
1810 onUploadError: function (e, i, h) {
\r
1811 var f = this.settings;
\r
1814 case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:
\r
1815 g = "HTTP Error (" + h + ")";
\r
1817 case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:
\r
1818 g = "Missing Upload URL";
\r
1820 case SWFUpload.UPLOAD_ERROR.IO_ERROR:
\r
1823 case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:
\r
1824 g = "Security Error";
\r
1826 case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
\r
1827 alert("The upload limit has been reached (" + h + ").");
\r
1828 g = "Exceeds Upload Limit";
\r
1830 case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:
\r
1833 case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:
\r
1835 case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:
\r
1836 g = "Validation Error";
\r
1838 case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:
\r
1840 this.queueData.queueSize -= e.size;
\r
1841 this.queueData.queueLength -= 1;
\r
1842 if (e.status == SWFUpload.FILE_STATUS.IN_PROGRESS || c.inArray(e.id, this.queueData.uploadQueue) >= 0) {
\r
1843 this.queueData.uploadSize -= e.size;
\r
1846 f.onCancel.call(this, e);
\r
1848 delete this.queueData.files[e.id];
\r
1850 case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:
\r
1854 if (c.inArray("onUploadError", f.overrideEvents) < 0) {
\r
1855 if (i != SWFUpload.UPLOAD_ERROR.FILE_CANCELLED && i != SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED) {
\r
1856 c("#" + e.id).addClass("uploadify-error");
\r
1858 c("#" + e.id).find(".uploadify-progress-bar").css("width", "1px");
\r
1859 if (i != SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND && e.status != SWFUpload.FILE_STATUS.COMPLETE) {
\r
1860 c("#" + e.id).find(".data").html(" - " + g);
\r
1863 var d = this.getStats();
\r
1864 this.queueData.uploadsErrored = d.upload_errors;
\r
1865 if (f.onUploadError) {
\r
1866 f.onUploadError.call(this, e, i, h, g);
\r
1869 onUploadProgress: function (g, m, j) {
\r
1870 var h = this.settings;
\r
1871 var e = new Date();
\r
1872 var n = e.getTime();
\r
1873 var k = n - this.timer;
\r
1877 var i = m - this.bytesLoaded;
\r
1878 this.bytesLoaded = m;
\r
1879 var d = this.queueData.queueBytesUploaded + m;
\r
1880 var p = Math.round(m / j * 100);
\r
1883 var f = (i / 1024) / (k / 1000);
\r
1884 f = Math.floor(f * 10) / 10;
\r
1885 if (this.queueData.averageSpeed > 0) {
\r
1886 this.queueData.averageSpeed = Math.floor((this.queueData.averageSpeed + f) / 2);
\r
1888 this.queueData.averageSpeed = Math.floor(f);
\r
1892 this.queueData.averageSpeed = Math.floor(l);
\r
1895 if (c.inArray("onUploadProgress", h.overrideEvents) < 0) {
\r
1896 if (h.progressData == "percentage") {
\r
1897 c("#" + g.id).find(".data").html(" - " + p + "%");
\r
1899 if (h.progressData == "speed" && k > 500) {
\r
1900 c("#" + g.id).find(".data").html(" - " + this.queueData.averageSpeed + o);
\r
1903 c("#" + g.id).find(".uploadify-progress-bar").css("width", p + "%");
\r
1905 if (h.onUploadProgress) {
\r
1906 h.onUploadProgress.call(this, g, m, j, d, this.queueData.uploadSize);
\r
1909 onUploadStart: function (d) {
\r
1910 var e = this.settings;
\r
1911 var f = new Date();
\r
1912 this.timer = f.getTime();
\r
1913 this.bytesLoaded = 0;
\r
1914 if (this.queueData.uploadQueue.length == 0) {
\r
1915 this.queueData.uploadSize = d.size;
\r
1917 if (e.checkExisting) {
\r
1921 url: e.checkExisting,
\r
1925 success: function (h) {
\r
1927 var g = confirm('A file with the name "' + d.name + '" already exists on the server.\nWould you like to replace the existing file?');
\r
1929 this.cancelUpload(d.id);
\r
1930 c("#" + d.id).remove();
\r
1931 if (this.queueData.uploadQueue.length > 0 && this.queueData.queueLength > 0) {
\r
1932 if (this.queueData.uploadQueue[0] == "*") {
\r
1933 this.startUpload();
\r
1935 this.startUpload(this.queueData.uploadQueue.shift());
\r
1943 if (e.onUploadStart) {
\r
1944 e.onUploadStart.call(this, d);
\r
1947 onUploadSuccess: function (f, h, d) {
\r
1948 var g = this.settings;
\r
1949 var e = this.getStats();
\r
1950 this.queueData.uploadsSuccessful = e.successful_uploads;
\r
1951 this.queueData.queueBytesUploaded += f.size;
\r
1952 if (c.inArray("onUploadSuccess", g.overrideEvents) < 0) {
\r
1953 c("#" + f.id).find(".data").html(" - Complete");
\r
1955 if (g.onUploadSuccess) {
\r
1956 g.onUploadSuccess.call(this, f, h, d);
\r
1960 c.fn.uploadify = function (d) {
\r
1962 return b[d].apply(this, Array.prototype.slice.call(arguments, 1));
\r
1964 if (typeof d === "object" || !d) {
\r
1965 return b.init.apply(this, arguments);
\r
1967 c.error("The method " + d + " does not exist in $.uploadify");
\r