IDEMPIERE-5282 Memory Leak ZK Detached Dom Objects are cleared only a… (#1322)
* IDEMPIERE-5282 Memory Leak ZK Detached Dom Objects are cleared only after ZK session is destroyed - Fix global variable pollution: use closure and replace var with let - Fix memory leak of Grid and ListBox * IDEMPIERE-5282 Memory Leak ZK Detached Dom Objects are cleared only after ZK session is destroyed - Fix js error reported by igorpojzl
This commit is contained in:
parent
a5247574c5
commit
895923f7f2
|
@ -44,14 +44,14 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
|
|||
</mold>
|
||||
</component>
|
||||
|
||||
<javascript-module name="org.idempiere.websocket" version="202011211500"/>
|
||||
<javascript-module name="jawwa.atmosphere" version="202110220730"/>
|
||||
<javascript-module name="adempiere.local.storage" version="202011151100"/>
|
||||
<javascript-module name="org.idempiere.websocket" version="202205100600"/>
|
||||
<javascript-module name="jawwa.atmosphere" version="202205100600"/>
|
||||
<javascript-module name="adempiere.local.storage" version="202205100600"/>
|
||||
<javascript-moudle name="html2canvas" version="1.3.1"/>
|
||||
<javascript-module name="org.idempiere.commons" version="202111051000"/>
|
||||
<javascript-module name="org.idempiere.commons" version="202205100600"/>
|
||||
<javascript-module name="jquery.maskedinput" version="1.4.1" />
|
||||
<javascript-module name="photobooth" version="0.7-rsd3" />
|
||||
<javascript-module name="chosenbox" version="202012041500"/>
|
||||
<javascript-module name="chosenbox" version="202205100600"/>
|
||||
<javascript-module name="zkforge.keylistener" version="202012120100"/>
|
||||
|
||||
<!-- this js module doesn't actually exists and it is here for default theme version -->
|
||||
|
|
|
@ -324,9 +324,10 @@ public final class LayoutUtils {
|
|||
mask.showMask();
|
||||
mask.getMaskComponent().appendChild(window);
|
||||
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
|
||||
StringBuilder script = new StringBuilder("(function(){let w=zk.Widget.$('#");
|
||||
script.append(mask.getMaskComponent().getUuid()).append("');");
|
||||
script.append("var d=zk.Widget.$('#").append(window.getUuid()).append("');w.busy=d;");
|
||||
script.append("let d=zk.Widget.$('#").append(window.getUuid()).append("');w.busy=d;");
|
||||
script.append("})()");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
|
||||
LayoutUtils.openOverlappedWindow(mask.getMaskComponent(), window, "middle_center");
|
||||
|
@ -536,10 +537,11 @@ public final class LayoutUtils {
|
|||
*/
|
||||
public static void sameWidth(HtmlBasedComponent target, HtmlBasedComponent ref) {
|
||||
StringBuilder script = new StringBuilder()
|
||||
.append("var t=zk.Widget.$('#").append(target.getUuid()).append("');")
|
||||
.append("var r=zk.Widget.$('#").append(ref.getUuid()).append("');")
|
||||
.append("(function(){let t=zk.Widget.$('#").append(target.getUuid()).append("');")
|
||||
.append("let r=zk.Widget.$('#").append(ref.getUuid()).append("');")
|
||||
.append("jq(t).css({'width':").append("jq(r).width()+'px'});")
|
||||
.append("t.setWidth(\"").append("jq(r).width()+'px'\");");
|
||||
script.append("})()");
|
||||
Clients.response("_sameWidth_", new AuScript(target, script.toString()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,9 +78,10 @@ public class ShowMaskWrapper implements ISupportMask {
|
|||
Component p = maskObj.getParent();
|
||||
maskObj.detach();
|
||||
if (p == comp) {
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
|
||||
StringBuilder script = new StringBuilder("(function(){let w=zk.Widget.$('#");
|
||||
script.append(p.getUuid()).append("');");
|
||||
script.append("w.busy=null;");
|
||||
script.append("})()");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -316,27 +316,28 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
|
||||
private void setupFormSwipeListener() {
|
||||
String uuid = form.getUuid();
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('")
|
||||
StringBuilder script = new StringBuilder("(function(){let w=zk.Widget.$('")
|
||||
.append(uuid)
|
||||
.append("');");
|
||||
script.append("jq(w).on('touchstart', function(e) {var w=zk.Widget.$(this);w._touchstart=e;});");
|
||||
script.append("jq(w).on('touchmove', function(e) {var w=zk.Widget.$(this);w._touchmove=e;});");
|
||||
script.append("jq(w).on('touchend', function(e) {var w=zk.Widget.$(this);var ts = w._touchstart; var tl = w._touchmove;"
|
||||
script.append("jq(w).on('touchstart', function(e) {let w=zk.Widget.$(this);w._touchstart=e;});");
|
||||
script.append("jq(w).on('touchmove', function(e) {let w=zk.Widget.$(this);w._touchmove=e;});");
|
||||
script.append("jq(w).on('touchend', function(e) {let w=zk.Widget.$(this);let ts = w._touchstart; let tl = w._touchmove;"
|
||||
+ "w._touchstart=null;w._touchmove=null;"
|
||||
+ "if (ts && tl) {"
|
||||
+ "if (ts.originalEvent) ts = ts.originalEvent;"
|
||||
+ "if (tl.originalEvent) tl = tl.originalEvent;"
|
||||
+ "if (ts.changedTouches && ts.changedTouches.length==1 && tl.changedTouches && tl.changedTouches.length==1) {"
|
||||
+ "var diff=(tl.timeStamp-ts.timeStamp)/1000;if (diff > 1) return;"
|
||||
+ "var diffx=tl.changedTouches[0].pageX-ts.changedTouches[0].pageX;"
|
||||
+ "var diffy=tl.changedTouches[0].pageY-ts.changedTouches[0].pageY;"
|
||||
+ "let diff=(tl.timeStamp-ts.timeStamp)/1000;if (diff > 1) return;"
|
||||
+ "let diffx=tl.changedTouches[0].pageX-ts.changedTouches[0].pageX;"
|
||||
+ "let diffy=tl.changedTouches[0].pageY-ts.changedTouches[0].pageY;"
|
||||
+ "if (Math.abs(diffx) >= 100 && Math.abs(diffy) < 80) {"
|
||||
+ "if (diffx > 0) {var event = new zk.Event(w, 'onSwipeRight', null, {toServer: true});zAu.send(event);} "
|
||||
+ "else {var event = new zk.Event(w, 'onSwipeLeft', null, {toServer: true});zAu.send(event);}"
|
||||
+ "if (diffx > 0) {let event = new zk.Event(w, 'onSwipeRight', null, {toServer: true});zAu.send(event);} "
|
||||
+ "else {let event = new zk.Event(w, 'onSwipeLeft', null, {toServer: true});zAu.send(event);}"
|
||||
+ "}"
|
||||
+ "}"
|
||||
+ "}"
|
||||
+ "});");
|
||||
script.append("})()");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
|
||||
|
@ -2168,11 +2169,12 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
|
|||
if (!checkCurrent) {
|
||||
((HtmlBasedComponent)c).focus();
|
||||
} else {
|
||||
StringBuilder script = new StringBuilder("var b=true;try{if (zk.currentFocus) {");
|
||||
script.append("var p=zk.Widget.$('#").append(formContainer.getCenter().getUuid()).append("');");
|
||||
StringBuilder script = new StringBuilder("(function(){let b=true;try{if (zk.currentFocus) {");
|
||||
script.append("let p=zk.Widget.$('#").append(formContainer.getCenter().getUuid()).append("');");
|
||||
script.append("if (zUtl.isAncestor(p, zk.currentFocus)) {");
|
||||
script.append("b=false;}}}catch(error){}");
|
||||
script.append("if(b){var w=zk.Widget.$('#").append(c.getUuid()).append("');w.focus(0);}");
|
||||
script.append("if(b){let w=zk.Widget.$('#").append(c.getUuid()).append("');w.focus(0);}");
|
||||
script.append("})()");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,9 +185,9 @@ public class ADWindowContent extends AbstractADWindowContent
|
|||
* generated serial id
|
||||
*/
|
||||
private static final long serialVersionUID = 6104341168705201721L;
|
||||
private AbstractADWindowContent content;
|
||||
private ADWindowContent content;
|
||||
|
||||
protected ADWindowVlayout(AbstractADWindowContent content) {
|
||||
protected ADWindowVlayout(ADWindowContent content) {
|
||||
super();
|
||||
this.content = content;
|
||||
}
|
||||
|
@ -198,6 +198,7 @@ public class ADWindowContent extends AbstractADWindowContent
|
|||
try {
|
||||
SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, content);
|
||||
} catch (Exception e){}
|
||||
content.layout.removeEventListener(WindowContainer.ON_WINDOW_CONTAINER_SELECTION_CHANGED_EVENT, content);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1000,31 +1000,31 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
|||
LayoutUtils.addSclass("mobile", this);
|
||||
addEventListener("onOverflowButton", evt -> onOverflowButton(evt));
|
||||
this.setWidgetOverride("toolbarScrollable", "function (wgt) {\n" +
|
||||
" var total = jq(wgt.$n()).width();\n" +
|
||||
" var w = wgt.firstChild;\n" +
|
||||
" var a = " + !mobileShowMoreButtons.isEmpty() + ";\n" +
|
||||
" let total = jq(wgt.$n()).width();\n" +
|
||||
" let w = wgt.firstChild;\n" +
|
||||
" let a = " + !mobileShowMoreButtons.isEmpty() + ";\n" +
|
||||
"\n" +
|
||||
" // make sure all images are loaded.\n" +
|
||||
" if (zUtl.isImageLoading()) {\n" +
|
||||
" var f = arguments.callee;\n" +
|
||||
" let f = arguments.callee;\n" +
|
||||
" setTimeout(function () {\n" +
|
||||
" return f(wgt);\n" +
|
||||
" }, 20);\n" +
|
||||
" return;\n" +
|
||||
" }\n" +
|
||||
" for (; w; w = w.nextSibling) {\n" +
|
||||
" var ow = jq(w.$n()).outerWidth(true);\n" +
|
||||
" let ow = jq(w.$n()).outerWidth(true);\n" +
|
||||
" if (typeof ow != 'undefined') {total -= ow;}\n" +
|
||||
" if (total < 0 && w.className == 'zul.wgt.Toolbarbutton') {\n" +
|
||||
" break;\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" if (w && total < 0) {\n" +
|
||||
" var event = new zk.Event(wgt, 'onOverflowButton', w.uuid, {toServer: true}); \n" +
|
||||
" let event = new zk.Event(wgt, 'onOverflowButton', w.uuid, {toServer: true}); \n" +
|
||||
" zAu.send(event); \n" +
|
||||
" }\n" +
|
||||
" else if (a) {\n" +
|
||||
" var event = new zk.Event(wgt, 'onOverflowButton', null, {toServer: true}); \n" +
|
||||
" let event = new zk.Event(wgt, 'onOverflowButton', null, {toServer: true}); \n" +
|
||||
" zAu.send(event); \n" +
|
||||
" }\n" +
|
||||
"}");
|
||||
|
@ -1122,9 +1122,10 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
|||
cnt++;
|
||||
}
|
||||
if (overflows.size() >= cnt) {
|
||||
String script = "var e = jq('#" + getUuid() + "');";
|
||||
script = script + "var b=zk.Widget.$('#" + overflowPopup.getUuid() + "'); ";
|
||||
String script = "(function(){let e = jq('#" + getUuid() + "');";
|
||||
script = script + "let b=zk.Widget.$('#" + overflowPopup.getUuid() + "'); ";
|
||||
script = script + "b.setWidth(e.css('width'));";
|
||||
script = script + "})()";
|
||||
Clients.evalJavaScript(script);
|
||||
} else {
|
||||
overflowPopup.setWidth(null);
|
||||
|
@ -1187,7 +1188,8 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
|
|||
|
||||
public void onPostAfterSize() {
|
||||
if (this.getPage() != null) {
|
||||
String script = "var w = zk.Widget.$('#" + getUuid() + "'); w.toolbarScrollable(w);";
|
||||
String script = "(function(){let w = zk.Widget.$('#" + getUuid() + "'); w.toolbarScrollable(w);";
|
||||
script = script + "})()";
|
||||
Clients.evalJavaScript(script);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3417,21 +3417,23 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
public void hideBusyMask() {
|
||||
if (mask != null && mask.getParent() != null) {
|
||||
mask.detach();
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
|
||||
StringBuilder script = new StringBuilder("(function(){let w=zk.Widget.$('#");
|
||||
script.append(getComponent().getParent().getUuid()).append("');if(w) w.busy=false;");
|
||||
script.append("})()");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public void showBusyMask(Window window) {
|
||||
getComponent().getParent().appendChild(getMask());
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
|
||||
StringBuilder script = new StringBuilder("(function(){let w=zk.Widget.$('#");
|
||||
script.append(getComponent().getParent().getUuid()).append("');");
|
||||
if (window != null) {
|
||||
script.append("var d=zk.Widget.$('#").append(window.getUuid()).append("');w.busy=d;");
|
||||
script.append("let d=zk.Widget.$('#").append(window.getUuid()).append("');w.busy=d;");
|
||||
} else {
|
||||
script.append("w.busy=true;");
|
||||
}
|
||||
script.append("})()");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
|
||||
|
|
|
@ -207,9 +207,9 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
if (linkPopup != null && linkPopup.getPage() != null && linkPopup.isVisible()) {
|
||||
if (event.getName().equals(Events.ON_MOUSE_OUT)) {
|
||||
linkPopup.setAttribute(ON_MOUSE_OUT_ECHO_EVENT, Boolean.TRUE);
|
||||
StringBuilder script = new StringBuilder("setTimeout(function(){var w=zk('#")
|
||||
StringBuilder script = new StringBuilder("setTimeout(function(){let w=zk('#")
|
||||
.append(BreadCrumb.this.getUuid()).append("').$();")
|
||||
.append("var e=new zk.Event(w, '")
|
||||
.append("let e=new zk.Event(w, '")
|
||||
.append(ON_MOUSE_OUT_ECHO_EVENT)
|
||||
.append("', null, {toServer:true});")
|
||||
.append("zAu.send(e);},500)");
|
||||
|
@ -229,9 +229,9 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
if (linkPopup != null && linkPopup.getPage() != null)
|
||||
linkPopup.detach();
|
||||
linkPopup = new Menupopup();
|
||||
StringBuilder script = new StringBuilder("setTimeout(function(){var w=zk('#")
|
||||
StringBuilder script = new StringBuilder("setTimeout(function(){let w=zk('#")
|
||||
.append(event.getTarget().getUuid()).append("').$();")
|
||||
.append("var e=new zk.Event(w, '")
|
||||
.append("let e=new zk.Event(w, '")
|
||||
.append(ON_MOUSE_OVER_ECHO_EVENT)
|
||||
.append("', null, {toServer:true});")
|
||||
.append("zAu.send(e);},500)");
|
||||
|
@ -258,9 +258,9 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
linkPopup.appendChild(item);
|
||||
}
|
||||
|
||||
StringBuilder script = new StringBuilder("setTimeout(function(){var w=zk('#")
|
||||
StringBuilder script = new StringBuilder("setTimeout(function(){let w=zk('#")
|
||||
.append(BreadCrumb.this.getUuid()).append("').$();")
|
||||
.append("var e=new zk.Event(w, '")
|
||||
.append("let e=new zk.Event(w, '")
|
||||
.append(ON_MOUSE_OUT_ECHO_EVENT)
|
||||
.append("', null, {toServer:true});")
|
||||
.append("zAu.send(e);},500)");
|
||||
|
|
|
@ -141,8 +141,8 @@ public class CompositeADTabbox extends AbstractADTabbox
|
|||
if (!headerTab.isDetailVisible()) {
|
||||
String uuid = headerTab.getDetailPane().getParent().getUuid();
|
||||
String vid = getSelectedDetailADTabpanel().getGridView().getUuid();
|
||||
String script = "setTimeout(function(){zk('#"+uuid+"').$().setOpen(true);setTimeout(function(){var v=zk('#" + vid
|
||||
+ "').$();var e=new zk.Event(v,'onEditCurrentRow',null,{toServer:true});zAu.send(e);},200);},200)";
|
||||
String script = "setTimeout(function(){zk('#"+uuid+"').$().setOpen(true);setTimeout(function(){let v=zk('#" + vid
|
||||
+ "').$();let e=new zk.Event(v,'onEditCurrentRow',null,{toServer:true});zAu.send(e);},200);},200)";
|
||||
Clients.response(new AuScript(script));
|
||||
} else {
|
||||
boolean isFormView = headerTab.getDetailPane().getSelectedPanel().isToggleToFormView();
|
||||
|
|
|
@ -1078,8 +1078,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
|||
if (!btn.isDisabled() && btn.isVisible()) {
|
||||
Events.sendEvent(btn, new Event(Events.ON_CLICK, btn));
|
||||
//client side script to close combobox popup
|
||||
String script = "var w=zk.Widget.$('#" + btn.getUuid()+"'); " +
|
||||
"zWatch.fire('onFloatUp', w);";
|
||||
String script = "(function(){let w=zk.Widget.$('#" + btn.getUuid()+"'); " +
|
||||
"zWatch.fire('onFloatUp', w);})()";
|
||||
Clients.response(new AuScript(script));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,9 +170,9 @@ public class GlobalSearch extends Div implements EventListener<Event> {
|
|||
} else if (event.getName().equals(ON_CREATE_ECHO)) {
|
||||
StringBuilder script = new StringBuilder("jq('#")
|
||||
.append(bandbox.getUuid())
|
||||
.append("').bind('keydown', function(e) {var code=e.keyCode||e.which;if(code==13){")
|
||||
.append("var widget=zk.Widget.$(this);")
|
||||
.append("var event=new zk.Event(widget,'")
|
||||
.append("').bind('keydown', function(e) {let code=e.keyCode||e.which;if(code==13){")
|
||||
.append("let widget=zk.Widget.$(this);")
|
||||
.append("let event=new zk.Event(widget,'")
|
||||
.append(ON_ENTER_KEY)
|
||||
.append("',{},{toServer:true});")
|
||||
.append("zAu.send(event);")
|
||||
|
|
|
@ -296,13 +296,14 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
|
|||
private void showBusyMask(Window window) {
|
||||
if (getParent() != null) {
|
||||
getParent().appendChild(getMask());
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
|
||||
StringBuilder script = new StringBuilder("(function(){let w=zk.Widget.$('#");
|
||||
script.append(getParent().getUuid()).append("');");
|
||||
if (window != null) {
|
||||
script.append("var d=zk.Widget.$('#").append(window.getUuid()).append("');w.busy=d;");
|
||||
script.append("let d=zk.Widget.$('#").append(window.getUuid()).append("');w.busy=d;");
|
||||
} else {
|
||||
script.append("w.busy=true;");
|
||||
}
|
||||
script.append("})()");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
}
|
||||
|
@ -311,8 +312,9 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
|
|||
{
|
||||
if (mask != null && mask.getParent() != null) {
|
||||
mask.detach();
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
|
||||
StringBuilder script = new StringBuilder("(function(){let w=zk.Widget.$('#");
|
||||
script.append(getParent().getUuid()).append("');w.busy=false;");
|
||||
script.append("})()");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,11 +235,12 @@ public class AddAuthorizationForm extends ADForm {
|
|||
this.pInstanceId = pInstanceId;
|
||||
|
||||
StringBuilder authScript = new StringBuilder()
|
||||
.append("var x = window.outerWidth / 2 + window.screenX - (800 / 2);\n")
|
||||
.append("var y = window.outerHeight / 2 + window.screenY - (600 / 2);\n")
|
||||
.append("var authWindow = window.open('").append(authURL).append("','_blank','width=800, height=600, top='+y+', left='+x);\n")
|
||||
.append("var timer = zk.Widget.$('#").append(timer.getUuid()).append("');\n")
|
||||
.append("timer.windowRef = authWindow; timer.play();");
|
||||
.append("(function(){let x = window.outerWidth / 2 + window.screenX - (800 / 2);\n")
|
||||
.append("let y = window.outerHeight / 2 + window.screenY - (600 / 2);\n")
|
||||
.append("let authWindow = window.open('").append(authURL).append("','_blank','width=800, height=600, top='+y+', left='+x);\n")
|
||||
.append("let timer = zk.Widget.$('#").append(timer.getUuid()).append("');\n")
|
||||
.append("timer.windowRef = authWindow; timer.play();")
|
||||
.append("})()");
|
||||
// Note: the listener can be set to onBind instead of onClick to open the popup without user intervention,
|
||||
// but in this case the browser popup restrictions apply.
|
||||
// As most browser block popups by default I prefer to go the safest route using onClick
|
||||
|
@ -250,8 +251,8 @@ public class AddAuthorizationForm extends ADForm {
|
|||
StringBuilder timerScript = new StringBuilder()
|
||||
.append("function sleep (time) {return new Promise((resolve) => setTimeout(resolve, time));}\n")
|
||||
.append("try {\n")
|
||||
.append(" var t = zk.Widget.$('#").append(msgBox.getUuid()).append("');\n")
|
||||
.append(" var authWindow = this.windowRef;\n")
|
||||
.append(" let t = zk.Widget.$('#").append(msgBox.getUuid()).append("');\n")
|
||||
.append(" let authWindow = this.windowRef;\n")
|
||||
.append(" if (authWindow && authWindow.closed) {\n")
|
||||
.append(" t.setValue('! ").append(msgError).append(msgFailure).append("'); t.fireOnChange(); \n") // prefix "! " - see onMsgBoxChanged
|
||||
.append(" this.stop();\n")
|
||||
|
@ -260,11 +261,11 @@ public class AddAuthorizationForm extends ADForm {
|
|||
.append(" if (authWindow && authWindow.location) {\n")
|
||||
.append(" if (authWindow.location.href.indexOf('/callback.jsp') >= 0) {\n")
|
||||
.append(" this.stop();\n")
|
||||
.append(" var url = new URL(authWindow.location.href);\n")
|
||||
.append(" var error = url.searchParams.get('error');\n")
|
||||
.append(" var msg = url.searchParams.get('msg');\n")
|
||||
.append(" let url = new URL(authWindow.location.href);\n")
|
||||
.append(" let error = url.searchParams.get('error');\n")
|
||||
.append(" let msg = url.searchParams.get('msg');\n")
|
||||
.append(" if (error) {\n" )
|
||||
.append(" var msg = '").append(msgError).append("'+error;\n")
|
||||
.append(" let msg = '").append(msgError).append("'+error;\n")
|
||||
.append(" t.setValue(msg, false); t.fireOnChange();\n")
|
||||
.append(" } else if (msg) {\n")
|
||||
.append(" t.setValue(msg, false); t.fireOnChange();\n")
|
||||
|
|
|
@ -78,8 +78,9 @@ public class Combobox extends org.zkoss.zul.Combobox implements IdSpace
|
|||
//ensure list is close and not on focus
|
||||
if (this.getPage() != null)
|
||||
{
|
||||
String script = "var w=zk('#"+getUuid()+"').$(); if (w){w.close();var j=jq('#"
|
||||
+getUuid()+" :focus');if(j.get(0)){j.blur();}}";
|
||||
String script = "(function(){let w=zk('#"+getUuid()+"').$(); if (w){w.close();let j=jq('#"
|
||||
+getUuid()+" :focus');if(j.get(0)){j.blur();}}"
|
||||
+"})()";
|
||||
Clients.response(new AuScript(script));
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +193,7 @@ public class Combobox extends org.zkoss.zul.Combobox implements IdSpace
|
|||
* add widget listener to auto scroll selected item to view (i.e make visible)
|
||||
*/
|
||||
public void addScrollSelectedIntoViewListener() {
|
||||
String script = "var id='#'+this.uuid+'-pp .z-comboitem-selected';var selected=zk($(id));if(selected.jq.length==1)selected.scrollIntoView();";
|
||||
String script = "(function(){let id='#'+this.uuid+'-pp .z-comboitem-selected';let selected=zk($(id));if(selected.jq.length==1)selected.scrollIntoView();})()";
|
||||
setWidgetListener("onKeyUp", script);
|
||||
}
|
||||
}
|
|
@ -107,19 +107,21 @@ public class NumberBox extends Div
|
|||
decimalBox.setWidgetOverride("doKeyPress_", funct.toString());
|
||||
funct = new StringBuffer();
|
||||
// debug // funct.append("console.log('keyCode='+event.keyCode);");
|
||||
funct.append("function(event) {");
|
||||
funct.append("let key=0;");
|
||||
funct.append("if (window.event)");
|
||||
funct.append(" key = event.keyCode;");
|
||||
funct.append("else");
|
||||
funct.append(" key = event.which;");
|
||||
funct.append("if (key == 108 || key == 110 || key == 188 || key == 190 || key == 194) {");
|
||||
funct.append(" var id = '$'.concat('").append(decimalBox.getId()).append("');");
|
||||
funct.append(" var calcText = jq(id)[0];");
|
||||
funct.append(" var position = calcText.selectionStart;");
|
||||
funct.append(" var newValue = calcText.value.substring(0, position) + '").append(separator).append("' + calcText.value.substring(position);");
|
||||
funct.append(" let id = '$'.concat('").append(decimalBox.getId()).append("');");
|
||||
funct.append(" let calcText = jq(id)[0];");
|
||||
funct.append(" let position = calcText.selectionStart;");
|
||||
funct.append(" let newValue = calcText.value.substring(0, position) + '").append(separator).append("' + calcText.value.substring(position);");
|
||||
funct.append(" calcText.value = newValue;");
|
||||
funct.append(" calcText.setSelectionRange(position+1, position+1);");
|
||||
funct.append(" event.stop;");
|
||||
funct.append("};");
|
||||
funct.append("}}");
|
||||
decimalBox.setWidgetListener("onKeyDown", funct.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ public class DPPerformance extends DashboardPanel {
|
|||
{
|
||||
int timeout = MSysConfig.getIntValue(MSysConfig.ZK_DASHBOARD_PERFORMANCE_TIMEOUT, 500, Env.getAD_Client_ID(Env.getCtx()));
|
||||
Component grid = this.getFirstChild().getFirstChild();
|
||||
String script = "setTimeout(function() { var grid = jq('#" + grid.getUuid() + "');";
|
||||
String script = "setTimeout(function() { let grid = jq('#" + grid.getUuid() + "');";
|
||||
script = script + "grid.parent().height(grid.css('height'));}, " + timeout + ");";
|
||||
if (Executions.getCurrent() != null)
|
||||
Clients.response(new AuScript(script));
|
||||
|
|
|
@ -862,8 +862,8 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
}
|
||||
|
||||
//use _docClick undocumented api. need verification after major zk release update
|
||||
private final static String autoHideMenuScript = "try{var w=zk.Widget.$('#{0}');var t=zk.Widget.$('#{1}');" +
|
||||
"var e=new Object;e.target=t;w._docClick(e);}catch(error){}";
|
||||
private final static String autoHideMenuScript = "(function(){try{let w=zk.Widget.$('#{0}');let t=zk.Widget.$('#{1}');" +
|
||||
"let e=new Object;e.target=t;w._docClick(e);}catch(error){}})()";
|
||||
|
||||
private void autoHideMenu() {
|
||||
if (mobile) {
|
||||
|
@ -1063,8 +1063,8 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
super.onMenuSelected(menuId);
|
||||
if (showHeader != null && showHeader.isVisible()) {
|
||||
//ensure header popup is close
|
||||
String script = "var w=zk.Widget.$('#" + layout.getUuid()+"'); " +
|
||||
"zWatch.fire('onFloatUp', w);";
|
||||
String script = "(function(){let w=zk.Widget.$('#" + layout.getUuid()+"'); " +
|
||||
"zWatch.fire('onFloatUp', w);})()";
|
||||
Clients.response(new AuScript(script));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ public class WAccountEditor extends WEditor implements ContextMenuListener
|
|||
|
||||
//safety check: if focus is going no where, focus back to self
|
||||
String uid = getComponent().getTextbox().getUuid();
|
||||
String script = "setTimeout(function(){try{var e = zk.Widget.$('#" + uid +
|
||||
String script = "setTimeout(function(){try{let e = zk.Widget.$('#" + uid +
|
||||
"').$n(); if (jq(':focus').size() == 0) e.focus();} catch(error){}}, 100);";
|
||||
Clients.response(new AuScript(script));
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ public class WColorEditor extends WEditor implements ContextMenuListener
|
|||
|
||||
public void openColorPicker() { // TODO color picker is opening at upper left ; better to open it at center of screen
|
||||
String uid = colorbox.getUuid();
|
||||
String script = "var wgt = zk.Widget.$('#"+uid+"');wgt.$n().click();";
|
||||
String script = "(function(){let wgt = zk.Widget.$('#"+uid+"');wgt.$n().click();})()";
|
||||
Clients.response(new AuScript(script));
|
||||
}
|
||||
|
||||
|
|
|
@ -486,7 +486,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
|||
|
||||
//safety check: if focus is going no where, focus back to self
|
||||
String uid = getComponent().getCombobox().getUuid();
|
||||
String script = "setTimeout(function(){try{var e = zk.Widget.$('#" + uid +
|
||||
String script = "setTimeout(function(){try{let e = zk.Widget.$('#" + uid +
|
||||
"').$n(); if (jq(':focus').size() == 0) e.focus();} catch(error){}}, 100);";
|
||||
Clients.response(new AuScript(script));
|
||||
|
||||
|
@ -886,7 +886,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
|||
public void onPageAttached(Page newpage, Page oldpage) {
|
||||
super.onPageAttached(newpage, oldpage);
|
||||
if (newpage != null) {
|
||||
String w = "try{var btn=jq('#'+this.parent.uuid+' @button').zk.$();}catch(err){}";
|
||||
String w = "try{let btn=jq('#'+this.parent.uuid+' @button').zk.$();}catch(err){}";
|
||||
if (ThemeManager.isUseFontIconForImage()) {
|
||||
String sclass = "z-icon-spinner z-icon-spin";
|
||||
getCombobox().setWidgetListener("onChange", "try{"+w+"btn.setIconSclass('" + sclass + "');"
|
||||
|
|
|
@ -74,8 +74,8 @@ public class DefaultFeedbackService implements IFeedbackService {
|
|||
|
||||
String script = "html2canvas(document.body).then(canvas => " +
|
||||
"{ const dataUrl = canvas.toDataURL();" +
|
||||
" var widget = zk.Widget.$('#" + SessionManager.getAppDesktop().getComponent().getUuid()+"');"+
|
||||
" var event = new zk.Event(widget, 'onEmailSupport', dataUrl, {toServer: true});" +
|
||||
" let widget = zk.Widget.$('#" + SessionManager.getAppDesktop().getComponent().getUuid()+"');"+
|
||||
" let event = new zk.Event(widget, 'onEmailSupport', dataUrl, {toServer: true});" +
|
||||
" zAu.send(event);" +
|
||||
"});";
|
||||
Clients.response(new AuScript(script));
|
||||
|
@ -151,9 +151,9 @@ public class DefaultFeedbackService implements IFeedbackService {
|
|||
SessionManager.getAppDesktop().getComponent().addEventListener("onCreateFeedbackRequest", this);
|
||||
|
||||
String script = "html2canvas(document.body).then(canvas => " +
|
||||
"{ var dataUrl = canvas.toDataURL();" +
|
||||
" var widget = zk.Widget.$('#" + SessionManager.getAppDesktop().getComponent().getUuid()+"');"+
|
||||
" var event = new zk.Event(widget, 'onCreateFeedbackRequest', dataUrl, {toServer: true});" +
|
||||
"{ let dataUrl = canvas.toDataURL();" +
|
||||
" let widget = zk.Widget.$('#" + SessionManager.getAppDesktop().getComponent().getUuid()+"');"+
|
||||
" let event = new zk.Event(widget, 'onCreateFeedbackRequest', dataUrl, {toServer: true});" +
|
||||
" zAu.send(event); " +
|
||||
"});";
|
||||
Clients.response(new AuScript(script));
|
||||
|
|
|
@ -135,7 +135,7 @@ public class HelpController
|
|||
content.appendChild(htmlToolTip = new Html());
|
||||
htmlToolTip.setWidgetOverride("defaultMessage", "'"+Msg.getMsg(Env.getCtx(), "PlaceCursorIntoField")+"'");
|
||||
htmlToolTip.setWidgetOverride("onFieldTooltip", "function(origin,opts,header,description,help)" +
|
||||
"{var s='<html><body><div class=\"help-content\">';" +
|
||||
"{let s='<html><body><div class=\"help-content\">';" +
|
||||
"if (typeof header == 'undefined') {s=s+'<i>'+this.defaultMessage+'</i>';} " +
|
||||
"else {s=s+'<b>'+header+'</b>';" +
|
||||
"if (typeof description=='string' && description.length > 0) {s=s+'<br><br><i>'+description+'</i>';}" +
|
||||
|
@ -161,7 +161,9 @@ public class HelpController
|
|||
}
|
||||
|
||||
public void setupFieldTooltip() {
|
||||
Clients.response("helpControllerFieldTooltip", new AuScript(htmlToolTip, "var w=zk.Widget.$('#"+htmlToolTip.getUuid()+"');zWatch.listen({onFieldTooltip: w});"));
|
||||
Clients.response("helpControllerFieldTooltip",
|
||||
new AuScript(htmlToolTip, "(function(){let w=zk.Widget.$('#"+htmlToolTip.getUuid()
|
||||
+"');zWatch.listen({onFieldTooltip: w});})()"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -260,17 +260,17 @@ public class StatusBarPanel extends Panel implements EventListener<Event>, IStat
|
|||
popup.setStyle(popupStyle);
|
||||
if (getRoot() == null || !getRoot().isVisible() ) return;
|
||||
|
||||
String script = "var d = zk.Widget.$('" + popup.getUuid() + "').$n();";
|
||||
String script = "(function(){let d = zk.Widget.$('" + popup.getUuid() + "').$n();";
|
||||
script += "d.style.display='block';d.style.visibility='hidden';";
|
||||
script += "var dhs = document.defaultView.getComputedStyle(d, null).getPropertyValue('height');";
|
||||
script += "var dh = parseInt(dhs, 10);";
|
||||
script += "var r = zk.Widget.$('" + getRoot().getUuid() + "').$n();";
|
||||
script += "var rhs = document.defaultView.getComputedStyle(r, null).getPropertyValue('height');";
|
||||
script += "var rh = parseInt(rhs, 10);";
|
||||
script += "var p = jq('#"+getRoot().getUuid()+"').zk.cmOffset();";
|
||||
script += "let dhs = document.defaultView.getComputedStyle(d, null).getPropertyValue('height');";
|
||||
script += "let dh = parseInt(dhs, 10);";
|
||||
script += "let r = zk.Widget.$('" + getRoot().getUuid() + "').$n();";
|
||||
script += "let rhs = document.defaultView.getComputedStyle(r, null).getPropertyValue('height');";
|
||||
script += "let rh = parseInt(rhs, 10);";
|
||||
script += "let p = jq('#"+getRoot().getUuid()+"').zk.cmOffset();";
|
||||
script += "d.style.top=(rh-dh-5)+'px';";
|
||||
script += "d.style.left=(p[0]+1)+'px';";
|
||||
script += "d.style.visibility='visible';";
|
||||
script += "d.style.visibility='visible';})()";
|
||||
|
||||
AuScript aus = new AuScript(popup, script);
|
||||
Clients.response(aus);
|
||||
|
|
|
@ -137,12 +137,12 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
|||
init();
|
||||
}
|
||||
|
||||
private static final String onComboSelectEchoScript = "var combo=zk('@combo').$();"
|
||||
+ "var panel=zk('@this').$();"
|
||||
+ "var comboitem=zk('@item').$();"
|
||||
+ "var popupheight=combo.getPopupNode_().offsetHeight;"
|
||||
+ "var evt = new zk.Event(panel, 'onComboSelectEcho', [comboitem.uuid, popupheight], {toServer: true});"
|
||||
+ "zAu.send(evt);";
|
||||
private static final String onComboSelectEchoScript = "(function(){let combo=zk('@combo').$();"
|
||||
+ "let panel=zk('@this').$();"
|
||||
+ "let comboitem=zk('@item').$();"
|
||||
+ "let popupheight=combo.getPopupNode_().offsetHeight;"
|
||||
+ "let evt = new zk.Event(panel, 'onComboSelectEcho', [comboitem.uuid, popupheight], {toServer: true});"
|
||||
+ "zAu.send(evt);})()";
|
||||
|
||||
protected void init()
|
||||
{
|
||||
|
@ -267,9 +267,9 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
|||
tree.getSelectedItem().focus();
|
||||
});
|
||||
this.insertBefore(moveItemBox, layout);
|
||||
String script = "var w=zk.Widget.$('#" + moveItemBox.getUuid() + "'); ";
|
||||
script += "var e=jq('#" + layout.getUuid() + "'); ";
|
||||
script += "w.setWidth(e.css('width')); ";
|
||||
String script = "(function(){let w=zk.Widget.$('#" + moveItemBox.getUuid() + "'); ";
|
||||
script += "let e=jq('#" + layout.getUuid() + "'); ";
|
||||
script += "w.setWidth(e.css('width'));})() ";
|
||||
Clients.response(new AuScript(script));
|
||||
ti.focus();
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
|
|||
{
|
||||
StringBuilder f = new StringBuilder();
|
||||
f.append("function(way, tb) {\n")
|
||||
.append(" var tabbox = this.getTabbox();var tabs = this.$n();\n")
|
||||
.append(" let tabbox = this.getTabbox();let tabs = this.$n();\n")
|
||||
.append(" this.$_scrollcheck(way,tb);\n")
|
||||
.append(" if (tabs && !tabbox.isVertical() && !tabbox.inAccordionMold()) {\n")
|
||||
.append(" this.__offsetWidth=tabs.offsetWidth;this.__scrollLeft=tabs.scrollLeft;\n")
|
||||
|
@ -153,9 +153,9 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
|
|||
tabs.setWidgetOverride("_scrollcheck", f.toString());
|
||||
f = new StringBuilder();
|
||||
f.append("function (toSel) {\n")
|
||||
.append(" var tabbox = this.getTabbox();\n")
|
||||
.append(" var tabs = this.$n();\n")
|
||||
.append(" var tabsOffsetWidth=tabs.offsetWidth;\n")
|
||||
.append(" let tabbox = this.getTabbox();\n")
|
||||
.append(" let tabs = this.$n();\n")
|
||||
.append(" let tabsOffsetWidth=tabs.offsetWidth;\n")
|
||||
.append(" this.$_fixWidth(toSel);\n")
|
||||
.append(" if(this.__selectedTab && this.__selectedTab == tabbox.getSelectedTab() && this.__selectedIndex == tabbox.getSelectedIndex()) {\n")
|
||||
.append(" if(tabs.offsetWidth == this.__offsetWidth) {\n")
|
||||
|
@ -170,7 +170,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
|
|||
f = new StringBuilder();
|
||||
f.append("function (to, move) {\n")
|
||||
.append(" if (move <= 0) return;\n")
|
||||
.append(" var self=this,tabs = this.$n();\n")
|
||||
.append(" let self=this,tabs = this.$n();\n")
|
||||
.append(" switch (to) {\n")
|
||||
.append(" case 'right':\n")
|
||||
.append(" self._fixTabsScrollLeft(self._tabsScrollLeft + move);break;")
|
||||
|
@ -181,7 +181,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
|
|||
.append(" default:\n")
|
||||
.append(" self._fixTabsScrollTop(self._tabsScrollTop + move);\n")
|
||||
.append(" }\n")
|
||||
.append(" var tabsScrollLeft = self._tabsScrollLeft, tabsScrollTop = self._tabsScrollTop;\n")
|
||||
.append(" let tabsScrollLeft = self._tabsScrollLeft, tabsScrollTop = self._tabsScrollTop;\n")
|
||||
.append(" self._fixTabsScrollLeft(tabsScrollLeft <= 0 ? 0 : tabsScrollLeft);\n")
|
||||
.append(" self._fixTabsScrollTop(tabsScrollTop <= 0 ? 0 : tabsScrollTop);\n")
|
||||
.append("}");
|
||||
|
@ -383,6 +383,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
|
|||
public void close() {
|
||||
super.close();
|
||||
popupClose.detach();
|
||||
popupClose.removeEventListener(Events.ON_OPEN, WindowContainer.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -69,15 +69,15 @@ public class ZKUpdateUtil {
|
|||
}
|
||||
|
||||
public static void setCSSHeight(HtmlBasedComponent component) {
|
||||
String script = "setTimeout(function() { var e = jq('#" + component.getUuid() + "');";
|
||||
script = script + "var b=zk.Widget.$('#" + component.getUuid() + "'); ";
|
||||
String script = "setTimeout(function() { let e = jq('#" + component.getUuid() + "');";
|
||||
script = script + "let b=zk.Widget.$('#" + component.getUuid() + "'); ";
|
||||
script = script + "b.setHeight(e.css('height')); }, 50 );";
|
||||
Clients.response(new AuScript(script));
|
||||
}
|
||||
|
||||
public static void setCSSWidth(HtmlBasedComponent component) {
|
||||
String script = "setTimeout(function() { var e = jq('#" + component.getUuid() + "');";
|
||||
script = script + "var b=zk.Widget.$('#" + component.getUuid() + "'); ";
|
||||
String script = "setTimeout(function() { let e = jq('#" + component.getUuid() + "');";
|
||||
script = script + "let b=zk.Widget.$('#" + component.getUuid() + "'); ";
|
||||
script = script + "b.setWidth(e.css('width')); }, 50 );";
|
||||
Clients.response(new AuScript(script));
|
||||
}
|
||||
|
|
|
@ -273,10 +273,11 @@ public class WImageDialog extends Window implements EventListener<Event>
|
|||
cancelCaptureButton.setVisible(true);
|
||||
cancelCaptureButton.setEnabled(true);
|
||||
mainLayout.setVisible(false);
|
||||
String script = "var wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');";
|
||||
script = script + "var cancelBtn=zk.Widget.$('#"+cancelCaptureButton.getUuid()+"');";
|
||||
String script = "(function(){let wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');";
|
||||
script = script + "let cancelBtn=zk.Widget.$('#"+cancelCaptureButton.getUuid()+"');";
|
||||
script = script + "jq(wgt).photobooth(); ";
|
||||
script = script + "jq(wgt).bind( 'image', function( event, dataUrl ){ cancelBtn.setVisible(false);zAu.send(new zk.Event(wgt, 'onCaptureImage', dataUrl, {toServer:true})); });";
|
||||
script = script + "})()";
|
||||
Clients.evalJavaScript(script);
|
||||
}
|
||||
else if (e.getName().equals("onCaptureImage"))
|
||||
|
@ -302,8 +303,8 @@ public class WImageDialog extends Window implements EventListener<Event>
|
|||
m_mImage.setBinaryData(imageData);
|
||||
fileNameTextbox.setValue(defaultNameForCaptureImage);
|
||||
}
|
||||
String script = "var wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');";
|
||||
script = script + "jq(wgt).data( 'photobooth').destroy(); ";
|
||||
String script = "(function(){let wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');";
|
||||
script = script + "jq(wgt).data( 'photobooth').destroy();})() ";
|
||||
Clients.evalJavaScript(script);
|
||||
}
|
||||
else if (e.getTarget() == cancelCaptureButton)
|
||||
|
@ -311,8 +312,8 @@ public class WImageDialog extends Window implements EventListener<Event>
|
|||
captureDiv.setVisible(false);
|
||||
cancelCaptureButton.setVisible(false);
|
||||
mainLayout.setVisible(true);
|
||||
String script = "var wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');";
|
||||
script = script + "jq(wgt).data( 'photobooth').destroy(); ";
|
||||
String script = "(function(){let wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');";
|
||||
script = script + "jq(wgt).data( 'photobooth').destroy();})() ";
|
||||
Clients.evalJavaScript(script);
|
||||
}
|
||||
else if (e.getName().equals("onSave"))
|
||||
|
|
|
@ -221,8 +221,8 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
|
|||
text = textBox.getText();
|
||||
detach();
|
||||
} else {
|
||||
String script = "var w=zk('#"+editor.getUuid()+"').$();var d=w.getEditor().getData();var t=zk('#" +
|
||||
this.getUuid()+"').$();var e=new zk.Event(t,'onEditorCallback',d,{toServer:true});zAu.send(e);";
|
||||
String script = "(function(){let w=zk('#"+editor.getUuid()+"').$();let d=w.getEditor().getData();let t=zk('#" +
|
||||
this.getUuid()+"').$();let e=new zk.Event(t,'onEditorCallback',d,{toServer:true});zAu.send(e);})()";
|
||||
Clients.response(new AuScript(script));
|
||||
}
|
||||
|
||||
|
|
|
@ -1691,21 +1691,23 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
|
|||
|
||||
private void showBusyMask(Window window) {
|
||||
getParent().appendChild(getMask());
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
|
||||
StringBuilder script = new StringBuilder("(function(){let w=zk.Widget.$('#");
|
||||
script.append(getParent().getUuid()).append("');");
|
||||
if (window != null) {
|
||||
script.append("var d=zk.Widget.$('#").append(window.getUuid()).append("');w.busy=d;");
|
||||
script.append("let d=zk.Widget.$('#").append(window.getUuid()).append("');w.busy=d;");
|
||||
} else {
|
||||
script.append("w.busy=true;");
|
||||
}
|
||||
script.append("})()");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
|
||||
public void hideBusyMask() {
|
||||
if (mask != null && mask.getParent() != null) {
|
||||
mask.detach();
|
||||
StringBuilder script = new StringBuilder("var w=zk.Widget.$('#");
|
||||
StringBuilder script = new StringBuilder("(function(){let w=zk.Widget.$('#");
|
||||
script.append(getParent().getUuid()).append("');w.busy=false;");
|
||||
script.append("})()");
|
||||
Clients.response(new AuScript(script.toString()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -812,8 +812,8 @@ public class Chosenbox<T> extends HtmlBasedComponent {
|
|||
objects, null, null, null, index, 0));
|
||||
if (selItems.size() < (getSubListModel() != null ? getSubListModel().getSize() : getModel().getSize())) {
|
||||
StringBuilder script = new StringBuilder();
|
||||
script.append("var w=zk.Widget.$('#").append(getUuid()).append("');");
|
||||
script.append("w.$n('inp').focus();");
|
||||
script.append("(function(){let w=zk.Widget.$('#").append(getUuid()).append("');");
|
||||
script.append("w.$n('inp').focus();})()");
|
||||
Executions.schedule(getDesktop(), e -> {setOpen(true);Clients.evalJavaScript(script.toString());}, new Event("onPostSelect"));
|
||||
}
|
||||
_onSelectTimestamp = System.currentTimeMillis();
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*****************************************************************************/
|
||||
|
||||
window.adempiere = {};
|
||||
var adempiere = window.adempiere;
|
||||
let adempiere = window.adempiere;
|
||||
adempiere.isSupportSavePass=typeof(Storage) !== "undefined";
|
||||
|
||||
adempiere.saveUserToken = function (key, hash, sessionId)
|
||||
|
@ -29,15 +29,15 @@ adempiere.findUserToken = function (cmpid, key)
|
|||
if (!adempiere.isSupportSavePass)
|
||||
return;
|
||||
|
||||
var sid = localStorage[key+".sid"];
|
||||
var hash = localStorage[key+".hash"];
|
||||
let sid = localStorage[key+".sid"];
|
||||
let hash = localStorage[key+".hash"];
|
||||
|
||||
if (sid == null || sid == "" || hash == null || hash == ""){
|
||||
return
|
||||
}
|
||||
|
||||
var widget = zk.Widget.$(cmpid);
|
||||
var event = new zk.Event(widget, 'onUserToken', {sid: sid, hash: hash}, {toServer: true});
|
||||
let widget = zk.Widget.$(cmpid);
|
||||
let event = new zk.Event(widget, 'onUserToken', {sid: sid, hash: hash}, {toServer: true});
|
||||
zAu.send(event);
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
}, 350);
|
||||
}
|
||||
|
||||
var Chosenbox =
|
||||
let Chosenbox =
|
||||
|
||||
chosenbox.Chosenbox = zk.$extends(zul.Widget, {
|
||||
$init : function(props) {
|
||||
|
@ -55,7 +55,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
* tabindex
|
||||
*/
|
||||
tabindex : function(tabindex) {
|
||||
var n = this.$n('inp');
|
||||
let n = this.$n('inp');
|
||||
if (n)
|
||||
n.tabindex = tabindex || '';
|
||||
},
|
||||
|
@ -72,7 +72,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
* selectedIndex
|
||||
*/
|
||||
selectedIndex : function(v, opts) {
|
||||
var options, sel;
|
||||
let options, sel;
|
||||
this._clearSelection();
|
||||
if ((sel = this.$n('sel')) && v >= 0) {
|
||||
options = jq(sel).children();
|
||||
|
@ -99,7 +99,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
* disabled
|
||||
*/
|
||||
disabled : function(disabled) {
|
||||
var n = this.$n('inp');
|
||||
let n = this.$n('inp');
|
||||
if (n)
|
||||
n.disabled = disabled ? 'disabled' : '';
|
||||
},
|
||||
|
@ -135,7 +135,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
* name the name of this component.
|
||||
*/
|
||||
name : function(name) {
|
||||
var n = this.$n('inp');
|
||||
let n = this.$n('inp');
|
||||
if (n)
|
||||
n.name = name;
|
||||
},
|
||||
|
@ -231,7 +231,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
* this component.
|
||||
*/
|
||||
separator : function(v) {
|
||||
var separatorCode = this._separatorCode;
|
||||
let separatorCode = this._separatorCode;
|
||||
separatorCode.length = 0;
|
||||
// save keycode for special symble
|
||||
// handle the code of special char because
|
||||
|
@ -288,7 +288,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
open : null
|
||||
},
|
||||
setListContent : function(v) {
|
||||
var sel, out, oldHlite, value;
|
||||
let sel, out, oldHlite, value;
|
||||
if (sel = this.$n('sel')) {
|
||||
if (oldHlite = jq(this.$n('sel'))
|
||||
.find(
|
||||
|
@ -317,27 +317,27 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
}
|
||||
},
|
||||
_renderItems : function(out, content) {
|
||||
var s = $eval(content ? content : this._items)
|
||||
let s = $eval(content ? content : this._items)
|
||||
|| [], zcls = this.getZclass();
|
||||
for (var i = 0, j = s.length; i < j; i++) {
|
||||
for (let i = 0, j = s.length; i < j; i++) {
|
||||
out.push('<div class="', zcls, '-option">',
|
||||
zUtl.encodeXML(s[i]), '</div>');
|
||||
}
|
||||
return out;
|
||||
},
|
||||
getZclass : function() {
|
||||
var zcls = this._zclass;
|
||||
let zcls = this._zclass;
|
||||
return zcls != null ? zcls : "z-chosenbox";
|
||||
},
|
||||
// update the selected items, the old selection will be
|
||||
// cleared at first
|
||||
setChgSel : function(val) { // called from the server
|
||||
this._clearSelection();
|
||||
var sel, options;
|
||||
let sel, options;
|
||||
if (sel = this.$n('sel')) { // select each item
|
||||
options = jq(sel).children();
|
||||
var s = $eval(val), renderByServer = this._renderByServer, item, value;
|
||||
for (var i = 0; i < s.length; i++) {
|
||||
let s = $eval(val), renderByServer = this._renderByServer, item, value;
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
value = s[i];
|
||||
if (item = this._getItemByValue(value))
|
||||
this._doSelect(item);
|
||||
|
@ -350,7 +350,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
bind_ : function() {
|
||||
this.$supers(Chosenbox, 'bind_', arguments);
|
||||
var n = this.$n(), inp = this.$n('inp');
|
||||
let n = this.$n(), inp = this.$n('inp');
|
||||
|
||||
this.domListen_(inp, 'onFocus', 'doFocus_')
|
||||
.domListen_(inp, 'onBlur', 'doBlur_');
|
||||
|
@ -361,19 +361,19 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
this._fixWidth(n);
|
||||
//fix selection
|
||||
if (this._selItems && this._selItems.length > 0) {
|
||||
var s = this._selItems;
|
||||
let s = this._selItems;
|
||||
this._selItems = [];
|
||||
for (var i = 0; i < s.length; i++) {
|
||||
var value = s[i];
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
let value = s[i];
|
||||
if (item = this._getItemByValue(value))
|
||||
this._doSelect(item);
|
||||
else
|
||||
this._selectItemDirectly(value);
|
||||
}
|
||||
} else if (this._chgSel) {
|
||||
var s = this._chgSel;
|
||||
let s = this._chgSel;
|
||||
this._chgSel = null;
|
||||
for (var i = 0; i < s.length; i++) {
|
||||
for (let i = 0; i < s.length; i++) {
|
||||
value = s[i];
|
||||
if (item = this._getItemByValue(value))
|
||||
this._doSelect(item);
|
||||
|
@ -387,7 +387,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
this.setOpen(true);
|
||||
},
|
||||
unbind_ : function() {
|
||||
var inp = this.$n('inp');
|
||||
let inp = this.$n('inp');
|
||||
this.domUnlisten_(inp, 'onFocus', 'doFocus_')
|
||||
.domUnlisten_(inp, 'onBlur', 'doBlur_');
|
||||
zWatch.unlisten({
|
||||
|
@ -418,24 +418,24 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
this.getZclass() + '-focus');
|
||||
},
|
||||
doMouseOver_ : function(evt) {
|
||||
var target = evt.domTarget;
|
||||
let target = evt.domTarget;
|
||||
// mouseover option
|
||||
if (jq(target).hasClass(
|
||||
this.getZclass() + '-option'))
|
||||
this._hliteOpt(target, true);
|
||||
},
|
||||
doMouseOut_ : function(evt) {
|
||||
var target = evt.domTarget;
|
||||
let target = evt.domTarget;
|
||||
// mouseout option
|
||||
if (jq(target).hasClass(
|
||||
this.getZclass() + '-option-over'))
|
||||
this._hliteOpt(target, false);
|
||||
},
|
||||
_hliteOpt : function(target, highlight) {
|
||||
var zcls = this.getZclass() + '-option-over';
|
||||
let zcls = this.getZclass() + '-option-over';
|
||||
if (highlight) {
|
||||
// clear old first
|
||||
var oldHlite = jq(this.$n('sel'))
|
||||
let oldHlite = jq(this.$n('sel'))
|
||||
.find(
|
||||
'.' + this.getZclass()
|
||||
+ '-option-over')[0];
|
||||
|
@ -451,7 +451,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
else if (key == 'down')
|
||||
this._moveOptionFocus('next');
|
||||
else {
|
||||
var inp = this.$n('inp'), pos = zk(inp)
|
||||
let inp = this.$n('inp'), pos = zk(inp)
|
||||
.getSelectionRange(), label = jq(
|
||||
this.$n()).find(
|
||||
'.' + this.getZclass()
|
||||
|
@ -472,7 +472,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
// focus previous or next visible option,
|
||||
// depends on dir
|
||||
_moveOptionFocus : function(dir) {
|
||||
var sel = this.$n('sel'), $sel = jq(sel), oldHlite = $sel
|
||||
let sel = this.$n('sel'), $sel = jq(sel), oldHlite = $sel
|
||||
.find('.' + this.getZclass()
|
||||
+ '-option-over')[0], newHlite, next = dir == 'next', prev = dir == 'prev';
|
||||
if (next && !this._open) // default focus first
|
||||
|
@ -511,7 +511,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
// focus previous or next label,
|
||||
// depends on dir
|
||||
_moveLabelFocus : function(label, dir) {
|
||||
var zcls = this.getZclass() + '-sel-item-focus', newLabel, prev = dir == 'prev', next = dir == 'next';
|
||||
let zcls = this.getZclass() + '-sel-item-focus', newLabel, prev = dir == 'prev', next = dir == 'next';
|
||||
if (label) {
|
||||
jq(label).removeClass(zcls);
|
||||
newLabel = prev ? label.previousSibling
|
||||
|
@ -527,14 +527,14 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
// called after press backspace or del and release
|
||||
_deleteLabel : function(key, evt) {
|
||||
var inp = this.$n('inp'), pos = zk(inp)
|
||||
let inp = this.$n('inp'), pos = zk(inp)
|
||||
.getSelectionRange(), label;
|
||||
|
||||
// only works if cursor is at the begining of input
|
||||
if (pos[0] == 0 && pos[1] == 0) {
|
||||
var zcls = this.getZclass() + '-sel-item-focus';
|
||||
let zcls = this.getZclass() + '-sel-item-focus';
|
||||
if (label = jq(this.$n()).find('.' + zcls)[0]) {
|
||||
var dir = (label.previousSibling && key == 'backspace') ? 'prev'
|
||||
let dir = (label.previousSibling && key == 'backspace') ? 'prev'
|
||||
: 'next';
|
||||
this._moveLabelFocus(label, dir);
|
||||
this._doDeselect(label, {
|
||||
|
@ -550,14 +550,14 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
}
|
||||
},
|
||||
_removeLabelFocus : function() {
|
||||
var zcls = this.getZclass() + '-sel-item-focus', label = jq(
|
||||
let zcls = this.getZclass() + '-sel-item-focus', label = jq(
|
||||
this.$n()).find('.' + zcls)[0];
|
||||
if (label)
|
||||
jq(label).removeClass(zcls);
|
||||
},
|
||||
// called after press enter and release
|
||||
_doEnterPressed : function(evt) {
|
||||
var $sel, hlited, old;
|
||||
let $sel, hlited, old;
|
||||
// clear timer and fix display before process
|
||||
if (old = this.fixDisplay)
|
||||
clearTimeout(old);
|
||||
|
@ -577,7 +577,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
&& (hlited = $sel.find('.'
|
||||
+ this.getZclass()
|
||||
+ '-option-over')[0])) {
|
||||
var options = $sel.children();
|
||||
let options = $sel.children();
|
||||
this._doSelect(hlited, {
|
||||
sendOnSelect : true
|
||||
});
|
||||
|
@ -591,7 +591,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
doClick_ : function(evt) {
|
||||
if (!this.isDisabled()) {
|
||||
var target = evt.domTarget, $target = jq(target), inp = this
|
||||
let target = evt.domTarget, $target = jq(target), inp = this
|
||||
.$n('inp'), zcls = this.getZclass();
|
||||
this._removeLabelFocus();
|
||||
if (inp.value == this._emptyMessage)
|
||||
|
@ -616,7 +616,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
sendOnOpen : true
|
||||
});
|
||||
} else {
|
||||
var label = target, zcls = this.getZclass()
|
||||
let label = target, zcls = this.getZclass()
|
||||
+ '-sel-item';
|
||||
if ($target.hasClass(zcls)
|
||||
|| (label = $target.parent('.'
|
||||
|
@ -637,7 +637,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
// select an item
|
||||
_doSelect : function(target, opts) {
|
||||
this._hliteOpt(target, false);
|
||||
var value = target.innerHTML;
|
||||
let value = target.innerHTML;
|
||||
if (this._selItems.indexOf(value) == -1) {
|
||||
this._createLabel(value);
|
||||
target.style.display = 'none'; // hide selected
|
||||
|
@ -660,7 +660,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
// deselect an item
|
||||
_doDeselect : function(selectedItem, opts) {
|
||||
var value = jq(selectedItem).find(
|
||||
let value = jq(selectedItem).find(
|
||||
'.' + this.getZclass() + '-sel-item-cnt')[0].innerHTML, element = this
|
||||
._getItemByValue(value), _selItems = this._selItems;
|
||||
if (this._open)
|
||||
|
@ -682,8 +682,8 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
this._startFixDisplay();
|
||||
},
|
||||
_getItemByValue : function(value) {
|
||||
var options = jq(this.$n('sel')).children(), item;
|
||||
for (var i = 0; i < options.length; i++)
|
||||
let options = jq(this.$n('sel')).children(), item;
|
||||
for (let i = 0; i < options.length; i++)
|
||||
if ((item = options[i])
|
||||
&& item.innerHTML == value)
|
||||
return item;
|
||||
|
@ -692,7 +692,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
// create label for selected item
|
||||
_createLabel : function(value) {
|
||||
var span = document.createElement("span"), content = document
|
||||
let span = document.createElement("span"), content = document
|
||||
.createElement("div"), delbtn = document
|
||||
.createElement("div"), wgt = this, zcls = this
|
||||
.getZclass();
|
||||
|
@ -717,7 +717,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
// clear all selected items
|
||||
_clearSelection : function(opts) {
|
||||
var n = this.$n(), inp = this.$n('inp'), c, // selected
|
||||
let n = this.$n(), inp = this.$n('inp'), c, // selected
|
||||
// item
|
||||
del;
|
||||
if (n)
|
||||
|
@ -731,21 +731,21 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
// fire onSelectevent to server
|
||||
fireSelectEvent : function() {
|
||||
var data = [], selItems = this._selItems; // selected
|
||||
let data = [], selItems = this._selItems; // selected
|
||||
// item
|
||||
for (var i = 0; i < selItems.length; i++)
|
||||
for (let i = 0; i < selItems.length; i++)
|
||||
data.push(selItems[i]);
|
||||
this.fire('onSelect', data);
|
||||
},
|
||||
// fire onSearch event
|
||||
_fireOnSearch : function(value) {
|
||||
var data = [];
|
||||
let data = [];
|
||||
data.push(value);
|
||||
this.fire('onSearch', data);
|
||||
},
|
||||
// fire onSearching event
|
||||
_fireOnSearching : function(value) {
|
||||
var data = [];
|
||||
let data = [];
|
||||
data.push(value);
|
||||
this.fire('onSearching', data);
|
||||
},
|
||||
|
@ -762,7 +762,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
|
||||
doKeyDown_ : function(evt) {
|
||||
var keyCode = evt.keyCode;
|
||||
let keyCode = evt.keyCode;
|
||||
switch (keyCode) {
|
||||
case 8:// backspace
|
||||
this._deleteLabel('backspace', evt);
|
||||
|
@ -802,7 +802,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
this._removeLabelFocus();
|
||||
},
|
||||
doKeyUp_ : function(evt) {
|
||||
var keyCode = evt.keyCode, opts = {
|
||||
let keyCode = evt.keyCode, opts = {
|
||||
hliteFirst : true
|
||||
};
|
||||
switch (keyCode) {
|
||||
|
@ -831,7 +831,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
startOnSearching(this);
|
||||
},
|
||||
_isSeparator : function(keyCode) {
|
||||
var separator = this._separator, separatorCode = this._separatorCode;
|
||||
let separator = this._separator, separatorCode = this._separatorCode;
|
||||
return (separatorCode && separatorCode
|
||||
.indexOf(keyCode) != -1)
|
||||
|| ((keyCode >= 48 && keyCode <= 122)
|
||||
|
@ -842,7 +842,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
.fromCharCode(keyCode)) != -1);
|
||||
},
|
||||
_updateInput : function(evt) {
|
||||
var inp = evt ? evt.domTarget : this.$n('inp'), txcnt = this
|
||||
let inp = evt ? evt.domTarget : this.$n('inp'), txcnt = this
|
||||
.$n('txcnt'), wgt = this;
|
||||
|
||||
// check every 100ms while input
|
||||
|
@ -855,7 +855,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
if (!this.isDisabled())
|
||||
this._open = open;
|
||||
if (this.$n('pp')) {
|
||||
var pp = this.$n('pp');
|
||||
let pp = this.$n('pp');
|
||||
if (open)
|
||||
this.open(this.$n(), pp, opts);
|
||||
else
|
||||
|
@ -863,7 +863,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
}
|
||||
},
|
||||
open : function(n, pp, opts) {
|
||||
var ppstyle = pp.style;
|
||||
let ppstyle = pp.style;
|
||||
|
||||
this._fixWidth(n);
|
||||
this._fixsz(pp);
|
||||
|
@ -875,7 +875,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
ppstyle.zIndex = n.style.zIndex;
|
||||
ppstyle.display = 'block';
|
||||
if (opts) {
|
||||
var inp = this.$n();
|
||||
let inp = this.$n();
|
||||
zk(pp).position(inp, "after_start");
|
||||
}
|
||||
|
||||
|
@ -908,7 +908,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
this._clearListContent();
|
||||
},
|
||||
_fixsz : function(pp) {
|
||||
var ppstyle = pp.style, maxh = this._ppMaxHeight;
|
||||
let ppstyle = pp.style, maxh = this._ppMaxHeight;
|
||||
ppstyle.height = 'auto';
|
||||
ppstyle.left = "-10000px";
|
||||
ppstyle.display = "block";
|
||||
|
@ -920,7 +920,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
// calculate the width for input field
|
||||
_fixInputWidth : function() {
|
||||
var n = this.$n(), inp = this.$n('inp'), txcnt = this
|
||||
let n = this.$n(), inp = this.$n('inp'), txcnt = this
|
||||
.$n('txcnt'), oldh = jq(n).height(), width, max = parseInt(this._width) - 10;
|
||||
// copy value to hidden txcnt
|
||||
txcnt.innerHTML = inp.value;
|
||||
|
@ -942,7 +942,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
this._fixDisplay(opts);
|
||||
else { // replace old if exist and hold a while
|
||||
// while input
|
||||
var wgt = this, old;
|
||||
let wgt = this, old;
|
||||
if (old = this.fixDisplay)
|
||||
clearTimeout(old);
|
||||
this.fixDisplay = setTimeout(function() {
|
||||
|
@ -954,10 +954,10 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
_fixDisplay : function(opts) {
|
||||
if (!this._open)
|
||||
return;
|
||||
var fromServer = opts && opts.fromServer;
|
||||
let fromServer = opts && opts.fromServer;
|
||||
if (!this._renderByServer
|
||||
|| (opts && opts.fromServer)) {
|
||||
var str = this.$n('inp').value, oldhlite = jq(
|
||||
let str = this.$n('inp').value, oldhlite = jq(
|
||||
this.$n('sel'))
|
||||
.find(
|
||||
'.' + this.getZclass()
|
||||
|
@ -976,7 +976,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
// fix the display content of options
|
||||
_fixSelDisplay : function(hliteFirst, str, fromServer) {
|
||||
var pp = this.$n('pp'), $pp = jq(pp), maxh = this._ppMaxHeight, ppstyle = pp.style, selItems = this._selItems, options = jq(
|
||||
let pp = this.$n('pp'), $pp = jq(pp), maxh = this._ppMaxHeight, ppstyle = pp.style, selItems = this._selItems, options = jq(
|
||||
this.$n('sel')).children(), found = false, // unselected
|
||||
// match
|
||||
// item
|
||||
|
@ -1034,7 +1034,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
// fix the display of no-result text block
|
||||
_fixEmptyDisplay : function(type, str, found, exist) {
|
||||
var ecls = this.getZclass() + '-empty-creatable', empty = this
|
||||
let ecls = this.getZclass() + '-empty-creatable', empty = this
|
||||
.$n('empty');
|
||||
if (type
|
||||
&& (type.showBlank || type.showExistance
|
||||
|
@ -1054,7 +1054,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
// item
|
||||
// and
|
||||
// creatable
|
||||
var createMsg = this._createMessage;
|
||||
let createMsg = this._createMessage;
|
||||
if (createMsg)
|
||||
createMsg = zUtl.encodeXML(
|
||||
createMsg.replace(/\{0\}/g,
|
||||
|
@ -1066,7 +1066,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
jq(empty).addClass(ecls);
|
||||
} else { // show no-result text if
|
||||
// nothing can be selected
|
||||
var empMsg = this._noResultsText;
|
||||
let empMsg = this._noResultsText;
|
||||
if (empMsg)
|
||||
empMsg = zUtl.encodeXML(
|
||||
empMsg.replace(/\{0\}/g,
|
||||
|
@ -1086,7 +1086,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
},
|
||||
// show emptyMessage or clear input
|
||||
_fixEmptyMessage : function(force) {
|
||||
var inp;
|
||||
let inp;
|
||||
if ((!this._open || force)
|
||||
&& (inp = this.$n('inp'))) {
|
||||
|
||||
|
@ -1099,7 +1099,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
|
|||
}
|
||||
},
|
||||
domAttrs_ : function() {
|
||||
var v;
|
||||
let v;
|
||||
return this.$supers('domAttrs_', arguments)
|
||||
+ (this.isDisabled() ? ' disabled="disabled"'
|
||||
: '')
|
||||
|
|
|
@ -13,7 +13,7 @@ This program is distributed under LGPL Version 3.0 in the hope that
|
|||
it will be useful, but WITHOUT ANY WARRANTY.
|
||||
*/
|
||||
function (out) {
|
||||
var zcls = this.getZclass(),
|
||||
let zcls = this.getZclass(),
|
||||
uid = this.uuid;
|
||||
|
||||
out.push('<i id="', uid, '" class="',zcls,'"', (!this.isVisible() ? 'style="display:none;"' : ''), '>',
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
(function() {
|
||||
jawwa.atmosphere.startServerPush = function(dtid, timeout) {
|
||||
var dt = zk.Desktop.$(dtid);
|
||||
let dt = zk.Desktop.$(dtid);
|
||||
if (dt._serverpush)
|
||||
dt._serverpush.stop();
|
||||
|
||||
//change to true to enable trace of execution
|
||||
var trace = false;
|
||||
var spush = new jawwa.atmosphere.ServerPush(dt, timeout, trace);
|
||||
let trace = false;
|
||||
let spush = new jawwa.atmosphere.ServerPush(dt, timeout, trace);
|
||||
spush.start();
|
||||
};
|
||||
jawwa.atmosphere.stopServerPush = function(dtid) {
|
||||
var dt = zk.Desktop.$(dtid);
|
||||
let dt = zk.Desktop.$(dtid);
|
||||
if (dt._serverpush)
|
||||
dt._serverpush.stop();
|
||||
};
|
||||
|
@ -37,7 +37,7 @@
|
|||
this.ajaxOptions.timeout = this.timeout;
|
||||
this.ajaxOptions.url = zk.ajaxURI("/comet", {au: true,desktop:this.desktop.id,ignoreSession:true}),
|
||||
this.trace = trace;
|
||||
var me = this;
|
||||
let me = this;
|
||||
this.ajaxOptions.error = function(jqxhr, textStatus, errorThrown) {
|
||||
if (me.trace)
|
||||
console.log("error: " + textStatus + " dtid: " + me.desktop.id + " errorThrown: " + errorThrown + " status: " + jqxhr.status);
|
||||
|
@ -67,7 +67,7 @@
|
|||
},
|
||||
_schedule: function() {
|
||||
if (this.failures < 3) {
|
||||
var d = this.delay;
|
||||
let d = this.delay;
|
||||
if (this._req && (this._req.status == 0 || this._req.status == 400))
|
||||
d = 500;
|
||||
this._req = null;
|
||||
|
@ -83,7 +83,7 @@
|
|||
|
||||
if (this.trace)
|
||||
console.log("_send"+ " dtid: " + this.desktop.id);
|
||||
var jqxhr = $.ajax(this.ajaxOptions);
|
||||
let jqxhr = $.ajax(this.ajaxOptions);
|
||||
this._req = jqxhr;
|
||||
zAu.cmd0.echo(this.desktop);
|
||||
},
|
||||
|
|
|
@ -10,7 +10,7 @@ function Calc()
|
|||
|
||||
function validateDown(displayTextId, calcTextId, integral, separatorKey, e, processDotKeypad)
|
||||
{
|
||||
var key;
|
||||
let key;
|
||||
if(window.event)
|
||||
key = e.keyCode; //IE
|
||||
else
|
||||
|
@ -31,8 +31,8 @@ function Calc()
|
|||
{
|
||||
try
|
||||
{
|
||||
var id = "$".concat(calcTextId);
|
||||
var calcText = jq(id)[0];
|
||||
let id = "$".concat(calcTextId);
|
||||
let calcText = jq(id)[0];
|
||||
calcText.value = "";
|
||||
}
|
||||
catch (err)
|
||||
|
@ -44,9 +44,9 @@ function Calc()
|
|||
{
|
||||
try
|
||||
{
|
||||
var id = "$".concat(calcTextId);
|
||||
var calcText = jq(id)[0];
|
||||
var val = calcText.value;
|
||||
let id = "$".concat(calcTextId);
|
||||
let calcText = jq(id)[0];
|
||||
let val = calcText.value;
|
||||
if (val != "")
|
||||
{
|
||||
val = val.substring(0, val.length - 1);
|
||||
|
@ -62,15 +62,15 @@ function Calc()
|
|||
function evaluate(displayTextId, calcTextId, separator)
|
||||
{
|
||||
// console.log("evaluate: " + displayTextId + " / " + calcTextId + " / " + separator);
|
||||
var newValue = "error";
|
||||
let newValue = "error";
|
||||
try
|
||||
{
|
||||
var id = "$".concat(calcTextId);
|
||||
var calcText = jq(id)[0];
|
||||
var value = calcText.value;
|
||||
let id = "$".concat(calcTextId);
|
||||
let calcText = jq(id)[0];
|
||||
let value = calcText.value;
|
||||
if (separator != '.')
|
||||
{
|
||||
var re = new RegExp("[" + separator + "]", "g");
|
||||
let re = new RegExp("[" + separator + "]", "g");
|
||||
value = value.replace(re,'.');
|
||||
}
|
||||
value = value
|
||||
|
@ -82,7 +82,7 @@ function Calc()
|
|||
.replace(/0/g, '') // throw away the rest of the zeros
|
||||
.replace(/z/g, '0'); // turn sentinels back to zeros
|
||||
newValue = value;
|
||||
var result = "" + eval(value);
|
||||
let result = "" + eval(value);
|
||||
if (separator != '.')
|
||||
{
|
||||
result = result.replace(/\./, separator);
|
||||
|
@ -90,7 +90,7 @@ function Calc()
|
|||
calcText.value = result;
|
||||
|
||||
id = "$".concat(displayTextId);
|
||||
var displayText = jq(id)[0];
|
||||
let displayText = jq(id)[0];
|
||||
|
||||
if (!displayText.readOnly && calcText.value != 'undefined')
|
||||
{
|
||||
|
@ -106,18 +106,18 @@ function Calc()
|
|||
|
||||
function append(calcTextId, val)
|
||||
{
|
||||
var id = "$".concat(calcTextId);
|
||||
var calcText = jq(id)[0];
|
||||
let id = "$".concat(calcTextId);
|
||||
let calcText = jq(id)[0];
|
||||
calcText.value += val;
|
||||
calcText.focus();
|
||||
}
|
||||
|
||||
function appendOnCursor(calcTextId, val)
|
||||
{
|
||||
var id = "$".concat(calcTextId);
|
||||
var calcText = jq(id)[0];
|
||||
var position = calcText.selectionStart;
|
||||
var newValue = calcText.value.substring(0, position) + val + calcText.value.substring(position);
|
||||
let id = "$".concat(calcTextId);
|
||||
let calcText = jq(id)[0];
|
||||
let position = calcText.selectionStart;
|
||||
let newValue = calcText.value.substring(0, position) + val + calcText.value.substring(position);
|
||||
calcText.value = newValue;
|
||||
calcText.setSelectionRange(position+1, position+1);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
zk.afterLoad('calendar', function() {
|
||||
zk.override(calendar.Event.prototype, "calculate_", function() {
|
||||
if (typeof this.event === "undefined" || this.event == null) {
|
||||
return;
|
||||
}
|
||||
this.$calculate_.apply(this, arguments);
|
||||
});
|
||||
|
||||
zk.override(calendar.Event.prototype, "unbind_", function() {
|
||||
let node = this.$n();
|
||||
if (typeof node === "undefined") {
|
||||
return;
|
||||
}
|
||||
if (typeof this.$unbind_ === "undefined") {
|
||||
return;
|
||||
}
|
||||
this.$unbind_.apply(this, arguments);
|
||||
});
|
||||
|
||||
zk.override(calendar.CalendarsMonth.prototype, "onSize", function() {
|
||||
let cmp = this.$n();
|
||||
if (typeof cmp === "undefined" || cmp == null) {
|
||||
return;
|
||||
}
|
||||
this.$onSize.apply(this, arguments);
|
||||
});
|
||||
|
||||
zk.override(calendar.CalendarsDefault.prototype, "onSize", function() {
|
||||
let cmp = this.$n();
|
||||
if (typeof cmp === "undefined" || cmp == null) {
|
||||
return;
|
||||
}
|
||||
this.$onSize.apply(this, arguments);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,129 @@
|
|||
zk.afterLoad(function() {
|
||||
zk.$package('id.zk');
|
||||
|
||||
id.zk.Extend = zk.$extends(zk.Object, {}, {
|
||||
fakeOnchange: function(wgt) {
|
||||
// just sent fake event when control is textfield and value is not yet sync to server
|
||||
if ((wgt.$instanceof(zul.inp.Textbox) || wgt.$instanceof(zul.inp.Decimalbox)) && wgt.$n().value != wgt.getText())
|
||||
zAu.send(new zk.Event(zk.Widget.$(wgt), 'onChange', {
|
||||
"value": wgt.$n().value
|
||||
}));
|
||||
|
||||
else if (zk.$import("ckez.CKeditor") != undefined && wgt.$instanceof(ckez.CKeditor)) { //https://www.zkoss.org/javadoc/latest/jsdoc/_global_/zk.html#$import(_global_.String)
|
||||
// CKEditor extend from zul.Widget not from wget zul.inp.InputWidget
|
||||
// so some behavior is not same standard input
|
||||
// this code bring from ckez.CKeditor.onBlur
|
||||
let editor = wgt._editor;
|
||||
|
||||
if (wgt._tidChg) {
|
||||
clearInterval(wgt._tidChg);
|
||||
wgt._tidChg = null;
|
||||
}
|
||||
|
||||
if (!editor.document)
|
||||
editor.document = editor.element.getDocument();
|
||||
|
||||
if (wgt.$class._checkEditorDirty(editor)) { // Issue #13
|
||||
let val = editor.getData();
|
||||
wgt._value = val; //save for onRestore
|
||||
//ZKCK-16, 17 use sendAhead to make sure onChange always happens first
|
||||
wgt.fire('onChange', {
|
||||
value: val
|
||||
});
|
||||
editor.resetDirty();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
fireOnInitEdit: function(wgt) {
|
||||
// sent even to indicate field is start edit, this event sent new value to server but now don't use this data.
|
||||
if (wgt.$instanceof(zul.inp.Textbox))
|
||||
zAu.send(new zk.Event(zk.Widget.$(wgt), 'onInitEdit', {
|
||||
"value": wgt.$n().value
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
zk.afterLoad('zul.inp', function() {
|
||||
|
||||
// should filter out for only component inside standard window or component wish fire this event,
|
||||
// or ever rise other event like start editting to distinguish with true onChange event
|
||||
zk.override(zul.inp.InputWidget.prototype, "doInput_", function(evt) {
|
||||
this.$doInput_(evt);
|
||||
|
||||
if (this.get("isOnStardardWindow") == 'false' || this.get("isChangeEventWhenEditing") != true) {
|
||||
return; // don't waste time to check component don't lay on standard window
|
||||
}
|
||||
|
||||
let domElemOfLayout = jq('#' + this.$n().id).closest(".adwindow-layout"); // return a array
|
||||
if (domElemOfLayout.length == 0) {
|
||||
this.set("isOnStardardWindow", "false"); // next time don't waste time to check this component
|
||||
// in case, you move this component to a standard window, please update this properties at client by javascript Widget.set ()
|
||||
// or at server by java function component.setWidgetOverride
|
||||
} else {
|
||||
let winLayoutWg = zk.Widget.$(domElemOfLayout);
|
||||
if (winLayoutWg == null) {
|
||||
; // do nothing, this case rare happen because ".adwindow-layout" always is a component
|
||||
} else {
|
||||
let isEditting = winLayoutWg.get("isEditting");
|
||||
// winLayoutWg should cache to improve perfomance
|
||||
if (isEditting == "false") {
|
||||
winLayoutWg.set("isEditting", "true");
|
||||
id.zk.Extend.fireOnInitEdit(this); //fire change event to move to edit
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
zk.override(zk.Widget.prototype, "onAutofill", function(evt) {
|
||||
id.zk.Extend.fakeOnchange(this); //fire change event to move to edit
|
||||
});
|
||||
|
||||
zk.override(zul.inp.Textbox.prototype, "bind_", function(dt, skipper, after) {
|
||||
if (!this.$bind_)
|
||||
return;
|
||||
|
||||
this.$bind_(dt, skipper, after);
|
||||
|
||||
let txtid = this.getId()
|
||||
if (txtid != "txtUserId" && txtid != "txtPassword") {
|
||||
return;
|
||||
}
|
||||
|
||||
this.domListen_(this.$n(), "onChange", "onAutofill");
|
||||
});
|
||||
|
||||
zk.override(zul.inp.Textbox.prototype, "unbind_", function(dt, skipper) {
|
||||
if (!this.$unbind_)
|
||||
return;
|
||||
|
||||
this.$unbind_(dt, skipper);
|
||||
|
||||
let txtid = this.getId()
|
||||
if (txtid != "txtUserId" && txtid != "txtPassword") {
|
||||
return;
|
||||
}
|
||||
|
||||
this.domUnlisten_(this.$n(), "onChange", "onAutofill"); //unlisten
|
||||
});
|
||||
|
||||
zk.override(zul.inp.Combobox.prototype, "doKeyDown_", function(evt) {
|
||||
// avoid confuse of idempiere shortcut key and function key of combobox
|
||||
if ((evt.altKey || evt.ctrlKey || evt.shiftKey) &&
|
||||
(evt.keyCode == 33 || evt.keyCode == 34 || evt.keyCode == 35 || evt.keyCode == 36 || evt.keyCode == 38 || evt.keyCode == 40 || evt.keyCode == 37 || evt.keyCode == 39)) { //page up | page down | end | home | up | down | left | write
|
||||
|
||||
if (this.isOpen()) //close drop down if already open. it will let combobox select current item, it's consistent with lost focus
|
||||
this.close({
|
||||
sendOnOpen: true
|
||||
});
|
||||
|
||||
return;
|
||||
// TODO:current idempiere use alt + down/up to move child parrent tab, but combobox also use it to open, close drop down
|
||||
// at the moment, idempiere shortcut is more useful, so just get it work
|
||||
} else {
|
||||
this.$doKeyDown_(evt);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
|
@ -3,7 +3,7 @@ if (typeof window.idempiere === 'undefined')
|
|||
|
||||
window.idempiere.scrollToRow = function(uuid){
|
||||
try {
|
||||
var cmp = zk.Widget.$(uuid);
|
||||
let cmp = zk.Widget.$(uuid);
|
||||
if (cmp) {
|
||||
cmp.scrollIntoView();
|
||||
cmp.focus();
|
||||
|
@ -16,9 +16,9 @@ window.idempiere.scrollToRow = function(uuid){
|
|||
//overload for recalculate width of grid frozen scroll
|
||||
//base on _onSizeLater(wgt) from Frozen.js
|
||||
window.idempiere.syncScrollFrozen = function(wgt){
|
||||
var parent = wgt.parent;
|
||||
let parent = wgt.parent;
|
||||
if (parent.eheadtbl && parent._nativebar) {
|
||||
var cells = parent._getFirstRowCells(parent.eheadrows),
|
||||
let cells = parent._getFirstRowCells(parent.eheadrows),
|
||||
head = parent.head,
|
||||
totalcols = cells.length - jq(head).find(head.$n('bar')).length,
|
||||
columns = wgt._columns,
|
||||
|
@ -30,8 +30,8 @@ window.idempiere.syncScrollFrozen = function(wgt){
|
|||
return;
|
||||
}
|
||||
|
||||
for (var i = columns; i < totalcols; i++) {
|
||||
var n = cells[i],
|
||||
for (let i = columns; i < totalcols; i++) {
|
||||
let n = cells[i],
|
||||
hdWgt = zk.Widget.$(n),
|
||||
isVisible = hdWgt && hdWgt.isVisible();
|
||||
if (!isVisible)
|
||||
|
@ -44,24 +44,24 @@ window.idempiere.syncScrollFrozen = function(wgt){
|
|||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < columns; i++)
|
||||
for (let i = 0; i < columns; i++)
|
||||
leftWidth += cells[i].offsetWidth;
|
||||
|
||||
parent._deleteFakeRow(parent.eheadrows);
|
||||
|
||||
wgt.$n('cave').style.width = jq.px0(leftWidth);
|
||||
var scroll = wgt.$n('scrollX'),
|
||||
let scroll = wgt.$n('scrollX'),
|
||||
width = parent.$n('body').offsetWidth;
|
||||
|
||||
// B70-ZK-2074: Resize forzen's width as meshwidget's body.
|
||||
parent.$n('frozen').style.width = jq.px0(width);
|
||||
width -= leftWidth;
|
||||
scroll.style.width = jq.px0(width);
|
||||
var rightWidth = 0;
|
||||
var toScroll = 0;
|
||||
for (var i = columns; i < cells.length; i++){
|
||||
var hdWgt = zk.Widget.$(cells[i]);
|
||||
var isVisible = hdWgt && hdWgt.isVisible();
|
||||
let rightWidth = 0;
|
||||
let toScroll = 0;
|
||||
for (let i = columns; i < cells.length; i++){
|
||||
let hdWgt = zk.Widget.$(cells[i]);
|
||||
let isVisible = hdWgt && hdWgt.isVisible();
|
||||
if (!isVisible)
|
||||
continue;
|
||||
if (cells[i].offsetWidth==0) {
|
||||
|
@ -74,10 +74,10 @@ window.idempiere.syncScrollFrozen = function(wgt){
|
|||
rightWidth += cells[i].offsetWidth;
|
||||
}
|
||||
}
|
||||
for (var i = columns; i < cells.length; i++){
|
||||
var ow=cells[i].offsetWidth;
|
||||
for (let i = columns; i < cells.length; i++){
|
||||
let ow=cells[i].offsetWidth;
|
||||
if (ow==0) {
|
||||
var hdWgt = zk.Widget.$(cells[i]);
|
||||
let hdWgt = zk.Widget.$(cells[i]);
|
||||
if (hdWgt._origWd && hdWgt._origWd.indexOf('px')>0)
|
||||
ow = parseInt(hdWgt._origWd,10);
|
||||
else if (hdWgt._hflexWidth && hdWgt._hflexWidth > 0)
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
zk.afterLoad('zul.mesh', function() {
|
||||
|
||||
zk.override(zul.mesh.Paging.prototype, "bind_", function() {
|
||||
this.$bind_.apply(this, arguments);
|
||||
if (this._totalSize == 0x7fffffff) {
|
||||
jq(".z-paging-text", this).text(" / ?");
|
||||
}
|
||||
});
|
||||
|
||||
zk.override(zul.mesh.Paging.prototype, "infoText_",
|
||||
function() {
|
||||
//this.$infoText_.apply(this, arguments);
|
||||
let acp = this._activePage,
|
||||
psz = this._pageSize,
|
||||
tsz = this._totalSize,
|
||||
|
||||
lastItem = (acp + 1) * psz,
|
||||
dash = '';
|
||||
|
||||
if ('os' != this.getMold())
|
||||
dash = ' - ' + (lastItem > tsz ? tsz : lastItem);
|
||||
|
||||
if (this._totalSize == 0x7fffffff)
|
||||
tsz = "?";
|
||||
|
||||
return '[ ' + (acp * psz + 1) + dash + ' / ' + tsz + ' ]';
|
||||
});
|
||||
|
||||
let _xFrozen = {};
|
||||
zk.override(zul.mesh.Frozen.prototype, _xFrozen, {
|
||||
_doScrollNow: function() {
|
||||
let result = _xFrozen._doScrollNow.apply(this, arguments);
|
||||
/*Patch: add class to non-visible columns*/
|
||||
let mesh = this.parent;
|
||||
if (mesh.head) {
|
||||
let totalCols = mesh.head.nChildren,
|
||||
hdcol = mesh.ehdfaker.firstChild;
|
||||
|
||||
for (let faker, i = 0; hdcol && i < totalCols; hdcol = hdcol.nextSibling, i++) {
|
||||
if (hdcol.style.width.indexOf('0.001px') != -1 || hdcol.style.width.indexOf('0px') != -1) {
|
||||
jq(zk.$(hdcol).$n()).addClass("hiddencol");
|
||||
} else {
|
||||
jq(zk.$(hdcol).$n()).removeClass("hiddencol");
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
|
||||
zk.override(zul.mesh.MeshWidget.prototype, "clearCache", function() {
|
||||
this.$clearCache();
|
||||
if (this.eheadrows) this.eheadrows = null;
|
||||
if (this.efootrows) this.efootrows = null;
|
||||
});
|
||||
});
|
|
@ -3,38 +3,38 @@ if (typeof window.idempiere === 'undefined')
|
|||
|
||||
window.idempiere.zoom = function(cmpid, column, value){
|
||||
zAu.cmd0.showBusy(null);
|
||||
var widget = zk.Widget.$(cmpid);
|
||||
var event = new zk.Event(widget, 'onZoom', {data: [column, value]}, {toServer: true});
|
||||
let widget = zk.Widget.$(cmpid);
|
||||
let event = new zk.Event(widget, 'onZoom', {data: [column, value]}, {toServer: true});
|
||||
zAu.send(event);
|
||||
};
|
||||
|
||||
window.idempiere.zoomWindow = function(cmpid, column, value, windowuu){
|
||||
zAu.cmd0.showBusy(null);
|
||||
var widget = zk.Widget.$(cmpid);
|
||||
var event = new zk.Event(widget, 'onZoom', {data: [column, value, 'AD_Window_UU', windowuu]}, {toServer: true});
|
||||
let widget = zk.Widget.$(cmpid);
|
||||
let event = new zk.Event(widget, 'onZoom', {data: [column, value, 'AD_Window_UU', windowuu]}, {toServer: true});
|
||||
zAu.send(event);
|
||||
};
|
||||
|
||||
window.idempiere.drillAcross = function(cmpid, column, value){
|
||||
zAu.cmd0.showBusy(null);
|
||||
var widget = zk.Widget.$(cmpid);
|
||||
var event = new zk.Event(widget, 'onDrillAcross', {data: [column, value]}, {toServer: true});
|
||||
let widget = zk.Widget.$(cmpid);
|
||||
let event = new zk.Event(widget, 'onDrillAcross', {data: [column, value]}, {toServer: true});
|
||||
zAu.send(event);
|
||||
};
|
||||
|
||||
window.idempiere.drillDown = function(cmpid, column, value){
|
||||
zAu.cmd0.showBusy(null);
|
||||
var widget = zk.Widget.$(cmpid);
|
||||
var event = new zk.Event(widget, 'onDrillDown', {data: [column, value]}, {toServer: true});
|
||||
let widget = zk.Widget.$(cmpid);
|
||||
let event = new zk.Event(widget, 'onDrillDown', {data: [column, value]}, {toServer: true});
|
||||
zAu.send(event);
|
||||
};
|
||||
|
||||
window.idempiere.showColumnMenu = function(doc, e, columnName, row) {
|
||||
var d = idempiere.getMenu (doc, e.target.getAttribute ("componentId"), e.target.getAttribute ("foreignColumnName"), e.target.getAttribute ("value"));
|
||||
let d = idempiere.getMenu (doc, e.target.getAttribute ("componentId"), e.target.getAttribute ("foreignColumnName"), e.target.getAttribute ("value"));
|
||||
|
||||
var posx = 0;
|
||||
var posy = 0;
|
||||
if (!e) var e = window.event;
|
||||
let posx = 0;
|
||||
let posy = 0;
|
||||
if (!e) e = window.event;
|
||||
if (e.pageX || e.pageY) {
|
||||
posx = e.pageX;
|
||||
posy = e.pageY;
|
||||
|
@ -50,7 +50,7 @@ window.idempiere.showColumnMenu = function(doc, e, columnName, row) {
|
|||
d.style.left = posx;
|
||||
d.style.display = "block";
|
||||
|
||||
var f = function() {
|
||||
let f = function() {
|
||||
doc.contextMenu.style.display='none'
|
||||
};
|
||||
setTimeout(f, 3000);
|
||||
|
@ -60,7 +60,7 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
|
|||
doc.contextMenu = null;
|
||||
if (componentId != null){
|
||||
//menu div
|
||||
var menu = doc.createElement("div");
|
||||
let menu = doc.createElement("div");
|
||||
menu.style.position = "absolute";
|
||||
menu.style.display = "none";
|
||||
menu.style.top = "0";
|
||||
|
@ -70,13 +70,13 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
|
|||
menu.style.backgroundColor = "white";
|
||||
|
||||
//window menu item
|
||||
var windowMenu = doc.createElement("div");
|
||||
let windowMenu = doc.createElement("div");
|
||||
windowMenu.style.padding = "3px";
|
||||
windowMenu.style.verticalAlign = "middle";
|
||||
windowMenu.setAttribute("onmouseover", "this.style.backgroundColor = 'lightgray'");
|
||||
windowMenu.setAttribute("onmouseout", "this.style.backgroundColor = 'white'");
|
||||
|
||||
var href = doc.createElement("a");
|
||||
let href = doc.createElement("a");
|
||||
href.style.fontSize = "11px";
|
||||
href.style.textDecoration = "none";
|
||||
href.style.verticalAlign = "middle";
|
||||
|
@ -86,9 +86,9 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
|
|||
windowMenu.appendChild(href);
|
||||
menu.appendChild(windowMenu);
|
||||
|
||||
var windowIco = doc.body.getAttribute ("windowIco");
|
||||
let windowIco = doc.body.getAttribute ("windowIco");
|
||||
if (typeof windowIco === 'string' && windowIco.length > 0) {
|
||||
var image = doc.createElement("img");
|
||||
let image = doc.createElement("img");
|
||||
image.src = windowIco;
|
||||
image.setAttribute("align", "middle");
|
||||
href.appendChild(image);
|
||||
|
@ -96,14 +96,14 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
|
|||
href.appendChild(doc.createTextNode(doc.body.getAttribute ("windowLabel")));
|
||||
|
||||
//report menu item
|
||||
var report = doc.createElement("div");
|
||||
let report = doc.createElement("div");
|
||||
report.style.padding = "3px";
|
||||
report.style.verticalAlign = "middle";
|
||||
|
||||
report.setAttribute("onmouseover", "this.style.backgroundColor = 'lightgray'");
|
||||
report.setAttribute("onmouseout", "this.style.backgroundColor = 'white'");
|
||||
|
||||
var reportHref = doc.createElement("a");
|
||||
let reportHref = doc.createElement("a");
|
||||
reportHref.href = "javascript:void(0)";
|
||||
reportHref.style.textDecoration = "none";
|
||||
reportHref.style.fontSize = "11px";
|
||||
|
@ -112,9 +112,9 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
|
|||
|
||||
report.appendChild(reportHref);
|
||||
menu.appendChild(report);
|
||||
var reportIco = doc.body.getAttribute ("reportIco");
|
||||
let reportIco = doc.body.getAttribute ("reportIco");
|
||||
if (typeof reportIco === 'string' && reportIco.length > 0) {
|
||||
var reportimage = doc.createElement("img");
|
||||
let reportimage = doc.createElement("img");
|
||||
reportimage.src = reportIco;
|
||||
reportimage.setAttribute("align", "middle");
|
||||
reportHref.appendChild(reportimage);
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
zk.afterLoad("zul.sel", function () {
|
||||
var _tWgt = {},
|
||||
let _tWgt = {},
|
||||
_tiWgt = {};
|
||||
zk.override(zul.sel.Treerow.prototype, _tiWgt, {
|
||||
getDragOptions_: function (map) {
|
||||
var copy = map.constructor(),
|
||||
let copy = map.constructor(),
|
||||
wgt = this;
|
||||
// clone map
|
||||
for (var attr in map) {
|
||||
for (let attr in map) {
|
||||
if (map.hasOwnProperty(attr)) copy[attr] = map[attr];
|
||||
}
|
||||
// change functions as needed
|
||||
var oldChange = copy.change,
|
||||
let oldChange = copy.change,
|
||||
oldEnd = copy.endeffect;
|
||||
copy.change = function (drag, pt, evt) {
|
||||
var tree = wgt.getTree();
|
||||
let tree = wgt.getTree();
|
||||
oldChange(drag, pt, evt);
|
||||
tree.triggerAutoScroll(evt.pageX, evt.pageY);
|
||||
};
|
||||
copy.endeffect = function (drag, evt) {
|
||||
var tree = wgt.getTree();
|
||||
let tree = wgt.getTree();
|
||||
oldEnd(drag, evt);
|
||||
tree.stopAutoScroll();
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ zk.afterLoad("zul.sel", function () {
|
|||
speedGap: 50,
|
||||
speedGapCounter: 0,
|
||||
triggerAutoScroll: function (x, y) {
|
||||
var $n = jq(this.$n()),
|
||||
let $n = jq(this.$n()),
|
||||
offset = $n.offset(),
|
||||
top = offset.top + (this.$n('head')? 10 : 0),
|
||||
bottom = $n.outerHeight(true);
|
||||
|
@ -52,7 +52,7 @@ zk.afterLoad("zul.sel", function () {
|
|||
this.clearScrollToBottomTimer();
|
||||
},
|
||||
startScrollToTop: function (y) {
|
||||
var wgt = this;
|
||||
let wgt = this;
|
||||
this.clearScrollToBottomTimer();
|
||||
if (!this._scrollToTopTimer) {
|
||||
this.scrollDelay = this.initialScrollDelay;
|
||||
|
@ -84,7 +84,7 @@ zk.afterLoad("zul.sel", function () {
|
|||
}
|
||||
},
|
||||
startScrollToBottom: function (y) {
|
||||
var wgt = this;
|
||||
let wgt = this;
|
||||
this.clearScrollToTopTimer();
|
||||
if (!this._scrollToBottomTimer) {
|
||||
this.scrollDelay = this.initialScrollDelay;
|
||||
|
@ -116,13 +116,13 @@ zk.afterLoad("zul.sel", function () {
|
|||
}
|
||||
},
|
||||
clearScrollToTopTimer: function () {
|
||||
var timer = this._scrollToTopTimer;
|
||||
let timer = this._scrollToTopTimer;
|
||||
if (timer)
|
||||
clearInterval(timer);
|
||||
this._scrollToTopTimer = null;
|
||||
},
|
||||
clearScrollToBottomTimer: function () {
|
||||
var timer = this._scrollToBottomTimer;
|
||||
let timer = this._scrollToBottomTimer;
|
||||
if (timer)
|
||||
clearInterval(timer);
|
||||
this._scrollToBottomTimer = null;
|
||||
|
|
|
@ -2,19 +2,19 @@ if (typeof window.idempiere === 'undefined')
|
|||
window.idempiere = {};
|
||||
|
||||
window.idempiere.show_popup_window = function(refid, windowid, position) {
|
||||
var ref = zk.Widget.$(refid);
|
||||
var window = zk(windowid);
|
||||
let ref = zk.Widget.$(refid);
|
||||
let window = zk(windowid);
|
||||
window.position(ref.$n(), position);
|
||||
};
|
||||
|
||||
zk.override(zk.Widget.prototype, "canActivate",
|
||||
function () {
|
||||
var b = this.$canActivate.apply(this, arguments);
|
||||
let b = this.$canActivate.apply(this, arguments);
|
||||
if (b) {
|
||||
if (zk.currentModal) {
|
||||
return true;
|
||||
}
|
||||
var wgt = this;
|
||||
let wgt = this;
|
||||
while (wgt) {
|
||||
if (wgt.busy) {
|
||||
if (wgt.busy.className) {
|
||||
|
|
|
@ -5,4 +5,7 @@
|
|||
<script src="report.js" />
|
||||
<script src="window.js" />
|
||||
<script src="tree.js" />
|
||||
<script src="mesh.js" />
|
||||
<script src="input.js" />
|
||||
<script src="calendar.js" />
|
||||
</package>
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
(function() {
|
||||
org.idempiere.websocket.startServerPush = function(dtid) {
|
||||
var dt = zk.Desktop.$(dtid);
|
||||
let dt = zk.Desktop.$(dtid);
|
||||
if (dt._serverpush && dt._serverpush.socket) {
|
||||
if (dt._serverpush._reconnectId) {
|
||||
return;
|
||||
}
|
||||
dt._serverpush.restart();
|
||||
} else {
|
||||
var spush = new org.idempiere.websocket.ServerPush(dtid);
|
||||
let spush = new org.idempiere.websocket.ServerPush(dtid);
|
||||
spush.start();
|
||||
}
|
||||
};
|
||||
org.idempiere.websocket.stopServerPush = function(dtid) {
|
||||
var dt = zk.Desktop.$(dtid);
|
||||
let dt = zk.Desktop.$(dtid);
|
||||
if (dt._serverpush)
|
||||
dt._serverpush.stop();
|
||||
};
|
||||
|
@ -22,26 +22,26 @@
|
|||
this.socket = null;
|
||||
this.active = false;
|
||||
this.reconnect = false;
|
||||
var desktop = zk.Desktop.$(this.dtid);
|
||||
let desktop = zk.Desktop.$(this.dtid);
|
||||
desktop._serverpush = this;
|
||||
},
|
||||
start: function() {
|
||||
var desktop = zk.Desktop.$(this.dtid);
|
||||
let desktop = zk.Desktop.$(this.dtid);
|
||||
if (typeof desktop === 'undefined')
|
||||
return;
|
||||
this.reconnect = false;
|
||||
this._reconnectId = null;
|
||||
var url = window.location.protocol == "http:" ? "ws://" : "wss://";
|
||||
var path = window.location.href.substring(window.location.protocol.length+2);
|
||||
let url = window.location.protocol == "http:" ? "ws://" : "wss://";
|
||||
let path = window.location.href.substring(window.location.protocol.length+2);
|
||||
path = path.substring(location.host.length+1);
|
||||
var last=path.lastIndexOf("/");
|
||||
let last=path.lastIndexOf("/");
|
||||
if (last > 0) {
|
||||
path = "/" + path.substring(0, last) + "/serverpush/";
|
||||
} else {
|
||||
path = "/serverpush/";
|
||||
}
|
||||
url = url + window.location.host + path + desktop.id;
|
||||
var me = this;
|
||||
let me = this;
|
||||
this.socket = new WebSocket(url);
|
||||
this.socket.onopen = function (event) {
|
||||
me.active = true;
|
||||
|
@ -49,7 +49,7 @@
|
|||
};
|
||||
this.socket.onmessage = function (event) {
|
||||
if (event.data=="echo") {
|
||||
var desktop = zk.Desktop.$(me.dtid);
|
||||
let desktop = zk.Desktop.$(me.dtid);
|
||||
zAu.cmd0.echo(desktop);
|
||||
} else if (event.data=="stop") {
|
||||
me.stop();
|
||||
|
@ -69,7 +69,7 @@
|
|||
},
|
||||
stop: function() {
|
||||
this.active = false;
|
||||
var desktop = zk.Desktop.$(this.dtid);
|
||||
let desktop = zk.Desktop.$(this.dtid);
|
||||
desktop._serverpush = null;
|
||||
if (this.socket) {
|
||||
try {
|
||||
|
|
|
@ -35,224 +35,6 @@ if (window.location.protocol == 'https:') {
|
|||
zk._Erbx.push = function(msg) {
|
||||
if (console) console.log(msg);
|
||||
};
|
||||
|
||||
zk.$package('id.zk');
|
||||
|
||||
id.zk.Extend = zk.$extends(zk.Object, {}, {
|
||||
fakeOnchange: function(wgt) {
|
||||
// just sent fake event when control is textfield and value is not yet sync to server
|
||||
if ((wgt.$instanceof(zul.inp.Textbox) || wgt.$instanceof(zul.inp.Decimalbox)) && wgt.$n().value != wgt.getText())
|
||||
zAu.send(new zk.Event(zk.Widget.$(wgt), 'onChange', {
|
||||
"value": wgt.$n().value
|
||||
}));
|
||||
|
||||
else if (zk.$import("ckez.CKeditor") != undefined && wgt.$instanceof(ckez.CKeditor)) { //https://www.zkoss.org/javadoc/latest/jsdoc/_global_/zk.html#$import(_global_.String)
|
||||
// CKEditor extend from zul.Widget not from wget zul.inp.InputWidget
|
||||
// so some behavior is not same standard input
|
||||
// this code bring from ckez.CKeditor.onBlur
|
||||
var editor = wgt._editor;
|
||||
|
||||
if (wgt._tidChg) {
|
||||
clearInterval(wgt._tidChg);
|
||||
wgt._tidChg = null;
|
||||
}
|
||||
|
||||
if (!editor.document)
|
||||
editor.document = editor.element.getDocument();
|
||||
|
||||
if (wgt.$class._checkEditorDirty(editor)) { // Issue #13
|
||||
var val = editor.getData();
|
||||
wgt._value = val; //save for onRestore
|
||||
//ZKCK-16, 17 use sendAhead to make sure onChange always happens first
|
||||
wgt.fire('onChange', {
|
||||
value: val
|
||||
});
|
||||
editor.resetDirty();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
fireOnInitEdit: function(wgt) {
|
||||
// sent even to indicate field is start edit, this event sent new value to server but now don't use this data.
|
||||
if (wgt.$instanceof(zul.inp.Textbox))
|
||||
zAu.send(new zk.Event(zk.Widget.$(wgt), 'onInitEdit', {
|
||||
"value": wgt.$n().value
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
zk.afterLoad('zul.inp', function() {
|
||||
|
||||
// should filter out for only component inside standard window or component wish fire this event,
|
||||
// or ever rise other event like start editting to distinguish with true onChange event
|
||||
zk.override(zul.inp.InputWidget.prototype, "doInput_", function(evt) {
|
||||
this.$doInput_(evt);
|
||||
|
||||
if (this.get("isOnStardardWindow") == 'false' || this.get("isChangeEventWhenEditing") != true) {
|
||||
return; // don't waste time to check component don't lay on standard window
|
||||
}
|
||||
|
||||
var domElemOfLayout = jq('#' + this.$n().id).closest(".adwindow-layout"); // return a array
|
||||
if (domElemOfLayout.length == 0) {
|
||||
this.set("isOnStardardWindow", "false"); // next time don't waste time to check this component
|
||||
// in case, you move this component to a standard window, please update this properties at client by javascript Widget.set ()
|
||||
// or at server by java function component.setWidgetOverride
|
||||
} else {
|
||||
var winLayoutWg = zk.Widget.$(domElemOfLayout);
|
||||
if (winLayoutWg == null) {
|
||||
; // do nothing, this case rare happen because ".adwindow-layout" always is a component
|
||||
} else {
|
||||
var isEditting = winLayoutWg.get("isEditting");
|
||||
// winLayoutWg should cache to improve perfomance
|
||||
if (isEditting == "false") {
|
||||
winLayoutWg.set("isEditting", "true");
|
||||
id.zk.Extend.fireOnInitEdit(this); //fire change event to move to edit
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
zk.override(zk.Widget.prototype, "onAutofill", function(evt) {
|
||||
id.zk.Extend.fakeOnchange(this); //fire change event to move to edit
|
||||
});
|
||||
|
||||
zk.override(zul.inp.Textbox.prototype, "bind_", function(dt, skipper, after) {
|
||||
if (!this.$bind_)
|
||||
return;
|
||||
|
||||
this.$bind_(dt, skipper, after);
|
||||
|
||||
var txtid = this.getId()
|
||||
if (txtid != "txtUserId" && txtid != "txtPassword") {
|
||||
return;
|
||||
}
|
||||
|
||||
this.domListen_(this.$n(), "onChange", "onAutofill");
|
||||
});
|
||||
|
||||
zk.override(zul.inp.Textbox.prototype, "unbind_", function(dt, skipper) {
|
||||
if (!this.$unbind_)
|
||||
return;
|
||||
|
||||
this.$unbind_(dt, skipper);
|
||||
|
||||
var txtid = this.getId()
|
||||
if (txtid != "txtUserId" && txtid != "txtPassword") {
|
||||
return;
|
||||
}
|
||||
|
||||
this.domUnlisten_(this.$n(), "onChange", "onAutofill"); //unlisten
|
||||
});
|
||||
|
||||
zk.override(zul.inp.Combobox.prototype, "doKeyDown_", function(evt) {
|
||||
// avoid confuse of idempiere shortcut key and function key of combobox
|
||||
if ((evt.altKey || evt.ctrlKey || evt.shiftKey) &&
|
||||
(evt.keyCode == 33 || evt.keyCode == 34 || evt.keyCode == 35 || evt.keyCode == 36 || evt.keyCode == 38 || evt.keyCode == 40 || evt.keyCode == 37 || evt.keyCode == 39)) { //page up | page down | end | home | up | down | left | write
|
||||
|
||||
if (this.isOpen()) //close drop down if already open. it will let combobox select current item, it's consistent with lost focus
|
||||
this.close({
|
||||
sendOnOpen: true
|
||||
});
|
||||
|
||||
return;
|
||||
// TODO:current idempiere use alt + down/up to move child parrent tab, but combobox also use it to open, close drop down
|
||||
// at the moment, idempiere shortcut is more useful, so just get it work
|
||||
} else {
|
||||
this.$doKeyDown_(evt);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
zk.afterLoad('zul.mesh', function() {
|
||||
|
||||
zk.override(zul.mesh.Paging.prototype, "bind_", function() {
|
||||
this.$bind_.apply(this, arguments);
|
||||
if (this._totalSize == 0x7fffffff) {
|
||||
jq(".z-paging-text", this).text(" / ?");
|
||||
}
|
||||
});
|
||||
|
||||
zk.override(zul.mesh.Paging.prototype, "infoText_",
|
||||
function() {
|
||||
//this.$infoText_.apply(this, arguments);
|
||||
var acp = this._activePage,
|
||||
psz = this._pageSize,
|
||||
tsz = this._totalSize,
|
||||
|
||||
lastItem = (acp + 1) * psz,
|
||||
dash = '';
|
||||
|
||||
if ('os' != this.getMold())
|
||||
dash = ' - ' + (lastItem > tsz ? tsz : lastItem);
|
||||
|
||||
if (this._totalSize == 0x7fffffff)
|
||||
tsz = "?";
|
||||
|
||||
return '[ ' + (acp * psz + 1) + dash + ' / ' + tsz + ' ]';
|
||||
});
|
||||
});
|
||||
|
||||
zk.afterLoad('calendar', function() {
|
||||
zk.override(calendar.Event.prototype, "calculate_", function() {
|
||||
if (typeof this.event === "undefined" || this.event == null) {
|
||||
return;
|
||||
}
|
||||
this.$calculate_.apply(this, arguments);
|
||||
});
|
||||
|
||||
zk.override(calendar.Event.prototype, "unbind_", function() {
|
||||
var node = this.$n();
|
||||
if (typeof node === "undefined") {
|
||||
return;
|
||||
}
|
||||
if (typeof this.$unbind_ === "undefined") {
|
||||
return;
|
||||
}
|
||||
this.$unbind_.apply(this, arguments);
|
||||
});
|
||||
|
||||
zk.override(calendar.CalendarsMonth.prototype, "onSize", function() {
|
||||
var cmp = this.$n();
|
||||
if (typeof cmp === "undefined" || cmp == null) {
|
||||
return;
|
||||
}
|
||||
this.$onSize.apply(this, arguments);
|
||||
});
|
||||
|
||||
zk.override(calendar.CalendarsDefault.prototype, "onSize", function() {
|
||||
var cmp = this.$n();
|
||||
if (typeof cmp === "undefined" || cmp == null) {
|
||||
return;
|
||||
}
|
||||
this.$onSize.apply(this, arguments);
|
||||
});
|
||||
});
|
||||
|
||||
zk.afterLoad("zul.mesh", function() {
|
||||
var _xFrozen = {};
|
||||
zk.override(zul.mesh.Frozen.prototype, _xFrozen, {
|
||||
_doScrollNow: function() {
|
||||
var result = _xFrozen._doScrollNow.apply(this, arguments);
|
||||
/*Patch: add class to non-visible columns*/
|
||||
var mesh = this.parent;
|
||||
if (mesh.head) {
|
||||
var totalCols = mesh.head.nChildren,
|
||||
hdcol = mesh.ehdfaker.firstChild;
|
||||
|
||||
for (var faker, i = 0; hdcol && i < totalCols; hdcol = hdcol.nextSibling, i++) {
|
||||
if (hdcol.style.width.indexOf('0.001px') != -1 || hdcol.style.width.indexOf('0px') != -1) {
|
||||
jq(zk.$(hdcol).$n()).addClass("hiddencol");
|
||||
} else {
|
||||
jq(zk.$(hdcol).$n()).removeClass("hiddencol");
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
} //window.location.protocol check
|
||||
|
|
Loading…
Reference in New Issue