diff --git a/comp/src/gb.web.gui/.src/Menu/FPopupMenu.class b/comp/src/gb.web.gui/.src/Menu/FPopupMenu.class index 99334dedf..8048ee93f 100644 --- a/comp/src/gb.web.gui/.src/Menu/FPopupMenu.class +++ b/comp/src/gb.web.gui/.src/Menu/FPopupMenu.class @@ -80,7 +80,7 @@ Public Sub _UpdateProperty(sProp As String, vValue As Variant) WebForm._AddJavascript("$_(" & JS(vValue) & ").parentNode.addClass('gw-active');") hMenu = WebForm.FromName(vValue) sClick = PopupMenu(hMenu) - WebForm._AddJavascript("$_(" & JS(vValue) & ").parentNode.removeClass('gw-active');") + WebForm._AddJavascript("$_(" & JS(vValue) & ") && $_(" & JS(vValue) & ").parentNode.removeClass('gw-active');") If sClick Then Me.Close(sClick) Endif diff --git a/comp/src/gb.web.gui/.src/Paint/Paint.class b/comp/src/gb.web.gui/.src/Paint/Paint.class index 5a9e7ad29..c25ef773e 100644 --- a/comp/src/gb.web.gui/.src/Paint/Paint.class +++ b/comp/src/gb.web.gui/.src/Paint/Paint.class @@ -179,7 +179,6 @@ Static Private Sub Brush_Write(Value As PaintBrush) End - Static Public Sub DrawImage(Image As String, X As Float, Y As Float, Optional Width As Float, Height As Float, Opacity As Float = 1.0, Source As Rect) $hCurrent.DrawImage(Image, X, Y, Width, Height, Opacity, Source) diff --git a/comp/src/gb.web.gui/.src/WebButton.class b/comp/src/gb.web.gui/.src/WebButton.class index e4f043cca..6f0aeea0d 100644 --- a/comp/src/gb.web.gui/.src/WebButton.class +++ b/comp/src/gb.web.gui/.src/WebButton.class @@ -51,9 +51,7 @@ Private Sub Text_Write(Value As String) If $sText = Value Then Return $sText = Value - If Me._CanRefresh() Then - WebForm._AddJavascript("gw.button.setText(" & JS(Me.Name) & "," & JS(Html(Value)) & ");") - Endif + If Me._CanRefresh() Then Me._AddRefresh("gw.button.setText(" & JS(Me.Name) & "," & JS(Html(Value)) & ");") End diff --git a/comp/src/gb.web.gui/.src/WebCheckBox.class b/comp/src/gb.web.gui/.src/WebCheckBox.class index de67d39d7..fc217c578 100644 --- a/comp/src/gb.web.gui/.src/WebCheckBox.class +++ b/comp/src/gb.web.gui/.src/WebCheckBox.class @@ -67,7 +67,7 @@ Private Sub Value_Write(Value As Boolean) If $bChecked = Value Then Return $bChecked = Value If Me._CanRefresh() Then - WebForm._AddJavascript("$_(" & JS(Me.Name & ":input") & ").checked = " & JS($bChecked) & ";") + Me._AddRefresh("$_(" & JS(Me.Name & ":input") & ").checked = " & JS($bChecked) & ";") Endif Raise Click diff --git a/comp/src/gb.web.gui/.src/WebComboBox.class b/comp/src/gb.web.gui/.src/WebComboBox.class index 72c10b820..cf79365db 100644 --- a/comp/src/gb.web.gui/.src/WebComboBox.class +++ b/comp/src/gb.web.gui/.src/WebComboBox.class @@ -130,7 +130,7 @@ Private Sub Index_Write(Value As Integer) Endif 'Me.Refresh - If Me._CanRefresh() Then WebForm._AddJavascript("gw.combobox.update(" & JS(Me.Name) & "," & CStr($iIndex) & If($bReadOnly, "", "," & JS($sText)) & ");") + If Me._CanRefresh() Then Me._AddRefresh("gw.combobox.update(" & JS(Me.Name) & "," & CStr($iIndex) & If($bReadOnly, "", "," & JS($sText)) & ");") Raise Click @@ -254,8 +254,7 @@ Private Sub Text_Write(Value As String) $sText = Value - If Me._CanRefresh() Then WebForm._AddJavascript("gw.combobox.update(" & JS(Me.Name) & "," & CStr(iIndex) & "," & JS($sText) & ");") - 'WebForm._AddJavascript("$_(" & JS(Me.Name & ":entry") & ").value = " & JS($sText)) + If Me._CanRefresh() Then Me._AddRefresh("gw.combobox.update(" & JS(Me.Name) & "," & CStr(iIndex) & "," & JS($sText) & ");") If iIndex <> $iIndex Then $iIndex = iIndex diff --git a/comp/src/gb.web.gui/.src/WebContainer.class b/comp/src/gb.web.gui/.src/WebContainer.class index 1ccf8820f..6f737517a 100644 --- a/comp/src/gb.web.gui/.src/WebContainer.class +++ b/comp/src/gb.web.gui/.src/WebContainer.class @@ -63,7 +63,7 @@ Public Sub _Remove(hChild As WebControl) $aChildren.Remove($aChildren.Find(hChild.Name)) If Me._CanRefresh() Then - WebForm._AddJavascript("gw.removeElement(" & JS(hChild.Name) & ");") + WebForm._AddJavascriptBefore("gw.removeElement(" & JS(hChild.Name) & ");") Endif End diff --git a/comp/src/gb.web.gui/.src/WebControl.class b/comp/src/gb.web.gui/.src/WebControl.class index 91a8335b9..331b15cf8 100644 --- a/comp/src/gb.web.gui/.src/WebControl.class +++ b/comp/src/gb.web.gui/.src/WebControl.class @@ -98,6 +98,8 @@ Static Public _NextName As String Static Public _Shortcuts As New Collection +Static Public _RefreshJavascript As New Collection + Static Private $hCellParent As WebControl Static Private $sCellId As String @@ -642,6 +644,7 @@ Public Sub Refresh() _Refresh = True WebForm._HasRefresh = True + _RefreshJavascript.Remove($iId) Me._CancelChildrenRefresh() @@ -651,6 +654,7 @@ Public Sub _CancelRefresh() 'WebForm.PrintLog("Cancel refresh: " & Me.Name) _Refresh = False + _RefreshJavascript.Remove($iId) Me._CancelChildrenRefresh() End @@ -680,8 +684,6 @@ Public Sub _RefreshReply() As Boolean sResult = Close #hFile Output To Default - 'WebForm._AddRefresh("$_(" & JS(Me.Name) & ").outerHTML = " & JS(sResult) & ";") - If _Naked Then Print "gw.setInnerHtml("; JS(Me.Name); ","; JS(sResult); ");" Else @@ -790,7 +792,7 @@ Private Sub Visible_Write(Value As Boolean) $bHidden = Not Value If bCanRefresh Then - WebForm._AddJavascript("gw.setVisible(" & JS(Me.Name) & "," & JS(Not $bHidden) & ");") + Me._AddRefresh("gw.setVisible(" & JS(Me.Name) & "," & JS(Not $bHidden) & ");") If Me.Parent Then Me.Parent.Refresh Else If Me Is WebContainer Then @@ -1296,3 +1298,9 @@ Public Sub _RaiseMouseEvent(sEvent As String, cEvent As Variant) Object.Raise(Me, sEvent) End + +Public Sub _AddRefresh(sJavascript As String) + + _RefreshJavascript[$iId] &= sJavascript + +End diff --git a/comp/src/gb.web.gui/.src/WebFileButton.class b/comp/src/gb.web.gui/.src/WebFileButton.class index ed0a9ff12..9a17aa456 100644 --- a/comp/src/gb.web.gui/.src/WebFileButton.class +++ b/comp/src/gb.web.gui/.src/WebFileButton.class @@ -49,7 +49,7 @@ Private Sub Text_Write(Value As String) If $sText = Value Then Return $sText = Value If Me._CanRefresh() Then - WebForm._AddJavascript("gw.button.setText(" & JS(Me.Name) & "," & JS(Html(Value)) & ");") + Me._AddRefresh("gw.button.setText(" & JS(Me.Name) & "," & JS(Html(Value)) & ");") Endif End diff --git a/comp/src/gb.web.gui/.src/WebForm.class b/comp/src/gb.web.gui/.src/WebForm.class index 2c9e2bf3b..e74dd4c22 100644 --- a/comp/src/gb.web.gui/.src/WebForm.class +++ b/comp/src/gb.web.gui/.src/WebForm.class @@ -748,16 +748,27 @@ End Static Private Sub PrintJavascript() + Dim sJavascript As Variant + If $aJavascriptBefore.Count Then Print $aJavascriptBefore.Join("\n") $aJavascriptBefore.Clear Endif + ' Handle full refreshes + If _HasRefresh Then _HasRefresh = False _Current._RefreshReply() Endif + ' Handle small refreshes done by javascript, and that were not cancelled by a full refreh + + For Each sJavascript In WebControl._RefreshJavascript + Print sJavascript + Next + WebControl._RefreshJavascript.Clear + If $aJavascript.Count Then Print $aJavascript.Join("\n") $aJavascript.Clear @@ -1345,7 +1356,6 @@ Public Sub ShowPopup(Control As WebControl) As Variant If _Window Then hWindow = WebControl.FromId(_Window) If hWindow.Visible Then Return - hWindow.Show() Endif If Not hWindow Then hWindow = New WebWindow(_Current._GetWindowContainer()) @@ -1357,6 +1367,8 @@ Public Sub ShowPopup(Control As WebControl) As Variant _Window = hWindow.Id + hWindow.Show() + hPrevious = _CurrentPopup _CurrentPopup = Me diff --git a/comp/src/gb.web.gui/.src/WebLabel.class b/comp/src/gb.web.gui/.src/WebLabel.class index e8aca33f1..1f540771d 100644 --- a/comp/src/gb.web.gui/.src/WebLabel.class +++ b/comp/src/gb.web.gui/.src/WebLabel.class @@ -43,7 +43,7 @@ Private Sub Text_Write(Value As String) $sText = Value If Me._CanRefresh() Then - WebForm._AddJavascript("gw.setInnerHtml(" & JS(Me.Name) & "," & JS(GetRenderText()) & ");") + Me._AddRefresh("gw.setInnerHtml(" & JS(Me.Name) & "," & JS(GetRenderText()) & ");") Endif End diff --git a/comp/src/gb.web.gui/.src/WebProgressBar.class b/comp/src/gb.web.gui/.src/WebProgressBar.class index 0fffba3ca..8966c5dba 100644 --- a/comp/src/gb.web.gui/.src/WebProgressBar.class +++ b/comp/src/gb.web.gui/.src/WebProgressBar.class @@ -47,8 +47,8 @@ Private Sub Value_Write(Value As Float) $fValue = Min(1, Max(0, Value)) If Me._CanRefresh() Then - WebForm._AddJavascript("$_(" & JS(Me.Name & ":p") & ").style.width = '" & CStr(CInt($fValue * 100)) & "." & CStr(CInt(Frac($fValue * 100) * 10)) & "%';") - If $bLabel Then WebForm._AddJavascript("gw.setInnerHtml(" & JS(Me.Name & ":l") & "," & JS(Html(Format($fValue, "0%"))) & ");") + Me._AddRefresh("$_(" & JS(Me.Name & ":p") & ").style.width = '" & CStr(CInt($fValue * 100)) & "." & CStr(CInt(Frac($fValue * 100) * 10)) & "%';") + If $bLabel Then Me._AddRefresh("gw.setInnerHtml(" & JS(Me.Name & ":l") & "," & JS(Html(Format($fValue, "0%"))) & ");") Else WebForm.PrintLog("Cannot refresh " & Me.Name & ": " & WebForm._InMessage & " / " & Me._NoRefresh & " / " & Me.IsHidden() & " / " & Me._Refresh) Endif diff --git a/comp/src/gb.web.gui/.src/WebRadioButton.class b/comp/src/gb.web.gui/.src/WebRadioButton.class index f2b7e0f62..a475bf99b 100644 --- a/comp/src/gb.web.gui/.src/WebRadioButton.class +++ b/comp/src/gb.web.gui/.src/WebRadioButton.class @@ -66,7 +66,7 @@ Private Sub Value_Write(Value As Boolean) If $bChecked <> Value Then $bChecked = Value If Me._CanRefresh() Then - WebForm._AddJavascript("$_(" & JS(Me.Name & ":input") & ").checked = " & JS($bChecked) & ";") + WebForm._AddJavascriptBefore("$_(" & JS(Me.Name & ":input") & ").checked = " & JS($bChecked) & ";") Endif Endif diff --git a/comp/src/gb.web.gui/.src/WebScrollView.class b/comp/src/gb.web.gui/.src/WebScrollView.class index b88738419..cb6898878 100644 --- a/comp/src/gb.web.gui/.src/WebScrollView.class +++ b/comp/src/gb.web.gui/.src/WebScrollView.class @@ -101,7 +101,7 @@ Private Sub ScrollX_Write(Value As Integer) If $iScrollX = Value Then Return $iScrollX = Value - If Me._CanRefresh() Then WebForm._AddJavascript("gw.scrollview.scroll(" & JS(Me.Name) & "," & JS($iScrollX) & "," & JS($iScrollY) & "); // _ScrollX") + If Me._CanRefresh() Then Me._AddRefresh("gw.scrollview.scroll(" & JS(Me.Name) & "," & JS($iScrollX) & "," & JS($iScrollY) & "); // _ScrollX") End @@ -116,7 +116,7 @@ Private Sub ScrollY_Write(Value As Integer) If $iScrollY = Value Then Return $iScrollY = Value - If Me._CanRefresh() Then WebForm._AddJavascript("gw.scrollview.scroll(" & JS(Me.Name) & "," & JS($iScrollX) & "," & JS($iScrollY) & "); // _ScrollY") + If Me._CanRefresh() Then Me._AddRefresh("gw.scrollview.scroll(" & JS(Me.Name) & "," & JS($iScrollX) & "," & JS($iScrollY) & "); // _ScrollY") End @@ -126,7 +126,7 @@ Public Sub Scroll(X As Integer, Y As Integer) $iScrollX = X $iScrollY = Y - If Me._CanRefresh() Then WebForm._AddJavascript("gw.scrollview.scroll(" & JS(Me.Name) & "," & JS($iScrollX) & "," & JS($iScrollY) & ");") + If Me._CanRefresh() Then Me._AddRefresh("gw.scrollview.scroll(" & JS(Me.Name) & "," & JS($iScrollX) & "," & JS($iScrollY) & ");") End diff --git a/comp/src/gb.web.gui/.src/WebTabPanel.class b/comp/src/gb.web.gui/.src/WebTabPanel.class index 66de192a9..ccf2e62e3 100644 --- a/comp/src/gb.web.gui/.src/WebTabPanel.class +++ b/comp/src/gb.web.gui/.src/WebTabPanel.class @@ -130,12 +130,12 @@ Private Sub SetCurrent(iIndex As Integer) If $aTab[I].Visible = bShow Then Continue $aTab[I].Visible = bShow 'If Not bShow Then - WebForm._AddJavascript("gw.setVisible(" & JS($aTab[I].Name) & "," & JS(bShow) & ");") + Me._AddRefresh("gw.setVisible(" & JS($aTab[I].Name) & "," & JS(bShow) & ");") Next Dec Me._NoRefresh Me._SetContainer($aTab[iIndex]) - WebForm._AddJavascript("gw.setOuterHtml(" & JS(Me.Name & ":header") & "," & JS(GetHeaderHTML()) & ");") + Me._AddRefresh("gw.setOuterHtml(" & JS(Me.Name & ":header") & "," & JS(GetHeaderHTML()) & ");") 'WebForm._AddJavascript("gw.setVisible(" & JS($aTab[iIndex].Name) & ",true);") '$aTab[iIndex].Refresh diff --git a/comp/src/gb.web.gui/.src/WebTextBox.class b/comp/src/gb.web.gui/.src/WebTextBox.class index ac3f19cb2..91b1d001b 100644 --- a/comp/src/gb.web.gui/.src/WebTextBox.class +++ b/comp/src/gb.web.gui/.src/WebTextBox.class @@ -47,7 +47,9 @@ Private Sub SetText(Value As String, Optional bNoRefresh As Boolean) $sText = Value - If Not bNoRefresh And If Me._CanRefresh() Then WebForm._AddJavascript("$_(" & JS(Me.Name & ":entry") & ").value = " & JS($sText) & ";") + If Not bNoRefresh And If Me._CanRefresh() Then + Me._AddRefresh("$_(" & JS(Me.Name & ":entry") & ").value = " & JS($sText) & ";") + Endif Raise Change diff --git a/comp/src/gb.web.gui/.src/WebTimer.class b/comp/src/gb.web.gui/.src/WebTimer.class index c69da418f..8816eb92a 100644 --- a/comp/src/gb.web.gui/.src/WebTimer.class +++ b/comp/src/gb.web.gui/.src/WebTimer.class @@ -66,9 +66,9 @@ Private Sub Enabled_Write(Value As Boolean) If Me._CanRefresh() Then If $bEnabled Then - WebForm._AddJavascript("gw.addTimer(" & JS(Me.Name) & "," & CStr($iDelay) & ");") + Me._AddRefresh("gw.addTimer(" & JS(Me.Name) & "," & CStr($iDelay) & ");") Else - WebForm._AddJavascript("gw.removeTimer(" & JS(Me.Name) & ");") + Me._AddRefresh("gw.removeTimer(" & JS(Me.Name) & ");") Endif Endif diff --git a/comp/src/gb.web.gui/.src/WebWindow.class b/comp/src/gb.web.gui/.src/WebWindow.class index ad4fbe439..d3b3b59e3 100644 --- a/comp/src/gb.web.gui/.src/WebWindow.class +++ b/comp/src/gb.web.gui/.src/WebWindow.class @@ -350,7 +350,7 @@ Private Sub Maximized_Write(Value As Boolean) If $bMaximized = Value Then Return $bMaximized = Value - If Me._CanRefresh() Then WebForm._AddJavascript("gw.window.maximize(" & JS(Me.Name) & ");") + If Me._CanRefresh() Then Me._AddRefresh("gw.window.maximize(" & JS(Me.Name) & ");") End diff --git a/comp/src/gb.web.gui/lib.js b/comp/src/gb.web.gui/lib.js index b61a47e44..8301c4547 100644 --- a/comp/src/gb.web.gui/lib.js +++ b/comp/src/gb.web.gui/lib.js @@ -283,7 +283,14 @@ gw = { else gw.log('--> ' + expr); } - eval(expr); + try { + eval(expr); + } + catch(e) + { + gw.log('eval: ' + expr); + throw e; + } if (!gw.focus) gw.restoreFocus(save); diff --git a/comp/src/gb.web.gui/style.css b/comp/src/gb.web.gui/style.css index f7158eacc..7b52c31e0 100644 --- a/comp/src/gb.web.gui/style.css +++ b/comp/src/gb.web.gui/style.css @@ -323,7 +323,6 @@ P:first-child,UL:first-child,OL:first-child { .gw-popup { position: absolute !important; - border: solid 1px #C0C0C0; border-radius: 0; box-shadow: none; }