diff --git a/org.adempiere.ui.zk/WEB-INF/cwr/js/zk/utl.src.js b/org.adempiere.ui.zk/WEB-INF/cwr/js/zk/utl.src.js
index 021338bab9..10dc460cf6 100644
--- a/org.adempiere.ui.zk/WEB-INF/cwr/js/zk/utl.src.js
+++ b/org.adempiere.ui.zk/WEB-INF/cwr/js/zk/utl.src.js
@@ -1,4 +1,17 @@
+/* util.js
+ Purpose:
+
+ Description:
+
+ History:
+ Tue Sep 30 09:02:06 2008, Created by tomyeh
+
+Copyright (C) 2008 Potix Corporation. All Rights Reserved.
+
+This program is distributed under LGPL Version 2.1 in the hope that
+it will be useful, but WITHOUT ANY WARRANTY.
+*/
(function () {
var _decs = {lt: '<', gt: '>', amp: '&', quot: '"'},
_encs = {};
@@ -19,7 +32,11 @@
for (var fs = w.frames, j = 0, l = fs.length; j < l; ++j)
_frames(ary, fs[j]);
}
-
+ /* Returns the onSize target of the given widget.
+ * The following code is dirty since it checks _hflexsz (which is implementation)
+ * FUTRE: consider to have zk.Widget.beforeSize to clean up _hflexsz and
+ * this method considers only if _hflex is min
+ */
function _onSizeTarget(wgt) {
var r1 = wgt, p1 = r1,
j1 = -1;
@@ -27,7 +44,7 @@
delete p1._hflexsz;
r1 = p1;
++j1;
- if (p1.ignoreFlexSize_('w'))
+ if (p1.ignoreFlexSize_('w')) //p1 will not affect its parent's flex size
break;
}
@@ -37,16 +54,60 @@
delete p2._vflexsz;
r2 = p2;
++j2;
- if (p2.ignoreFlexSize_('h'))
+ if (p2.ignoreFlexSize_('h')) //p2 will not affect its parent's flex size
break;
}
return j1 > 0 || j2 > 0 ? j1 > j2 ? r1 : r2: wgt;
}
-
-zUtl = {
-
-
+/** @class zUtl
+ * @import zk.Widget
+ * @import zk.xml.Utl
+ * The basic utilties.
+ *
For more utilities, refer to {@link Utl}.
+ */
+zUtl = { //static methods
+ //Character
+ /**
+ * Returns whether the character is according to its opts.
+ * @param char cc the character
+ * @param Map opts the options.
+
+ Allowed Options
+
+
+| Name
+ | Allowed Values
+ | Description
+ |
+
+| digit
+ | true, false
+ | Specifies the character is digit only.
+ |
+
+| upper
+ | true, false
+ | Specifies the character is upper case only.
+ |
+
+| lower
+ | true, false
+ | Specifies the character is lower case only.
+ |
+
+| whitespace
+ | true, false
+ | Specifies the character is whitespace only.
+ |
+
+| opts[cc]
+ | true, false
+ | Specifies the character is allowed only.
+ |
+
+ * @return boolean
+ */
isChar: function (cc, opts) {
return (opts.digit && cc >= '0' && cc <= '9')
|| (opts.upper && cc >= 'A' && cc <= 'Z')
@@ -55,8 +116,19 @@ zUtl = {
|| opts[cc];
},
-
-
+ //HTML/XML
+ /** Parses the specifie text into a map.
+ * For example
+ *
+zUtl.parseMap("a=b,c=d");
+zUtl.parseMap("a='b c',c=de", ',', "'\"");
+
+ * @param String text the text to parse
+ * @param String separator the separator. If omitted, ','
+ * is assumed
+ * @param String quote the quote to handle. Ignored if omitted.
+ * @return Map the map
+ */
parseMap: function (text, separator, quote) {
var map = {};
if (text) {
@@ -85,7 +157,17 @@ zUtl = {
return map;
},
-
+ /** Encodes the string to a valid XML string.
+ * Refer to {@link Utl} for more XML utilities.
+ * @param String txt the text to encode
+ * @param Map opts [optional] the options. Allowd value:
+ *
+ * - pre - whether to replace whitespace with
+ * - multiline - whether to replace linefeed with <br/>
+ * - maxlength - the maximal allowed length of the text
+ *
+ * @return String the encoded text.
+ */
encodeXML: function (txt, opts) {
txt = txt != null ? String(txt):'';
var tl = txt.length,
@@ -97,7 +179,7 @@ zUtl = {
var j = maxlength;
while (j > 0 && txt.charAt(j - 1) == ' ')
--j;
- opts.maxlength = 0;
+ opts.maxlength = 0; //no limit
return zUtl.encodeXML(txt.substring(0, j) + '...', opts);
}
@@ -130,7 +212,11 @@ zUtl = {
out.push(txt.substring(k));
return out.join('');
},
-
+ /** Decodes the XML string into a normal string.
+ * For example, < is convert to <
+ * @param String txt the text to decode
+ * @return String the decoded string
+ */
decodeXML: function (txt) {
var out = '';
if (!txt) return out;
@@ -157,17 +243,39 @@ zUtl = {
k < tl ? out + txt.substring(k): out;
},
-
+ /** A shortcut of ' cellpadding="0" cellspacing="0" border="0"'.
+ * @type String
+ */
cellps0: ' cellpadding="0" cellspacing="0" border="0"',
-
+ /** A shortcut of '<img style="height:0;width:0"/>'.
+ * @type String
+ */
img0: '
',
-
+ /** A shortcut of '<i style="height:0;width:0"/>'.
+ * @type String
+ */
i0: '',
-
+ /** Returns a long value representing the current time (unit: miliseconds).
+ * @return long
+ * @deprecated As of release 5.0.6, replaced with jq.now().
+ */
now: jq.now,
-
-
+ /** Returns today.
+ * @param boolean full if true, returns the full time,
+ * else only returns year, month, and day.
+ * If omitted, false is assumed
+ * @return Date
+ */
+ /** Returns today.
+ * @param String fmt the time format, such as HH:mm:ss.SSS
+ * If a time element such as seconds not specified in the format, it will
+ * be considered as 0. For example, if the format is "HH:mm", then
+ * the returned object will be today, this hour and this minute, but
+ * the second and milliseconds will be zero.
+ * @return Date
+ * @since 5.0.6
+ */
today: function (fmt) {
var d = new Date(), hr = 0, min = 0, sec = 0, msec = 0;
if (typeof fmt == 'string') {
@@ -182,7 +290,20 @@ zUtl = {
hr, min, sec, msec);
},
-
+ /** Returns if one is ancestor of the other.
+ * It assumes the object has either a method called getParent
+ * or a field called parent.
+ * A typical example is used to test the widgets ({@link Widget}).
+ *
+ * Notice that, if you want to test DOM elements, please use
+ * {@link jq#isAncestor} instead.
+ *
+ * @param Object p the parent. This method return true if p is null
+ or p is the same as c
+ * @param Object c the child
+ * @return boolean
+ * @see jq#isAncestor
+ */
isAncestor: function (p, c) {
if (!p) return true;
for (; c; c = c.getParent ? c.getParent(): c.parent)
@@ -191,8 +312,16 @@ zUtl = {
return false;
},
-
-
+ //progress//
+ /** Creates a message box to indicate something is being processed
+ * @param String id the ID of the DOM element being created
+ * @param String msg the message to shown
+ * @param boolean mask whether to show sem-transparent mask to prevent
+ * the user from accessing it.
+ * @param String icon the CSS class used to shown an icon in the box.
+ * Ignored if not specified.
+ * @see #destroyProgressbox
+ */
progressbox: function (id, msg, mask, icon, _opts) {
if (mask && zk.Page.contained.length) {
for (var c = zk.Page.contained.length, e = zk.Page.contained[--c]; e; e = zk.Page.contained[--c]) {
@@ -208,7 +337,7 @@ zUtl = {
if (_opts && _opts.busy) {
zk.busy++;
- jq.focusOut();
+ jq.focusOut(); //Bug 2912533
}
var x = jq.innerX(), y = jq.innerY(),
@@ -241,7 +370,7 @@ zUtl = {
});
}
- if (mask && $txt.length) {
+ if (mask && $txt.length) { //center
st.left = jq.px((jq.innerWidth() - txt.offsetWidth) / 2 + x);
st.top = jq.px((jq.innerHeight() - txt.offsetHeight) / 2 + y);
} else {
@@ -279,7 +408,9 @@ zUtl = {
$n.zk.cleanVisibility();
},
-
+ /** Removes the message box created by {@link #progressbox}.
+ * @param String id the ID of the DOM element of the message box
+ */
destroyProgressbox: function (id, _opts) {
if (_opts && _opts.busy && --zk.busy < 0)
zk.busy = 0;
@@ -296,8 +427,19 @@ zUtl = {
}
},
-
-
+ //HTTP//
+ /** Navigates to the specified URL.
+ * @param String url the URL to go to
+ * @param Map opts [optional] the options. Allowed values:
+ *
+ * - target - the name of the target browser window. The same browswer
+ * window is assumed if omitted. You can use any value allowed in
+ * the target attribute of the HTML FORM tag, such as _self, _blank,
+ * _parent and _top.
+ * - overwrite - whether load a new page in the current browser window.
+ * If true, the new page replaces the previous page's position in the history list.
+ *
+ */
go: function (url, opts) {
opts = opts || {};
if (opts.target) {
@@ -309,7 +451,7 @@ zUtl = {
location.href = url;
var j = url.indexOf('#');
-
+ //bug 3363687, only if '#" exist, has to reload()
if(j < 0)
return;
@@ -320,20 +462,32 @@ zUtl = {
if (j >= 0) pn = pn.substring(0, j);
if (pn != un)
return;
-
+ //fall thru (bug 2882149)
}
location.reload();
}
},
-
+ /** Returns all descendant frames of the given window.
+ * To retrieve all, invoke zUtl.frames(top).
+ * Notice: w is included in the returned array.
+ * If you want to exclude it, invoke zUtl.frames(w).$remove(w).
+ * @param Window w the browser window
+ * @return Array
+ * @since 5.0.4
+ */
frames: function (w) {
var ary = [];
_frames(ary, w);
return ary;
},
-
+ /** Converts an integer array to a string (separated by comma).
+ * @param int[] ary the integer array to convert.
+ * If null, an empty string is returned.
+ * @return String
+ * @see #stringToInts
+ */
intsToString: function (ary) {
if (!ary) return '';
@@ -342,7 +496,14 @@ zUtl = {
sb.push(ary[j]);
return sb.join();
},
-
+ /** Converts a string separated by comma to an array of integers.
+ * @see #intsToString
+ * @param String text the string to convert.
+ * If null, null is returned.
+ * @param int defaultValue the default value used if the value
+ * is not specified. For example, zUtl.stringToInts("1,,3", 2) returns [1, 2, 3].
+ * @return int[]
+ */
stringToInts: function (text, defaultValue) {
if (text == null)
return null;
@@ -362,7 +523,13 @@ zUtl = {
}
return list;
},
-
+ /** Converts a map to a string
+ * @see #intsToString
+ * @param Map map the map to convert
+ * @param String assign the symbol for assignment. If omitted, '=' is assumed.
+ * @param String separator the symbol for separator. If omitted, ',' is assumed.
+ * @return String
+ */
mapToString: function (map, assign, separator) {
assign = assign || '=';
separator = separator || ' ';
@@ -372,12 +539,38 @@ zUtl = {
out[0] = '';
return out.join('');
},
-
-
+ /** Appends an attribute.
+ * Notice that the attribute won't be appended if val is empty or false.
+ * In other words, it is equivalent to
+ * val ? ' ' + nm + '="' + val + '"': "".
+ *
If you want to generate the attribute no matter what val is, use
+ * {@link #appendAttr(String, Object, boolean)}.
+ * @param String nm the name of the attribute
+ * @param Object val the value of the attribute
+ * @since 5.0.3
+ */
+ /** Appends an attribute.
+ * Notice that the attribute won't be appended.
+ * @param String nm the name of the attribute
+ * @param Object val the value of the attribute
+ * @param boolean force whether to append attribute no matter what value it is.
+ * If false (or omitted), it is the same as {@link #appendAttr(String, Object)}.
+ * @since 5.0.3
+ */
appendAttr: function (nm, val, force) {
return val || force ? ' ' + nm + '="' + val + '"': '';
},
-
+ /** Fires beforeSize, onFitSize and onSize
+ * @param Widget wgt the widget which the zWatch event will be fired against.
+ * @param int bfsz the beforeSize mode:
+ *
+ * - 0 (null/undefined/false): beforeSize sent normally.
+ * - -1: beforeSize won't be sent.
+ * - 1: beforeSize will be sent with an additional cleanup option,
+ * which will clean up the cached minimal size (if flex=min).
+ *
+ * @since 5.0.8
+ */
fireSized: function (wgt, bfsz) {
if (zUtl.isImageLoading() || zk.clientinfo) {
var f = arguments.callee;
@@ -387,24 +580,42 @@ zUtl = {
return;
}
wgt = _onSizeTarget(wgt);
- if (!(bfsz < 0))
+ if (!(bfsz < 0)) //don't use >= (because bfsz might be undefined)
zWatch.fireDown('beforeSize', wgt, null, bfsz > 0);
zWatch.fireDown('onFitSize', wgt, {reverse: true});
zWatch.fireDown('onSize', wgt);
},
-
+ /** Fires onBeforeSize, onShow, onFitSize, and onSize
+ * @param Widget wgt the widget which the zWatch event will be fired against.
+ * @param int bfsz the beforeSize mode:
+ *
+ * - 0 (null/undefined/false): beforeSize sent normally.
+ * - -1: beforeSize won't be sent.
+ * - 1: beforeSize will be sent with an additional cleanup option,
+ * which will clean up the cached minimal size (if flex=min).
+ *
+ * @since 5.0.8
+ */
fireShown: function (wgt, bfsz) {
zWatch.fireDown('onShow', wgt);
zUtl.fireSized(wgt, bfsz);
},
-
+ /**
+ * Loads an image before ZK client engine to calculate the widget's layout.
+ * @param String url the loading image's localation
+ * @since 6.0.0
+ */
loadImage: function (url) {
if (!_imgMap[url]) {
_imgMap[url] = true;
_loadImage(url);
}
},
-
+ /**
+ * Checks whether all the loading images are finish.
+ * @see #loadImage
+ * @since 6.0.0
+ */
isImageLoading: function () {
for (var url in _imgObjectMap) {
var img = _imgObjectMap[url];
diff --git a/org.adempiere.ui.zk/WEB-INF/cwr/js/zul/Upload.js b/org.adempiere.ui.zk/WEB-INF/cwr/js/zul/Upload.js
deleted file mode 100644
index 1946cfe298..0000000000
--- a/org.adempiere.ui.zk/WEB-INF/cwr/js/zul/Upload.js
+++ /dev/null
@@ -1 +0,0 @@
-(function(){function e(q,l,n){var m=q.getKey(l),p=q.uploaders[m];if(p){p.destroy(n)}delete q.uploaders[m]}function j(q,m,p){var l=q.getKey(q.sid),n=new zul.Uploader(q,l,m,p);zul.Upload.start(n);q.uploaders[l]=n}function b(n,l,m){j(n,l,m);n.sid++;n.initContent()}function f(t){var q=this,v=q._ctrl,u=v._wgt,o=u.desktop,r=zk.ajaxURI("/upload",{desktop:o,au:true})+"?uuid="+u.uuid+"&dtid="+o.id+"&sid="+v.sid+(v.maxsize!==""?"&maxsize="+v.maxsize:"")+(v.isNative?"&native=true":""),m=q.form;m.action=r;var l=m.parentNode;l.parentNode.removeChild(l);v._formDetached=true;var s=!q.files||q.files.length==1?q.value:(function(w){var p=[];for(var n=w.length;n--;){p.unshift(w[n].name)}return p.join(",")})(q.files);b(q._ctrl,m,s)}if(zk.opera){var i=[],d;function c(){for(var l=i.length;l--;){i[l].sync()}}function h(l){if(!i.length){d=setInterval(c,1500)}i.push(l)}function k(l){i.$remove(l);if(d&&!i.length){clearInterval(d);d=null}}}zul.Upload=zk.$extends(zk.Object,{sid:0,$init:function(s,q,r){this.uploaders={};var n;for(var o=r.split(","),p=0,m=o.length;p';if(n){jq(n).append(m)}else{jq(r).after(m)}delete this._formDetached;if(!r._autodisable_self){this.sync()}var l=this._outer=n?n.lastChild:q.nextSibling,o=l.firstChild.firstChild;if(zk.opera){l.style.position="absolute";h(this)}o.z$proxy=q;o._ctrl=this;jq(o).change(f)},destroy:function(){if(zk.opera){k(this)}jq(this._outer).remove();this._wgt=this._parent=null;for(var l in this.uploaders){var m=this.uploaders[l];if(m){delete this.uploaders[l];m.destroy()}}},getKey:function(l){return(this._wgt?this._wgt.uuid:"")+"_uplder_"+l},cancel:function(l){e(this,l)},finish:function(l){e(this,l,true)}},{error:function(o,m,l){var n=zk.Widget.$(m);if(n){jq.alert(o,{desktop:n.desktop,icon:"ERROR"});zul.Upload.close(m,l)}},close:function(m,l){var n=zk.Widget.$(m);if(!n||!n._uplder){return}n._uplder.cancel(l)},sendResult:function(m,o,l){var n=zk.Widget.$(m);if(!n||!n._uplder){return}n._uplder.finish(l);zAu.send(new zk.Event(n.desktop,"updateResult",{contentId:o,wid:n.uuid,sid:l}))},isFinish:function(o){for(var m=(typeof o=="string"?o:o.uuid)+"_uplder_",n=zul.Upload.files,l=n.length;l--;){if(n[0].id.startsWith(m)){return false}}return true},start:function(m){var l=zul.Upload.files;if(m){l.push(m)}if(l[0]&&!l[0].isStart){l[0].isStart=true;l[0].start()}},destroy:function(n){for(var m=zul.Upload.files,l=m.length;l--;){if(m[l].id==n.id){m.splice(l,1);break}}zul.Upload.start()},files:[]});zul.Uploader=zk.$extends(zk.Object,{$init:function(m,q,n,p){this.id=q;this.flnm=p;this._upload=m;this._form=n;this._parent=n.parentNode;this._sid=m.sid;this._wgt=m._wgt;var o,l=this;if(!m._clsnm){o=new zul.UploadViewer(this,p)}else{zk.$import(m._clsnm,function(r){o=new r(l,p)})}this.viewer=o},getWidget:function(){return this._wgt},destroy:function(l){this.end(l);if(this._form){jq(this._form.parentNode).remove();jq("#"+this.id+"_ifm").remove()}this._form=this._upload=this._wgt=null},start:function(){var p=this._wgt,n=this.id+"_ifm";document.body.appendChild(this._parent);if(!jq("#"+n).length){jq.newFrame(n)}this._form.target=n;this._form.submit();this._form.style.display="none";var l=this,o="cmd=uploadInfo&dtid="+p.desktop.id+"&wid="+p.uuid+"&sid="+this._sid;if(zul.Uploader._tmupload){clearInterval(zul.Uploader._tmupload)}function m(){jq.ajax({type:"POST",url:zk.ajaxURI("/upload",{desktop:p.desktop,au:true}),data:o,dataType:"text",success:function(q){var r=q.split(",");if(q.startsWith("error:")){l._echo=true;zul.Uploader.clearInterval(l.id);if(p){l.cancel();zul.Upload.error(q.substring(6,q.length),p.uuid,l._sid)}}else{if(!l.update(zk.parseInt(r[0]),zk.parseInt(r[1]))){zul.Uploader.clearInterval(l.id)}}},complete:function(s,q){var r;if((r=s.getResponseHeader("ZK-Error"))=="404"||r=="410"||q=="error"||q==404||q==405||q==410){zul.Uploader.clearInterval(l.id);var t=l.getWidget();if(t){l.cancel();zul.Upload.error(msgzk.FAILED_TO_RESPONSE,t.uuid,l._sid)}return}}})}m.id=this.id;zul.Uploader.clearInterval=function(q){if(m.id==q){clearInterval(zul.Uploader._tmupload);zul.Uploader._tmupload=undefined}};zul.Uploader._tmupload=setInterval(m,1000);zul.wgt.ADBS.autodisable(p)},cancel:function(){zul.Uploader.clearInterval(this.id);if(this._upload){this._upload.cancel(this._sid)}},update:function(l,m){var n=this.getWidget();if(!n||m<=0){if(this._echo){this.end()}else{return true}}else{if(zul.Uploader._tmupload){this._echo=true;if(l>=0&&l<=100){this.viewer.update(l,m)}return l>=0&&l<100}}return false},end:function(n){this.viewer.destroy(n);zul.Upload.destroy(this);this._echo=true;var p,l,m,o;if((p=this._wgt)&&(l=this._upload)&&(m=l._aded)){p._uplder=null;m.onResponse();l._aded=null;if(p._uplder != null)p._uplder.destroy();if((o=l._parent)&&!jq(o).parents("html").length){l._parent=p._getUploadRef();l.initContent()}p._uplder=l;p._uplder.sync();delete p._autodisable_self}}});function g(m,n){var l=zul.UploadViewer.flman;if(!l||!l.desktop){if(l){l.detach()}zul.UploadViewer.flman=l=new zul.UploadManager();m.getWidget().getPage().appendChild(l)}l.removeFile(m);l.addFile(m)}function a(l,m){if(zul.UploadManager){return g(l,m)}zk.load("zul.wgt,zul.box",function(){zul.UploadManager=zk.$extends(zul.wgt.Popup,{$init:function(){this.$supers("$init",arguments);this._files={};this.setSclass("z-fileupload-manager")},onFloatUp:function(n){var o=n.origin;if(!this.isVisible()){return}this.setTopmost()},getFileItem:function(n){return this._files[n]||zk.Widget.$(n)},addFile:function(p){var r=p.id,q=p.flnm,o=this.getFileItem(r);if(!o){o=new zul.wgt.Div({uuid:r,children:[new zul.wgt.Label({value:q+":"}),new zul.box.Box({mold:"horizontal",children:[new zul.wgt.Progressmeter({id:r,sclass:"z-fileupload-progress"}),new zul.wgt.Div({sclass:"z-fileupload-remove z-icon-times",listeners:{onClick:function(){var s=r.substring(0,r.indexOf("_uplder_"));zul.Uploader.clearInterval(r);var t=zk.Widget.$(s);if(t){t._uplder.cancel(r.substring(r.lastIndexOf("_")+1,r.length))}}}})]}),new zul.wgt.Label({id:r+"_total"}),new zul.wgt.Separator()]});try{this.appendChild(o)}catch(n){}this._files[r]=o}return o},updateFile:function(p,q,n){var r=p.id,o=this.getFileItem(r);if(!o){return}o.$f(r).setValue(q);o.$f(r+"_total").setValue(n)},removeFile:function(q){var s=q.id,o=this.getFileItem(s);if(o){o.detach()}delete this._files[s];var r=true;for(var n in this._files){if(!(r=false)){break}}if(r){this.close()}},open:function(o,n){this.$super("open",o,null,n||"after_start",{sendOnOpen:false,disableMask:true})}});g(l,m)})}zul.UploadViewer=zk.$extends(zk.Object,{$init:function(l,m){this._uplder=l;a(l,m)},update:function(m,n){var l=zul.UploadViewer.flman;if(l){if(!l.isOpen()){l.open(this._uplder.getWidget())}l.updateFile(this._uplder,m,msgzk.FILE_SIZE+Math.round(n/1024)+msgzk.KBYTES)}},destroy:function(){var l=zul.UploadViewer.flman;if(l){l.removeFile(this._uplder)}}})})();
\ No newline at end of file
diff --git a/org.adempiere.ui.zk/WEB-INF/cwr/js/zul/Upload.src.js b/org.adempiere.ui.zk/WEB-INF/cwr/js/zul/Upload.src.js
deleted file mode 100644
index 78e7f424d8..0000000000
--- a/org.adempiere.ui.zk/WEB-INF/cwr/js/zul/Upload.src.js
+++ /dev/null
@@ -1,514 +0,0 @@
-
-(function () {
-
- function _cancel(o, sid, finish) {
- var key = o.getKey(sid),
- uplder = o.uploaders[key];
- if (uplder)
- uplder.destroy(finish);
- delete o.uploaders[key];
- }
- function _initUploader(o, form, val) {
- var key = o.getKey(o.sid),
- uplder = new zul.Uploader(o, key, form, val);
- zul.Upload.start(uplder);
- o.uploaders[key] = uplder;
- }
- function _start(o, form, val) {
-
-
- _initUploader(o, form, val);
- o.sid++;
- o.initContent();
- }
- function _onchange(evt) {
- var n = this,
- upload = n._ctrl,
- wgt = upload._wgt,
- dt = wgt.desktop,
- action = zk.ajaxURI('/upload', {desktop:dt,au:true}) + '?uuid=' + wgt.uuid + '&dtid=' + dt.id + '&sid=' + upload.sid
- + (upload.maxsize !== '' ? '&maxsize=' + upload.maxsize : '')
- + (upload.isNative ? '&native=true' : ''),
- form = n.form;
- form.action = action;
-
-
- var p = form.parentNode;
- p.parentNode.removeChild(p);
- upload._formDetached = true;
- var fileName = !n.files || n.files.length == 1 ? n.value : (function(files){
- var fns = [];
- for (var len = files.length; len--;)
- fns.unshift(files[len].name);
- return fns.join(",");
- })(n.files);
- _start(n._ctrl, form, fileName);
- }
-
- if (zk.opera) {
- var _syncQue = [], _syncId;
- function _syncNow() {
- for (var j = _syncQue.length; j--;)
- _syncQue[j].sync();
- }
- function _addSyncQue(upld) {
- if (!_syncQue.length)
- _syncId = setInterval(_syncNow, 1500);
-
- _syncQue.push(upld);
- }
- function _rmSyncQue(upld) {
- _syncQue.$remove(upld);
- if (_syncId && !_syncQue.length) {
- clearInterval(_syncId);
- _syncId = null;
- }
- }
- }
-
-
-zul.Upload = zk.$extends(zk.Object, {
- sid: 0,
-
- $init: function(wgt, parent, clsnm) {
- this.uploaders = {};
-
- var cls;
- for (var attrs = clsnm.split(','), i = 0, len = attrs.length; i < len; i++) {
- var attr = attrs[i].trim();
- if (attr.startsWith('maxsize='))
- this.maxsize = attr.match(new RegExp(/maxsize=([^,]*)/))[1];
- else if (attr.startsWith('multiple='))
- this.multiple = attr.match(new RegExp(/multiple=([^,]*)/))[1];
- else if (attr.startsWith('accept='))
- this.accept = attr.match(new RegExp(/accept=([^,]*)/))[1];
- else if (attr == 'native')
- this.isNative = true;
- else if (attr != 'true')
- cls = attr;
- }
-
- this._clsnm = cls || '';
-
- this._wgt = wgt;
- this._parent = parent;
- if (wgt._tooltiptext)
- this._tooltiptext = wgt._tooltiptext;
-
- this.initContent();
- },
-
- sync: function () {
- if (!this._formDetached) {
- var wgt = this._wgt,
- ref = wgt.$n(),
- parent = this._parent,
- outer = parent ? parent.lastChild : ref.nextSibling,
- inp = outer.firstChild.firstChild,
- refof = zk(ref).revisedOffset(),
- outerof = jq(outer).css({top: '0', left: '0'}).zk.revisedOffset(),
- diff = inp.offsetWidth - ref.offsetWidth,
- st = outer.style;
- st.top = (refof[1] - outerof[1]) + "px";
- st.left = refof[0] - outerof[0] - diff + "px";
-
- inp.style.height = ref.offsetHeight + 'px';
- inp.style.clip = 'rect(auto,auto,auto,' + diff + 'px)';
- }
- },
- initContent: function () {
- var wgt = this._wgt,
- parent = this._parent,
- ref = wgt.$n(), dt = wgt.desktop,
- html = '';
-
- if (parent)
- jq(parent).append(html);
- else
- jq(wgt).after(html);
- delete this._formDetached;
-
-
- if (!wgt._autodisable_self)
- this.sync();
-
- var outer = this._outer = parent ? parent.lastChild : ref.nextSibling,
- inp = outer.firstChild.firstChild;
-
- if (zk.opera) {
- outer.style.position = 'absolute';
- _addSyncQue(this);
- }
-
- inp.z$proxy = ref;
- inp._ctrl = this;
-
- jq(inp).change(_onchange);
- },
-
- destroy: function () {
- if (zk.opera)
- _rmSyncQue(this);
-
- jq(this._outer).remove();
- this._wgt = this._parent = null;
- for (var v in this.uploaders) {
- var uplder = this.uploaders[v];
- if (uplder) {
- delete this.uploaders[v];
- uplder.destroy();
- }
- }
- },
-
- getKey: function (sid) {
- return (this._wgt ? this._wgt.uuid : '' )+ '_uplder_' + sid;
- },
-
- cancel: function (sid) {
- _cancel(this, sid);
- },
-
- finish: function (sid) {
- _cancel(this, sid, true);
- }
-},{
-
- error: function (msg, uuid, sid) {
- var wgt = zk.Widget.$(uuid);
- if (wgt) {
- jq.alert(msg, {desktop: wgt.desktop, icon: 'ERROR'});
- zul.Upload.close(uuid, sid);
- }
- },
-
- close: function (uuid, sid) {
- var wgt = zk.Widget.$(uuid);
- if (!wgt || !wgt._uplder) return;
- wgt._uplder.cancel(sid);
- },
-
- sendResult: function (uuid, contentId, sid) {
- var wgt = zk.Widget.$(uuid);
- if (!wgt || !wgt._uplder) return;
- wgt._uplder.finish(sid);
- zAu.send(new zk.Event(wgt.desktop, "updateResult", {
- contentId: contentId,
- wid: wgt.uuid,
- sid: sid
- }));
- },
-
- isFinish: function (wgt) {
- for (var key = (typeof wgt == 'string' ? wgt : wgt.uuid) + '_uplder_',
- f = zul.Upload.files, i = f.length; i--;)
- if (f[0].id.startsWith(key))
- return false;
- return true;
- },
-
- start: function (uplder) {
- var files = zul.Upload.files;
- if (uplder)
- files.push(uplder);
- if (files[0] && !files[0].isStart) {
- files[0].isStart = true;
- files[0].start();
- }
- },
-
- destroy: function (uplder) {
- for (var files = zul.Upload.files, i = files.length; i--;)
- if (files[i].id == uplder.id) {
- files.splice(i, 1);
- break;
- }
- zul.Upload.start();
- },
- files: []
-});
-
-zul.Uploader = zk.$extends(zk.Object, {
-
- $init: function (upload, id, form, flnm) {
- this.id = id;
- this.flnm = flnm;
- this._upload = upload;
- this._form = form;
- this._parent = form.parentNode;
- this._sid = upload.sid;
- this._wgt = upload._wgt;
-
- var viewer, self = this;
- if (!upload._clsnm) viewer = new zul.UploadViewer(this, flnm);
- else
- zk.$import(upload._clsnm, function (cls) {
- viewer = new cls(self, flnm);
- });
- this.viewer = viewer;
- },
-
- getWidget: function () {
- return this._wgt;
- },
-
- destroy: function (finish) {
- this.end(finish);
- if (this._form) {
- jq(this._form.parentNode).remove();
- jq('#' + this.id + '_ifm').remove();
- }
- this._form = this._upload = this._wgt = null;
- },
-
- start: function () {
- var wgt = this._wgt,
- frameId = this.id + '_ifm';
-
- document.body.appendChild(this._parent);
- if (!jq('#' + frameId).length)
- jq.newFrame(frameId);
- this._form.target = frameId;
- this._form.submit();
- this._form.style.display = "none";
-
- var self = this,
- data = 'cmd=uploadInfo&dtid=' + wgt.desktop.id
- + '&wid=' + wgt.uuid + '&sid=' + this._sid;
-
- if (zul.Uploader._tmupload)
- clearInterval(zul.Uploader._tmupload);
-
- function t() {
- jq.ajax({
- type: 'POST',
- url: zk.ajaxURI('/upload', {desktop: wgt.desktop, au: true}),
- data: data,
- dataType: 'text',
- success: function(data) {
- var d = data.split(',');
- if (data.startsWith('error:')) {
- self._echo = true;
- zul.Uploader.clearInterval(self.id);
- if (wgt) {
- self.cancel();
- zul.Upload.error(data.substring(6, data.length), wgt.uuid, self._sid);
- }
- } else if (!self.update(zk.parseInt(d[0]), zk.parseInt(d[1])))
- zul.Uploader.clearInterval(self.id);
- },
- complete: function(req, status) {
- var v;
- if ((v = req.getResponseHeader("ZK-Error")) == "404"
- || v == "410" || status == 'error'
- || status == 404 || status == 405 || status == 410) {
- zul.Uploader.clearInterval(self.id);
- var wgt = self.getWidget();
- if (wgt) {
- self.cancel();
- zul.Upload.error(msgzk.FAILED_TO_RESPONSE, wgt.uuid, self._sid);
- }
- return;
- }
- }
- });
- }
- t.id = this.id;
-
- zul.Uploader.clearInterval = function (id) {
- if (t.id == id) {
- clearInterval(zul.Uploader._tmupload);
- zul.Uploader._tmupload = undefined;
- }
- };
- zul.Uploader._tmupload = setInterval(t, 1000);
-
- zul.wgt.ADBS.autodisable(wgt);
- },
-
- cancel: function () {
- zul.Uploader.clearInterval(this.id);
- if (this._upload)
- this._upload.cancel(this._sid);
- },
-
- update: function (sent, total) {
- var wgt = this.getWidget();
- if (!wgt || total <= 0)
- if (this._echo)
- this.end();
- else
- return true;
- else if (zul.Uploader._tmupload) {
- this._echo = true;
- if (sent >= 0 && sent <= 100)
- this.viewer.update(sent, total);
- return sent >= 0 && sent < 100;
- }
- return false;
- },
-
- end: function (finish) {
- this.viewer.destroy(finish);
- zul.Upload.destroy(this);
- this._echo = true;
-
-
- var wgt, upload, aded, parent;
- if ((wgt = this._wgt) && (upload = this._upload) &&
- (aded = upload._aded)) {
- wgt._uplder = null;
- aded.onResponse();
- upload._aded = null;
-
-
- if (wgt._uplder != null)
- wgt._uplder.destroy();
- if ((parent = upload._parent) && !jq(parent).parents('html').length) {
- upload._parent = wgt._getUploadRef();
- upload.initContent();
- }
- wgt._uplder = upload;
- wgt._uplder.sync();
- delete wgt._autodisable_self;
- }
- }
-});
-
-
- function _addUM(uplder, flnm) {
- var flman = zul.UploadViewer.flman;
- if (!flman || !flman.desktop) {
- if (flman) flman.detach();
- zul.UploadViewer.flman = flman = new zul.UploadManager();
- uplder.getWidget().getPage().appendChild(flman);
- }
- flman.removeFile(uplder);
- flman.addFile(uplder);
- }
- function _initUM(uplder, flnm) {
- if (zul.UploadManager)
- return _addUM(uplder, flnm);
-
- zk.load('zul.wgt,zul.box', function() {
-
- zul.UploadManager = zk.$extends(zul.wgt.Popup, {
- $init: function () {
- this.$supers('$init', arguments);
- this._files = {};
- this.setSclass('z-fileupload-manager');
- },
- onFloatUp: function(ctl) {
- var wgt = ctl.origin;
- if (!this.isVisible())
- return;
- this.setTopmost();
- },
-
- getFileItem: function(id) {
- return this._files[id] || zk.Widget.$(id);
- },
-
- addFile: function(uplder) {
- var id = uplder.id,
- flnm = uplder.flnm,
- prog = this.getFileItem(id);
- if (!prog) {
- prog = new zul.wgt.Div({
- uuid: id,
- children: [new zul.wgt.Label({
- value: flnm + ':'
- }), new zul.box.Box({
- mold: 'horizontal',
- children: [new zul.wgt.Progressmeter({
- id: id,
- sclass: 'z-fileupload-progress'
- })
- , new zul.wgt.Div({
- sclass: 'z-fileupload-remove z-icon-times',
- listeners: {
- onClick: function () {
- var uuid = id.substring(0, id.indexOf('_uplder_'));
- zul.Uploader.clearInterval(id);
- var wgt = zk.Widget.$(uuid);
- if (wgt) wgt._uplder.cancel(id.substring(id.lastIndexOf('_')+1, id.length));
- }
- }
- })]
- }), new zul.wgt.Label({id: id + '_total'}), new zul.wgt.Separator()]
- });
-
- try {
- this.appendChild(prog);
- } catch (e) {}
- this._files[id] = prog;
- }
- return prog;
- },
-
- updateFile: function(uplder, val, total) {
- var id = uplder.id,
- prog = this.getFileItem(id);
- if (!prog) return;
- prog.$f(id).setValue(val);
- prog.$f(id + '_total').setValue(total);
- },
-
- removeFile: function(uplder) {
- var id = uplder.id,
- prog = this.getFileItem(id);
- if (prog)
- prog.detach();
- delete this._files[id];
- var close = true;
- for (var p in this._files)
- if (!(close = false))
- break;
-
- if (close)
- this.close();
- },
-
- open: function(wgt, position) {
- this.$super('open', wgt, null, position || 'after_start', {
- sendOnOpen: false,
- disableMask: true
- });
- }
- });
- _addUM(uplder, flnm);
- });
- }
-
-zul.UploadViewer = zk.$extends(zk.Object, {
-
- $init: function (uplder, flnm) {
- this._uplder = uplder;
- _initUM(uplder, flnm);
- },
-
- update: function (sent, total) {
- var flman = zul.UploadViewer.flman;
- if (flman) {
- if (!flman.isOpen())
- flman.open(this._uplder.getWidget());
- flman.updateFile(this._uplder, sent, msgzk.FILE_SIZE+Math.round(total/1024)+msgzk.KBYTES);
- }
- },
-
- destroy: function () {
- var flman = zul.UploadViewer.flman;
- if (flman)
- flman.removeFile(this._uplder);
- }
-});
-
-})();
diff --git a/org.zkoss.zk.library/.classpath b/org.zkoss.zk.library/.classpath
index 939a09a28f..0b93562e30 100644
--- a/org.zkoss.zk.library/.classpath
+++ b/org.zkoss.zk.library/.classpath
@@ -2,7 +2,7 @@
-
+