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:
hengsin 2022-05-13 17:20:46 +08:00 committed by GitHub
parent a5247574c5
commit 895923f7f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 531 additions and 504 deletions

View File

@ -44,14 +44,14 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
</mold> </mold>
</component> </component>
<javascript-module name="org.idempiere.websocket" version="202011211500"/> <javascript-module name="org.idempiere.websocket" version="202205100600"/>
<javascript-module name="jawwa.atmosphere" version="202110220730"/> <javascript-module name="jawwa.atmosphere" version="202205100600"/>
<javascript-module name="adempiere.local.storage" version="202011151100"/> <javascript-module name="adempiere.local.storage" version="202205100600"/>
<javascript-moudle name="html2canvas" version="1.3.1"/> <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="jquery.maskedinput" version="1.4.1" />
<javascript-module name="photobooth" version="0.7-rsd3" /> <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"/> <javascript-module name="zkforge.keylistener" version="202012120100"/>
<!-- this js module doesn't actually exists and it is here for default theme version --> <!-- this js module doesn't actually exists and it is here for default theme version -->

View File

@ -324,9 +324,10 @@ public final class LayoutUtils {
mask.showMask(); mask.showMask();
mask.getMaskComponent().appendChild(window); 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(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())); Clients.response(new AuScript(script.toString()));
LayoutUtils.openOverlappedWindow(mask.getMaskComponent(), window, "middle_center"); LayoutUtils.openOverlappedWindow(mask.getMaskComponent(), window, "middle_center");
@ -536,10 +537,11 @@ public final class LayoutUtils {
*/ */
public static void sameWidth(HtmlBasedComponent target, HtmlBasedComponent ref) { public static void sameWidth(HtmlBasedComponent target, HtmlBasedComponent ref) {
StringBuilder script = new StringBuilder() StringBuilder script = new StringBuilder()
.append("var t=zk.Widget.$('#").append(target.getUuid()).append("');") .append("(function(){let t=zk.Widget.$('#").append(target.getUuid()).append("');")
.append("var r=zk.Widget.$('#").append(ref.getUuid()).append("');") .append("let r=zk.Widget.$('#").append(ref.getUuid()).append("');")
.append("jq(t).css({'width':").append("jq(r).width()+'px'});") .append("jq(t).css({'width':").append("jq(r).width()+'px'});")
.append("t.setWidth(\"").append("jq(r).width()+'px'\");"); .append("t.setWidth(\"").append("jq(r).width()+'px'\");");
script.append("})()");
Clients.response("_sameWidth_", new AuScript(target, script.toString())); Clients.response("_sameWidth_", new AuScript(target, script.toString()));
} }
} }

View File

@ -78,9 +78,10 @@ public class ShowMaskWrapper implements ISupportMask {
Component p = maskObj.getParent(); Component p = maskObj.getParent();
maskObj.detach(); maskObj.detach();
if (p == comp) { 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(p.getUuid()).append("');");
script.append("w.busy=null;"); script.append("w.busy=null;");
script.append("})()");
Clients.response(new AuScript(script.toString())); Clients.response(new AuScript(script.toString()));
} }
} }

View File

@ -316,27 +316,28 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
private void setupFormSwipeListener() { private void setupFormSwipeListener() {
String uuid = form.getUuid(); String uuid = form.getUuid();
StringBuilder script = new StringBuilder("var w=zk.Widget.$('") StringBuilder script = new StringBuilder("(function(){let w=zk.Widget.$('")
.append(uuid) .append(uuid)
.append("');"); .append("');");
script.append("jq(w).on('touchstart', function(e) {var w=zk.Widget.$(this);w._touchstart=e;});"); script.append("jq(w).on('touchstart', function(e) {let 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('touchmove', function(e) {let 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('touchend', function(e) {let w=zk.Widget.$(this);let ts = w._touchstart; let tl = w._touchmove;"
+ "w._touchstart=null;w._touchmove=null;" + "w._touchstart=null;w._touchmove=null;"
+ "if (ts && tl) {" + "if (ts && tl) {"
+ "if (ts.originalEvent) ts = ts.originalEvent;" + "if (ts.originalEvent) ts = ts.originalEvent;"
+ "if (tl.originalEvent) tl = tl.originalEvent;" + "if (tl.originalEvent) tl = tl.originalEvent;"
+ "if (ts.changedTouches && ts.changedTouches.length==1 && tl.changedTouches && tl.changedTouches.length==1) {" + "if (ts.changedTouches && ts.changedTouches.length==1 && tl.changedTouches && tl.changedTouches.length==1) {"
+ "var diff=(tl.timeStamp-ts.timeStamp)/1000;if (diff > 1) return;" + "let diff=(tl.timeStamp-ts.timeStamp)/1000;if (diff > 1) return;"
+ "var diffx=tl.changedTouches[0].pageX-ts.changedTouches[0].pageX;" + "let diffx=tl.changedTouches[0].pageX-ts.changedTouches[0].pageX;"
+ "var diffy=tl.changedTouches[0].pageY-ts.changedTouches[0].pageY;" + "let diffy=tl.changedTouches[0].pageY-ts.changedTouches[0].pageY;"
+ "if (Math.abs(diffx) >= 100 && Math.abs(diffy) < 80) {" + "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);} " + "if (diffx > 0) {let 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);}" + "else {let event = new zk.Event(w, 'onSwipeLeft', null, {toServer: true});zAu.send(event);}"
+ "}" + "}"
+ "}" + "}"
+ "}" + "}"
+ "});"); + "});");
script.append("})()");
Clients.response(new AuScript(script.toString())); Clients.response(new AuScript(script.toString()));
} }
@ -2168,11 +2169,12 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer
if (!checkCurrent) { if (!checkCurrent) {
((HtmlBasedComponent)c).focus(); ((HtmlBasedComponent)c).focus();
} else { } else {
StringBuilder script = new StringBuilder("var b=true;try{if (zk.currentFocus) {"); StringBuilder script = new StringBuilder("(function(){let b=true;try{if (zk.currentFocus) {");
script.append("var p=zk.Widget.$('#").append(formContainer.getCenter().getUuid()).append("');"); script.append("let p=zk.Widget.$('#").append(formContainer.getCenter().getUuid()).append("');");
script.append("if (zUtl.isAncestor(p, zk.currentFocus)) {"); script.append("if (zUtl.isAncestor(p, zk.currentFocus)) {");
script.append("b=false;}}}catch(error){}"); 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())); Clients.response(new AuScript(script.toString()));
} }
} }

View File

@ -185,9 +185,9 @@ public class ADWindowContent extends AbstractADWindowContent
* generated serial id * generated serial id
*/ */
private static final long serialVersionUID = 6104341168705201721L; private static final long serialVersionUID = 6104341168705201721L;
private AbstractADWindowContent content; private ADWindowContent content;
protected ADWindowVlayout(AbstractADWindowContent content) { protected ADWindowVlayout(ADWindowContent content) {
super(); super();
this.content = content; this.content = content;
} }
@ -198,6 +198,7 @@ public class ADWindowContent extends AbstractADWindowContent
try { try {
SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, content); SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, content);
} catch (Exception e){} } catch (Exception e){}
content.layout.removeEventListener(WindowContainer.ON_WINDOW_CONTAINER_SELECTION_CHANGED_EVENT, content);
} }
} }

View File

@ -1000,31 +1000,31 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
LayoutUtils.addSclass("mobile", this); LayoutUtils.addSclass("mobile", this);
addEventListener("onOverflowButton", evt -> onOverflowButton(evt)); addEventListener("onOverflowButton", evt -> onOverflowButton(evt));
this.setWidgetOverride("toolbarScrollable", "function (wgt) {\n" + this.setWidgetOverride("toolbarScrollable", "function (wgt) {\n" +
" var total = jq(wgt.$n()).width();\n" + " let total = jq(wgt.$n()).width();\n" +
" var w = wgt.firstChild;\n" + " let w = wgt.firstChild;\n" +
" var a = " + !mobileShowMoreButtons.isEmpty() + ";\n" + " let a = " + !mobileShowMoreButtons.isEmpty() + ";\n" +
"\n" + "\n" +
" // make sure all images are loaded.\n" + " // make sure all images are loaded.\n" +
" if (zUtl.isImageLoading()) {\n" + " if (zUtl.isImageLoading()) {\n" +
" var f = arguments.callee;\n" + " let f = arguments.callee;\n" +
" setTimeout(function () {\n" + " setTimeout(function () {\n" +
" return f(wgt);\n" + " return f(wgt);\n" +
" }, 20);\n" + " }, 20);\n" +
" return;\n" + " return;\n" +
" }\n" + " }\n" +
" for (; w; w = w.nextSibling) {\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 (typeof ow != 'undefined') {total -= ow;}\n" +
" if (total < 0 && w.className == 'zul.wgt.Toolbarbutton') {\n" + " if (total < 0 && w.className == 'zul.wgt.Toolbarbutton') {\n" +
" break;\n" + " break;\n" +
" }\n" + " }\n" +
" }\n" + " }\n" +
" if (w && total < 0) {\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" + " zAu.send(event); \n" +
" }\n" + " }\n" +
" else if (a) {\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" + " zAu.send(event); \n" +
" }\n" + " }\n" +
"}"); "}");
@ -1122,9 +1122,10 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
cnt++; cnt++;
} }
if (overflows.size() >= cnt) { if (overflows.size() >= cnt) {
String script = "var e = jq('#" + getUuid() + "');"; String script = "(function(){let e = jq('#" + getUuid() + "');";
script = script + "var b=zk.Widget.$('#" + overflowPopup.getUuid() + "'); "; script = script + "let b=zk.Widget.$('#" + overflowPopup.getUuid() + "'); ";
script = script + "b.setWidth(e.css('width'));"; script = script + "b.setWidth(e.css('width'));";
script = script + "})()";
Clients.evalJavaScript(script); Clients.evalJavaScript(script);
} else { } else {
overflowPopup.setWidth(null); overflowPopup.setWidth(null);
@ -1187,7 +1188,8 @@ public class ADWindowToolbar extends FToolbar implements EventListener<Event>
public void onPostAfterSize() { public void onPostAfterSize() {
if (this.getPage() != null) { 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); Clients.evalJavaScript(script);
} }
} }

View File

@ -3417,21 +3417,23 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
public void hideBusyMask() { public void hideBusyMask() {
if (mask != null && mask.getParent() != null) { if (mask != null && mask.getParent() != null) {
mask.detach(); 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(getComponent().getParent().getUuid()).append("');if(w) w.busy=false;");
script.append("})()");
Clients.response(new AuScript(script.toString())); Clients.response(new AuScript(script.toString()));
} }
} }
public void showBusyMask(Window window) { public void showBusyMask(Window window) {
getComponent().getParent().appendChild(getMask()); 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("');"); script.append(getComponent().getParent().getUuid()).append("');");
if (window != null) { 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 { } else {
script.append("w.busy=true;"); script.append("w.busy=true;");
} }
script.append("})()");
Clients.response(new AuScript(script.toString())); Clients.response(new AuScript(script.toString()));
} }

View File

@ -207,9 +207,9 @@ public class BreadCrumb extends Div implements EventListener<Event> {
if (linkPopup != null && linkPopup.getPage() != null && linkPopup.isVisible()) { if (linkPopup != null && linkPopup.getPage() != null && linkPopup.isVisible()) {
if (event.getName().equals(Events.ON_MOUSE_OUT)) { if (event.getName().equals(Events.ON_MOUSE_OUT)) {
linkPopup.setAttribute(ON_MOUSE_OUT_ECHO_EVENT, Boolean.TRUE); 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(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(ON_MOUSE_OUT_ECHO_EVENT)
.append("', null, {toServer:true});") .append("', null, {toServer:true});")
.append("zAu.send(e);},500)"); .append("zAu.send(e);},500)");
@ -229,9 +229,9 @@ public class BreadCrumb extends Div implements EventListener<Event> {
if (linkPopup != null && linkPopup.getPage() != null) if (linkPopup != null && linkPopup.getPage() != null)
linkPopup.detach(); linkPopup.detach();
linkPopup = new Menupopup(); 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(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(ON_MOUSE_OVER_ECHO_EVENT)
.append("', null, {toServer:true});") .append("', null, {toServer:true});")
.append("zAu.send(e);},500)"); .append("zAu.send(e);},500)");
@ -258,9 +258,9 @@ public class BreadCrumb extends Div implements EventListener<Event> {
linkPopup.appendChild(item); 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(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(ON_MOUSE_OUT_ECHO_EVENT)
.append("', null, {toServer:true});") .append("', null, {toServer:true});")
.append("zAu.send(e);},500)"); .append("zAu.send(e);},500)");

View File

@ -141,8 +141,8 @@ public class CompositeADTabbox extends AbstractADTabbox
if (!headerTab.isDetailVisible()) { if (!headerTab.isDetailVisible()) {
String uuid = headerTab.getDetailPane().getParent().getUuid(); String uuid = headerTab.getDetailPane().getParent().getUuid();
String vid = getSelectedDetailADTabpanel().getGridView().getUuid(); String vid = getSelectedDetailADTabpanel().getGridView().getUuid();
String script = "setTimeout(function(){zk('#"+uuid+"').$().setOpen(true);setTimeout(function(){var v=zk('#" + vid String script = "setTimeout(function(){zk('#"+uuid+"').$().setOpen(true);setTimeout(function(){let v=zk('#" + vid
+ "').$();var e=new zk.Event(v,'onEditCurrentRow',null,{toServer:true});zAu.send(e);},200);},200)"; + "').$();let e=new zk.Event(v,'onEditCurrentRow',null,{toServer:true});zAu.send(e);},200);},200)";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
} else { } else {
boolean isFormView = headerTab.getDetailPane().getSelectedPanel().isToggleToFormView(); boolean isFormView = headerTab.getDetailPane().getSelectedPanel().isToggleToFormView();

View File

@ -1078,8 +1078,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
if (!btn.isDisabled() && btn.isVisible()) { if (!btn.isDisabled() && btn.isVisible()) {
Events.sendEvent(btn, new Event(Events.ON_CLICK, btn)); Events.sendEvent(btn, new Event(Events.ON_CLICK, btn));
//client side script to close combobox popup //client side script to close combobox popup
String script = "var w=zk.Widget.$('#" + btn.getUuid()+"'); " + String script = "(function(){let w=zk.Widget.$('#" + btn.getUuid()+"'); " +
"zWatch.fire('onFloatUp', w);"; "zWatch.fire('onFloatUp', w);})()";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
} }
} }

View File

@ -170,9 +170,9 @@ public class GlobalSearch extends Div implements EventListener<Event> {
} else if (event.getName().equals(ON_CREATE_ECHO)) { } else if (event.getName().equals(ON_CREATE_ECHO)) {
StringBuilder script = new StringBuilder("jq('#") StringBuilder script = new StringBuilder("jq('#")
.append(bandbox.getUuid()) .append(bandbox.getUuid())
.append("').bind('keydown', function(e) {var code=e.keyCode||e.which;if(code==13){") .append("').bind('keydown', function(e) {let code=e.keyCode||e.which;if(code==13){")
.append("var widget=zk.Widget.$(this);") .append("let widget=zk.Widget.$(this);")
.append("var event=new zk.Event(widget,'") .append("let event=new zk.Event(widget,'")
.append(ON_ENTER_KEY) .append(ON_ENTER_KEY)
.append("',{},{toServer:true});") .append("',{},{toServer:true});")
.append("zAu.send(event);") .append("zAu.send(event);")

View File

@ -296,13 +296,14 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
private void showBusyMask(Window window) { private void showBusyMask(Window window) {
if (getParent() != null) { if (getParent() != null) {
getParent().appendChild(getMask()); 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("');"); script.append(getParent().getUuid()).append("');");
if (window != null) { 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 { } else {
script.append("w.busy=true;"); script.append("w.busy=true;");
} }
script.append("})()");
Clients.response(new AuScript(script.toString())); Clients.response(new AuScript(script.toString()));
} }
} }
@ -311,8 +312,9 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
{ {
if (mask != null && mask.getParent() != null) { if (mask != null && mask.getParent() != null) {
mask.detach(); 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(getParent().getUuid()).append("');w.busy=false;");
script.append("})()");
Clients.response(new AuScript(script.toString())); Clients.response(new AuScript(script.toString()));
} }
} }

View File

@ -235,11 +235,12 @@ public class AddAuthorizationForm extends ADForm {
this.pInstanceId = pInstanceId; this.pInstanceId = pInstanceId;
StringBuilder authScript = new StringBuilder() StringBuilder authScript = new StringBuilder()
.append("var x = window.outerWidth / 2 + window.screenX - (800 / 2);\n") .append("(function(){let x = window.outerWidth / 2 + window.screenX - (800 / 2);\n")
.append("var y = window.outerHeight / 2 + window.screenY - (600 / 2);\n") .append("let 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("let 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("let timer = zk.Widget.$('#").append(timer.getUuid()).append("');\n")
.append("timer.windowRef = authWindow; timer.play();"); .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, // 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. // 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 // 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() StringBuilder timerScript = new StringBuilder()
.append("function sleep (time) {return new Promise((resolve) => setTimeout(resolve, time));}\n") .append("function sleep (time) {return new Promise((resolve) => setTimeout(resolve, time));}\n")
.append("try {\n") .append("try {\n")
.append(" var t = zk.Widget.$('#").append(msgBox.getUuid()).append("');\n") .append(" let t = zk.Widget.$('#").append(msgBox.getUuid()).append("');\n")
.append(" var authWindow = this.windowRef;\n") .append(" let authWindow = this.windowRef;\n")
.append(" if (authWindow && authWindow.closed) {\n") .append(" if (authWindow && authWindow.closed) {\n")
.append(" t.setValue('! ").append(msgError).append(msgFailure).append("'); t.fireOnChange(); \n") // prefix "! " - see onMsgBoxChanged .append(" t.setValue('! ").append(msgError).append(msgFailure).append("'); t.fireOnChange(); \n") // prefix "! " - see onMsgBoxChanged
.append(" this.stop();\n") .append(" this.stop();\n")
@ -260,11 +261,11 @@ public class AddAuthorizationForm extends ADForm {
.append(" if (authWindow && authWindow.location) {\n") .append(" if (authWindow && authWindow.location) {\n")
.append(" if (authWindow.location.href.indexOf('/callback.jsp') >= 0) {\n") .append(" if (authWindow.location.href.indexOf('/callback.jsp') >= 0) {\n")
.append(" this.stop();\n") .append(" this.stop();\n")
.append(" var url = new URL(authWindow.location.href);\n") .append(" let url = new URL(authWindow.location.href);\n")
.append(" var error = url.searchParams.get('error');\n") .append(" let error = url.searchParams.get('error');\n")
.append(" var msg = url.searchParams.get('msg');\n") .append(" let msg = url.searchParams.get('msg');\n")
.append(" if (error) {\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(" t.setValue(msg, false); t.fireOnChange();\n")
.append(" } else if (msg) {\n") .append(" } else if (msg) {\n")
.append(" t.setValue(msg, false); t.fireOnChange();\n") .append(" t.setValue(msg, false); t.fireOnChange();\n")

View File

@ -78,8 +78,9 @@ public class Combobox extends org.zkoss.zul.Combobox implements IdSpace
//ensure list is close and not on focus //ensure list is close and not on focus
if (this.getPage() != null) if (this.getPage() != null)
{ {
String script = "var w=zk('#"+getUuid()+"').$(); if (w){w.close();var j=jq('#" String script = "(function(){let w=zk('#"+getUuid()+"').$(); if (w){w.close();let j=jq('#"
+getUuid()+" :focus');if(j.get(0)){j.blur();}}"; +getUuid()+" :focus');if(j.get(0)){j.blur();}}"
+"})()";
Clients.response(new AuScript(script)); 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) * add widget listener to auto scroll selected item to view (i.e make visible)
*/ */
public void addScrollSelectedIntoViewListener() { 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); setWidgetListener("onKeyUp", script);
} }
} }

View File

@ -107,19 +107,21 @@ public class NumberBox extends Div
decimalBox.setWidgetOverride("doKeyPress_", funct.toString()); decimalBox.setWidgetOverride("doKeyPress_", funct.toString());
funct = new StringBuffer(); funct = new StringBuffer();
// debug // funct.append("console.log('keyCode='+event.keyCode);"); // debug // funct.append("console.log('keyCode='+event.keyCode);");
funct.append("function(event) {");
funct.append("let key=0;");
funct.append("if (window.event)"); funct.append("if (window.event)");
funct.append(" key = event.keyCode;"); funct.append(" key = event.keyCode;");
funct.append("else"); funct.append("else");
funct.append(" key = event.which;"); funct.append(" key = event.which;");
funct.append("if (key == 108 || key == 110 || key == 188 || key == 190 || key == 194) {"); funct.append("if (key == 108 || key == 110 || key == 188 || key == 190 || key == 194) {");
funct.append(" var id = '$'.concat('").append(decimalBox.getId()).append("');"); funct.append(" let id = '$'.concat('").append(decimalBox.getId()).append("');");
funct.append(" var calcText = jq(id)[0];"); funct.append(" let calcText = jq(id)[0];");
funct.append(" var position = calcText.selectionStart;"); funct.append(" let position = calcText.selectionStart;");
funct.append(" var newValue = calcText.value.substring(0, position) + '").append(separator).append("' + calcText.value.substring(position);"); funct.append(" let newValue = calcText.value.substring(0, position) + '").append(separator).append("' + calcText.value.substring(position);");
funct.append(" calcText.value = newValue;"); funct.append(" calcText.value = newValue;");
funct.append(" calcText.setSelectionRange(position+1, position+1);"); funct.append(" calcText.setSelectionRange(position+1, position+1);");
funct.append(" event.stop;"); funct.append(" event.stop;");
funct.append("};"); funct.append("}}");
decimalBox.setWidgetListener("onKeyDown", funct.toString()); decimalBox.setWidgetListener("onKeyDown", funct.toString());
} }

View File

@ -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())); int timeout = MSysConfig.getIntValue(MSysConfig.ZK_DASHBOARD_PERFORMANCE_TIMEOUT, 500, Env.getAD_Client_ID(Env.getCtx()));
Component grid = this.getFirstChild().getFirstChild(); 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 + ");"; script = script + "grid.parent().height(grid.css('height'));}, " + timeout + ");";
if (Executions.getCurrent() != null) if (Executions.getCurrent() != null)
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));

View File

@ -862,8 +862,8 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
} }
//use _docClick undocumented api. need verification after major zk release update //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}');" + private final static String autoHideMenuScript = "(function(){try{let w=zk.Widget.$('#{0}');let t=zk.Widget.$('#{1}');" +
"var e=new Object;e.target=t;w._docClick(e);}catch(error){}"; "let e=new Object;e.target=t;w._docClick(e);}catch(error){}})()";
private void autoHideMenu() { private void autoHideMenu() {
if (mobile) { if (mobile) {
@ -1063,8 +1063,8 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
super.onMenuSelected(menuId); super.onMenuSelected(menuId);
if (showHeader != null && showHeader.isVisible()) { if (showHeader != null && showHeader.isVisible()) {
//ensure header popup is close //ensure header popup is close
String script = "var w=zk.Widget.$('#" + layout.getUuid()+"'); " + String script = "(function(){let w=zk.Widget.$('#" + layout.getUuid()+"'); " +
"zWatch.fire('onFloatUp', w);"; "zWatch.fire('onFloatUp', w);})()";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
} }
} }

View File

@ -153,7 +153,7 @@ public class WAccountEditor extends WEditor implements ContextMenuListener
//safety check: if focus is going no where, focus back to self //safety check: if focus is going no where, focus back to self
String uid = getComponent().getTextbox().getUuid(); 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);"; "').$n(); if (jq(':focus').size() == 0) e.focus();} catch(error){}}, 100);";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
} }

View File

@ -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 public void openColorPicker() { // TODO color picker is opening at upper left ; better to open it at center of screen
String uid = colorbox.getUuid(); 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)); Clients.response(new AuScript(script));
} }

View File

@ -486,7 +486,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
//safety check: if focus is going no where, focus back to self //safety check: if focus is going no where, focus back to self
String uid = getComponent().getCombobox().getUuid(); 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);"; "').$n(); if (jq(':focus').size() == 0) e.focus();} catch(error){}}, 100);";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
@ -886,7 +886,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
public void onPageAttached(Page newpage, Page oldpage) { public void onPageAttached(Page newpage, Page oldpage) {
super.onPageAttached(newpage, oldpage); super.onPageAttached(newpage, oldpage);
if (newpage != null) { 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()) { if (ThemeManager.isUseFontIconForImage()) {
String sclass = "z-icon-spinner z-icon-spin"; String sclass = "z-icon-spinner z-icon-spin";
getCombobox().setWidgetListener("onChange", "try{"+w+"btn.setIconSclass('" + sclass + "');" getCombobox().setWidgetListener("onChange", "try{"+w+"btn.setIconSclass('" + sclass + "');"

View File

@ -74,8 +74,8 @@ public class DefaultFeedbackService implements IFeedbackService {
String script = "html2canvas(document.body).then(canvas => " + String script = "html2canvas(document.body).then(canvas => " +
"{ const dataUrl = canvas.toDataURL();" + "{ const dataUrl = canvas.toDataURL();" +
" var widget = zk.Widget.$('#" + SessionManager.getAppDesktop().getComponent().getUuid()+"');"+ " let widget = zk.Widget.$('#" + SessionManager.getAppDesktop().getComponent().getUuid()+"');"+
" var event = new zk.Event(widget, 'onEmailSupport', dataUrl, {toServer: true});" + " let event = new zk.Event(widget, 'onEmailSupport', dataUrl, {toServer: true});" +
" zAu.send(event);" + " zAu.send(event);" +
"});"; "});";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
@ -151,9 +151,9 @@ public class DefaultFeedbackService implements IFeedbackService {
SessionManager.getAppDesktop().getComponent().addEventListener("onCreateFeedbackRequest", this); SessionManager.getAppDesktop().getComponent().addEventListener("onCreateFeedbackRequest", this);
String script = "html2canvas(document.body).then(canvas => " + String script = "html2canvas(document.body).then(canvas => " +
"{ var dataUrl = canvas.toDataURL();" + "{ let dataUrl = canvas.toDataURL();" +
" var widget = zk.Widget.$('#" + SessionManager.getAppDesktop().getComponent().getUuid()+"');"+ " let widget = zk.Widget.$('#" + SessionManager.getAppDesktop().getComponent().getUuid()+"');"+
" var event = new zk.Event(widget, 'onCreateFeedbackRequest', dataUrl, {toServer: true});" + " let event = new zk.Event(widget, 'onCreateFeedbackRequest', dataUrl, {toServer: true});" +
" zAu.send(event); " + " zAu.send(event); " +
"});"; "});";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));

View File

@ -135,7 +135,7 @@ public class HelpController
content.appendChild(htmlToolTip = new Html()); content.appendChild(htmlToolTip = new Html());
htmlToolTip.setWidgetOverride("defaultMessage", "'"+Msg.getMsg(Env.getCtx(), "PlaceCursorIntoField")+"'"); htmlToolTip.setWidgetOverride("defaultMessage", "'"+Msg.getMsg(Env.getCtx(), "PlaceCursorIntoField")+"'");
htmlToolTip.setWidgetOverride("onFieldTooltip", "function(origin,opts,header,description,help)" + 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>';} " + "if (typeof header == 'undefined') {s=s+'<i>'+this.defaultMessage+'</i>';} " +
"else {s=s+'<b>'+header+'</b>';" + "else {s=s+'<b>'+header+'</b>';" +
"if (typeof description=='string' && description.length > 0) {s=s+'<br><br><i>'+description+'</i>';}" + "if (typeof description=='string' && description.length > 0) {s=s+'<br><br><i>'+description+'</i>';}" +
@ -161,7 +161,9 @@ public class HelpController
} }
public void setupFieldTooltip() { 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});})()"));
} }
/** /**

View File

@ -260,17 +260,17 @@ public class StatusBarPanel extends Panel implements EventListener<Event>, IStat
popup.setStyle(popupStyle); popup.setStyle(popupStyle);
if (getRoot() == null || !getRoot().isVisible() ) return; 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 += "d.style.display='block';d.style.visibility='hidden';";
script += "var dhs = document.defaultView.getComputedStyle(d, null).getPropertyValue('height');"; script += "let dhs = document.defaultView.getComputedStyle(d, null).getPropertyValue('height');";
script += "var dh = parseInt(dhs, 10);"; script += "let dh = parseInt(dhs, 10);";
script += "var r = zk.Widget.$('" + getRoot().getUuid() + "').$n();"; script += "let r = zk.Widget.$('" + getRoot().getUuid() + "').$n();";
script += "var rhs = document.defaultView.getComputedStyle(r, null).getPropertyValue('height');"; script += "let rhs = document.defaultView.getComputedStyle(r, null).getPropertyValue('height');";
script += "var rh = parseInt(rhs, 10);"; script += "let rh = parseInt(rhs, 10);";
script += "var p = jq('#"+getRoot().getUuid()+"').zk.cmOffset();"; script += "let p = jq('#"+getRoot().getUuid()+"').zk.cmOffset();";
script += "d.style.top=(rh-dh-5)+'px';"; script += "d.style.top=(rh-dh-5)+'px';";
script += "d.style.left=(p[0]+1)+'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); AuScript aus = new AuScript(popup, script);
Clients.response(aus); Clients.response(aus);

View File

@ -137,12 +137,12 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
init(); init();
} }
private static final String onComboSelectEchoScript = "var combo=zk('@combo').$();" private static final String onComboSelectEchoScript = "(function(){let combo=zk('@combo').$();"
+ "var panel=zk('@this').$();" + "let panel=zk('@this').$();"
+ "var comboitem=zk('@item').$();" + "let comboitem=zk('@item').$();"
+ "var popupheight=combo.getPopupNode_().offsetHeight;" + "let popupheight=combo.getPopupNode_().offsetHeight;"
+ "var evt = new zk.Event(panel, 'onComboSelectEcho', [comboitem.uuid, popupheight], {toServer: true});" + "let evt = new zk.Event(panel, 'onComboSelectEcho', [comboitem.uuid, popupheight], {toServer: true});"
+ "zAu.send(evt);"; + "zAu.send(evt);})()";
protected void init() protected void init()
{ {
@ -267,9 +267,9 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
tree.getSelectedItem().focus(); tree.getSelectedItem().focus();
}); });
this.insertBefore(moveItemBox, layout); this.insertBefore(moveItemBox, layout);
String script = "var w=zk.Widget.$('#" + moveItemBox.getUuid() + "'); "; String script = "(function(){let w=zk.Widget.$('#" + moveItemBox.getUuid() + "'); ";
script += "var e=jq('#" + layout.getUuid() + "'); "; script += "let e=jq('#" + layout.getUuid() + "'); ";
script += "w.setWidth(e.css('width')); "; script += "w.setWidth(e.css('width'));})() ";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
ti.focus(); ti.focus();
} }

View File

@ -140,7 +140,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
{ {
StringBuilder f = new StringBuilder(); StringBuilder f = new StringBuilder();
f.append("function(way, tb) {\n") 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(" this.$_scrollcheck(way,tb);\n")
.append(" if (tabs && !tabbox.isVertical() && !tabbox.inAccordionMold()) {\n") .append(" if (tabs && !tabbox.isVertical() && !tabbox.inAccordionMold()) {\n")
.append(" this.__offsetWidth=tabs.offsetWidth;this.__scrollLeft=tabs.scrollLeft;\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()); tabs.setWidgetOverride("_scrollcheck", f.toString());
f = new StringBuilder(); f = new StringBuilder();
f.append("function (toSel) {\n") f.append("function (toSel) {\n")
.append(" var tabbox = this.getTabbox();\n") .append(" let tabbox = this.getTabbox();\n")
.append(" var tabs = this.$n();\n") .append(" let tabs = this.$n();\n")
.append(" var tabsOffsetWidth=tabs.offsetWidth;\n") .append(" let tabsOffsetWidth=tabs.offsetWidth;\n")
.append(" this.$_fixWidth(toSel);\n") .append(" this.$_fixWidth(toSel);\n")
.append(" if(this.__selectedTab && this.__selectedTab == tabbox.getSelectedTab() && this.__selectedIndex == tabbox.getSelectedIndex()) {\n") .append(" if(this.__selectedTab && this.__selectedTab == tabbox.getSelectedTab() && this.__selectedIndex == tabbox.getSelectedIndex()) {\n")
.append(" if(tabs.offsetWidth == this.__offsetWidth) {\n") .append(" if(tabs.offsetWidth == this.__offsetWidth) {\n")
@ -170,7 +170,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
f = new StringBuilder(); f = new StringBuilder();
f.append("function (to, move) {\n") f.append("function (to, move) {\n")
.append(" if (move <= 0) return;\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(" switch (to) {\n")
.append(" case 'right':\n") .append(" case 'right':\n")
.append(" self._fixTabsScrollLeft(self._tabsScrollLeft + move);break;") .append(" self._fixTabsScrollLeft(self._tabsScrollLeft + move);break;")
@ -181,7 +181,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
.append(" default:\n") .append(" default:\n")
.append(" self._fixTabsScrollTop(self._tabsScrollTop + move);\n") .append(" self._fixTabsScrollTop(self._tabsScrollTop + move);\n")
.append(" }\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._fixTabsScrollLeft(tabsScrollLeft <= 0 ? 0 : tabsScrollLeft);\n")
.append(" self._fixTabsScrollTop(tabsScrollTop <= 0 ? 0 : tabsScrollTop);\n") .append(" self._fixTabsScrollTop(tabsScrollTop <= 0 ? 0 : tabsScrollTop);\n")
.append("}"); .append("}");
@ -383,6 +383,7 @@ public class WindowContainer extends AbstractUIPart implements EventListener<Eve
public void close() { public void close() {
super.close(); super.close();
popupClose.detach(); popupClose.detach();
popupClose.removeEventListener(Events.ON_OPEN, WindowContainer.this);
} }
@Override @Override

View File

@ -69,15 +69,15 @@ public class ZKUpdateUtil {
} }
public static void setCSSHeight(HtmlBasedComponent component) { public static void setCSSHeight(HtmlBasedComponent component) {
String script = "setTimeout(function() { var e = jq('#" + component.getUuid() + "');"; String script = "setTimeout(function() { let e = jq('#" + component.getUuid() + "');";
script = script + "var b=zk.Widget.$('#" + component.getUuid() + "'); "; script = script + "let b=zk.Widget.$('#" + component.getUuid() + "'); ";
script = script + "b.setHeight(e.css('height')); }, 50 );"; script = script + "b.setHeight(e.css('height')); }, 50 );";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
} }
public static void setCSSWidth(HtmlBasedComponent component) { public static void setCSSWidth(HtmlBasedComponent component) {
String script = "setTimeout(function() { var e = jq('#" + component.getUuid() + "');"; String script = "setTimeout(function() { let e = jq('#" + component.getUuid() + "');";
script = script + "var b=zk.Widget.$('#" + component.getUuid() + "'); "; script = script + "let b=zk.Widget.$('#" + component.getUuid() + "'); ";
script = script + "b.setWidth(e.css('width')); }, 50 );"; script = script + "b.setWidth(e.css('width')); }, 50 );";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
} }

View File

@ -273,10 +273,11 @@ public class WImageDialog extends Window implements EventListener<Event>
cancelCaptureButton.setVisible(true); cancelCaptureButton.setVisible(true);
cancelCaptureButton.setEnabled(true); cancelCaptureButton.setEnabled(true);
mainLayout.setVisible(false); mainLayout.setVisible(false);
String script = "var wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');"; String script = "(function(){let wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');";
script = script + "var cancelBtn=zk.Widget.$('#"+cancelCaptureButton.getUuid()+"');"; script = script + "let cancelBtn=zk.Widget.$('#"+cancelCaptureButton.getUuid()+"');";
script = script + "jq(wgt).photobooth(); "; 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 + "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); Clients.evalJavaScript(script);
} }
else if (e.getName().equals("onCaptureImage")) else if (e.getName().equals("onCaptureImage"))
@ -302,8 +303,8 @@ public class WImageDialog extends Window implements EventListener<Event>
m_mImage.setBinaryData(imageData); m_mImage.setBinaryData(imageData);
fileNameTextbox.setValue(defaultNameForCaptureImage); fileNameTextbox.setValue(defaultNameForCaptureImage);
} }
String script = "var wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');"; String script = "(function(){let wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');";
script = script + "jq(wgt).data( 'photobooth').destroy(); "; script = script + "jq(wgt).data( 'photobooth').destroy();})() ";
Clients.evalJavaScript(script); Clients.evalJavaScript(script);
} }
else if (e.getTarget() == cancelCaptureButton) else if (e.getTarget() == cancelCaptureButton)
@ -311,8 +312,8 @@ public class WImageDialog extends Window implements EventListener<Event>
captureDiv.setVisible(false); captureDiv.setVisible(false);
cancelCaptureButton.setVisible(false); cancelCaptureButton.setVisible(false);
mainLayout.setVisible(true); mainLayout.setVisible(true);
String script = "var wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');"; String script = "(function(){let wgt = zk.Widget.$('#"+captureDiv.getUuid()+"');";
script = script + "jq(wgt).data( 'photobooth').destroy(); "; script = script + "jq(wgt).data( 'photobooth').destroy();})() ";
Clients.evalJavaScript(script); Clients.evalJavaScript(script);
} }
else if (e.getName().equals("onSave")) else if (e.getName().equals("onSave"))

View File

@ -221,8 +221,8 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
text = textBox.getText(); text = textBox.getText();
detach(); detach();
} else { } else {
String script = "var w=zk('#"+editor.getUuid()+"').$();var d=w.getEditor().getData();var t=zk('#" + String script = "(function(){let w=zk('#"+editor.getUuid()+"').$();let d=w.getEditor().getData();let t=zk('#" +
this.getUuid()+"').$();var e=new zk.Event(t,'onEditorCallback',d,{toServer:true});zAu.send(e);"; this.getUuid()+"').$();let e=new zk.Event(t,'onEditorCallback',d,{toServer:true});zAu.send(e);})()";
Clients.response(new AuScript(script)); Clients.response(new AuScript(script));
} }

View File

@ -1691,21 +1691,23 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
private void showBusyMask(Window window) { private void showBusyMask(Window window) {
getParent().appendChild(getMask()); 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("');"); script.append(getParent().getUuid()).append("');");
if (window != null) { 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 { } else {
script.append("w.busy=true;"); script.append("w.busy=true;");
} }
script.append("})()");
Clients.response(new AuScript(script.toString())); Clients.response(new AuScript(script.toString()));
} }
public void hideBusyMask() { public void hideBusyMask() {
if (mask != null && mask.getParent() != null) { if (mask != null && mask.getParent() != null) {
mask.detach(); 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(getParent().getUuid()).append("');w.busy=false;");
script.append("})()");
Clients.response(new AuScript(script.toString())); Clients.response(new AuScript(script.toString()));
} }
} }

View File

@ -812,8 +812,8 @@ public class Chosenbox<T> extends HtmlBasedComponent {
objects, null, null, null, index, 0)); objects, null, null, null, index, 0));
if (selItems.size() < (getSubListModel() != null ? getSubListModel().getSize() : getModel().getSize())) { if (selItems.size() < (getSubListModel() != null ? getSubListModel().getSize() : getModel().getSize())) {
StringBuilder script = new StringBuilder(); StringBuilder script = new StringBuilder();
script.append("var w=zk.Widget.$('#").append(getUuid()).append("');"); script.append("(function(){let w=zk.Widget.$('#").append(getUuid()).append("');");
script.append("w.$n('inp').focus();"); script.append("w.$n('inp').focus();})()");
Executions.schedule(getDesktop(), e -> {setOpen(true);Clients.evalJavaScript(script.toString());}, new Event("onPostSelect")); Executions.schedule(getDesktop(), e -> {setOpen(true);Clients.evalJavaScript(script.toString());}, new Event("onPostSelect"));
} }
_onSelectTimestamp = System.currentTimeMillis(); _onSelectTimestamp = System.currentTimeMillis();

View File

@ -13,7 +13,7 @@
*****************************************************************************/ *****************************************************************************/
window.adempiere = {}; window.adempiere = {};
var adempiere = window.adempiere; let adempiere = window.adempiere;
adempiere.isSupportSavePass=typeof(Storage) !== "undefined"; adempiere.isSupportSavePass=typeof(Storage) !== "undefined";
adempiere.saveUserToken = function (key, hash, sessionId) adempiere.saveUserToken = function (key, hash, sessionId)
@ -29,15 +29,15 @@ adempiere.findUserToken = function (cmpid, key)
if (!adempiere.isSupportSavePass) if (!adempiere.isSupportSavePass)
return; return;
var sid = localStorage[key+".sid"]; let sid = localStorage[key+".sid"];
var hash = localStorage[key+".hash"]; let hash = localStorage[key+".hash"];
if (sid == null || sid == "" || hash == null || hash == ""){ if (sid == null || sid == "" || hash == null || hash == ""){
return return
} }
var widget = zk.Widget.$(cmpid); let widget = zk.Widget.$(cmpid);
var event = new zk.Event(widget, 'onUserToken', {sid: sid, hash: hash}, {toServer: true}); let event = new zk.Event(widget, 'onUserToken', {sid: sid, hash: hash}, {toServer: true});
zAu.send(event); zAu.send(event);
}; };

View File

@ -25,7 +25,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, 350); }, 350);
} }
var Chosenbox = let Chosenbox =
chosenbox.Chosenbox = zk.$extends(zul.Widget, { chosenbox.Chosenbox = zk.$extends(zul.Widget, {
$init : function(props) { $init : function(props) {
@ -55,7 +55,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
* tabindex * tabindex
*/ */
tabindex : function(tabindex) { tabindex : function(tabindex) {
var n = this.$n('inp'); let n = this.$n('inp');
if (n) if (n)
n.tabindex = tabindex || ''; n.tabindex = tabindex || '';
}, },
@ -72,7 +72,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
* selectedIndex * selectedIndex
*/ */
selectedIndex : function(v, opts) { selectedIndex : function(v, opts) {
var options, sel; let options, sel;
this._clearSelection(); this._clearSelection();
if ((sel = this.$n('sel')) && v >= 0) { if ((sel = this.$n('sel')) && v >= 0) {
options = jq(sel).children(); options = jq(sel).children();
@ -99,7 +99,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
* disabled * disabled
*/ */
disabled : function(disabled) { disabled : function(disabled) {
var n = this.$n('inp'); let n = this.$n('inp');
if (n) if (n)
n.disabled = disabled ? 'disabled' : ''; n.disabled = disabled ? 'disabled' : '';
}, },
@ -135,7 +135,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
* name the name of this component. * name the name of this component.
*/ */
name : function(name) { name : function(name) {
var n = this.$n('inp'); let n = this.$n('inp');
if (n) if (n)
n.name = name; n.name = name;
}, },
@ -231,7 +231,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
* this component. * this component.
*/ */
separator : function(v) { separator : function(v) {
var separatorCode = this._separatorCode; let separatorCode = this._separatorCode;
separatorCode.length = 0; separatorCode.length = 0;
// save keycode for special symble // save keycode for special symble
// handle the code of special char because // handle the code of special char because
@ -288,7 +288,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
open : null open : null
}, },
setListContent : function(v) { setListContent : function(v) {
var sel, out, oldHlite, value; let sel, out, oldHlite, value;
if (sel = this.$n('sel')) { if (sel = this.$n('sel')) {
if (oldHlite = jq(this.$n('sel')) if (oldHlite = jq(this.$n('sel'))
.find( .find(
@ -317,27 +317,27 @@ it will be useful, but WITHOUT ANY WARRANTY.
} }
}, },
_renderItems : function(out, content) { _renderItems : function(out, content) {
var s = $eval(content ? content : this._items) let s = $eval(content ? content : this._items)
|| [], zcls = this.getZclass(); || [], 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">', out.push('<div class="', zcls, '-option">',
zUtl.encodeXML(s[i]), '</div>'); zUtl.encodeXML(s[i]), '</div>');
} }
return out; return out;
}, },
getZclass : function() { getZclass : function() {
var zcls = this._zclass; let zcls = this._zclass;
return zcls != null ? zcls : "z-chosenbox"; return zcls != null ? zcls : "z-chosenbox";
}, },
// update the selected items, the old selection will be // update the selected items, the old selection will be
// cleared at first // cleared at first
setChgSel : function(val) { // called from the server setChgSel : function(val) { // called from the server
this._clearSelection(); this._clearSelection();
var sel, options; let sel, options;
if (sel = this.$n('sel')) { // select each item if (sel = this.$n('sel')) { // select each item
options = jq(sel).children(); options = jq(sel).children();
var s = $eval(val), renderByServer = this._renderByServer, item, value; let s = $eval(val), renderByServer = this._renderByServer, item, value;
for (var i = 0; i < s.length; i++) { for (let i = 0; i < s.length; i++) {
value = s[i]; value = s[i];
if (item = this._getItemByValue(value)) if (item = this._getItemByValue(value))
this._doSelect(item); this._doSelect(item);
@ -350,7 +350,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
bind_ : function() { bind_ : function() {
this.$supers(Chosenbox, 'bind_', arguments); 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_') this.domListen_(inp, 'onFocus', 'doFocus_')
.domListen_(inp, 'onBlur', 'doBlur_'); .domListen_(inp, 'onBlur', 'doBlur_');
@ -361,19 +361,19 @@ it will be useful, but WITHOUT ANY WARRANTY.
this._fixWidth(n); this._fixWidth(n);
//fix selection //fix selection
if (this._selItems && this._selItems.length > 0) { if (this._selItems && this._selItems.length > 0) {
var s = this._selItems; let s = this._selItems;
this._selItems = []; this._selItems = [];
for (var i = 0; i < s.length; i++) { for (let i = 0; i < s.length; i++) {
var value = s[i]; let value = s[i];
if (item = this._getItemByValue(value)) if (item = this._getItemByValue(value))
this._doSelect(item); this._doSelect(item);
else else
this._selectItemDirectly(value); this._selectItemDirectly(value);
} }
} else if (this._chgSel) { } else if (this._chgSel) {
var s = this._chgSel; let s = this._chgSel;
this._chgSel = null; this._chgSel = null;
for (var i = 0; i < s.length; i++) { for (let i = 0; i < s.length; i++) {
value = s[i]; value = s[i];
if (item = this._getItemByValue(value)) if (item = this._getItemByValue(value))
this._doSelect(item); this._doSelect(item);
@ -387,7 +387,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
this.setOpen(true); this.setOpen(true);
}, },
unbind_ : function() { unbind_ : function() {
var inp = this.$n('inp'); let inp = this.$n('inp');
this.domUnlisten_(inp, 'onFocus', 'doFocus_') this.domUnlisten_(inp, 'onFocus', 'doFocus_')
.domUnlisten_(inp, 'onBlur', 'doBlur_'); .domUnlisten_(inp, 'onBlur', 'doBlur_');
zWatch.unlisten({ zWatch.unlisten({
@ -418,24 +418,24 @@ it will be useful, but WITHOUT ANY WARRANTY.
this.getZclass() + '-focus'); this.getZclass() + '-focus');
}, },
doMouseOver_ : function(evt) { doMouseOver_ : function(evt) {
var target = evt.domTarget; let target = evt.domTarget;
// mouseover option // mouseover option
if (jq(target).hasClass( if (jq(target).hasClass(
this.getZclass() + '-option')) this.getZclass() + '-option'))
this._hliteOpt(target, true); this._hliteOpt(target, true);
}, },
doMouseOut_ : function(evt) { doMouseOut_ : function(evt) {
var target = evt.domTarget; let target = evt.domTarget;
// mouseout option // mouseout option
if (jq(target).hasClass( if (jq(target).hasClass(
this.getZclass() + '-option-over')) this.getZclass() + '-option-over'))
this._hliteOpt(target, false); this._hliteOpt(target, false);
}, },
_hliteOpt : function(target, highlight) { _hliteOpt : function(target, highlight) {
var zcls = this.getZclass() + '-option-over'; let zcls = this.getZclass() + '-option-over';
if (highlight) { if (highlight) {
// clear old first // clear old first
var oldHlite = jq(this.$n('sel')) let oldHlite = jq(this.$n('sel'))
.find( .find(
'.' + this.getZclass() '.' + this.getZclass()
+ '-option-over')[0]; + '-option-over')[0];
@ -451,7 +451,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
else if (key == 'down') else if (key == 'down')
this._moveOptionFocus('next'); this._moveOptionFocus('next');
else { else {
var inp = this.$n('inp'), pos = zk(inp) let inp = this.$n('inp'), pos = zk(inp)
.getSelectionRange(), label = jq( .getSelectionRange(), label = jq(
this.$n()).find( this.$n()).find(
'.' + this.getZclass() '.' + this.getZclass()
@ -472,7 +472,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
// focus previous or next visible option, // focus previous or next visible option,
// depends on dir // depends on dir
_moveOptionFocus : function(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() .find('.' + this.getZclass()
+ '-option-over')[0], newHlite, next = dir == 'next', prev = dir == 'prev'; + '-option-over')[0], newHlite, next = dir == 'next', prev = dir == 'prev';
if (next && !this._open) // default focus first if (next && !this._open) // default focus first
@ -511,7 +511,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
// focus previous or next label, // focus previous or next label,
// depends on dir // depends on dir
_moveLabelFocus : function(label, 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) { if (label) {
jq(label).removeClass(zcls); jq(label).removeClass(zcls);
newLabel = prev ? label.previousSibling newLabel = prev ? label.previousSibling
@ -527,14 +527,14 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
// called after press backspace or del and release // called after press backspace or del and release
_deleteLabel : function(key, evt) { _deleteLabel : function(key, evt) {
var inp = this.$n('inp'), pos = zk(inp) let inp = this.$n('inp'), pos = zk(inp)
.getSelectionRange(), label; .getSelectionRange(), label;
// only works if cursor is at the begining of input // only works if cursor is at the begining of input
if (pos[0] == 0 && pos[1] == 0) { 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]) { if (label = jq(this.$n()).find('.' + zcls)[0]) {
var dir = (label.previousSibling && key == 'backspace') ? 'prev' let dir = (label.previousSibling && key == 'backspace') ? 'prev'
: 'next'; : 'next';
this._moveLabelFocus(label, dir); this._moveLabelFocus(label, dir);
this._doDeselect(label, { this._doDeselect(label, {
@ -550,14 +550,14 @@ it will be useful, but WITHOUT ANY WARRANTY.
} }
}, },
_removeLabelFocus : function() { _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]; this.$n()).find('.' + zcls)[0];
if (label) if (label)
jq(label).removeClass(zcls); jq(label).removeClass(zcls);
}, },
// called after press enter and release // called after press enter and release
_doEnterPressed : function(evt) { _doEnterPressed : function(evt) {
var $sel, hlited, old; let $sel, hlited, old;
// clear timer and fix display before process // clear timer and fix display before process
if (old = this.fixDisplay) if (old = this.fixDisplay)
clearTimeout(old); clearTimeout(old);
@ -577,7 +577,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
&& (hlited = $sel.find('.' && (hlited = $sel.find('.'
+ this.getZclass() + this.getZclass()
+ '-option-over')[0])) { + '-option-over')[0])) {
var options = $sel.children(); let options = $sel.children();
this._doSelect(hlited, { this._doSelect(hlited, {
sendOnSelect : true sendOnSelect : true
}); });
@ -591,7 +591,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
doClick_ : function(evt) { doClick_ : function(evt) {
if (!this.isDisabled()) { 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(); .$n('inp'), zcls = this.getZclass();
this._removeLabelFocus(); this._removeLabelFocus();
if (inp.value == this._emptyMessage) if (inp.value == this._emptyMessage)
@ -616,7 +616,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
sendOnOpen : true sendOnOpen : true
}); });
} else { } else {
var label = target, zcls = this.getZclass() let label = target, zcls = this.getZclass()
+ '-sel-item'; + '-sel-item';
if ($target.hasClass(zcls) if ($target.hasClass(zcls)
|| (label = $target.parent('.' || (label = $target.parent('.'
@ -637,7 +637,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
// select an item // select an item
_doSelect : function(target, opts) { _doSelect : function(target, opts) {
this._hliteOpt(target, false); this._hliteOpt(target, false);
var value = target.innerHTML; let value = target.innerHTML;
if (this._selItems.indexOf(value) == -1) { if (this._selItems.indexOf(value) == -1) {
this._createLabel(value); this._createLabel(value);
target.style.display = 'none'; // hide selected target.style.display = 'none'; // hide selected
@ -660,7 +660,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
// deselect an item // deselect an item
_doDeselect : function(selectedItem, opts) { _doDeselect : function(selectedItem, opts) {
var value = jq(selectedItem).find( let value = jq(selectedItem).find(
'.' + this.getZclass() + '-sel-item-cnt')[0].innerHTML, element = this '.' + this.getZclass() + '-sel-item-cnt')[0].innerHTML, element = this
._getItemByValue(value), _selItems = this._selItems; ._getItemByValue(value), _selItems = this._selItems;
if (this._open) if (this._open)
@ -682,8 +682,8 @@ it will be useful, but WITHOUT ANY WARRANTY.
this._startFixDisplay(); this._startFixDisplay();
}, },
_getItemByValue : function(value) { _getItemByValue : function(value) {
var options = jq(this.$n('sel')).children(), item; let options = jq(this.$n('sel')).children(), item;
for (var i = 0; i < options.length; i++) for (let i = 0; i < options.length; i++)
if ((item = options[i]) if ((item = options[i])
&& item.innerHTML == value) && item.innerHTML == value)
return item; return item;
@ -692,7 +692,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
// create label for selected item // create label for selected item
_createLabel : function(value) { _createLabel : function(value) {
var span = document.createElement("span"), content = document let span = document.createElement("span"), content = document
.createElement("div"), delbtn = document .createElement("div"), delbtn = document
.createElement("div"), wgt = this, zcls = this .createElement("div"), wgt = this, zcls = this
.getZclass(); .getZclass();
@ -717,7 +717,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
// clear all selected items // clear all selected items
_clearSelection : function(opts) { _clearSelection : function(opts) {
var n = this.$n(), inp = this.$n('inp'), c, // selected let n = this.$n(), inp = this.$n('inp'), c, // selected
// item // item
del; del;
if (n) if (n)
@ -731,21 +731,21 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
// fire onSelectevent to server // fire onSelectevent to server
fireSelectEvent : function() { fireSelectEvent : function() {
var data = [], selItems = this._selItems; // selected let data = [], selItems = this._selItems; // selected
// item // item
for (var i = 0; i < selItems.length; i++) for (let i = 0; i < selItems.length; i++)
data.push(selItems[i]); data.push(selItems[i]);
this.fire('onSelect', data); this.fire('onSelect', data);
}, },
// fire onSearch event // fire onSearch event
_fireOnSearch : function(value) { _fireOnSearch : function(value) {
var data = []; let data = [];
data.push(value); data.push(value);
this.fire('onSearch', data); this.fire('onSearch', data);
}, },
// fire onSearching event // fire onSearching event
_fireOnSearching : function(value) { _fireOnSearching : function(value) {
var data = []; let data = [];
data.push(value); data.push(value);
this.fire('onSearching', data); this.fire('onSearching', data);
}, },
@ -762,7 +762,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
doKeyDown_ : function(evt) { doKeyDown_ : function(evt) {
var keyCode = evt.keyCode; let keyCode = evt.keyCode;
switch (keyCode) { switch (keyCode) {
case 8:// backspace case 8:// backspace
this._deleteLabel('backspace', evt); this._deleteLabel('backspace', evt);
@ -802,7 +802,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
this._removeLabelFocus(); this._removeLabelFocus();
}, },
doKeyUp_ : function(evt) { doKeyUp_ : function(evt) {
var keyCode = evt.keyCode, opts = { let keyCode = evt.keyCode, opts = {
hliteFirst : true hliteFirst : true
}; };
switch (keyCode) { switch (keyCode) {
@ -831,7 +831,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
startOnSearching(this); startOnSearching(this);
}, },
_isSeparator : function(keyCode) { _isSeparator : function(keyCode) {
var separator = this._separator, separatorCode = this._separatorCode; let separator = this._separator, separatorCode = this._separatorCode;
return (separatorCode && separatorCode return (separatorCode && separatorCode
.indexOf(keyCode) != -1) .indexOf(keyCode) != -1)
|| ((keyCode >= 48 && keyCode <= 122) || ((keyCode >= 48 && keyCode <= 122)
@ -842,7 +842,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
.fromCharCode(keyCode)) != -1); .fromCharCode(keyCode)) != -1);
}, },
_updateInput : function(evt) { _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; .$n('txcnt'), wgt = this;
// check every 100ms while input // check every 100ms while input
@ -855,7 +855,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
if (!this.isDisabled()) if (!this.isDisabled())
this._open = open; this._open = open;
if (this.$n('pp')) { if (this.$n('pp')) {
var pp = this.$n('pp'); let pp = this.$n('pp');
if (open) if (open)
this.open(this.$n(), pp, opts); this.open(this.$n(), pp, opts);
else else
@ -863,7 +863,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
} }
}, },
open : function(n, pp, opts) { open : function(n, pp, opts) {
var ppstyle = pp.style; let ppstyle = pp.style;
this._fixWidth(n); this._fixWidth(n);
this._fixsz(pp); this._fixsz(pp);
@ -875,7 +875,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
ppstyle.zIndex = n.style.zIndex; ppstyle.zIndex = n.style.zIndex;
ppstyle.display = 'block'; ppstyle.display = 'block';
if (opts) { if (opts) {
var inp = this.$n(); let inp = this.$n();
zk(pp).position(inp, "after_start"); zk(pp).position(inp, "after_start");
} }
@ -908,7 +908,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
this._clearListContent(); this._clearListContent();
}, },
_fixsz : function(pp) { _fixsz : function(pp) {
var ppstyle = pp.style, maxh = this._ppMaxHeight; let ppstyle = pp.style, maxh = this._ppMaxHeight;
ppstyle.height = 'auto'; ppstyle.height = 'auto';
ppstyle.left = "-10000px"; ppstyle.left = "-10000px";
ppstyle.display = "block"; ppstyle.display = "block";
@ -920,7 +920,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
// calculate the width for input field // calculate the width for input field
_fixInputWidth : function() { _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; .$n('txcnt'), oldh = jq(n).height(), width, max = parseInt(this._width) - 10;
// copy value to hidden txcnt // copy value to hidden txcnt
txcnt.innerHTML = inp.value; txcnt.innerHTML = inp.value;
@ -942,7 +942,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
this._fixDisplay(opts); this._fixDisplay(opts);
else { // replace old if exist and hold a while else { // replace old if exist and hold a while
// while input // while input
var wgt = this, old; let wgt = this, old;
if (old = this.fixDisplay) if (old = this.fixDisplay)
clearTimeout(old); clearTimeout(old);
this.fixDisplay = setTimeout(function() { this.fixDisplay = setTimeout(function() {
@ -954,10 +954,10 @@ it will be useful, but WITHOUT ANY WARRANTY.
_fixDisplay : function(opts) { _fixDisplay : function(opts) {
if (!this._open) if (!this._open)
return; return;
var fromServer = opts && opts.fromServer; let fromServer = opts && opts.fromServer;
if (!this._renderByServer if (!this._renderByServer
|| (opts && opts.fromServer)) { || (opts && opts.fromServer)) {
var str = this.$n('inp').value, oldhlite = jq( let str = this.$n('inp').value, oldhlite = jq(
this.$n('sel')) this.$n('sel'))
.find( .find(
'.' + this.getZclass() '.' + this.getZclass()
@ -976,7 +976,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
// fix the display content of options // fix the display content of options
_fixSelDisplay : function(hliteFirst, str, fromServer) { _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 this.$n('sel')).children(), found = false, // unselected
// match // match
// item // item
@ -1034,7 +1034,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
// fix the display of no-result text block // fix the display of no-result text block
_fixEmptyDisplay : function(type, str, found, exist) { _fixEmptyDisplay : function(type, str, found, exist) {
var ecls = this.getZclass() + '-empty-creatable', empty = this let ecls = this.getZclass() + '-empty-creatable', empty = this
.$n('empty'); .$n('empty');
if (type if (type
&& (type.showBlank || type.showExistance && (type.showBlank || type.showExistance
@ -1054,7 +1054,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
// item // item
// and // and
// creatable // creatable
var createMsg = this._createMessage; let createMsg = this._createMessage;
if (createMsg) if (createMsg)
createMsg = zUtl.encodeXML( createMsg = zUtl.encodeXML(
createMsg.replace(/\{0\}/g, createMsg.replace(/\{0\}/g,
@ -1066,7 +1066,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
jq(empty).addClass(ecls); jq(empty).addClass(ecls);
} else { // show no-result text if } else { // show no-result text if
// nothing can be selected // nothing can be selected
var empMsg = this._noResultsText; let empMsg = this._noResultsText;
if (empMsg) if (empMsg)
empMsg = zUtl.encodeXML( empMsg = zUtl.encodeXML(
empMsg.replace(/\{0\}/g, empMsg.replace(/\{0\}/g,
@ -1086,7 +1086,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
}, },
// show emptyMessage or clear input // show emptyMessage or clear input
_fixEmptyMessage : function(force) { _fixEmptyMessage : function(force) {
var inp; let inp;
if ((!this._open || force) if ((!this._open || force)
&& (inp = this.$n('inp'))) { && (inp = this.$n('inp'))) {
@ -1099,7 +1099,7 @@ it will be useful, but WITHOUT ANY WARRANTY.
} }
}, },
domAttrs_ : function() { domAttrs_ : function() {
var v; let v;
return this.$supers('domAttrs_', arguments) return this.$supers('domAttrs_', arguments)
+ (this.isDisabled() ? ' disabled="disabled"' + (this.isDisabled() ? ' disabled="disabled"'
: '') : '')

View File

@ -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. it will be useful, but WITHOUT ANY WARRANTY.
*/ */
function (out) { function (out) {
var zcls = this.getZclass(), let zcls = this.getZclass(),
uid = this.uuid; uid = this.uuid;
out.push('<i id="', uid, '" class="',zcls,'"', (!this.isVisible() ? 'style="display:none;"' : ''), '>', out.push('<i id="', uid, '" class="',zcls,'"', (!this.isVisible() ? 'style="display:none;"' : ''), '>',

View File

@ -1,16 +1,16 @@
(function() { (function() {
jawwa.atmosphere.startServerPush = function(dtid, timeout) { jawwa.atmosphere.startServerPush = function(dtid, timeout) {
var dt = zk.Desktop.$(dtid); let dt = zk.Desktop.$(dtid);
if (dt._serverpush) if (dt._serverpush)
dt._serverpush.stop(); dt._serverpush.stop();
//change to true to enable trace of execution //change to true to enable trace of execution
var trace = false; let trace = false;
var spush = new jawwa.atmosphere.ServerPush(dt, timeout, trace); let spush = new jawwa.atmosphere.ServerPush(dt, timeout, trace);
spush.start(); spush.start();
}; };
jawwa.atmosphere.stopServerPush = function(dtid) { jawwa.atmosphere.stopServerPush = function(dtid) {
var dt = zk.Desktop.$(dtid); let dt = zk.Desktop.$(dtid);
if (dt._serverpush) if (dt._serverpush)
dt._serverpush.stop(); dt._serverpush.stop();
}; };
@ -37,7 +37,7 @@
this.ajaxOptions.timeout = this.timeout; this.ajaxOptions.timeout = this.timeout;
this.ajaxOptions.url = zk.ajaxURI("/comet", {au: true,desktop:this.desktop.id,ignoreSession:true}), this.ajaxOptions.url = zk.ajaxURI("/comet", {au: true,desktop:this.desktop.id,ignoreSession:true}),
this.trace = trace; this.trace = trace;
var me = this; let me = this;
this.ajaxOptions.error = function(jqxhr, textStatus, errorThrown) { this.ajaxOptions.error = function(jqxhr, textStatus, errorThrown) {
if (me.trace) if (me.trace)
console.log("error: " + textStatus + " dtid: " + me.desktop.id + " errorThrown: " + errorThrown + " status: " + jqxhr.status); console.log("error: " + textStatus + " dtid: " + me.desktop.id + " errorThrown: " + errorThrown + " status: " + jqxhr.status);
@ -67,7 +67,7 @@
}, },
_schedule: function() { _schedule: function() {
if (this.failures < 3) { if (this.failures < 3) {
var d = this.delay; let d = this.delay;
if (this._req && (this._req.status == 0 || this._req.status == 400)) if (this._req && (this._req.status == 0 || this._req.status == 400))
d = 500; d = 500;
this._req = null; this._req = null;
@ -83,7 +83,7 @@
if (this.trace) if (this.trace)
console.log("_send"+ " dtid: " + this.desktop.id); console.log("_send"+ " dtid: " + this.desktop.id);
var jqxhr = $.ajax(this.ajaxOptions); let jqxhr = $.ajax(this.ajaxOptions);
this._req = jqxhr; this._req = jqxhr;
zAu.cmd0.echo(this.desktop); zAu.cmd0.echo(this.desktop);
}, },

View File

@ -10,7 +10,7 @@ function Calc()
function validateDown(displayTextId, calcTextId, integral, separatorKey, e, processDotKeypad) function validateDown(displayTextId, calcTextId, integral, separatorKey, e, processDotKeypad)
{ {
var key; let key;
if(window.event) if(window.event)
key = e.keyCode; //IE key = e.keyCode; //IE
else else
@ -31,8 +31,8 @@ function Calc()
{ {
try try
{ {
var id = "$".concat(calcTextId); let id = "$".concat(calcTextId);
var calcText = jq(id)[0]; let calcText = jq(id)[0];
calcText.value = ""; calcText.value = "";
} }
catch (err) catch (err)
@ -44,9 +44,9 @@ function Calc()
{ {
try try
{ {
var id = "$".concat(calcTextId); let id = "$".concat(calcTextId);
var calcText = jq(id)[0]; let calcText = jq(id)[0];
var val = calcText.value; let val = calcText.value;
if (val != "") if (val != "")
{ {
val = val.substring(0, val.length - 1); val = val.substring(0, val.length - 1);
@ -62,15 +62,15 @@ function Calc()
function evaluate(displayTextId, calcTextId, separator) function evaluate(displayTextId, calcTextId, separator)
{ {
// console.log("evaluate: " + displayTextId + " / " + calcTextId + " / " + separator); // console.log("evaluate: " + displayTextId + " / " + calcTextId + " / " + separator);
var newValue = "error"; let newValue = "error";
try try
{ {
var id = "$".concat(calcTextId); let id = "$".concat(calcTextId);
var calcText = jq(id)[0]; let calcText = jq(id)[0];
var value = calcText.value; let value = calcText.value;
if (separator != '.') if (separator != '.')
{ {
var re = new RegExp("[" + separator + "]", "g"); let re = new RegExp("[" + separator + "]", "g");
value = value.replace(re,'.'); value = value.replace(re,'.');
} }
value = value value = value
@ -82,7 +82,7 @@ function Calc()
.replace(/0/g, '') // throw away the rest of the zeros .replace(/0/g, '') // throw away the rest of the zeros
.replace(/z/g, '0'); // turn sentinels back to zeros .replace(/z/g, '0'); // turn sentinels back to zeros
newValue = value; newValue = value;
var result = "" + eval(value); let result = "" + eval(value);
if (separator != '.') if (separator != '.')
{ {
result = result.replace(/\./, separator); result = result.replace(/\./, separator);
@ -90,7 +90,7 @@ function Calc()
calcText.value = result; calcText.value = result;
id = "$".concat(displayTextId); id = "$".concat(displayTextId);
var displayText = jq(id)[0]; let displayText = jq(id)[0];
if (!displayText.readOnly && calcText.value != 'undefined') if (!displayText.readOnly && calcText.value != 'undefined')
{ {
@ -106,18 +106,18 @@ function Calc()
function append(calcTextId, val) function append(calcTextId, val)
{ {
var id = "$".concat(calcTextId); let id = "$".concat(calcTextId);
var calcText = jq(id)[0]; let calcText = jq(id)[0];
calcText.value += val; calcText.value += val;
calcText.focus(); calcText.focus();
} }
function appendOnCursor(calcTextId, val) function appendOnCursor(calcTextId, val)
{ {
var id = "$".concat(calcTextId); let id = "$".concat(calcTextId);
var calcText = jq(id)[0]; let calcText = jq(id)[0];
var position = calcText.selectionStart; let position = calcText.selectionStart;
var newValue = calcText.value.substring(0, position) + val + calcText.value.substring(position); let newValue = calcText.value.substring(0, position) + val + calcText.value.substring(position);
calcText.value = newValue; calcText.value = newValue;
calcText.setSelectionRange(position+1, position+1); calcText.setSelectionRange(position+1, position+1);
} }

View File

@ -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);
});
});

View File

@ -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);
}
});
});

View File

@ -3,7 +3,7 @@ if (typeof window.idempiere === 'undefined')
window.idempiere.scrollToRow = function(uuid){ window.idempiere.scrollToRow = function(uuid){
try { try {
var cmp = zk.Widget.$(uuid); let cmp = zk.Widget.$(uuid);
if (cmp) { if (cmp) {
cmp.scrollIntoView(); cmp.scrollIntoView();
cmp.focus(); cmp.focus();
@ -16,9 +16,9 @@ window.idempiere.scrollToRow = function(uuid){
//overload for recalculate width of grid frozen scroll //overload for recalculate width of grid frozen scroll
//base on _onSizeLater(wgt) from Frozen.js //base on _onSizeLater(wgt) from Frozen.js
window.idempiere.syncScrollFrozen = function(wgt){ window.idempiere.syncScrollFrozen = function(wgt){
var parent = wgt.parent; let parent = wgt.parent;
if (parent.eheadtbl && parent._nativebar) { if (parent.eheadtbl && parent._nativebar) {
var cells = parent._getFirstRowCells(parent.eheadrows), let cells = parent._getFirstRowCells(parent.eheadrows),
head = parent.head, head = parent.head,
totalcols = cells.length - jq(head).find(head.$n('bar')).length, totalcols = cells.length - jq(head).find(head.$n('bar')).length,
columns = wgt._columns, columns = wgt._columns,
@ -30,8 +30,8 @@ window.idempiere.syncScrollFrozen = function(wgt){
return; return;
} }
for (var i = columns; i < totalcols; i++) { for (let i = columns; i < totalcols; i++) {
var n = cells[i], let n = cells[i],
hdWgt = zk.Widget.$(n), hdWgt = zk.Widget.$(n),
isVisible = hdWgt && hdWgt.isVisible(); isVisible = hdWgt && hdWgt.isVisible();
if (!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; leftWidth += cells[i].offsetWidth;
parent._deleteFakeRow(parent.eheadrows); parent._deleteFakeRow(parent.eheadrows);
wgt.$n('cave').style.width = jq.px0(leftWidth); wgt.$n('cave').style.width = jq.px0(leftWidth);
var scroll = wgt.$n('scrollX'), let scroll = wgt.$n('scrollX'),
width = parent.$n('body').offsetWidth; width = parent.$n('body').offsetWidth;
// B70-ZK-2074: Resize forzen's width as meshwidget's body. // B70-ZK-2074: Resize forzen's width as meshwidget's body.
parent.$n('frozen').style.width = jq.px0(width); parent.$n('frozen').style.width = jq.px0(width);
width -= leftWidth; width -= leftWidth;
scroll.style.width = jq.px0(width); scroll.style.width = jq.px0(width);
var rightWidth = 0; let rightWidth = 0;
var toScroll = 0; let toScroll = 0;
for (var i = columns; i < cells.length; i++){ for (let i = columns; i < cells.length; i++){
var hdWgt = zk.Widget.$(cells[i]); let hdWgt = zk.Widget.$(cells[i]);
var isVisible = hdWgt && hdWgt.isVisible(); let isVisible = hdWgt && hdWgt.isVisible();
if (!isVisible) if (!isVisible)
continue; continue;
if (cells[i].offsetWidth==0) { if (cells[i].offsetWidth==0) {
@ -74,10 +74,10 @@ window.idempiere.syncScrollFrozen = function(wgt){
rightWidth += cells[i].offsetWidth; rightWidth += cells[i].offsetWidth;
} }
} }
for (var i = columns; i < cells.length; i++){ for (let i = columns; i < cells.length; i++){
var ow=cells[i].offsetWidth; let ow=cells[i].offsetWidth;
if (ow==0) { if (ow==0) {
var hdWgt = zk.Widget.$(cells[i]); let hdWgt = zk.Widget.$(cells[i]);
if (hdWgt._origWd && hdWgt._origWd.indexOf('px')>0) if (hdWgt._origWd && hdWgt._origWd.indexOf('px')>0)
ow = parseInt(hdWgt._origWd,10); ow = parseInt(hdWgt._origWd,10);
else if (hdWgt._hflexWidth && hdWgt._hflexWidth > 0) else if (hdWgt._hflexWidth && hdWgt._hflexWidth > 0)

View File

@ -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;
});
});

View File

@ -3,38 +3,38 @@ if (typeof window.idempiere === 'undefined')
window.idempiere.zoom = function(cmpid, column, value){ window.idempiere.zoom = function(cmpid, column, value){
zAu.cmd0.showBusy(null); zAu.cmd0.showBusy(null);
var widget = zk.Widget.$(cmpid); let widget = zk.Widget.$(cmpid);
var event = new zk.Event(widget, 'onZoom', {data: [column, value]}, {toServer: true}); let event = new zk.Event(widget, 'onZoom', {data: [column, value]}, {toServer: true});
zAu.send(event); zAu.send(event);
}; };
window.idempiere.zoomWindow = function(cmpid, column, value, windowuu){ window.idempiere.zoomWindow = function(cmpid, column, value, windowuu){
zAu.cmd0.showBusy(null); zAu.cmd0.showBusy(null);
var widget = zk.Widget.$(cmpid); let widget = zk.Widget.$(cmpid);
var event = new zk.Event(widget, 'onZoom', {data: [column, value, 'AD_Window_UU', windowuu]}, {toServer: true}); let event = new zk.Event(widget, 'onZoom', {data: [column, value, 'AD_Window_UU', windowuu]}, {toServer: true});
zAu.send(event); zAu.send(event);
}; };
window.idempiere.drillAcross = function(cmpid, column, value){ window.idempiere.drillAcross = function(cmpid, column, value){
zAu.cmd0.showBusy(null); zAu.cmd0.showBusy(null);
var widget = zk.Widget.$(cmpid); let widget = zk.Widget.$(cmpid);
var event = new zk.Event(widget, 'onDrillAcross', {data: [column, value]}, {toServer: true}); let event = new zk.Event(widget, 'onDrillAcross', {data: [column, value]}, {toServer: true});
zAu.send(event); zAu.send(event);
}; };
window.idempiere.drillDown = function(cmpid, column, value){ window.idempiere.drillDown = function(cmpid, column, value){
zAu.cmd0.showBusy(null); zAu.cmd0.showBusy(null);
var widget = zk.Widget.$(cmpid); let widget = zk.Widget.$(cmpid);
var event = new zk.Event(widget, 'onDrillDown', {data: [column, value]}, {toServer: true}); let event = new zk.Event(widget, 'onDrillDown', {data: [column, value]}, {toServer: true});
zAu.send(event); zAu.send(event);
}; };
window.idempiere.showColumnMenu = function(doc, e, columnName, row) { 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; let posx = 0;
var posy = 0; let posy = 0;
if (!e) var e = window.event; if (!e) e = window.event;
if (e.pageX || e.pageY) { if (e.pageX || e.pageY) {
posx = e.pageX; posx = e.pageX;
posy = e.pageY; posy = e.pageY;
@ -50,7 +50,7 @@ window.idempiere.showColumnMenu = function(doc, e, columnName, row) {
d.style.left = posx; d.style.left = posx;
d.style.display = "block"; d.style.display = "block";
var f = function() { let f = function() {
doc.contextMenu.style.display='none' doc.contextMenu.style.display='none'
}; };
setTimeout(f, 3000); setTimeout(f, 3000);
@ -60,7 +60,7 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
doc.contextMenu = null; doc.contextMenu = null;
if (componentId != null){ if (componentId != null){
//menu div //menu div
var menu = doc.createElement("div"); let menu = doc.createElement("div");
menu.style.position = "absolute"; menu.style.position = "absolute";
menu.style.display = "none"; menu.style.display = "none";
menu.style.top = "0"; menu.style.top = "0";
@ -70,13 +70,13 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
menu.style.backgroundColor = "white"; menu.style.backgroundColor = "white";
//window menu item //window menu item
var windowMenu = doc.createElement("div"); let windowMenu = doc.createElement("div");
windowMenu.style.padding = "3px"; windowMenu.style.padding = "3px";
windowMenu.style.verticalAlign = "middle"; windowMenu.style.verticalAlign = "middle";
windowMenu.setAttribute("onmouseover", "this.style.backgroundColor = 'lightgray'"); windowMenu.setAttribute("onmouseover", "this.style.backgroundColor = 'lightgray'");
windowMenu.setAttribute("onmouseout", "this.style.backgroundColor = 'white'"); windowMenu.setAttribute("onmouseout", "this.style.backgroundColor = 'white'");
var href = doc.createElement("a"); let href = doc.createElement("a");
href.style.fontSize = "11px"; href.style.fontSize = "11px";
href.style.textDecoration = "none"; href.style.textDecoration = "none";
href.style.verticalAlign = "middle"; href.style.verticalAlign = "middle";
@ -86,9 +86,9 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
windowMenu.appendChild(href); windowMenu.appendChild(href);
menu.appendChild(windowMenu); menu.appendChild(windowMenu);
var windowIco = doc.body.getAttribute ("windowIco"); let windowIco = doc.body.getAttribute ("windowIco");
if (typeof windowIco === 'string' && windowIco.length > 0) { if (typeof windowIco === 'string' && windowIco.length > 0) {
var image = doc.createElement("img"); let image = doc.createElement("img");
image.src = windowIco; image.src = windowIco;
image.setAttribute("align", "middle"); image.setAttribute("align", "middle");
href.appendChild(image); href.appendChild(image);
@ -96,14 +96,14 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
href.appendChild(doc.createTextNode(doc.body.getAttribute ("windowLabel"))); href.appendChild(doc.createTextNode(doc.body.getAttribute ("windowLabel")));
//report menu item //report menu item
var report = doc.createElement("div"); let report = doc.createElement("div");
report.style.padding = "3px"; report.style.padding = "3px";
report.style.verticalAlign = "middle"; report.style.verticalAlign = "middle";
report.setAttribute("onmouseover", "this.style.backgroundColor = 'lightgray'"); report.setAttribute("onmouseover", "this.style.backgroundColor = 'lightgray'");
report.setAttribute("onmouseout", "this.style.backgroundColor = 'white'"); report.setAttribute("onmouseout", "this.style.backgroundColor = 'white'");
var reportHref = doc.createElement("a"); let reportHref = doc.createElement("a");
reportHref.href = "javascript:void(0)"; reportHref.href = "javascript:void(0)";
reportHref.style.textDecoration = "none"; reportHref.style.textDecoration = "none";
reportHref.style.fontSize = "11px"; reportHref.style.fontSize = "11px";
@ -112,9 +112,9 @@ window.idempiere.getMenu = function(doc, componentId, foreignColumnName, value){
report.appendChild(reportHref); report.appendChild(reportHref);
menu.appendChild(report); menu.appendChild(report);
var reportIco = doc.body.getAttribute ("reportIco"); let reportIco = doc.body.getAttribute ("reportIco");
if (typeof reportIco === 'string' && reportIco.length > 0) { if (typeof reportIco === 'string' && reportIco.length > 0) {
var reportimage = doc.createElement("img"); let reportimage = doc.createElement("img");
reportimage.src = reportIco; reportimage.src = reportIco;
reportimage.setAttribute("align", "middle"); reportimage.setAttribute("align", "middle");
reportHref.appendChild(reportimage); reportHref.appendChild(reportimage);

View File

@ -1,24 +1,24 @@
zk.afterLoad("zul.sel", function () { zk.afterLoad("zul.sel", function () {
var _tWgt = {}, let _tWgt = {},
_tiWgt = {}; _tiWgt = {};
zk.override(zul.sel.Treerow.prototype, _tiWgt, { zk.override(zul.sel.Treerow.prototype, _tiWgt, {
getDragOptions_: function (map) { getDragOptions_: function (map) {
var copy = map.constructor(), let copy = map.constructor(),
wgt = this; wgt = this;
// clone map // clone map
for (var attr in map) { for (let attr in map) {
if (map.hasOwnProperty(attr)) copy[attr] = map[attr]; if (map.hasOwnProperty(attr)) copy[attr] = map[attr];
} }
// change functions as needed // change functions as needed
var oldChange = copy.change, let oldChange = copy.change,
oldEnd = copy.endeffect; oldEnd = copy.endeffect;
copy.change = function (drag, pt, evt) { copy.change = function (drag, pt, evt) {
var tree = wgt.getTree(); let tree = wgt.getTree();
oldChange(drag, pt, evt); oldChange(drag, pt, evt);
tree.triggerAutoScroll(evt.pageX, evt.pageY); tree.triggerAutoScroll(evt.pageX, evt.pageY);
}; };
copy.endeffect = function (drag, evt) { copy.endeffect = function (drag, evt) {
var tree = wgt.getTree(); let tree = wgt.getTree();
oldEnd(drag, evt); oldEnd(drag, evt);
tree.stopAutoScroll(); tree.stopAutoScroll();
} }
@ -36,7 +36,7 @@ zk.afterLoad("zul.sel", function () {
speedGap: 50, speedGap: 50,
speedGapCounter: 0, speedGapCounter: 0,
triggerAutoScroll: function (x, y) { triggerAutoScroll: function (x, y) {
var $n = jq(this.$n()), let $n = jq(this.$n()),
offset = $n.offset(), offset = $n.offset(),
top = offset.top + (this.$n('head')? 10 : 0), top = offset.top + (this.$n('head')? 10 : 0),
bottom = $n.outerHeight(true); bottom = $n.outerHeight(true);
@ -52,7 +52,7 @@ zk.afterLoad("zul.sel", function () {
this.clearScrollToBottomTimer(); this.clearScrollToBottomTimer();
}, },
startScrollToTop: function (y) { startScrollToTop: function (y) {
var wgt = this; let wgt = this;
this.clearScrollToBottomTimer(); this.clearScrollToBottomTimer();
if (!this._scrollToTopTimer) { if (!this._scrollToTopTimer) {
this.scrollDelay = this.initialScrollDelay; this.scrollDelay = this.initialScrollDelay;
@ -84,7 +84,7 @@ zk.afterLoad("zul.sel", function () {
} }
}, },
startScrollToBottom: function (y) { startScrollToBottom: function (y) {
var wgt = this; let wgt = this;
this.clearScrollToTopTimer(); this.clearScrollToTopTimer();
if (!this._scrollToBottomTimer) { if (!this._scrollToBottomTimer) {
this.scrollDelay = this.initialScrollDelay; this.scrollDelay = this.initialScrollDelay;
@ -116,13 +116,13 @@ zk.afterLoad("zul.sel", function () {
} }
}, },
clearScrollToTopTimer: function () { clearScrollToTopTimer: function () {
var timer = this._scrollToTopTimer; let timer = this._scrollToTopTimer;
if (timer) if (timer)
clearInterval(timer); clearInterval(timer);
this._scrollToTopTimer = null; this._scrollToTopTimer = null;
}, },
clearScrollToBottomTimer: function () { clearScrollToBottomTimer: function () {
var timer = this._scrollToBottomTimer; let timer = this._scrollToBottomTimer;
if (timer) if (timer)
clearInterval(timer); clearInterval(timer);
this._scrollToBottomTimer = null; this._scrollToBottomTimer = null;

View File

@ -2,19 +2,19 @@ if (typeof window.idempiere === 'undefined')
window.idempiere = {}; window.idempiere = {};
window.idempiere.show_popup_window = function(refid, windowid, position) { window.idempiere.show_popup_window = function(refid, windowid, position) {
var ref = zk.Widget.$(refid); let ref = zk.Widget.$(refid);
var window = zk(windowid); let window = zk(windowid);
window.position(ref.$n(), position); window.position(ref.$n(), position);
}; };
zk.override(zk.Widget.prototype, "canActivate", zk.override(zk.Widget.prototype, "canActivate",
function () { function () {
var b = this.$canActivate.apply(this, arguments); let b = this.$canActivate.apply(this, arguments);
if (b) { if (b) {
if (zk.currentModal) { if (zk.currentModal) {
return true; return true;
} }
var wgt = this; let wgt = this;
while (wgt) { while (wgt) {
if (wgt.busy) { if (wgt.busy) {
if (wgt.busy.className) { if (wgt.busy.className) {

View File

@ -5,4 +5,7 @@
<script src="report.js" /> <script src="report.js" />
<script src="window.js" /> <script src="window.js" />
<script src="tree.js" /> <script src="tree.js" />
<script src="mesh.js" />
<script src="input.js" />
<script src="calendar.js" />
</package> </package>

View File

@ -1,18 +1,18 @@
(function() { (function() {
org.idempiere.websocket.startServerPush = function(dtid) { 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 && dt._serverpush.socket) {
if (dt._serverpush._reconnectId) { if (dt._serverpush._reconnectId) {
return; return;
} }
dt._serverpush.restart(); dt._serverpush.restart();
} else { } else {
var spush = new org.idempiere.websocket.ServerPush(dtid); let spush = new org.idempiere.websocket.ServerPush(dtid);
spush.start(); spush.start();
} }
}; };
org.idempiere.websocket.stopServerPush = function(dtid) { org.idempiere.websocket.stopServerPush = function(dtid) {
var dt = zk.Desktop.$(dtid); let dt = zk.Desktop.$(dtid);
if (dt._serverpush) if (dt._serverpush)
dt._serverpush.stop(); dt._serverpush.stop();
}; };
@ -22,26 +22,26 @@
this.socket = null; this.socket = null;
this.active = false; this.active = false;
this.reconnect = false; this.reconnect = false;
var desktop = zk.Desktop.$(this.dtid); let desktop = zk.Desktop.$(this.dtid);
desktop._serverpush = this; desktop._serverpush = this;
}, },
start: function() { start: function() {
var desktop = zk.Desktop.$(this.dtid); let desktop = zk.Desktop.$(this.dtid);
if (typeof desktop === 'undefined') if (typeof desktop === 'undefined')
return; return;
this.reconnect = false; this.reconnect = false;
this._reconnectId = null; this._reconnectId = null;
var url = window.location.protocol == "http:" ? "ws://" : "wss://"; let url = window.location.protocol == "http:" ? "ws://" : "wss://";
var path = window.location.href.substring(window.location.protocol.length+2); let path = window.location.href.substring(window.location.protocol.length+2);
path = path.substring(location.host.length+1); path = path.substring(location.host.length+1);
var last=path.lastIndexOf("/"); let last=path.lastIndexOf("/");
if (last > 0) { if (last > 0) {
path = "/" + path.substring(0, last) + "/serverpush/"; path = "/" + path.substring(0, last) + "/serverpush/";
} else { } else {
path = "/serverpush/"; path = "/serverpush/";
} }
url = url + window.location.host + path + desktop.id; url = url + window.location.host + path + desktop.id;
var me = this; let me = this;
this.socket = new WebSocket(url); this.socket = new WebSocket(url);
this.socket.onopen = function (event) { this.socket.onopen = function (event) {
me.active = true; me.active = true;
@ -49,7 +49,7 @@
}; };
this.socket.onmessage = function (event) { this.socket.onmessage = function (event) {
if (event.data=="echo") { if (event.data=="echo") {
var desktop = zk.Desktop.$(me.dtid); let desktop = zk.Desktop.$(me.dtid);
zAu.cmd0.echo(desktop); zAu.cmd0.echo(desktop);
} else if (event.data=="stop") { } else if (event.data=="stop") {
me.stop(); me.stop();
@ -69,7 +69,7 @@
}, },
stop: function() { stop: function() {
this.active = false; this.active = false;
var desktop = zk.Desktop.$(this.dtid); let desktop = zk.Desktop.$(this.dtid);
desktop._serverpush = null; desktop._serverpush = null;
if (this.socket) { if (this.socket) {
try { try {

View File

@ -35,224 +35,6 @@ if (window.location.protocol == 'https:') {
zk._Erbx.push = function(msg) { zk._Erbx.push = function(msg) {
if (console) console.log(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 } //window.location.protocol check