rails_kindeditor 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -0
  3. data/lib/generators/rails_kindeditor/install/templates/rails_kindeditor.rb +10 -0
  4. data/lib/rails_kindeditor.rb +9 -3
  5. data/lib/rails_kindeditor/helper.rb +3 -1
  6. data/lib/rails_kindeditor/version.rb +1 -1
  7. data/vendor/assets/javascripts/kindeditor/kindeditor.js +3950 -11
  8. data/vendor/assets/javascripts/kindeditor/lang/ar.js +9 -0
  9. data/vendor/assets/javascripts/kindeditor/lang/en.js +9 -0
  10. data/vendor/assets/javascripts/kindeditor/lang/ko.js +246 -237
  11. data/vendor/assets/javascripts/kindeditor/lang/ru.js +242 -0
  12. data/vendor/assets/javascripts/kindeditor/lang/{zh_CN.js → zh-CN.js} +3 -1
  13. data/vendor/assets/javascripts/kindeditor/lang/{zh_TW.js → zh-TW.js} +243 -235
  14. data/vendor/assets/javascripts/kindeditor/plugins/anchor/anchor.js +46 -46
  15. data/vendor/assets/javascripts/kindeditor/plugins/autoheight/autoheight.js +54 -54
  16. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/baidumap.js +93 -93
  17. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/index.html +82 -82
  18. data/vendor/assets/javascripts/kindeditor/plugins/baidumap/map.html +43 -43
  19. data/vendor/assets/javascripts/kindeditor/plugins/code/prettify.css +13 -13
  20. data/vendor/assets/javascripts/kindeditor/plugins/code/prettify.js +28 -28
  21. data/vendor/assets/javascripts/kindeditor/plugins/fixtoolbar/fixtoolbar.js +35 -0
  22. data/vendor/assets/javascripts/kindeditor/plugins/map/map.html +1 -1
  23. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/images/{select-files-zh_CN.png → select-files-zh-CN.png} +0 -0
  24. data/vendor/assets/javascripts/kindeditor/plugins/multiimage/multiimage.js +1384 -1384
  25. data/vendor/assets/javascripts/kindeditor/plugins/template/html/1.html +13 -13
  26. data/vendor/assets/javascripts/kindeditor/plugins/template/html/2.html +41 -41
  27. data/vendor/assets/javascripts/kindeditor/plugins/template/html/3.html +35 -35
  28. data/vendor/assets/javascripts/kindeditor/themes/default/background.png +0 -0
  29. data/vendor/assets/javascripts/kindeditor/themes/default/default.css +1147 -1149
  30. data/vendor/assets/javascripts/kindeditor/themes/qq/qq.css +143 -143
  31. data/vendor/assets/javascripts/kindeditor/themes/simple/simple.css +100 -100
  32. metadata +15 -14
@@ -1,43 +1,43 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <title>Baidu Maps</title>
6
- <style>
7
- html { height: 100% }
8
- body { height: 100%; margin: 0; padding: 0; background-color: #FFF }
9
- </style>
10
- <script charset="utf-8" src="http://api.map.baidu.com/api?v=1.3"></script>
11
- <script>
12
- var map, geocoder;
13
- function initialize() {
14
- map = new BMap.Map('map_canvas');
15
- var point = new BMap.Point(121.473704, 31.230393);
16
- map.centerAndZoom(point, 11);
17
- map.addControl(new BMap.NavigationControl());
18
- map.enableScrollWheelZoom();
19
-
20
- var gc = new BMap.Geocoder();
21
- gc.getLocation(point, function(rs){
22
- var addComp = rs.addressComponents;
23
- var address = [addComp.city].join('');
24
- parent.document.getElementById("kindeditor_plugin_map_address").value = address;
25
- });
26
- }
27
- function search(address) {
28
- if (!map) return;
29
- var local = new BMap.LocalSearch(map, {
30
- renderOptions: {
31
- map: map,
32
- autoViewport: true,
33
- selectFirstResult: false
34
- }
35
- });
36
- local.search(address);
37
- }
38
- </script>
39
- </head>
40
- <body onload="initialize();">
41
- <div id="map_canvas" style="width:100%; height:100%"></div>
42
- </body>
43
- </html>
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Baidu Maps</title>
6
+ <style>
7
+ html { height: 100% }
8
+ body { height: 100%; margin: 0; padding: 0; background-color: #FFF }
9
+ </style>
10
+ <script charset="utf-8" src="http://api.map.baidu.com/api?v=1.3"></script>
11
+ <script>
12
+ var map, geocoder;
13
+ function initialize() {
14
+ map = new BMap.Map('map_canvas');
15
+ var point = new BMap.Point(121.473704, 31.230393);
16
+ map.centerAndZoom(point, 11);
17
+ map.addControl(new BMap.NavigationControl());
18
+ map.enableScrollWheelZoom();
19
+
20
+ var gc = new BMap.Geocoder();
21
+ gc.getLocation(point, function(rs){
22
+ var addComp = rs.addressComponents;
23
+ var address = [addComp.city].join('');
24
+ parent.document.getElementById("kindeditor_plugin_map_address").value = address;
25
+ });
26
+ }
27
+ function search(address) {
28
+ if (!map) return;
29
+ var local = new BMap.LocalSearch(map, {
30
+ renderOptions: {
31
+ map: map,
32
+ autoViewport: true,
33
+ selectFirstResult: false
34
+ }
35
+ });
36
+ local.search(address);
37
+ }
38
+ </script>
39
+ </head>
40
+ <body onload="initialize();">
41
+ <div id="map_canvas" style="width:100%; height:100%"></div>
42
+ </body>
43
+ </html>
@@ -1,13 +1,13 @@
1
- .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
2
-
3
- pre.prettyprint {
4
- border: 0;
5
- border-left: 3px solid rgb(204, 204, 204);
6
- margin-left: 2em;
7
- padding: 0.5em;
8
- font-size: 110%;
9
- display: block;
10
- font-family: "Consolas", "Monaco", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
11
- margin: 1em 0px;
12
- white-space: pre;
13
- }
1
+ .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
2
+
3
+ pre.prettyprint {
4
+ border: 0;
5
+ border-left: 3px solid rgb(204, 204, 204);
6
+ margin-left: 2em;
7
+ padding: 0.5em;
8
+ font-size: 110%;
9
+ display: block;
10
+ font-family: "Consolas", "Monaco", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
11
+ margin: 1em 0px;
12
+ white-space: pre;
13
+ }
@@ -1,28 +1,28 @@
1
- var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
2
- (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
3
- [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
4
- f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
5
- (j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
6
- {b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
7
- t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
8
- "string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
9
- l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
10
- q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
11
- q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
12
- "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
13
- a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
14
- for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
15
- m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
16
- a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
17
- j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
18
- "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
19
- H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
20
- J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
21
- I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
22
- ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
23
- /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
24
- ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
25
- hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
26
- !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
27
- 250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
28
- PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
1
+ var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
2
+ (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
3
+ [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<
4
+ f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&
5
+ (j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r=
6
+ {b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,
7
+ t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b===
8
+ "string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),
9
+ l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,
10
+ q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/,
11
+ q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g,
12
+ "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a),
13
+ a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e}
14
+ for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value",
15
+ m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m=
16
+ a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue=
17
+ j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],
18
+ "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"],
19
+ H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],
20
+ J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+
21
+ I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),
22
+ ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",
23
+ /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),
24
+ ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes",
25
+ hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b=
26
+ !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m,
27
+ 250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",
28
+ PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Created by chenyihong on 14/12/4.
3
+ */
4
+
5
+ KindEditor.plugin('fixtoolbar', function (K) {
6
+ var self = this;
7
+ if (!self.fixToolBar) {
8
+ return;
9
+ }
10
+
11
+ function init() {
12
+ var toolbar = K('.ke-toolbar');
13
+ var originY = toolbar.pos().y;
14
+ K(window).bind('scroll', function () {
15
+ if (toolbar.css('position') == 'fixed') {
16
+ if(document.body.scrollTop - originY < 0){
17
+ toolbar.css('position', 'static');
18
+ toolbar.css('top', 'auto');
19
+ }
20
+ } else {
21
+ if (toolbar.pos().y - document.body.scrollTop < 0) {
22
+ toolbar.css('position', 'fixed');
23
+ toolbar.css('top', 0);
24
+ }
25
+ }
26
+ });
27
+ }
28
+
29
+ if (self.isCreated) {
30
+ init();
31
+ } else {
32
+ self.afterCreate(init);
33
+ }
34
+
35
+ });
@@ -11,7 +11,7 @@
11
11
  <script>
12
12
  var map, geocoder;
13
13
  function initialize() {
14
- var latlng = new google.maps.LatLng(31.230393, 121.473704);
14
+ var latlng = new google.maps.LatLng(-34.397, 150.644);
15
15
  var options = {
16
16
  zoom: 11,
17
17
  center: latlng,
@@ -1,1384 +1,1384 @@
1
- /*******************************************************************************
2
- * KindEditor - WYSIWYG HTML Editor for Internet
3
- * Copyright (C) 2006-2011 kindsoft.net
4
- *
5
- * @author Roddy <luolonghao@gmail.com>
6
- * @site http://www.kindsoft.net/
7
- * @licence http://www.kindsoft.net/license.php
8
- *******************************************************************************/
9
-
10
-
11
- (function(K) {
12
-
13
- function KSWFUpload(options) {
14
- this.init(options);
15
- }
16
- K.extend(KSWFUpload, {
17
- init : function(options) {
18
- var self = this;
19
- options.afterError = options.afterError || function(str) {
20
- alert(str);
21
- };
22
- self.options = options;
23
- self.progressbars = {};
24
- // template
25
- self.div = K(options.container).html([
26
- '<div class="ke-swfupload">',
27
- '<div class="ke-swfupload-top">',
28
- '<div class="ke-inline-block ke-swfupload-button">',
29
- '<input type="button" value="Browse" />',
30
- '</div>',
31
- '<div class="ke-inline-block ke-swfupload-desc">' + options.uploadDesc + '</div>',
32
- '<span class="ke-button-common ke-button-outer ke-swfupload-startupload">',
33
- '<input type="button" class="ke-button-common ke-button" value="' + options.startButtonValue + '" />',
34
- '</span>',
35
- '</div>',
36
- '<div class="ke-swfupload-body"></div>',
37
- '</div>'
38
- ].join(''));
39
- self.bodyDiv = K('.ke-swfupload-body', self.div);
40
-
41
- function showError(itemDiv, msg) {
42
- K('.ke-status > div', itemDiv).hide();
43
- K('.ke-message', itemDiv).addClass('ke-error').show().html(K.escape(msg));
44
- }
45
-
46
- var settings = {
47
- debug : false,
48
- upload_url : options.uploadUrl,
49
- flash_url : options.flashUrl,
50
- file_post_name : options.filePostName,
51
- button_placeholder : K('.ke-swfupload-button > input', self.div)[0],
52
- button_image_url: options.buttonImageUrl,
53
- button_width: options.buttonWidth,
54
- button_height: options.buttonHeight,
55
- button_cursor : SWFUpload.CURSOR.HAND,
56
- file_types : options.fileTypes,
57
- file_types_description : options.fileTypesDesc,
58
- file_upload_limit : options.fileUploadLimit,
59
- file_size_limit : options.fileSizeLimit,
60
- post_params : options.postParams,
61
- file_queued_handler : function(file) {
62
- file.url = self.options.fileIconUrl;
63
- self.appendFile(file);
64
- },
65
- file_queue_error_handler : function(file, errorCode, message) {
66
- var errorName = '';
67
- switch (errorCode) {
68
- case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
69
- errorName = options.queueLimitExceeded;
70
- break;
71
- case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
72
- errorName = options.fileExceedsSizeLimit;
73
- break;
74
- case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
75
- errorName = options.zeroByteFile;
76
- break;
77
- case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
78
- errorName = options.invalidFiletype;
79
- break;
80
- default:
81
- errorName = options.unknownError;
82
- break;
83
- }
84
- K.DEBUG && alert(errorName);
85
- },
86
- upload_start_handler : function(file) {
87
- var self = this;
88
- var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv);
89
- K('.ke-status > div', itemDiv).hide();
90
- K('.ke-progressbar', itemDiv).show();
91
- },
92
- upload_progress_handler : function(file, bytesLoaded, bytesTotal) {
93
- var percent = Math.round(bytesLoaded * 100 / bytesTotal);
94
- var progressbar = self.progressbars[file.id];
95
- progressbar.bar.css('width', Math.round(percent * 80 / 100) + 'px');
96
- progressbar.percent.html(percent + '%');
97
- },
98
- upload_error_handler : function(file, errorCode, message) {
99
- if (file && file.filestatus == SWFUpload.FILE_STATUS.ERROR) {
100
- var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv).eq(0);
101
- showError(itemDiv, self.options.errorMessage);
102
- }
103
- },
104
- upload_success_handler : function(file, serverData) {
105
- var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv).eq(0);
106
- var data = {};
107
- try {
108
- data = K.json(serverData);
109
- } catch (e) {
110
- self.options.afterError.call(this, '<!doctype html><html>' + serverData + '</html>');
111
- }
112
- if (data.error !== 0) {
113
- showError(itemDiv, K.DEBUG ? data.message : self.options.errorMessage);
114
- return;
115
- }
116
- file.url = data.url;
117
- K('.ke-img', itemDiv).attr('src', file.url).attr('data-status', file.filestatus).data('data', data);
118
- K('.ke-status > div', itemDiv).hide();
119
- }
120
- };
121
- self.swfu = new SWFUpload(settings);
122
-
123
- K('.ke-swfupload-startupload input', self.div).click(function() {
124
- self.swfu.startUpload();
125
- });
126
- },
127
- getUrlList : function() {
128
- var list = [];
129
- K('.ke-img', self.bodyDiv).each(function() {
130
- var img = K(this);
131
- var status = img.attr('data-status');
132
- if (status == SWFUpload.FILE_STATUS.COMPLETE) {
133
- list.push(img.data('data'));
134
- }
135
- });
136
- return list;
137
- },
138
- removeFile : function(fileId) {
139
- var self = this;
140
- self.swfu.cancelUpload(fileId);
141
- var itemDiv = K('div[data-id="' + fileId + '"]', self.bodyDiv);
142
- K('.ke-photo', itemDiv).unbind();
143
- K('.ke-delete', itemDiv).unbind();
144
- itemDiv.remove();
145
- },
146
- removeFiles : function() {
147
- var self = this;
148
- K('.ke-item', self.bodyDiv).each(function() {
149
- self.removeFile(K(this).attr('data-id'));
150
- });
151
- },
152
- appendFile : function(file) {
153
- var self = this;
154
- var itemDiv = K('<div class="ke-inline-block ke-item" data-id="' + file.id + '"></div>');
155
- self.bodyDiv.append(itemDiv);
156
- var photoDiv = K('<div class="ke-inline-block ke-photo"></div>')
157
- .mouseover(function(e) {
158
- K(this).addClass('ke-on');
159
- })
160
- .mouseout(function(e) {
161
- K(this).removeClass('ke-on');
162
- });
163
- itemDiv.append(photoDiv);
164
-
165
- var img = K('<img src="' + file.url + '" class="ke-img" data-status="' + file.filestatus + '" width="80" height="80" alt="' + file.name + '" />');
166
- photoDiv.append(img);
167
- K('<span class="ke-delete"></span>').appendTo(photoDiv).click(function() {
168
- self.removeFile(file.id);
169
- });
170
- var statusDiv = K('<div class="ke-status"></div>').appendTo(photoDiv);
171
- // progressbar
172
- K(['<div class="ke-progressbar">',
173
- '<div class="ke-progressbar-bar"><div class="ke-progressbar-bar-inner"></div></div>',
174
- '<div class="ke-progressbar-percent">0%</div></div>'].join('')).hide().appendTo(statusDiv);
175
- // message
176
- K('<div class="ke-message">' + self.options.pendingMessage + '</div>').appendTo(statusDiv);
177
-
178
- itemDiv.append('<div class="ke-name">' + file.name + '</div>');
179
-
180
- self.progressbars[file.id] = {
181
- bar : K('.ke-progressbar-bar-inner', photoDiv),
182
- percent : K('.ke-progressbar-percent', photoDiv)
183
- };
184
- },
185
- remove : function() {
186
- this.removeFiles();
187
- this.swfu.destroy();
188
- this.div.html('');
189
- }
190
- });
191
-
192
- K.swfupload = function(element, options) {
193
- return new KSWFUpload(element, options);
194
- };
195
-
196
- })(KindEditor);
197
-
198
- KindEditor.plugin('multiimage', function(K) {
199
- var self = this, name = 'multiimage',
200
- formatUploadUrl = K.undef(self.formatUploadUrl, true),
201
- uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
202
- imgPath = self.pluginsPath + 'multiimage/images/',
203
- imageSizeLimit = K.undef(self.imageSizeLimit, '1MB'),
204
- imageFileTypes = K.undef(self.imageFileTypes, '*.jpg;*.gif;*.png'),
205
- imageUploadLimit = K.undef(self.imageUploadLimit, 20),
206
- filePostName = K.undef(self.filePostName, 'imgFile'),
207
- lang = self.lang(name + '.');
208
-
209
- self.plugin.multiImageDialog = function(options) {
210
- var clickFn = options.clickFn,
211
- uploadDesc = K.tmpl(lang.uploadDesc, {uploadLimit : imageUploadLimit, sizeLimit : imageSizeLimit});
212
- var html = [
213
- '<div style="padding:20px;">',
214
- '<div class="swfupload">',
215
- '</div>',
216
- '</div>'
217
- ].join('');
218
- var dialog = self.createDialog({
219
- name : name,
220
- width : 650,
221
- height : 510,
222
- title : self.lang(name),
223
- body : html,
224
- previewBtn : {
225
- name : lang.insertAll,
226
- click : function(e) {
227
- clickFn.call(self, swfupload.getUrlList());
228
- }
229
- },
230
- yesBtn : {
231
- name : lang.clearAll,
232
- click : function(e) {
233
- swfupload.removeFiles();
234
- }
235
- },
236
- beforeRemove : function() {
237
- // IE9 bugfix: https://github.com/kindsoft/kindeditor/issues/72
238
- if (!K.IE || K.V <= 8) {
239
- swfupload.remove();
240
- }
241
- }
242
- }),
243
- div = dialog.div;
244
-
245
- var swfupload = K.swfupload({
246
- container : K('.swfupload', div),
247
- buttonImageUrl : imgPath + (self.langType == 'zh_CN' ? 'select-files-zh_CN.png' : 'select-files-en.png'),
248
- buttonWidth : self.langType == 'zh_CN' ? 72 : 88,
249
- buttonHeight : 23,
250
- fileIconUrl : imgPath + 'image.png',
251
- uploadDesc : uploadDesc,
252
- startButtonValue : lang.startUpload,
253
- uploadUrl : K.addParam(uploadJson, 'dir=image'),
254
- flashUrl : imgPath + 'swfupload.swf',
255
- filePostName : filePostName,
256
- fileTypes : '*.jpg;*.jpeg;*.gif;*.png;*.bmp',
257
- fileTypesDesc : 'Image Files',
258
- fileUploadLimit : imageUploadLimit,
259
- fileSizeLimit : imageSizeLimit,
260
- postParams : K.undef(self.extraFileUploadParams, {}),
261
- queueLimitExceeded : lang.queueLimitExceeded,
262
- fileExceedsSizeLimit : lang.fileExceedsSizeLimit,
263
- zeroByteFile : lang.zeroByteFile,
264
- invalidFiletype : lang.invalidFiletype,
265
- unknownError : lang.unknownError,
266
- pendingMessage : lang.pending,
267
- errorMessage : lang.uploadError,
268
- afterError : function(html) {
269
- self.errorDialog(html);
270
- }
271
- });
272
-
273
- return dialog;
274
- };
275
- self.clickToolbar(name, function() {
276
- self.plugin.multiImageDialog({
277
- clickFn : function (urlList) {
278
- if (urlList.length === 0) {
279
- return;
280
- }
281
- K.each(urlList, function(i, data) {
282
- if (self.afterUpload) {
283
- self.afterUpload.call(self, data.url, data, 'multiimage');
284
- }
285
- self.exec('insertimage', data.url, data.title, data.width, data.height, data.border, data.align);
286
- });
287
- // Bugfix: [Firefox] 上传图片后,总是出现正在加载的样式,需要延迟执行hideDialog
288
- setTimeout(function() {
289
- self.hideDialog().focus();
290
- }, 0);
291
- }
292
- });
293
- });
294
- });
295
-
296
-
297
- /**
298
- * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
299
- *
300
- * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
301
- *
302
- * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilz閚 and Mammon Media and is released under the MIT License:
303
- * http://www.opensource.org/licenses/mit-license.php
304
- *
305
- * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
306
- * http://www.opensource.org/licenses/mit-license.php
307
- *
308
- */
309
-
310
-
311
- /* ******************* */
312
- /* Constructor & Init */
313
- /* ******************* */
314
-
315
- (function() {
316
-
317
- window.SWFUpload = function (settings) {
318
- this.initSWFUpload(settings);
319
- };
320
-
321
- SWFUpload.prototype.initSWFUpload = function (settings) {
322
- try {
323
- this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
324
- this.settings = settings;
325
- this.eventQueue = [];
326
- this.movieName = "KindEditor_SWFUpload_" + SWFUpload.movieCount++;
327
- this.movieElement = null;
328
-
329
-
330
- // Setup global control tracking
331
- SWFUpload.instances[this.movieName] = this;
332
-
333
- // Load the settings. Load the Flash movie.
334
- this.initSettings();
335
- this.loadFlash();
336
- this.displayDebugInfo();
337
- } catch (ex) {
338
- delete SWFUpload.instances[this.movieName];
339
- throw ex;
340
- }
341
- };
342
-
343
- /* *************** */
344
- /* Static Members */
345
- /* *************** */
346
- SWFUpload.instances = {};
347
- SWFUpload.movieCount = 0;
348
- SWFUpload.version = "2.2.0 2009-03-25";
349
- SWFUpload.QUEUE_ERROR = {
350
- QUEUE_LIMIT_EXCEEDED : -100,
351
- FILE_EXCEEDS_SIZE_LIMIT : -110,
352
- ZERO_BYTE_FILE : -120,
353
- INVALID_FILETYPE : -130
354
- };
355
- SWFUpload.UPLOAD_ERROR = {
356
- HTTP_ERROR : -200,
357
- MISSING_UPLOAD_URL : -210,
358
- IO_ERROR : -220,
359
- SECURITY_ERROR : -230,
360
- UPLOAD_LIMIT_EXCEEDED : -240,
361
- UPLOAD_FAILED : -250,
362
- SPECIFIED_FILE_ID_NOT_FOUND : -260,
363
- FILE_VALIDATION_FAILED : -270,
364
- FILE_CANCELLED : -280,
365
- UPLOAD_STOPPED : -290
366
- };
367
- SWFUpload.FILE_STATUS = {
368
- QUEUED : -1,
369
- IN_PROGRESS : -2,
370
- ERROR : -3,
371
- COMPLETE : -4,
372
- CANCELLED : -5
373
- };
374
- SWFUpload.BUTTON_ACTION = {
375
- SELECT_FILE : -100,
376
- SELECT_FILES : -110,
377
- START_UPLOAD : -120
378
- };
379
- SWFUpload.CURSOR = {
380
- ARROW : -1,
381
- HAND : -2
382
- };
383
- SWFUpload.WINDOW_MODE = {
384
- WINDOW : "window",
385
- TRANSPARENT : "transparent",
386
- OPAQUE : "opaque"
387
- };
388
-
389
- // Private: takes a URL, determines if it is relative and converts to an absolute URL
390
- // using the current site. Only processes the URL if it can, otherwise returns the URL untouched
391
- SWFUpload.completeURL = function(url) {
392
- if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
393
- return url;
394
- }
395
-
396
- var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
397
-
398
- var indexSlash = window.location.pathname.lastIndexOf("/");
399
- if (indexSlash <= 0) {
400
- path = "/";
401
- } else {
402
- path = window.location.pathname.substr(0, indexSlash) + "/";
403
- }
404
-
405
- return /*currentURL +*/ path + url;
406
-
407
- };
408
-
409
-
410
- /* ******************** */
411
- /* Instance Members */
412
- /* ******************** */
413
-
414
- // Private: initSettings ensures that all the
415
- // settings are set, getting a default value if one was not assigned.
416
- SWFUpload.prototype.initSettings = function () {
417
- this.ensureDefault = function (settingName, defaultValue) {
418
- this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
419
- };
420
-
421
- // Upload backend settings
422
- this.ensureDefault("upload_url", "");
423
- this.ensureDefault("preserve_relative_urls", false);
424
- this.ensureDefault("file_post_name", "Filedata");
425
- this.ensureDefault("post_params", {});
426
- this.ensureDefault("use_query_string", false);
427
- this.ensureDefault("requeue_on_error", false);
428
- this.ensureDefault("http_success", []);
429
- this.ensureDefault("assume_success_timeout", 0);
430
-
431
- // File Settings
432
- this.ensureDefault("file_types", "*.*");
433
- this.ensureDefault("file_types_description", "All Files");
434
- this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
435
- this.ensureDefault("file_upload_limit", 0);
436
- this.ensureDefault("file_queue_limit", 0);
437
-
438
- // Flash Settings
439
- this.ensureDefault("flash_url", "swfupload.swf");
440
- this.ensureDefault("prevent_swf_caching", true);
441
-
442
- // Button Settings
443
- this.ensureDefault("button_image_url", "");
444
- this.ensureDefault("button_width", 1);
445
- this.ensureDefault("button_height", 1);
446
- this.ensureDefault("button_text", "");
447
- this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
448
- this.ensureDefault("button_text_top_padding", 0);
449
- this.ensureDefault("button_text_left_padding", 0);
450
- this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
451
- this.ensureDefault("button_disabled", false);
452
- this.ensureDefault("button_placeholder_id", "");
453
- this.ensureDefault("button_placeholder", null);
454
- this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
455
- this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
456
-
457
- // Debug Settings
458
- this.ensureDefault("debug", false);
459
- this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
460
-
461
- // Event Handlers
462
- this.settings.return_upload_start_handler = this.returnUploadStart;
463
- this.ensureDefault("swfupload_loaded_handler", null);
464
- this.ensureDefault("file_dialog_start_handler", null);
465
- this.ensureDefault("file_queued_handler", null);
466
- this.ensureDefault("file_queue_error_handler", null);
467
- this.ensureDefault("file_dialog_complete_handler", null);
468
-
469
- this.ensureDefault("upload_start_handler", null);
470
- this.ensureDefault("upload_progress_handler", null);
471
- this.ensureDefault("upload_error_handler", null);
472
- this.ensureDefault("upload_success_handler", null);
473
- this.ensureDefault("upload_complete_handler", null);
474
-
475
- this.ensureDefault("debug_handler", this.debugMessage);
476
-
477
- this.ensureDefault("custom_settings", {});
478
-
479
- // Other settings
480
- this.customSettings = this.settings.custom_settings;
481
-
482
- // Update the flash url if needed
483
- if (!!this.settings.prevent_swf_caching) {
484
- this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
485
- }
486
-
487
- if (!this.settings.preserve_relative_urls) {
488
- //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it
489
- this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
490
- this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
491
- }
492
-
493
- delete this.ensureDefault;
494
- };
495
-
496
- // Private: loadFlash replaces the button_placeholder element with the flash movie.
497
- SWFUpload.prototype.loadFlash = function () {
498
- var targetElement, tempParent;
499
-
500
- // Make sure an element with the ID we are going to use doesn't already exist
501
- if (document.getElementById(this.movieName) !== null) {
502
- throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
503
- }
504
-
505
- // Get the element where we will be placing the flash movie
506
- targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
507
-
508
- if (targetElement == undefined) {
509
- throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
510
- }
511
-
512
- // Append the container and load the flash
513
- tempParent = document.createElement("div");
514
- tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
515
- targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
516
-
517
- // Fix IE Flash/Form bug
518
- if (window[this.movieName] == undefined) {
519
- window[this.movieName] = this.getMovieElement();
520
- }
521
-
522
- };
523
-
524
- // Private: getFlashHTML generates the object tag needed to embed the flash in to the document
525
- SWFUpload.prototype.getFlashHTML = function () {
526
- // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
527
- // Fix bug for IE9
528
- // http://www.kindsoft.net/view.php?bbsid=7&postid=5825&pagenum=1
529
- var classid = '';
530
- if (KindEditor.IE && KindEditor.V > 8) {
531
- classid = ' classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
532
- }
533
- return ['<object id="', this.movieName, '"' + classid + ' type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
534
- '<param name="wmode" value="', this.settings.button_window_mode, '" />',
535
- '<param name="movie" value="', this.settings.flash_url, '" />',
536
- '<param name="quality" value="high" />',
537
- '<param name="menu" value="false" />',
538
- '<param name="allowScriptAccess" value="always" />',
539
- '<param name="flashvars" value="' + this.getFlashVars() + '" />',
540
- '</object>'].join("");
541
- };
542
-
543
- // Private: getFlashVars builds the parameter string that will be passed
544
- // to flash in the flashvars param.
545
- SWFUpload.prototype.getFlashVars = function () {
546
- // Build a string from the post param object
547
- var paramString = this.buildParamString();
548
- var httpSuccessString = this.settings.http_success.join(",");
549
-
550
- // Build the parameter string
551
- return ["movieName=", encodeURIComponent(this.movieName),
552
- "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
553
- "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
554
- "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
555
- "&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
556
- "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
557
- "&amp;params=", encodeURIComponent(paramString),
558
- "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
559
- "&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
560
- "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
561
- "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
562
- "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
563
- "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
564
- "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
565
- "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
566
- "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
567
- "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
568
- "&amp;buttonText=", encodeURIComponent(this.settings.button_text),
569
- "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
570
- "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
571
- "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
572
- "&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
573
- "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
574
- "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)
575
- ].join("");
576
- };
577
-
578
- // Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
579
- // The element is cached after the first lookup
580
- SWFUpload.prototype.getMovieElement = function () {
581
- if (this.movieElement == undefined) {
582
- this.movieElement = document.getElementById(this.movieName);
583
- }
584
-
585
- if (this.movieElement === null) {
586
- throw "Could not find Flash element";
587
- }
588
-
589
- return this.movieElement;
590
- };
591
-
592
- // Private: buildParamString takes the name/value pairs in the post_params setting object
593
- // and joins them up in to a string formatted "name=value&amp;name=value"
594
- SWFUpload.prototype.buildParamString = function () {
595
- var postParams = this.settings.post_params;
596
- var paramStringPairs = [];
597
-
598
- if (typeof(postParams) === "object") {
599
- for (var name in postParams) {
600
- if (postParams.hasOwnProperty(name)) {
601
- paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
602
- }
603
- }
604
- }
605
-
606
- return paramStringPairs.join("&amp;");
607
- };
608
-
609
- // Public: Used to remove a SWFUpload instance from the page. This method strives to remove
610
- // all references to the SWF, and other objects so memory is properly freed.
611
- // Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
612
- // Credits: Major improvements provided by steffen
613
- SWFUpload.prototype.destroy = function () {
614
- try {
615
- // Make sure Flash is done before we try to remove it
616
- this.cancelUpload(null, false);
617
-
618
-
619
- // Remove the SWFUpload DOM nodes
620
- var movieElement = null;
621
- movieElement = this.getMovieElement();
622
-
623
- if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
624
- // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
625
- for (var i in movieElement) {
626
- try {
627
- if (typeof(movieElement[i]) === "function") {
628
- movieElement[i] = null;
629
- }
630
- } catch (ex1) {}
631
- }
632
-
633
- // Remove the Movie Element from the page
634
- try {
635
- movieElement.parentNode.removeChild(movieElement);
636
- } catch (ex) {}
637
- }
638
-
639
- // Remove IE form fix reference
640
- window[this.movieName] = null;
641
-
642
- // Destroy other references
643
- SWFUpload.instances[this.movieName] = null;
644
- delete SWFUpload.instances[this.movieName];
645
-
646
- this.movieElement = null;
647
- this.settings = null;
648
- this.customSettings = null;
649
- this.eventQueue = null;
650
- this.movieName = null;
651
-
652
-
653
- return true;
654
- } catch (ex2) {
655
- return false;
656
- }
657
- };
658
-
659
-
660
- // Public: displayDebugInfo prints out settings and configuration
661
- // information about this SWFUpload instance.
662
- // This function (and any references to it) can be deleted when placing
663
- // SWFUpload in production.
664
- SWFUpload.prototype.displayDebugInfo = function () {
665
- this.debug(
666
- [
667
- "---SWFUpload Instance Info---\n",
668
- "Version: ", SWFUpload.version, "\n",
669
- "Movie Name: ", this.movieName, "\n",
670
- "Settings:\n",
671
- "\t", "upload_url: ", this.settings.upload_url, "\n",
672
- "\t", "flash_url: ", this.settings.flash_url, "\n",
673
- "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
674
- "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
675
- "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
676
- "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
677
- "\t", "file_post_name: ", this.settings.file_post_name, "\n",
678
- "\t", "post_params: ", this.settings.post_params.toString(), "\n",
679
- "\t", "file_types: ", this.settings.file_types, "\n",
680
- "\t", "file_types_description: ", this.settings.file_types_description, "\n",
681
- "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
682
- "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
683
- "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
684
- "\t", "debug: ", this.settings.debug.toString(), "\n",
685
-
686
- "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
687
-
688
- "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
689
- "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
690
- "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
691
- "\t", "button_width: ", this.settings.button_width.toString(), "\n",
692
- "\t", "button_height: ", this.settings.button_height.toString(), "\n",
693
- "\t", "button_text: ", this.settings.button_text.toString(), "\n",
694
- "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
695
- "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
696
- "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
697
- "\t", "button_action: ", this.settings.button_action.toString(), "\n",
698
- "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
699
-
700
- "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
701
- "Event Handlers:\n",
702
- "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
703
- "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
704
- "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
705
- "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
706
- "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
707
- "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
708
- "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
709
- "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
710
- "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
711
- "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
712
- ].join("")
713
- );
714
- };
715
-
716
- /* Note: addSetting and getSetting are no longer used by SWFUpload but are included
717
- the maintain v2 API compatibility
718
- */
719
- // Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
720
- SWFUpload.prototype.addSetting = function (name, value, default_value) {
721
- if (value == undefined) {
722
- return (this.settings[name] = default_value);
723
- } else {
724
- return (this.settings[name] = value);
725
- }
726
- };
727
-
728
- // Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
729
- SWFUpload.prototype.getSetting = function (name) {
730
- if (this.settings[name] != undefined) {
731
- return this.settings[name];
732
- }
733
-
734
- return "";
735
- };
736
-
737
-
738
-
739
- // Private: callFlash handles function calls made to the Flash element.
740
- // Calls are made with a setTimeout for some functions to work around
741
- // bugs in the ExternalInterface library.
742
- SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
743
- argumentArray = argumentArray || [];
744
-
745
- var movieElement = this.getMovieElement();
746
- var returnValue, returnString;
747
-
748
- // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
749
- try {
750
- returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
751
- returnValue = eval(returnString);
752
- } catch (ex) {
753
- throw "Call to " + functionName + " failed";
754
- }
755
-
756
- // Unescape file post param values
757
- if (returnValue != undefined && typeof returnValue.post === "object") {
758
- returnValue = this.unescapeFilePostParams(returnValue);
759
- }
760
-
761
- return returnValue;
762
- };
763
-
764
- /* *****************************
765
- -- Flash control methods --
766
- Your UI should use these
767
- to operate SWFUpload
768
- ***************************** */
769
-
770
- // WARNING: this function does not work in Flash Player 10
771
- // Public: selectFile causes a File Selection Dialog window to appear. This
772
- // dialog only allows 1 file to be selected.
773
- SWFUpload.prototype.selectFile = function () {
774
- this.callFlash("SelectFile");
775
- };
776
-
777
- // WARNING: this function does not work in Flash Player 10
778
- // Public: selectFiles causes a File Selection Dialog window to appear/ This
779
- // dialog allows the user to select any number of files
780
- // Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
781
- // If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
782
- // for this bug.
783
- SWFUpload.prototype.selectFiles = function () {
784
- this.callFlash("SelectFiles");
785
- };
786
-
787
-
788
- // Public: startUpload starts uploading the first file in the queue unless
789
- // the optional parameter 'fileID' specifies the ID
790
- SWFUpload.prototype.startUpload = function (fileID) {
791
- this.callFlash("StartUpload", [fileID]);
792
- };
793
-
794
- // Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
795
- // If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
796
- // If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
797
- SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
798
- if (triggerErrorEvent !== false) {
799
- triggerErrorEvent = true;
800
- }
801
- this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
802
- };
803
-
804
- // Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
805
- // If nothing is currently uploading then nothing happens.
806
- SWFUpload.prototype.stopUpload = function () {
807
- this.callFlash("StopUpload");
808
- };
809
-
810
- /* ************************
811
- * Settings methods
812
- * These methods change the SWFUpload settings.
813
- * SWFUpload settings should not be changed directly on the settings object
814
- * since many of the settings need to be passed to Flash in order to take
815
- * effect.
816
- * *********************** */
817
-
818
- // Public: getStats gets the file statistics object.
819
- SWFUpload.prototype.getStats = function () {
820
- return this.callFlash("GetStats");
821
- };
822
-
823
- // Public: setStats changes the SWFUpload statistics. You shouldn't need to
824
- // change the statistics but you can. Changing the statistics does not
825
- // affect SWFUpload accept for the successful_uploads count which is used
826
- // by the upload_limit setting to determine how many files the user may upload.
827
- SWFUpload.prototype.setStats = function (statsObject) {
828
- this.callFlash("SetStats", [statsObject]);
829
- };
830
-
831
- // Public: getFile retrieves a File object by ID or Index. If the file is
832
- // not found then 'null' is returned.
833
- SWFUpload.prototype.getFile = function (fileID) {
834
- if (typeof(fileID) === "number") {
835
- return this.callFlash("GetFileByIndex", [fileID]);
836
- } else {
837
- return this.callFlash("GetFile", [fileID]);
838
- }
839
- };
840
-
841
- // Public: addFileParam sets a name/value pair that will be posted with the
842
- // file specified by the Files ID. If the name already exists then the
843
- // exiting value will be overwritten.
844
- SWFUpload.prototype.addFileParam = function (fileID, name, value) {
845
- return this.callFlash("AddFileParam", [fileID, name, value]);
846
- };
847
-
848
- // Public: removeFileParam removes a previously set (by addFileParam) name/value
849
- // pair from the specified file.
850
- SWFUpload.prototype.removeFileParam = function (fileID, name) {
851
- this.callFlash("RemoveFileParam", [fileID, name]);
852
- };
853
-
854
- // Public: setUploadUrl changes the upload_url setting.
855
- SWFUpload.prototype.setUploadURL = function (url) {
856
- this.settings.upload_url = url.toString();
857
- this.callFlash("SetUploadURL", [url]);
858
- };
859
-
860
- // Public: setPostParams changes the post_params setting
861
- SWFUpload.prototype.setPostParams = function (paramsObject) {
862
- this.settings.post_params = paramsObject;
863
- this.callFlash("SetPostParams", [paramsObject]);
864
- };
865
-
866
- // Public: addPostParam adds post name/value pair. Each name can have only one value.
867
- SWFUpload.prototype.addPostParam = function (name, value) {
868
- this.settings.post_params[name] = value;
869
- this.callFlash("SetPostParams", [this.settings.post_params]);
870
- };
871
-
872
- // Public: removePostParam deletes post name/value pair.
873
- SWFUpload.prototype.removePostParam = function (name) {
874
- delete this.settings.post_params[name];
875
- this.callFlash("SetPostParams", [this.settings.post_params]);
876
- };
877
-
878
- // Public: setFileTypes changes the file_types setting and the file_types_description setting
879
- SWFUpload.prototype.setFileTypes = function (types, description) {
880
- this.settings.file_types = types;
881
- this.settings.file_types_description = description;
882
- this.callFlash("SetFileTypes", [types, description]);
883
- };
884
-
885
- // Public: setFileSizeLimit changes the file_size_limit setting
886
- SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
887
- this.settings.file_size_limit = fileSizeLimit;
888
- this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
889
- };
890
-
891
- // Public: setFileUploadLimit changes the file_upload_limit setting
892
- SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
893
- this.settings.file_upload_limit = fileUploadLimit;
894
- this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
895
- };
896
-
897
- // Public: setFileQueueLimit changes the file_queue_limit setting
898
- SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
899
- this.settings.file_queue_limit = fileQueueLimit;
900
- this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
901
- };
902
-
903
- // Public: setFilePostName changes the file_post_name setting
904
- SWFUpload.prototype.setFilePostName = function (filePostName) {
905
- this.settings.file_post_name = filePostName;
906
- this.callFlash("SetFilePostName", [filePostName]);
907
- };
908
-
909
- // Public: setUseQueryString changes the use_query_string setting
910
- SWFUpload.prototype.setUseQueryString = function (useQueryString) {
911
- this.settings.use_query_string = useQueryString;
912
- this.callFlash("SetUseQueryString", [useQueryString]);
913
- };
914
-
915
- // Public: setRequeueOnError changes the requeue_on_error setting
916
- SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
917
- this.settings.requeue_on_error = requeueOnError;
918
- this.callFlash("SetRequeueOnError", [requeueOnError]);
919
- };
920
-
921
- // Public: setHTTPSuccess changes the http_success setting
922
- SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
923
- if (typeof http_status_codes === "string") {
924
- http_status_codes = http_status_codes.replace(" ", "").split(",");
925
- }
926
-
927
- this.settings.http_success = http_status_codes;
928
- this.callFlash("SetHTTPSuccess", [http_status_codes]);
929
- };
930
-
931
- // Public: setHTTPSuccess changes the http_success setting
932
- SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
933
- this.settings.assume_success_timeout = timeout_seconds;
934
- this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
935
- };
936
-
937
- // Public: setDebugEnabled changes the debug_enabled setting
938
- SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
939
- this.settings.debug_enabled = debugEnabled;
940
- this.callFlash("SetDebugEnabled", [debugEnabled]);
941
- };
942
-
943
- // Public: setButtonImageURL loads a button image sprite
944
- SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
945
- if (buttonImageURL == undefined) {
946
- buttonImageURL = "";
947
- }
948
-
949
- this.settings.button_image_url = buttonImageURL;
950
- this.callFlash("SetButtonImageURL", [buttonImageURL]);
951
- };
952
-
953
- // Public: setButtonDimensions resizes the Flash Movie and button
954
- SWFUpload.prototype.setButtonDimensions = function (width, height) {
955
- this.settings.button_width = width;
956
- this.settings.button_height = height;
957
-
958
- var movie = this.getMovieElement();
959
- if (movie != undefined) {
960
- movie.style.width = width + "px";
961
- movie.style.height = height + "px";
962
- }
963
-
964
- this.callFlash("SetButtonDimensions", [width, height]);
965
- };
966
- // Public: setButtonText Changes the text overlaid on the button
967
- SWFUpload.prototype.setButtonText = function (html) {
968
- this.settings.button_text = html;
969
- this.callFlash("SetButtonText", [html]);
970
- };
971
- // Public: setButtonTextPadding changes the top and left padding of the text overlay
972
- SWFUpload.prototype.setButtonTextPadding = function (left, top) {
973
- this.settings.button_text_top_padding = top;
974
- this.settings.button_text_left_padding = left;
975
- this.callFlash("SetButtonTextPadding", [left, top]);
976
- };
977
-
978
- // Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
979
- SWFUpload.prototype.setButtonTextStyle = function (css) {
980
- this.settings.button_text_style = css;
981
- this.callFlash("SetButtonTextStyle", [css]);
982
- };
983
- // Public: setButtonDisabled disables/enables the button
984
- SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
985
- this.settings.button_disabled = isDisabled;
986
- this.callFlash("SetButtonDisabled", [isDisabled]);
987
- };
988
- // Public: setButtonAction sets the action that occurs when the button is clicked
989
- SWFUpload.prototype.setButtonAction = function (buttonAction) {
990
- this.settings.button_action = buttonAction;
991
- this.callFlash("SetButtonAction", [buttonAction]);
992
- };
993
-
994
- // Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
995
- SWFUpload.prototype.setButtonCursor = function (cursor) {
996
- this.settings.button_cursor = cursor;
997
- this.callFlash("SetButtonCursor", [cursor]);
998
- };
999
-
1000
- /* *******************************
1001
- Flash Event Interfaces
1002
- These functions are used by Flash to trigger the various
1003
- events.
1004
-
1005
- All these functions a Private.
1006
-
1007
- Because the ExternalInterface library is buggy the event calls
1008
- are added to a queue and the queue then executed by a setTimeout.
1009
- This ensures that events are executed in a determinate order and that
1010
- the ExternalInterface bugs are avoided.
1011
- ******************************* */
1012
-
1013
- SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
1014
- // Warning: Don't call this.debug inside here or you'll create an infinite loop
1015
-
1016
- if (argumentArray == undefined) {
1017
- argumentArray = [];
1018
- } else if (!(argumentArray instanceof Array)) {
1019
- argumentArray = [argumentArray];
1020
- }
1021
-
1022
- var self = this;
1023
- if (typeof this.settings[handlerName] === "function") {
1024
- // Queue the event
1025
- this.eventQueue.push(function () {
1026
- this.settings[handlerName].apply(this, argumentArray);
1027
- });
1028
-
1029
- // Execute the next queued event
1030
- setTimeout(function () {
1031
- self.executeNextEvent();
1032
- }, 0);
1033
-
1034
- } else if (this.settings[handlerName] !== null) {
1035
- throw "Event handler " + handlerName + " is unknown or is not a function";
1036
- }
1037
- };
1038
-
1039
- // Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
1040
- // we must queue them in order to garentee that they are executed in order.
1041
- SWFUpload.prototype.executeNextEvent = function () {
1042
- // Warning: Don't call this.debug inside here or you'll create an infinite loop
1043
-
1044
- var f = this.eventQueue ? this.eventQueue.shift() : null;
1045
- if (typeof(f) === "function") {
1046
- f.apply(this);
1047
- }
1048
- };
1049
-
1050
- // Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
1051
- // properties that contain characters that are not valid for JavaScript identifiers. To work around this
1052
- // the Flash Component escapes the parameter names and we must unescape again before passing them along.
1053
- SWFUpload.prototype.unescapeFilePostParams = function (file) {
1054
- var reg = /[$]([0-9a-f]{4})/i;
1055
- var unescapedPost = {};
1056
- var uk;
1057
-
1058
- if (file != undefined) {
1059
- for (var k in file.post) {
1060
- if (file.post.hasOwnProperty(k)) {
1061
- uk = k;
1062
- var match;
1063
- while ((match = reg.exec(uk)) !== null) {
1064
- uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
1065
- }
1066
- unescapedPost[uk] = file.post[k];
1067
- }
1068
- }
1069
-
1070
- file.post = unescapedPost;
1071
- }
1072
-
1073
- return file;
1074
- };
1075
-
1076
- // Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working)
1077
- SWFUpload.prototype.testExternalInterface = function () {
1078
- try {
1079
- return this.callFlash("TestExternalInterface");
1080
- } catch (ex) {
1081
- return false;
1082
- }
1083
- };
1084
-
1085
- // Private: This event is called by Flash when it has finished loading. Don't modify this.
1086
- // Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
1087
- SWFUpload.prototype.flashReady = function () {
1088
- // Check that the movie element is loaded correctly with its ExternalInterface methods defined
1089
- var movieElement = this.getMovieElement();
1090
-
1091
- if (!movieElement) {
1092
- this.debug("Flash called back ready but the flash movie can't be found.");
1093
- return;
1094
- }
1095
-
1096
- this.cleanUp(movieElement);
1097
-
1098
- this.queueEvent("swfupload_loaded_handler");
1099
- };
1100
-
1101
- // Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
1102
- // This function is called by Flash each time the ExternalInterface functions are created.
1103
- SWFUpload.prototype.cleanUp = function (movieElement) {
1104
- // Pro-actively unhook all the Flash functions
1105
- try {
1106
- if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
1107
- this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
1108
- for (var key in movieElement) {
1109
- try {
1110
- if (typeof(movieElement[key]) === "function") {
1111
- movieElement[key] = null;
1112
- }
1113
- } catch (ex) {
1114
- }
1115
- }
1116
- }
1117
- } catch (ex1) {
1118
-
1119
- }
1120
-
1121
- // Fix Flashes own cleanup code so if the SWFMovie was removed from the page
1122
- // it doesn't display errors.
1123
- window["__flash__removeCallback"] = function (instance, name) {
1124
- try {
1125
- if (instance) {
1126
- instance[name] = null;
1127
- }
1128
- } catch (flashEx) {
1129
-
1130
- }
1131
- };
1132
-
1133
- };
1134
-
1135
-
1136
- /* This is a chance to do something before the browse window opens */
1137
- SWFUpload.prototype.fileDialogStart = function () {
1138
- this.queueEvent("file_dialog_start_handler");
1139
- };
1140
-
1141
-
1142
- /* Called when a file is successfully added to the queue. */
1143
- SWFUpload.prototype.fileQueued = function (file) {
1144
- file = this.unescapeFilePostParams(file);
1145
- this.queueEvent("file_queued_handler", file);
1146
- };
1147
-
1148
-
1149
- /* Handle errors that occur when an attempt to queue a file fails. */
1150
- SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
1151
- file = this.unescapeFilePostParams(file);
1152
- this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
1153
- };
1154
-
1155
- /* Called after the file dialog has closed and the selected files have been queued.
1156
- You could call startUpload here if you want the queued files to begin uploading immediately. */
1157
- SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
1158
- this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
1159
- };
1160
-
1161
- SWFUpload.prototype.uploadStart = function (file) {
1162
- file = this.unescapeFilePostParams(file);
1163
- this.queueEvent("return_upload_start_handler", file);
1164
- };
1165
-
1166
- SWFUpload.prototype.returnUploadStart = function (file) {
1167
- var returnValue;
1168
- if (typeof this.settings.upload_start_handler === "function") {
1169
- file = this.unescapeFilePostParams(file);
1170
- returnValue = this.settings.upload_start_handler.call(this, file);
1171
- } else if (this.settings.upload_start_handler != undefined) {
1172
- throw "upload_start_handler must be a function";
1173
- }
1174
-
1175
- // Convert undefined to true so if nothing is returned from the upload_start_handler it is
1176
- // interpretted as 'true'.
1177
- if (returnValue === undefined) {
1178
- returnValue = true;
1179
- }
1180
-
1181
- returnValue = !!returnValue;
1182
-
1183
- this.callFlash("ReturnUploadStart", [returnValue]);
1184
- };
1185
-
1186
-
1187
-
1188
- SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
1189
- file = this.unescapeFilePostParams(file);
1190
- this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
1191
- };
1192
-
1193
- SWFUpload.prototype.uploadError = function (file, errorCode, message) {
1194
- file = this.unescapeFilePostParams(file);
1195
- this.queueEvent("upload_error_handler", [file, errorCode, message]);
1196
- };
1197
-
1198
- SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
1199
- file = this.unescapeFilePostParams(file);
1200
- this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
1201
- };
1202
-
1203
- SWFUpload.prototype.uploadComplete = function (file) {
1204
- file = this.unescapeFilePostParams(file);
1205
- this.queueEvent("upload_complete_handler", file);
1206
- };
1207
-
1208
- /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
1209
- internal debug console. You can override this event and have messages written where you want. */
1210
- SWFUpload.prototype.debug = function (message) {
1211
- this.queueEvent("debug_handler", message);
1212
- };
1213
-
1214
-
1215
- /* **********************************
1216
- Debug Console
1217
- The debug console is a self contained, in page location
1218
- for debug message to be sent. The Debug Console adds
1219
- itself to the body if necessary.
1220
-
1221
- The console is automatically scrolled as messages appear.
1222
-
1223
- If you are using your own debug handler or when you deploy to production and
1224
- have debug disabled you can remove these functions to reduce the file size
1225
- and complexity.
1226
- ********************************** */
1227
-
1228
- // Private: debugMessage is the default debug_handler. If you want to print debug messages
1229
- // call the debug() function. When overriding the function your own function should
1230
- // check to see if the debug setting is true before outputting debug information.
1231
- SWFUpload.prototype.debugMessage = function (message) {
1232
- if (this.settings.debug) {
1233
- var exceptionMessage, exceptionValues = [];
1234
-
1235
- // Check for an exception object and print it nicely
1236
- if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
1237
- for (var key in message) {
1238
- if (message.hasOwnProperty(key)) {
1239
- exceptionValues.push(key + ": " + message[key]);
1240
- }
1241
- }
1242
- exceptionMessage = exceptionValues.join("\n") || "";
1243
- exceptionValues = exceptionMessage.split("\n");
1244
- exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
1245
- SWFUpload.Console.writeLine(exceptionMessage);
1246
- } else {
1247
- SWFUpload.Console.writeLine(message);
1248
- }
1249
- }
1250
- };
1251
-
1252
- SWFUpload.Console = {};
1253
- SWFUpload.Console.writeLine = function (message) {
1254
- var console, documentForm;
1255
-
1256
- try {
1257
- console = document.getElementById("SWFUpload_Console");
1258
-
1259
- if (!console) {
1260
- documentForm = document.createElement("form");
1261
- document.getElementsByTagName("body")[0].appendChild(documentForm);
1262
-
1263
- console = document.createElement("textarea");
1264
- console.id = "SWFUpload_Console";
1265
- console.style.fontFamily = "monospace";
1266
- console.setAttribute("wrap", "off");
1267
- console.wrap = "off";
1268
- console.style.overflow = "auto";
1269
- console.style.width = "700px";
1270
- console.style.height = "350px";
1271
- console.style.margin = "5px";
1272
- documentForm.appendChild(console);
1273
- }
1274
-
1275
- console.value += message + "\n";
1276
-
1277
- console.scrollTop = console.scrollHeight - console.clientHeight;
1278
- } catch (ex) {
1279
- alert("Exception: " + ex.name + " Message: " + ex.message);
1280
- }
1281
- };
1282
-
1283
- })();
1284
-
1285
- (function() {
1286
- /*
1287
- Queue Plug-in
1288
-
1289
- Features:
1290
- *Adds a cancelQueue() method for cancelling the entire queue.
1291
- *All queued files are uploaded when startUpload() is called.
1292
- *If false is returned from uploadComplete then the queue upload is stopped.
1293
- If false is not returned (strict comparison) then the queue upload is continued.
1294
- *Adds a QueueComplete event that is fired when all the queued files have finished uploading.
1295
- Set the event handler with the queue_complete_handler setting.
1296
-
1297
- */
1298
-
1299
- if (typeof(SWFUpload) === "function") {
1300
- SWFUpload.queue = {};
1301
-
1302
- SWFUpload.prototype.initSettings = (function (oldInitSettings) {
1303
- return function () {
1304
- if (typeof(oldInitSettings) === "function") {
1305
- oldInitSettings.call(this);
1306
- }
1307
-
1308
- this.queueSettings = {};
1309
-
1310
- this.queueSettings.queue_cancelled_flag = false;
1311
- this.queueSettings.queue_upload_count = 0;
1312
-
1313
- this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
1314
- this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
1315
- this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
1316
- this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
1317
-
1318
- this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
1319
- };
1320
- })(SWFUpload.prototype.initSettings);
1321
-
1322
- SWFUpload.prototype.startUpload = function (fileID) {
1323
- this.queueSettings.queue_cancelled_flag = false;
1324
- this.callFlash("StartUpload", [fileID]);
1325
- };
1326
-
1327
- SWFUpload.prototype.cancelQueue = function () {
1328
- this.queueSettings.queue_cancelled_flag = true;
1329
- this.stopUpload();
1330
-
1331
- var stats = this.getStats();
1332
- while (stats.files_queued > 0) {
1333
- this.cancelUpload();
1334
- stats = this.getStats();
1335
- }
1336
- };
1337
-
1338
- SWFUpload.queue.uploadStartHandler = function (file) {
1339
- var returnValue;
1340
- if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
1341
- returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
1342
- }
1343
-
1344
- // To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value.
1345
- returnValue = (returnValue === false) ? false : true;
1346
-
1347
- this.queueSettings.queue_cancelled_flag = !returnValue;
1348
-
1349
- return returnValue;
1350
- };
1351
-
1352
- SWFUpload.queue.uploadCompleteHandler = function (file) {
1353
- var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
1354
- var continueUpload;
1355
-
1356
- if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
1357
- this.queueSettings.queue_upload_count++;
1358
- }
1359
-
1360
- if (typeof(user_upload_complete_handler) === "function") {
1361
- continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
1362
- } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
1363
- // If the file was stopped and re-queued don't restart the upload
1364
- continueUpload = false;
1365
- } else {
1366
- continueUpload = true;
1367
- }
1368
-
1369
- if (continueUpload) {
1370
- var stats = this.getStats();
1371
- if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
1372
- this.startUpload();
1373
- } else if (this.queueSettings.queue_cancelled_flag === false) {
1374
- this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
1375
- this.queueSettings.queue_upload_count = 0;
1376
- } else {
1377
- this.queueSettings.queue_cancelled_flag = false;
1378
- this.queueSettings.queue_upload_count = 0;
1379
- }
1380
- }
1381
- };
1382
- }
1383
-
1384
- })();
1
+ /*******************************************************************************
2
+ * KindEditor - WYSIWYG HTML Editor for Internet
3
+ * Copyright (C) 2006-2011 kindsoft.net
4
+ *
5
+ * @author Roddy <luolonghao@gmail.com>
6
+ * @site http://www.kindsoft.net/
7
+ * @licence http://www.kindsoft.net/license.php
8
+ *******************************************************************************/
9
+
10
+
11
+ (function(K) {
12
+
13
+ function KSWFUpload(options) {
14
+ this.init(options);
15
+ }
16
+ K.extend(KSWFUpload, {
17
+ init : function(options) {
18
+ var self = this;
19
+ options.afterError = options.afterError || function(str) {
20
+ alert(str);
21
+ };
22
+ self.options = options;
23
+ self.progressbars = {};
24
+ // template
25
+ self.div = K(options.container).html([
26
+ '<div class="ke-swfupload">',
27
+ '<div class="ke-swfupload-top">',
28
+ '<div class="ke-inline-block ke-swfupload-button">',
29
+ '<input type="button" value="Browse" />',
30
+ '</div>',
31
+ '<div class="ke-inline-block ke-swfupload-desc">' + options.uploadDesc + '</div>',
32
+ '<span class="ke-button-common ke-button-outer ke-swfupload-startupload">',
33
+ '<input type="button" class="ke-button-common ke-button" value="' + options.startButtonValue + '" />',
34
+ '</span>',
35
+ '</div>',
36
+ '<div class="ke-swfupload-body"></div>',
37
+ '</div>'
38
+ ].join(''));
39
+ self.bodyDiv = K('.ke-swfupload-body', self.div);
40
+
41
+ function showError(itemDiv, msg) {
42
+ K('.ke-status > div', itemDiv).hide();
43
+ K('.ke-message', itemDiv).addClass('ke-error').show().html(K.escape(msg));
44
+ }
45
+
46
+ var settings = {
47
+ debug : false,
48
+ upload_url : options.uploadUrl,
49
+ flash_url : options.flashUrl,
50
+ file_post_name : options.filePostName,
51
+ button_placeholder : K('.ke-swfupload-button > input', self.div)[0],
52
+ button_image_url: options.buttonImageUrl,
53
+ button_width: options.buttonWidth,
54
+ button_height: options.buttonHeight,
55
+ button_cursor : SWFUpload.CURSOR.HAND,
56
+ file_types : options.fileTypes,
57
+ file_types_description : options.fileTypesDesc,
58
+ file_upload_limit : options.fileUploadLimit,
59
+ file_size_limit : options.fileSizeLimit,
60
+ post_params : options.postParams,
61
+ file_queued_handler : function(file) {
62
+ file.url = self.options.fileIconUrl;
63
+ self.appendFile(file);
64
+ },
65
+ file_queue_error_handler : function(file, errorCode, message) {
66
+ var errorName = '';
67
+ switch (errorCode) {
68
+ case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
69
+ errorName = options.queueLimitExceeded;
70
+ break;
71
+ case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
72
+ errorName = options.fileExceedsSizeLimit;
73
+ break;
74
+ case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
75
+ errorName = options.zeroByteFile;
76
+ break;
77
+ case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
78
+ errorName = options.invalidFiletype;
79
+ break;
80
+ default:
81
+ errorName = options.unknownError;
82
+ break;
83
+ }
84
+ K.DEBUG && alert(errorName);
85
+ },
86
+ upload_start_handler : function(file) {
87
+ var self = this;
88
+ var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv);
89
+ K('.ke-status > div', itemDiv).hide();
90
+ K('.ke-progressbar', itemDiv).show();
91
+ },
92
+ upload_progress_handler : function(file, bytesLoaded, bytesTotal) {
93
+ var percent = Math.round(bytesLoaded * 100 / bytesTotal);
94
+ var progressbar = self.progressbars[file.id];
95
+ progressbar.bar.css('width', Math.round(percent * 80 / 100) + 'px');
96
+ progressbar.percent.html(percent + '%');
97
+ },
98
+ upload_error_handler : function(file, errorCode, message) {
99
+ if (file && file.filestatus == SWFUpload.FILE_STATUS.ERROR) {
100
+ var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv).eq(0);
101
+ showError(itemDiv, self.options.errorMessage);
102
+ }
103
+ },
104
+ upload_success_handler : function(file, serverData) {
105
+ var itemDiv = K('div[data-id="' + file.id + '"]', self.bodyDiv).eq(0);
106
+ var data = {};
107
+ try {
108
+ data = K.json(serverData);
109
+ } catch (e) {
110
+ self.options.afterError.call(this, '<!doctype html><html>' + serverData + '</html>');
111
+ }
112
+ if (data.error !== 0) {
113
+ showError(itemDiv, K.DEBUG ? data.message : self.options.errorMessage);
114
+ return;
115
+ }
116
+ file.url = data.url;
117
+ K('.ke-img', itemDiv).attr('src', file.url).attr('data-status', file.filestatus).data('data', data);
118
+ K('.ke-status > div', itemDiv).hide();
119
+ }
120
+ };
121
+ self.swfu = new SWFUpload(settings);
122
+
123
+ K('.ke-swfupload-startupload input', self.div).click(function() {
124
+ self.swfu.startUpload();
125
+ });
126
+ },
127
+ getUrlList : function() {
128
+ var list = [];
129
+ K('.ke-img', self.bodyDiv).each(function() {
130
+ var img = K(this);
131
+ var status = img.attr('data-status');
132
+ if (status == SWFUpload.FILE_STATUS.COMPLETE) {
133
+ list.push(img.data('data'));
134
+ }
135
+ });
136
+ return list;
137
+ },
138
+ removeFile : function(fileId) {
139
+ var self = this;
140
+ self.swfu.cancelUpload(fileId);
141
+ var itemDiv = K('div[data-id="' + fileId + '"]', self.bodyDiv);
142
+ K('.ke-photo', itemDiv).unbind();
143
+ K('.ke-delete', itemDiv).unbind();
144
+ itemDiv.remove();
145
+ },
146
+ removeFiles : function() {
147
+ var self = this;
148
+ K('.ke-item', self.bodyDiv).each(function() {
149
+ self.removeFile(K(this).attr('data-id'));
150
+ });
151
+ },
152
+ appendFile : function(file) {
153
+ var self = this;
154
+ var itemDiv = K('<div class="ke-inline-block ke-item" data-id="' + file.id + '"></div>');
155
+ self.bodyDiv.append(itemDiv);
156
+ var photoDiv = K('<div class="ke-inline-block ke-photo"></div>')
157
+ .mouseover(function(e) {
158
+ K(this).addClass('ke-on');
159
+ })
160
+ .mouseout(function(e) {
161
+ K(this).removeClass('ke-on');
162
+ });
163
+ itemDiv.append(photoDiv);
164
+
165
+ var img = K('<img src="' + file.url + '" class="ke-img" data-status="' + file.filestatus + '" width="80" height="80" alt="' + file.name + '" />');
166
+ photoDiv.append(img);
167
+ K('<span class="ke-delete"></span>').appendTo(photoDiv).click(function() {
168
+ self.removeFile(file.id);
169
+ });
170
+ var statusDiv = K('<div class="ke-status"></div>').appendTo(photoDiv);
171
+ // progressbar
172
+ K(['<div class="ke-progressbar">',
173
+ '<div class="ke-progressbar-bar"><div class="ke-progressbar-bar-inner"></div></div>',
174
+ '<div class="ke-progressbar-percent">0%</div></div>'].join('')).hide().appendTo(statusDiv);
175
+ // message
176
+ K('<div class="ke-message">' + self.options.pendingMessage + '</div>').appendTo(statusDiv);
177
+
178
+ itemDiv.append('<div class="ke-name">' + file.name + '</div>');
179
+
180
+ self.progressbars[file.id] = {
181
+ bar : K('.ke-progressbar-bar-inner', photoDiv),
182
+ percent : K('.ke-progressbar-percent', photoDiv)
183
+ };
184
+ },
185
+ remove : function() {
186
+ this.removeFiles();
187
+ this.swfu.destroy();
188
+ this.div.html('');
189
+ }
190
+ });
191
+
192
+ K.swfupload = function(element, options) {
193
+ return new KSWFUpload(element, options);
194
+ };
195
+
196
+ })(KindEditor);
197
+
198
+ KindEditor.plugin('multiimage', function(K) {
199
+ var self = this, name = 'multiimage',
200
+ formatUploadUrl = K.undef(self.formatUploadUrl, true),
201
+ uploadJson = K.undef(self.uploadJson, self.basePath + 'php/upload_json.php'),
202
+ imgPath = self.pluginsPath + 'multiimage/images/',
203
+ imageSizeLimit = K.undef(self.imageSizeLimit, '1MB'),
204
+ imageFileTypes = K.undef(self.imageFileTypes, '*.jpg;*.gif;*.png'),
205
+ imageUploadLimit = K.undef(self.imageUploadLimit, 20),
206
+ filePostName = K.undef(self.filePostName, 'imgFile'),
207
+ lang = self.lang(name + '.');
208
+
209
+ self.plugin.multiImageDialog = function(options) {
210
+ var clickFn = options.clickFn,
211
+ uploadDesc = K.tmpl(lang.uploadDesc, {uploadLimit : imageUploadLimit, sizeLimit : imageSizeLimit});
212
+ var html = [
213
+ '<div style="padding:20px;">',
214
+ '<div class="swfupload">',
215
+ '</div>',
216
+ '</div>'
217
+ ].join('');
218
+ var dialog = self.createDialog({
219
+ name : name,
220
+ width : 650,
221
+ height : 510,
222
+ title : self.lang(name),
223
+ body : html,
224
+ previewBtn : {
225
+ name : lang.insertAll,
226
+ click : function(e) {
227
+ clickFn.call(self, swfupload.getUrlList());
228
+ }
229
+ },
230
+ yesBtn : {
231
+ name : lang.clearAll,
232
+ click : function(e) {
233
+ swfupload.removeFiles();
234
+ }
235
+ },
236
+ beforeRemove : function() {
237
+ // IE9 bugfix: https://github.com/kindsoft/kindeditor/issues/72
238
+ if (!K.IE || K.V <= 8) {
239
+ swfupload.remove();
240
+ }
241
+ }
242
+ }),
243
+ div = dialog.div;
244
+
245
+ var swfupload = K.swfupload({
246
+ container : K('.swfupload', div),
247
+ buttonImageUrl : imgPath + (self.langType == 'zh-CN' ? 'select-files-zh-CN.png' : 'select-files-en.png'),
248
+ buttonWidth : self.langType == 'zh-CN' ? 72 : 88,
249
+ buttonHeight : 23,
250
+ fileIconUrl : imgPath + 'image.png',
251
+ uploadDesc : uploadDesc,
252
+ startButtonValue : lang.startUpload,
253
+ uploadUrl : K.addParam(uploadJson, 'dir=image'),
254
+ flashUrl : imgPath + 'swfupload.swf',
255
+ filePostName : filePostName,
256
+ fileTypes : '*.jpg;*.jpeg;*.gif;*.png;*.bmp',
257
+ fileTypesDesc : 'Image Files',
258
+ fileUploadLimit : imageUploadLimit,
259
+ fileSizeLimit : imageSizeLimit,
260
+ postParams : K.undef(self.extraFileUploadParams, {}),
261
+ queueLimitExceeded : lang.queueLimitExceeded,
262
+ fileExceedsSizeLimit : lang.fileExceedsSizeLimit,
263
+ zeroByteFile : lang.zeroByteFile,
264
+ invalidFiletype : lang.invalidFiletype,
265
+ unknownError : lang.unknownError,
266
+ pendingMessage : lang.pending,
267
+ errorMessage : lang.uploadError,
268
+ afterError : function(html) {
269
+ self.errorDialog(html);
270
+ }
271
+ });
272
+
273
+ return dialog;
274
+ };
275
+ self.clickToolbar(name, function() {
276
+ self.plugin.multiImageDialog({
277
+ clickFn : function (urlList) {
278
+ if (urlList.length === 0) {
279
+ return;
280
+ }
281
+ K.each(urlList, function(i, data) {
282
+ if (self.afterUpload) {
283
+ self.afterUpload.call(self, data.url, data, 'multiimage');
284
+ }
285
+ self.exec('insertimage', data.url, data.title, data.width, data.height, data.border, data.align);
286
+ });
287
+ // Bugfix: [Firefox] 上传图片后,总是出现正在加载的样式,需要延迟执行hideDialog
288
+ setTimeout(function() {
289
+ self.hideDialog().focus();
290
+ }, 0);
291
+ }
292
+ });
293
+ });
294
+ });
295
+
296
+
297
+ /**
298
+ * SWFUpload: http://www.swfupload.org, http://swfupload.googlecode.com
299
+ *
300
+ * mmSWFUpload 1.0: Flash upload dialog - http://profandesign.se/swfupload/, http://www.vinterwebb.se/
301
+ *
302
+ * SWFUpload is (c) 2006-2007 Lars Huring, Olov Nilz閚 and Mammon Media and is released under the MIT License:
303
+ * http://www.opensource.org/licenses/mit-license.php
304
+ *
305
+ * SWFUpload 2 is (c) 2007-2008 Jake Roberts and is released under the MIT License:
306
+ * http://www.opensource.org/licenses/mit-license.php
307
+ *
308
+ */
309
+
310
+
311
+ /* ******************* */
312
+ /* Constructor & Init */
313
+ /* ******************* */
314
+
315
+ (function() {
316
+
317
+ window.SWFUpload = function (settings) {
318
+ this.initSWFUpload(settings);
319
+ };
320
+
321
+ SWFUpload.prototype.initSWFUpload = function (settings) {
322
+ try {
323
+ this.customSettings = {}; // A container where developers can place their own settings associated with this instance.
324
+ this.settings = settings;
325
+ this.eventQueue = [];
326
+ this.movieName = "KindEditor_SWFUpload_" + SWFUpload.movieCount++;
327
+ this.movieElement = null;
328
+
329
+
330
+ // Setup global control tracking
331
+ SWFUpload.instances[this.movieName] = this;
332
+
333
+ // Load the settings. Load the Flash movie.
334
+ this.initSettings();
335
+ this.loadFlash();
336
+ this.displayDebugInfo();
337
+ } catch (ex) {
338
+ delete SWFUpload.instances[this.movieName];
339
+ throw ex;
340
+ }
341
+ };
342
+
343
+ /* *************** */
344
+ /* Static Members */
345
+ /* *************** */
346
+ SWFUpload.instances = {};
347
+ SWFUpload.movieCount = 0;
348
+ SWFUpload.version = "2.2.0 2009-03-25";
349
+ SWFUpload.QUEUE_ERROR = {
350
+ QUEUE_LIMIT_EXCEEDED : -100,
351
+ FILE_EXCEEDS_SIZE_LIMIT : -110,
352
+ ZERO_BYTE_FILE : -120,
353
+ INVALID_FILETYPE : -130
354
+ };
355
+ SWFUpload.UPLOAD_ERROR = {
356
+ HTTP_ERROR : -200,
357
+ MISSING_UPLOAD_URL : -210,
358
+ IO_ERROR : -220,
359
+ SECURITY_ERROR : -230,
360
+ UPLOAD_LIMIT_EXCEEDED : -240,
361
+ UPLOAD_FAILED : -250,
362
+ SPECIFIED_FILE_ID_NOT_FOUND : -260,
363
+ FILE_VALIDATION_FAILED : -270,
364
+ FILE_CANCELLED : -280,
365
+ UPLOAD_STOPPED : -290
366
+ };
367
+ SWFUpload.FILE_STATUS = {
368
+ QUEUED : -1,
369
+ IN_PROGRESS : -2,
370
+ ERROR : -3,
371
+ COMPLETE : -4,
372
+ CANCELLED : -5
373
+ };
374
+ SWFUpload.BUTTON_ACTION = {
375
+ SELECT_FILE : -100,
376
+ SELECT_FILES : -110,
377
+ START_UPLOAD : -120
378
+ };
379
+ SWFUpload.CURSOR = {
380
+ ARROW : -1,
381
+ HAND : -2
382
+ };
383
+ SWFUpload.WINDOW_MODE = {
384
+ WINDOW : "window",
385
+ TRANSPARENT : "transparent",
386
+ OPAQUE : "opaque"
387
+ };
388
+
389
+ // Private: takes a URL, determines if it is relative and converts to an absolute URL
390
+ // using the current site. Only processes the URL if it can, otherwise returns the URL untouched
391
+ SWFUpload.completeURL = function(url) {
392
+ if (typeof(url) !== "string" || url.match(/^https?:\/\//i) || url.match(/^\//)) {
393
+ return url;
394
+ }
395
+
396
+ var currentURL = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
397
+
398
+ var indexSlash = window.location.pathname.lastIndexOf("/");
399
+ if (indexSlash <= 0) {
400
+ path = "/";
401
+ } else {
402
+ path = window.location.pathname.substr(0, indexSlash) + "/";
403
+ }
404
+
405
+ return /*currentURL +*/ path + url;
406
+
407
+ };
408
+
409
+
410
+ /* ******************** */
411
+ /* Instance Members */
412
+ /* ******************** */
413
+
414
+ // Private: initSettings ensures that all the
415
+ // settings are set, getting a default value if one was not assigned.
416
+ SWFUpload.prototype.initSettings = function () {
417
+ this.ensureDefault = function (settingName, defaultValue) {
418
+ this.settings[settingName] = (this.settings[settingName] == undefined) ? defaultValue : this.settings[settingName];
419
+ };
420
+
421
+ // Upload backend settings
422
+ this.ensureDefault("upload_url", "");
423
+ this.ensureDefault("preserve_relative_urls", false);
424
+ this.ensureDefault("file_post_name", "Filedata");
425
+ this.ensureDefault("post_params", {});
426
+ this.ensureDefault("use_query_string", false);
427
+ this.ensureDefault("requeue_on_error", false);
428
+ this.ensureDefault("http_success", []);
429
+ this.ensureDefault("assume_success_timeout", 0);
430
+
431
+ // File Settings
432
+ this.ensureDefault("file_types", "*.*");
433
+ this.ensureDefault("file_types_description", "All Files");
434
+ this.ensureDefault("file_size_limit", 0); // Default zero means "unlimited"
435
+ this.ensureDefault("file_upload_limit", 0);
436
+ this.ensureDefault("file_queue_limit", 0);
437
+
438
+ // Flash Settings
439
+ this.ensureDefault("flash_url", "swfupload.swf");
440
+ this.ensureDefault("prevent_swf_caching", true);
441
+
442
+ // Button Settings
443
+ this.ensureDefault("button_image_url", "");
444
+ this.ensureDefault("button_width", 1);
445
+ this.ensureDefault("button_height", 1);
446
+ this.ensureDefault("button_text", "");
447
+ this.ensureDefault("button_text_style", "color: #000000; font-size: 16pt;");
448
+ this.ensureDefault("button_text_top_padding", 0);
449
+ this.ensureDefault("button_text_left_padding", 0);
450
+ this.ensureDefault("button_action", SWFUpload.BUTTON_ACTION.SELECT_FILES);
451
+ this.ensureDefault("button_disabled", false);
452
+ this.ensureDefault("button_placeholder_id", "");
453
+ this.ensureDefault("button_placeholder", null);
454
+ this.ensureDefault("button_cursor", SWFUpload.CURSOR.ARROW);
455
+ this.ensureDefault("button_window_mode", SWFUpload.WINDOW_MODE.WINDOW);
456
+
457
+ // Debug Settings
458
+ this.ensureDefault("debug", false);
459
+ this.settings.debug_enabled = this.settings.debug; // Here to maintain v2 API
460
+
461
+ // Event Handlers
462
+ this.settings.return_upload_start_handler = this.returnUploadStart;
463
+ this.ensureDefault("swfupload_loaded_handler", null);
464
+ this.ensureDefault("file_dialog_start_handler", null);
465
+ this.ensureDefault("file_queued_handler", null);
466
+ this.ensureDefault("file_queue_error_handler", null);
467
+ this.ensureDefault("file_dialog_complete_handler", null);
468
+
469
+ this.ensureDefault("upload_start_handler", null);
470
+ this.ensureDefault("upload_progress_handler", null);
471
+ this.ensureDefault("upload_error_handler", null);
472
+ this.ensureDefault("upload_success_handler", null);
473
+ this.ensureDefault("upload_complete_handler", null);
474
+
475
+ this.ensureDefault("debug_handler", this.debugMessage);
476
+
477
+ this.ensureDefault("custom_settings", {});
478
+
479
+ // Other settings
480
+ this.customSettings = this.settings.custom_settings;
481
+
482
+ // Update the flash url if needed
483
+ if (!!this.settings.prevent_swf_caching) {
484
+ this.settings.flash_url = this.settings.flash_url + (this.settings.flash_url.indexOf("?") < 0 ? "?" : "&") + "preventswfcaching=" + new Date().getTime();
485
+ }
486
+
487
+ if (!this.settings.preserve_relative_urls) {
488
+ //this.settings.flash_url = SWFUpload.completeURL(this.settings.flash_url); // Don't need to do this one since flash doesn't look at it
489
+ this.settings.upload_url = SWFUpload.completeURL(this.settings.upload_url);
490
+ this.settings.button_image_url = SWFUpload.completeURL(this.settings.button_image_url);
491
+ }
492
+
493
+ delete this.ensureDefault;
494
+ };
495
+
496
+ // Private: loadFlash replaces the button_placeholder element with the flash movie.
497
+ SWFUpload.prototype.loadFlash = function () {
498
+ var targetElement, tempParent;
499
+
500
+ // Make sure an element with the ID we are going to use doesn't already exist
501
+ if (document.getElementById(this.movieName) !== null) {
502
+ throw "ID " + this.movieName + " is already in use. The Flash Object could not be added";
503
+ }
504
+
505
+ // Get the element where we will be placing the flash movie
506
+ targetElement = document.getElementById(this.settings.button_placeholder_id) || this.settings.button_placeholder;
507
+
508
+ if (targetElement == undefined) {
509
+ throw "Could not find the placeholder element: " + this.settings.button_placeholder_id;
510
+ }
511
+
512
+ // Append the container and load the flash
513
+ tempParent = document.createElement("div");
514
+ tempParent.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)
515
+ targetElement.parentNode.replaceChild(tempParent.firstChild, targetElement);
516
+
517
+ // Fix IE Flash/Form bug
518
+ if (window[this.movieName] == undefined) {
519
+ window[this.movieName] = this.getMovieElement();
520
+ }
521
+
522
+ };
523
+
524
+ // Private: getFlashHTML generates the object tag needed to embed the flash in to the document
525
+ SWFUpload.prototype.getFlashHTML = function () {
526
+ // Flash Satay object syntax: http://www.alistapart.com/articles/flashsatay
527
+ // Fix bug for IE9
528
+ // http://www.kindsoft.net/view.php?bbsid=7&postid=5825&pagenum=1
529
+ var classid = '';
530
+ if (KindEditor.IE && KindEditor.V > 8) {
531
+ classid = ' classid = "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
532
+ }
533
+ return ['<object id="', this.movieName, '"' + classid + ' type="application/x-shockwave-flash" data="', this.settings.flash_url, '" width="', this.settings.button_width, '" height="', this.settings.button_height, '" class="swfupload">',
534
+ '<param name="wmode" value="', this.settings.button_window_mode, '" />',
535
+ '<param name="movie" value="', this.settings.flash_url, '" />',
536
+ '<param name="quality" value="high" />',
537
+ '<param name="menu" value="false" />',
538
+ '<param name="allowScriptAccess" value="always" />',
539
+ '<param name="flashvars" value="' + this.getFlashVars() + '" />',
540
+ '</object>'].join("");
541
+ };
542
+
543
+ // Private: getFlashVars builds the parameter string that will be passed
544
+ // to flash in the flashvars param.
545
+ SWFUpload.prototype.getFlashVars = function () {
546
+ // Build a string from the post param object
547
+ var paramString = this.buildParamString();
548
+ var httpSuccessString = this.settings.http_success.join(",");
549
+
550
+ // Build the parameter string
551
+ return ["movieName=", encodeURIComponent(this.movieName),
552
+ "&amp;uploadURL=", encodeURIComponent(this.settings.upload_url),
553
+ "&amp;useQueryString=", encodeURIComponent(this.settings.use_query_string),
554
+ "&amp;requeueOnError=", encodeURIComponent(this.settings.requeue_on_error),
555
+ "&amp;httpSuccess=", encodeURIComponent(httpSuccessString),
556
+ "&amp;assumeSuccessTimeout=", encodeURIComponent(this.settings.assume_success_timeout),
557
+ "&amp;params=", encodeURIComponent(paramString),
558
+ "&amp;filePostName=", encodeURIComponent(this.settings.file_post_name),
559
+ "&amp;fileTypes=", encodeURIComponent(this.settings.file_types),
560
+ "&amp;fileTypesDescription=", encodeURIComponent(this.settings.file_types_description),
561
+ "&amp;fileSizeLimit=", encodeURIComponent(this.settings.file_size_limit),
562
+ "&amp;fileUploadLimit=", encodeURIComponent(this.settings.file_upload_limit),
563
+ "&amp;fileQueueLimit=", encodeURIComponent(this.settings.file_queue_limit),
564
+ "&amp;debugEnabled=", encodeURIComponent(this.settings.debug_enabled),
565
+ "&amp;buttonImageURL=", encodeURIComponent(this.settings.button_image_url),
566
+ "&amp;buttonWidth=", encodeURIComponent(this.settings.button_width),
567
+ "&amp;buttonHeight=", encodeURIComponent(this.settings.button_height),
568
+ "&amp;buttonText=", encodeURIComponent(this.settings.button_text),
569
+ "&amp;buttonTextTopPadding=", encodeURIComponent(this.settings.button_text_top_padding),
570
+ "&amp;buttonTextLeftPadding=", encodeURIComponent(this.settings.button_text_left_padding),
571
+ "&amp;buttonTextStyle=", encodeURIComponent(this.settings.button_text_style),
572
+ "&amp;buttonAction=", encodeURIComponent(this.settings.button_action),
573
+ "&amp;buttonDisabled=", encodeURIComponent(this.settings.button_disabled),
574
+ "&amp;buttonCursor=", encodeURIComponent(this.settings.button_cursor)
575
+ ].join("");
576
+ };
577
+
578
+ // Public: getMovieElement retrieves the DOM reference to the Flash element added by SWFUpload
579
+ // The element is cached after the first lookup
580
+ SWFUpload.prototype.getMovieElement = function () {
581
+ if (this.movieElement == undefined) {
582
+ this.movieElement = document.getElementById(this.movieName);
583
+ }
584
+
585
+ if (this.movieElement === null) {
586
+ throw "Could not find Flash element";
587
+ }
588
+
589
+ return this.movieElement;
590
+ };
591
+
592
+ // Private: buildParamString takes the name/value pairs in the post_params setting object
593
+ // and joins them up in to a string formatted "name=value&amp;name=value"
594
+ SWFUpload.prototype.buildParamString = function () {
595
+ var postParams = this.settings.post_params;
596
+ var paramStringPairs = [];
597
+
598
+ if (typeof(postParams) === "object") {
599
+ for (var name in postParams) {
600
+ if (postParams.hasOwnProperty(name)) {
601
+ paramStringPairs.push(encodeURIComponent(name.toString()) + "=" + encodeURIComponent(postParams[name].toString()));
602
+ }
603
+ }
604
+ }
605
+
606
+ return paramStringPairs.join("&amp;");
607
+ };
608
+
609
+ // Public: Used to remove a SWFUpload instance from the page. This method strives to remove
610
+ // all references to the SWF, and other objects so memory is properly freed.
611
+ // Returns true if everything was destroyed. Returns a false if a failure occurs leaving SWFUpload in an inconsistant state.
612
+ // Credits: Major improvements provided by steffen
613
+ SWFUpload.prototype.destroy = function () {
614
+ try {
615
+ // Make sure Flash is done before we try to remove it
616
+ this.cancelUpload(null, false);
617
+
618
+
619
+ // Remove the SWFUpload DOM nodes
620
+ var movieElement = null;
621
+ movieElement = this.getMovieElement();
622
+
623
+ if (movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
624
+ // Loop through all the movie's properties and remove all function references (DOM/JS IE 6/7 memory leak workaround)
625
+ for (var i in movieElement) {
626
+ try {
627
+ if (typeof(movieElement[i]) === "function") {
628
+ movieElement[i] = null;
629
+ }
630
+ } catch (ex1) {}
631
+ }
632
+
633
+ // Remove the Movie Element from the page
634
+ try {
635
+ movieElement.parentNode.removeChild(movieElement);
636
+ } catch (ex) {}
637
+ }
638
+
639
+ // Remove IE form fix reference
640
+ window[this.movieName] = null;
641
+
642
+ // Destroy other references
643
+ SWFUpload.instances[this.movieName] = null;
644
+ delete SWFUpload.instances[this.movieName];
645
+
646
+ this.movieElement = null;
647
+ this.settings = null;
648
+ this.customSettings = null;
649
+ this.eventQueue = null;
650
+ this.movieName = null;
651
+
652
+
653
+ return true;
654
+ } catch (ex2) {
655
+ return false;
656
+ }
657
+ };
658
+
659
+
660
+ // Public: displayDebugInfo prints out settings and configuration
661
+ // information about this SWFUpload instance.
662
+ // This function (and any references to it) can be deleted when placing
663
+ // SWFUpload in production.
664
+ SWFUpload.prototype.displayDebugInfo = function () {
665
+ this.debug(
666
+ [
667
+ "---SWFUpload Instance Info---\n",
668
+ "Version: ", SWFUpload.version, "\n",
669
+ "Movie Name: ", this.movieName, "\n",
670
+ "Settings:\n",
671
+ "\t", "upload_url: ", this.settings.upload_url, "\n",
672
+ "\t", "flash_url: ", this.settings.flash_url, "\n",
673
+ "\t", "use_query_string: ", this.settings.use_query_string.toString(), "\n",
674
+ "\t", "requeue_on_error: ", this.settings.requeue_on_error.toString(), "\n",
675
+ "\t", "http_success: ", this.settings.http_success.join(", "), "\n",
676
+ "\t", "assume_success_timeout: ", this.settings.assume_success_timeout, "\n",
677
+ "\t", "file_post_name: ", this.settings.file_post_name, "\n",
678
+ "\t", "post_params: ", this.settings.post_params.toString(), "\n",
679
+ "\t", "file_types: ", this.settings.file_types, "\n",
680
+ "\t", "file_types_description: ", this.settings.file_types_description, "\n",
681
+ "\t", "file_size_limit: ", this.settings.file_size_limit, "\n",
682
+ "\t", "file_upload_limit: ", this.settings.file_upload_limit, "\n",
683
+ "\t", "file_queue_limit: ", this.settings.file_queue_limit, "\n",
684
+ "\t", "debug: ", this.settings.debug.toString(), "\n",
685
+
686
+ "\t", "prevent_swf_caching: ", this.settings.prevent_swf_caching.toString(), "\n",
687
+
688
+ "\t", "button_placeholder_id: ", this.settings.button_placeholder_id.toString(), "\n",
689
+ "\t", "button_placeholder: ", (this.settings.button_placeholder ? "Set" : "Not Set"), "\n",
690
+ "\t", "button_image_url: ", this.settings.button_image_url.toString(), "\n",
691
+ "\t", "button_width: ", this.settings.button_width.toString(), "\n",
692
+ "\t", "button_height: ", this.settings.button_height.toString(), "\n",
693
+ "\t", "button_text: ", this.settings.button_text.toString(), "\n",
694
+ "\t", "button_text_style: ", this.settings.button_text_style.toString(), "\n",
695
+ "\t", "button_text_top_padding: ", this.settings.button_text_top_padding.toString(), "\n",
696
+ "\t", "button_text_left_padding: ", this.settings.button_text_left_padding.toString(), "\n",
697
+ "\t", "button_action: ", this.settings.button_action.toString(), "\n",
698
+ "\t", "button_disabled: ", this.settings.button_disabled.toString(), "\n",
699
+
700
+ "\t", "custom_settings: ", this.settings.custom_settings.toString(), "\n",
701
+ "Event Handlers:\n",
702
+ "\t", "swfupload_loaded_handler assigned: ", (typeof this.settings.swfupload_loaded_handler === "function").toString(), "\n",
703
+ "\t", "file_dialog_start_handler assigned: ", (typeof this.settings.file_dialog_start_handler === "function").toString(), "\n",
704
+ "\t", "file_queued_handler assigned: ", (typeof this.settings.file_queued_handler === "function").toString(), "\n",
705
+ "\t", "file_queue_error_handler assigned: ", (typeof this.settings.file_queue_error_handler === "function").toString(), "\n",
706
+ "\t", "upload_start_handler assigned: ", (typeof this.settings.upload_start_handler === "function").toString(), "\n",
707
+ "\t", "upload_progress_handler assigned: ", (typeof this.settings.upload_progress_handler === "function").toString(), "\n",
708
+ "\t", "upload_error_handler assigned: ", (typeof this.settings.upload_error_handler === "function").toString(), "\n",
709
+ "\t", "upload_success_handler assigned: ", (typeof this.settings.upload_success_handler === "function").toString(), "\n",
710
+ "\t", "upload_complete_handler assigned: ", (typeof this.settings.upload_complete_handler === "function").toString(), "\n",
711
+ "\t", "debug_handler assigned: ", (typeof this.settings.debug_handler === "function").toString(), "\n"
712
+ ].join("")
713
+ );
714
+ };
715
+
716
+ /* Note: addSetting and getSetting are no longer used by SWFUpload but are included
717
+ the maintain v2 API compatibility
718
+ */
719
+ // Public: (Deprecated) addSetting adds a setting value. If the value given is undefined or null then the default_value is used.
720
+ SWFUpload.prototype.addSetting = function (name, value, default_value) {
721
+ if (value == undefined) {
722
+ return (this.settings[name] = default_value);
723
+ } else {
724
+ return (this.settings[name] = value);
725
+ }
726
+ };
727
+
728
+ // Public: (Deprecated) getSetting gets a setting. Returns an empty string if the setting was not found.
729
+ SWFUpload.prototype.getSetting = function (name) {
730
+ if (this.settings[name] != undefined) {
731
+ return this.settings[name];
732
+ }
733
+
734
+ return "";
735
+ };
736
+
737
+
738
+
739
+ // Private: callFlash handles function calls made to the Flash element.
740
+ // Calls are made with a setTimeout for some functions to work around
741
+ // bugs in the ExternalInterface library.
742
+ SWFUpload.prototype.callFlash = function (functionName, argumentArray) {
743
+ argumentArray = argumentArray || [];
744
+
745
+ var movieElement = this.getMovieElement();
746
+ var returnValue, returnString;
747
+
748
+ // Flash's method if calling ExternalInterface methods (code adapted from MooTools).
749
+ try {
750
+ returnString = movieElement.CallFunction('<invoke name="' + functionName + '" returntype="javascript">' + __flash__argumentsToXML(argumentArray, 0) + '</invoke>');
751
+ returnValue = eval(returnString);
752
+ } catch (ex) {
753
+ throw "Call to " + functionName + " failed";
754
+ }
755
+
756
+ // Unescape file post param values
757
+ if (returnValue != undefined && typeof returnValue.post === "object") {
758
+ returnValue = this.unescapeFilePostParams(returnValue);
759
+ }
760
+
761
+ return returnValue;
762
+ };
763
+
764
+ /* *****************************
765
+ -- Flash control methods --
766
+ Your UI should use these
767
+ to operate SWFUpload
768
+ ***************************** */
769
+
770
+ // WARNING: this function does not work in Flash Player 10
771
+ // Public: selectFile causes a File Selection Dialog window to appear. This
772
+ // dialog only allows 1 file to be selected.
773
+ SWFUpload.prototype.selectFile = function () {
774
+ this.callFlash("SelectFile");
775
+ };
776
+
777
+ // WARNING: this function does not work in Flash Player 10
778
+ // Public: selectFiles causes a File Selection Dialog window to appear/ This
779
+ // dialog allows the user to select any number of files
780
+ // Flash Bug Warning: Flash limits the number of selectable files based on the combined length of the file names.
781
+ // If the selection name length is too long the dialog will fail in an unpredictable manner. There is no work-around
782
+ // for this bug.
783
+ SWFUpload.prototype.selectFiles = function () {
784
+ this.callFlash("SelectFiles");
785
+ };
786
+
787
+
788
+ // Public: startUpload starts uploading the first file in the queue unless
789
+ // the optional parameter 'fileID' specifies the ID
790
+ SWFUpload.prototype.startUpload = function (fileID) {
791
+ this.callFlash("StartUpload", [fileID]);
792
+ };
793
+
794
+ // Public: cancelUpload cancels any queued file. The fileID parameter may be the file ID or index.
795
+ // If you do not specify a fileID the current uploading file or first file in the queue is cancelled.
796
+ // If you do not want the uploadError event to trigger you can specify false for the triggerErrorEvent parameter.
797
+ SWFUpload.prototype.cancelUpload = function (fileID, triggerErrorEvent) {
798
+ if (triggerErrorEvent !== false) {
799
+ triggerErrorEvent = true;
800
+ }
801
+ this.callFlash("CancelUpload", [fileID, triggerErrorEvent]);
802
+ };
803
+
804
+ // Public: stopUpload stops the current upload and requeues the file at the beginning of the queue.
805
+ // If nothing is currently uploading then nothing happens.
806
+ SWFUpload.prototype.stopUpload = function () {
807
+ this.callFlash("StopUpload");
808
+ };
809
+
810
+ /* ************************
811
+ * Settings methods
812
+ * These methods change the SWFUpload settings.
813
+ * SWFUpload settings should not be changed directly on the settings object
814
+ * since many of the settings need to be passed to Flash in order to take
815
+ * effect.
816
+ * *********************** */
817
+
818
+ // Public: getStats gets the file statistics object.
819
+ SWFUpload.prototype.getStats = function () {
820
+ return this.callFlash("GetStats");
821
+ };
822
+
823
+ // Public: setStats changes the SWFUpload statistics. You shouldn't need to
824
+ // change the statistics but you can. Changing the statistics does not
825
+ // affect SWFUpload accept for the successful_uploads count which is used
826
+ // by the upload_limit setting to determine how many files the user may upload.
827
+ SWFUpload.prototype.setStats = function (statsObject) {
828
+ this.callFlash("SetStats", [statsObject]);
829
+ };
830
+
831
+ // Public: getFile retrieves a File object by ID or Index. If the file is
832
+ // not found then 'null' is returned.
833
+ SWFUpload.prototype.getFile = function (fileID) {
834
+ if (typeof(fileID) === "number") {
835
+ return this.callFlash("GetFileByIndex", [fileID]);
836
+ } else {
837
+ return this.callFlash("GetFile", [fileID]);
838
+ }
839
+ };
840
+
841
+ // Public: addFileParam sets a name/value pair that will be posted with the
842
+ // file specified by the Files ID. If the name already exists then the
843
+ // exiting value will be overwritten.
844
+ SWFUpload.prototype.addFileParam = function (fileID, name, value) {
845
+ return this.callFlash("AddFileParam", [fileID, name, value]);
846
+ };
847
+
848
+ // Public: removeFileParam removes a previously set (by addFileParam) name/value
849
+ // pair from the specified file.
850
+ SWFUpload.prototype.removeFileParam = function (fileID, name) {
851
+ this.callFlash("RemoveFileParam", [fileID, name]);
852
+ };
853
+
854
+ // Public: setUploadUrl changes the upload_url setting.
855
+ SWFUpload.prototype.setUploadURL = function (url) {
856
+ this.settings.upload_url = url.toString();
857
+ this.callFlash("SetUploadURL", [url]);
858
+ };
859
+
860
+ // Public: setPostParams changes the post_params setting
861
+ SWFUpload.prototype.setPostParams = function (paramsObject) {
862
+ this.settings.post_params = paramsObject;
863
+ this.callFlash("SetPostParams", [paramsObject]);
864
+ };
865
+
866
+ // Public: addPostParam adds post name/value pair. Each name can have only one value.
867
+ SWFUpload.prototype.addPostParam = function (name, value) {
868
+ this.settings.post_params[name] = value;
869
+ this.callFlash("SetPostParams", [this.settings.post_params]);
870
+ };
871
+
872
+ // Public: removePostParam deletes post name/value pair.
873
+ SWFUpload.prototype.removePostParam = function (name) {
874
+ delete this.settings.post_params[name];
875
+ this.callFlash("SetPostParams", [this.settings.post_params]);
876
+ };
877
+
878
+ // Public: setFileTypes changes the file_types setting and the file_types_description setting
879
+ SWFUpload.prototype.setFileTypes = function (types, description) {
880
+ this.settings.file_types = types;
881
+ this.settings.file_types_description = description;
882
+ this.callFlash("SetFileTypes", [types, description]);
883
+ };
884
+
885
+ // Public: setFileSizeLimit changes the file_size_limit setting
886
+ SWFUpload.prototype.setFileSizeLimit = function (fileSizeLimit) {
887
+ this.settings.file_size_limit = fileSizeLimit;
888
+ this.callFlash("SetFileSizeLimit", [fileSizeLimit]);
889
+ };
890
+
891
+ // Public: setFileUploadLimit changes the file_upload_limit setting
892
+ SWFUpload.prototype.setFileUploadLimit = function (fileUploadLimit) {
893
+ this.settings.file_upload_limit = fileUploadLimit;
894
+ this.callFlash("SetFileUploadLimit", [fileUploadLimit]);
895
+ };
896
+
897
+ // Public: setFileQueueLimit changes the file_queue_limit setting
898
+ SWFUpload.prototype.setFileQueueLimit = function (fileQueueLimit) {
899
+ this.settings.file_queue_limit = fileQueueLimit;
900
+ this.callFlash("SetFileQueueLimit", [fileQueueLimit]);
901
+ };
902
+
903
+ // Public: setFilePostName changes the file_post_name setting
904
+ SWFUpload.prototype.setFilePostName = function (filePostName) {
905
+ this.settings.file_post_name = filePostName;
906
+ this.callFlash("SetFilePostName", [filePostName]);
907
+ };
908
+
909
+ // Public: setUseQueryString changes the use_query_string setting
910
+ SWFUpload.prototype.setUseQueryString = function (useQueryString) {
911
+ this.settings.use_query_string = useQueryString;
912
+ this.callFlash("SetUseQueryString", [useQueryString]);
913
+ };
914
+
915
+ // Public: setRequeueOnError changes the requeue_on_error setting
916
+ SWFUpload.prototype.setRequeueOnError = function (requeueOnError) {
917
+ this.settings.requeue_on_error = requeueOnError;
918
+ this.callFlash("SetRequeueOnError", [requeueOnError]);
919
+ };
920
+
921
+ // Public: setHTTPSuccess changes the http_success setting
922
+ SWFUpload.prototype.setHTTPSuccess = function (http_status_codes) {
923
+ if (typeof http_status_codes === "string") {
924
+ http_status_codes = http_status_codes.replace(" ", "").split(",");
925
+ }
926
+
927
+ this.settings.http_success = http_status_codes;
928
+ this.callFlash("SetHTTPSuccess", [http_status_codes]);
929
+ };
930
+
931
+ // Public: setHTTPSuccess changes the http_success setting
932
+ SWFUpload.prototype.setAssumeSuccessTimeout = function (timeout_seconds) {
933
+ this.settings.assume_success_timeout = timeout_seconds;
934
+ this.callFlash("SetAssumeSuccessTimeout", [timeout_seconds]);
935
+ };
936
+
937
+ // Public: setDebugEnabled changes the debug_enabled setting
938
+ SWFUpload.prototype.setDebugEnabled = function (debugEnabled) {
939
+ this.settings.debug_enabled = debugEnabled;
940
+ this.callFlash("SetDebugEnabled", [debugEnabled]);
941
+ };
942
+
943
+ // Public: setButtonImageURL loads a button image sprite
944
+ SWFUpload.prototype.setButtonImageURL = function (buttonImageURL) {
945
+ if (buttonImageURL == undefined) {
946
+ buttonImageURL = "";
947
+ }
948
+
949
+ this.settings.button_image_url = buttonImageURL;
950
+ this.callFlash("SetButtonImageURL", [buttonImageURL]);
951
+ };
952
+
953
+ // Public: setButtonDimensions resizes the Flash Movie and button
954
+ SWFUpload.prototype.setButtonDimensions = function (width, height) {
955
+ this.settings.button_width = width;
956
+ this.settings.button_height = height;
957
+
958
+ var movie = this.getMovieElement();
959
+ if (movie != undefined) {
960
+ movie.style.width = width + "px";
961
+ movie.style.height = height + "px";
962
+ }
963
+
964
+ this.callFlash("SetButtonDimensions", [width, height]);
965
+ };
966
+ // Public: setButtonText Changes the text overlaid on the button
967
+ SWFUpload.prototype.setButtonText = function (html) {
968
+ this.settings.button_text = html;
969
+ this.callFlash("SetButtonText", [html]);
970
+ };
971
+ // Public: setButtonTextPadding changes the top and left padding of the text overlay
972
+ SWFUpload.prototype.setButtonTextPadding = function (left, top) {
973
+ this.settings.button_text_top_padding = top;
974
+ this.settings.button_text_left_padding = left;
975
+ this.callFlash("SetButtonTextPadding", [left, top]);
976
+ };
977
+
978
+ // Public: setButtonTextStyle changes the CSS used to style the HTML/Text overlaid on the button
979
+ SWFUpload.prototype.setButtonTextStyle = function (css) {
980
+ this.settings.button_text_style = css;
981
+ this.callFlash("SetButtonTextStyle", [css]);
982
+ };
983
+ // Public: setButtonDisabled disables/enables the button
984
+ SWFUpload.prototype.setButtonDisabled = function (isDisabled) {
985
+ this.settings.button_disabled = isDisabled;
986
+ this.callFlash("SetButtonDisabled", [isDisabled]);
987
+ };
988
+ // Public: setButtonAction sets the action that occurs when the button is clicked
989
+ SWFUpload.prototype.setButtonAction = function (buttonAction) {
990
+ this.settings.button_action = buttonAction;
991
+ this.callFlash("SetButtonAction", [buttonAction]);
992
+ };
993
+
994
+ // Public: setButtonCursor changes the mouse cursor displayed when hovering over the button
995
+ SWFUpload.prototype.setButtonCursor = function (cursor) {
996
+ this.settings.button_cursor = cursor;
997
+ this.callFlash("SetButtonCursor", [cursor]);
998
+ };
999
+
1000
+ /* *******************************
1001
+ Flash Event Interfaces
1002
+ These functions are used by Flash to trigger the various
1003
+ events.
1004
+
1005
+ All these functions a Private.
1006
+
1007
+ Because the ExternalInterface library is buggy the event calls
1008
+ are added to a queue and the queue then executed by a setTimeout.
1009
+ This ensures that events are executed in a determinate order and that
1010
+ the ExternalInterface bugs are avoided.
1011
+ ******************************* */
1012
+
1013
+ SWFUpload.prototype.queueEvent = function (handlerName, argumentArray) {
1014
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
1015
+
1016
+ if (argumentArray == undefined) {
1017
+ argumentArray = [];
1018
+ } else if (!(argumentArray instanceof Array)) {
1019
+ argumentArray = [argumentArray];
1020
+ }
1021
+
1022
+ var self = this;
1023
+ if (typeof this.settings[handlerName] === "function") {
1024
+ // Queue the event
1025
+ this.eventQueue.push(function () {
1026
+ this.settings[handlerName].apply(this, argumentArray);
1027
+ });
1028
+
1029
+ // Execute the next queued event
1030
+ setTimeout(function () {
1031
+ self.executeNextEvent();
1032
+ }, 0);
1033
+
1034
+ } else if (this.settings[handlerName] !== null) {
1035
+ throw "Event handler " + handlerName + " is unknown or is not a function";
1036
+ }
1037
+ };
1038
+
1039
+ // Private: Causes the next event in the queue to be executed. Since events are queued using a setTimeout
1040
+ // we must queue them in order to garentee that they are executed in order.
1041
+ SWFUpload.prototype.executeNextEvent = function () {
1042
+ // Warning: Don't call this.debug inside here or you'll create an infinite loop
1043
+
1044
+ var f = this.eventQueue ? this.eventQueue.shift() : null;
1045
+ if (typeof(f) === "function") {
1046
+ f.apply(this);
1047
+ }
1048
+ };
1049
+
1050
+ // Private: unescapeFileParams is part of a workaround for a flash bug where objects passed through ExternalInterface cannot have
1051
+ // properties that contain characters that are not valid for JavaScript identifiers. To work around this
1052
+ // the Flash Component escapes the parameter names and we must unescape again before passing them along.
1053
+ SWFUpload.prototype.unescapeFilePostParams = function (file) {
1054
+ var reg = /[$]([0-9a-f]{4})/i;
1055
+ var unescapedPost = {};
1056
+ var uk;
1057
+
1058
+ if (file != undefined) {
1059
+ for (var k in file.post) {
1060
+ if (file.post.hasOwnProperty(k)) {
1061
+ uk = k;
1062
+ var match;
1063
+ while ((match = reg.exec(uk)) !== null) {
1064
+ uk = uk.replace(match[0], String.fromCharCode(parseInt("0x" + match[1], 16)));
1065
+ }
1066
+ unescapedPost[uk] = file.post[k];
1067
+ }
1068
+ }
1069
+
1070
+ file.post = unescapedPost;
1071
+ }
1072
+
1073
+ return file;
1074
+ };
1075
+
1076
+ // Private: Called by Flash to see if JS can call in to Flash (test if External Interface is working)
1077
+ SWFUpload.prototype.testExternalInterface = function () {
1078
+ try {
1079
+ return this.callFlash("TestExternalInterface");
1080
+ } catch (ex) {
1081
+ return false;
1082
+ }
1083
+ };
1084
+
1085
+ // Private: This event is called by Flash when it has finished loading. Don't modify this.
1086
+ // Use the swfupload_loaded_handler event setting to execute custom code when SWFUpload has loaded.
1087
+ SWFUpload.prototype.flashReady = function () {
1088
+ // Check that the movie element is loaded correctly with its ExternalInterface methods defined
1089
+ var movieElement = this.getMovieElement();
1090
+
1091
+ if (!movieElement) {
1092
+ this.debug("Flash called back ready but the flash movie can't be found.");
1093
+ return;
1094
+ }
1095
+
1096
+ this.cleanUp(movieElement);
1097
+
1098
+ this.queueEvent("swfupload_loaded_handler");
1099
+ };
1100
+
1101
+ // Private: removes Flash added fuctions to the DOM node to prevent memory leaks in IE.
1102
+ // This function is called by Flash each time the ExternalInterface functions are created.
1103
+ SWFUpload.prototype.cleanUp = function (movieElement) {
1104
+ // Pro-actively unhook all the Flash functions
1105
+ try {
1106
+ if (this.movieElement && typeof(movieElement.CallFunction) === "unknown") { // We only want to do this in IE
1107
+ this.debug("Removing Flash functions hooks (this should only run in IE and should prevent memory leaks)");
1108
+ for (var key in movieElement) {
1109
+ try {
1110
+ if (typeof(movieElement[key]) === "function") {
1111
+ movieElement[key] = null;
1112
+ }
1113
+ } catch (ex) {
1114
+ }
1115
+ }
1116
+ }
1117
+ } catch (ex1) {
1118
+
1119
+ }
1120
+
1121
+ // Fix Flashes own cleanup code so if the SWFMovie was removed from the page
1122
+ // it doesn't display errors.
1123
+ window["__flash__removeCallback"] = function (instance, name) {
1124
+ try {
1125
+ if (instance) {
1126
+ instance[name] = null;
1127
+ }
1128
+ } catch (flashEx) {
1129
+
1130
+ }
1131
+ };
1132
+
1133
+ };
1134
+
1135
+
1136
+ /* This is a chance to do something before the browse window opens */
1137
+ SWFUpload.prototype.fileDialogStart = function () {
1138
+ this.queueEvent("file_dialog_start_handler");
1139
+ };
1140
+
1141
+
1142
+ /* Called when a file is successfully added to the queue. */
1143
+ SWFUpload.prototype.fileQueued = function (file) {
1144
+ file = this.unescapeFilePostParams(file);
1145
+ this.queueEvent("file_queued_handler", file);
1146
+ };
1147
+
1148
+
1149
+ /* Handle errors that occur when an attempt to queue a file fails. */
1150
+ SWFUpload.prototype.fileQueueError = function (file, errorCode, message) {
1151
+ file = this.unescapeFilePostParams(file);
1152
+ this.queueEvent("file_queue_error_handler", [file, errorCode, message]);
1153
+ };
1154
+
1155
+ /* Called after the file dialog has closed and the selected files have been queued.
1156
+ You could call startUpload here if you want the queued files to begin uploading immediately. */
1157
+ SWFUpload.prototype.fileDialogComplete = function (numFilesSelected, numFilesQueued, numFilesInQueue) {
1158
+ this.queueEvent("file_dialog_complete_handler", [numFilesSelected, numFilesQueued, numFilesInQueue]);
1159
+ };
1160
+
1161
+ SWFUpload.prototype.uploadStart = function (file) {
1162
+ file = this.unescapeFilePostParams(file);
1163
+ this.queueEvent("return_upload_start_handler", file);
1164
+ };
1165
+
1166
+ SWFUpload.prototype.returnUploadStart = function (file) {
1167
+ var returnValue;
1168
+ if (typeof this.settings.upload_start_handler === "function") {
1169
+ file = this.unescapeFilePostParams(file);
1170
+ returnValue = this.settings.upload_start_handler.call(this, file);
1171
+ } else if (this.settings.upload_start_handler != undefined) {
1172
+ throw "upload_start_handler must be a function";
1173
+ }
1174
+
1175
+ // Convert undefined to true so if nothing is returned from the upload_start_handler it is
1176
+ // interpretted as 'true'.
1177
+ if (returnValue === undefined) {
1178
+ returnValue = true;
1179
+ }
1180
+
1181
+ returnValue = !!returnValue;
1182
+
1183
+ this.callFlash("ReturnUploadStart", [returnValue]);
1184
+ };
1185
+
1186
+
1187
+
1188
+ SWFUpload.prototype.uploadProgress = function (file, bytesComplete, bytesTotal) {
1189
+ file = this.unescapeFilePostParams(file);
1190
+ this.queueEvent("upload_progress_handler", [file, bytesComplete, bytesTotal]);
1191
+ };
1192
+
1193
+ SWFUpload.prototype.uploadError = function (file, errorCode, message) {
1194
+ file = this.unescapeFilePostParams(file);
1195
+ this.queueEvent("upload_error_handler", [file, errorCode, message]);
1196
+ };
1197
+
1198
+ SWFUpload.prototype.uploadSuccess = function (file, serverData, responseReceived) {
1199
+ file = this.unescapeFilePostParams(file);
1200
+ this.queueEvent("upload_success_handler", [file, serverData, responseReceived]);
1201
+ };
1202
+
1203
+ SWFUpload.prototype.uploadComplete = function (file) {
1204
+ file = this.unescapeFilePostParams(file);
1205
+ this.queueEvent("upload_complete_handler", file);
1206
+ };
1207
+
1208
+ /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the
1209
+ internal debug console. You can override this event and have messages written where you want. */
1210
+ SWFUpload.prototype.debug = function (message) {
1211
+ this.queueEvent("debug_handler", message);
1212
+ };
1213
+
1214
+
1215
+ /* **********************************
1216
+ Debug Console
1217
+ The debug console is a self contained, in page location
1218
+ for debug message to be sent. The Debug Console adds
1219
+ itself to the body if necessary.
1220
+
1221
+ The console is automatically scrolled as messages appear.
1222
+
1223
+ If you are using your own debug handler or when you deploy to production and
1224
+ have debug disabled you can remove these functions to reduce the file size
1225
+ and complexity.
1226
+ ********************************** */
1227
+
1228
+ // Private: debugMessage is the default debug_handler. If you want to print debug messages
1229
+ // call the debug() function. When overriding the function your own function should
1230
+ // check to see if the debug setting is true before outputting debug information.
1231
+ SWFUpload.prototype.debugMessage = function (message) {
1232
+ if (this.settings.debug) {
1233
+ var exceptionMessage, exceptionValues = [];
1234
+
1235
+ // Check for an exception object and print it nicely
1236
+ if (typeof message === "object" && typeof message.name === "string" && typeof message.message === "string") {
1237
+ for (var key in message) {
1238
+ if (message.hasOwnProperty(key)) {
1239
+ exceptionValues.push(key + ": " + message[key]);
1240
+ }
1241
+ }
1242
+ exceptionMessage = exceptionValues.join("\n") || "";
1243
+ exceptionValues = exceptionMessage.split("\n");
1244
+ exceptionMessage = "EXCEPTION: " + exceptionValues.join("\nEXCEPTION: ");
1245
+ SWFUpload.Console.writeLine(exceptionMessage);
1246
+ } else {
1247
+ SWFUpload.Console.writeLine(message);
1248
+ }
1249
+ }
1250
+ };
1251
+
1252
+ SWFUpload.Console = {};
1253
+ SWFUpload.Console.writeLine = function (message) {
1254
+ var console, documentForm;
1255
+
1256
+ try {
1257
+ console = document.getElementById("SWFUpload_Console");
1258
+
1259
+ if (!console) {
1260
+ documentForm = document.createElement("form");
1261
+ document.getElementsByTagName("body")[0].appendChild(documentForm);
1262
+
1263
+ console = document.createElement("textarea");
1264
+ console.id = "SWFUpload_Console";
1265
+ console.style.fontFamily = "monospace";
1266
+ console.setAttribute("wrap", "off");
1267
+ console.wrap = "off";
1268
+ console.style.overflow = "auto";
1269
+ console.style.width = "700px";
1270
+ console.style.height = "350px";
1271
+ console.style.margin = "5px";
1272
+ documentForm.appendChild(console);
1273
+ }
1274
+
1275
+ console.value += message + "\n";
1276
+
1277
+ console.scrollTop = console.scrollHeight - console.clientHeight;
1278
+ } catch (ex) {
1279
+ alert("Exception: " + ex.name + " Message: " + ex.message);
1280
+ }
1281
+ };
1282
+
1283
+ })();
1284
+
1285
+ (function() {
1286
+ /*
1287
+ Queue Plug-in
1288
+
1289
+ Features:
1290
+ *Adds a cancelQueue() method for cancelling the entire queue.
1291
+ *All queued files are uploaded when startUpload() is called.
1292
+ *If false is returned from uploadComplete then the queue upload is stopped.
1293
+ If false is not returned (strict comparison) then the queue upload is continued.
1294
+ *Adds a QueueComplete event that is fired when all the queued files have finished uploading.
1295
+ Set the event handler with the queue_complete_handler setting.
1296
+
1297
+ */
1298
+
1299
+ if (typeof(SWFUpload) === "function") {
1300
+ SWFUpload.queue = {};
1301
+
1302
+ SWFUpload.prototype.initSettings = (function (oldInitSettings) {
1303
+ return function () {
1304
+ if (typeof(oldInitSettings) === "function") {
1305
+ oldInitSettings.call(this);
1306
+ }
1307
+
1308
+ this.queueSettings = {};
1309
+
1310
+ this.queueSettings.queue_cancelled_flag = false;
1311
+ this.queueSettings.queue_upload_count = 0;
1312
+
1313
+ this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler;
1314
+ this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler;
1315
+ this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler;
1316
+ this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler;
1317
+
1318
+ this.settings.queue_complete_handler = this.settings.queue_complete_handler || null;
1319
+ };
1320
+ })(SWFUpload.prototype.initSettings);
1321
+
1322
+ SWFUpload.prototype.startUpload = function (fileID) {
1323
+ this.queueSettings.queue_cancelled_flag = false;
1324
+ this.callFlash("StartUpload", [fileID]);
1325
+ };
1326
+
1327
+ SWFUpload.prototype.cancelQueue = function () {
1328
+ this.queueSettings.queue_cancelled_flag = true;
1329
+ this.stopUpload();
1330
+
1331
+ var stats = this.getStats();
1332
+ while (stats.files_queued > 0) {
1333
+ this.cancelUpload();
1334
+ stats = this.getStats();
1335
+ }
1336
+ };
1337
+
1338
+ SWFUpload.queue.uploadStartHandler = function (file) {
1339
+ var returnValue;
1340
+ if (typeof(this.queueSettings.user_upload_start_handler) === "function") {
1341
+ returnValue = this.queueSettings.user_upload_start_handler.call(this, file);
1342
+ }
1343
+
1344
+ // To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value.
1345
+ returnValue = (returnValue === false) ? false : true;
1346
+
1347
+ this.queueSettings.queue_cancelled_flag = !returnValue;
1348
+
1349
+ return returnValue;
1350
+ };
1351
+
1352
+ SWFUpload.queue.uploadCompleteHandler = function (file) {
1353
+ var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler;
1354
+ var continueUpload;
1355
+
1356
+ if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) {
1357
+ this.queueSettings.queue_upload_count++;
1358
+ }
1359
+
1360
+ if (typeof(user_upload_complete_handler) === "function") {
1361
+ continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true;
1362
+ } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) {
1363
+ // If the file was stopped and re-queued don't restart the upload
1364
+ continueUpload = false;
1365
+ } else {
1366
+ continueUpload = true;
1367
+ }
1368
+
1369
+ if (continueUpload) {
1370
+ var stats = this.getStats();
1371
+ if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) {
1372
+ this.startUpload();
1373
+ } else if (this.queueSettings.queue_cancelled_flag === false) {
1374
+ this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]);
1375
+ this.queueSettings.queue_upload_count = 0;
1376
+ } else {
1377
+ this.queueSettings.queue_cancelled_flag = false;
1378
+ this.queueSettings.queue_upload_count = 0;
1379
+ }
1380
+ }
1381
+ };
1382
+ }
1383
+
1384
+ })();