[GB.WEB.FORM]
* BUG: WebDateBox: Settings the Value (or Date) property raise the Change event. * NEW: WebForm: The AddJavascriptFile() method now support extern javaascript files. * NEW: WebTable: EnsureVisible() is a new method ensuring that a specific row is visible to the screen. * BUG: WebTextBox: Fix the raise of Activate event. * BUG: WebTextBox: Fix autocompletion support. git-svn-id: svn://localhost/gambas/trunk@8041 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
12da889f63
commit
bb3b541b54
11 changed files with 180 additions and 47 deletions
comp/src/gb.web.form
|
@ -1196,6 +1196,10 @@ _GetJavascriptFiles
|
|||
m
|
||||
String[]
|
||||
|
||||
_GetJavascriptExternFiles
|
||||
m
|
||||
String[]
|
||||
|
||||
AddJavascriptFile
|
||||
m
|
||||
|
||||
|
@ -1794,6 +1798,10 @@ AddColumn
|
|||
m
|
||||
_WebTableColumn
|
||||
(Text)s[(Width)s(Alignment)i]
|
||||
EnsureVisible
|
||||
m
|
||||
|
||||
(Row)i
|
||||
#WebTableData
|
||||
|
||||
C
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 3.9.90
|
||||
Startup=Webform3
|
||||
Startup=Webform6
|
||||
UseHttpServer=1
|
||||
Version=3.9.90
|
||||
VersionFile=1
|
||||
|
|
|
@ -83,6 +83,7 @@ Private Sub Date_Write(Value As Date)
|
|||
|
||||
$dDate = Value
|
||||
Me._SetProperty("Date", Value)
|
||||
Raise Change
|
||||
|
||||
End
|
||||
|
||||
|
|
|
@ -19,5 +19,18 @@ Private Sub GetJavascript() As String
|
|||
aFiles = Form._GetJavascriptFiles()
|
||||
If aFiles And If aFiles.Count Then Return ":" & aFiles.Join(":")
|
||||
|
||||
|
||||
End
|
||||
|
||||
Private Sub PrintJavascriptExternFiles()
|
||||
|
||||
Dim aFiles As String[]
|
||||
Dim sFile As String
|
||||
|
||||
aFiles = Form._GetJavascriptExternFiles()
|
||||
If aFiles Then
|
||||
For Each sFile In aFiles
|
||||
Print "<script type=\"text/javascript\" src=\""; Html(sFile); "\"></script>"
|
||||
Next
|
||||
Endif
|
||||
|
||||
End
|
||||
|
|
|
@ -7,5 +7,6 @@
|
|||
<link rel="stylesheet" href="<%/%>/<%="style:" & Application.Version & ".css"%>">
|
||||
<link rel="icon" href="<%/%>/favicon.png" type="image/png">
|
||||
<script type="text/javascript" src="<%/%>/<%="lib" & GetJavascript() & ":" & Application.Version & ".js"%>"></script>
|
||||
<%PrintJavascriptExternFiles()%>
|
||||
<title><%=GetTitle()%></title>
|
||||
</head>
|
||||
|
|
|
@ -1,22 +1,14 @@
|
|||
' Gambas class file
|
||||
|
||||
|
||||
Public Sub WebTextBox1_Completion(Text As String)
|
||||
|
||||
Dim aList As String[]
|
||||
Dim I As Integer
|
||||
|
||||
aList = New String[]
|
||||
For I = 1 To 10
|
||||
aList.Add(Text & "-" & Chr$(64 + I))
|
||||
Next
|
||||
|
||||
WebTextBox1.CompleteWith(aList)
|
||||
|
||||
End
|
||||
|
||||
Public Sub WebForm_Open()
|
||||
|
||||
WebForm.Debug = True
|
||||
|
||||
End
|
||||
|
||||
Public Sub WebComboBox1_Click()
|
||||
|
||||
Debug
|
||||
|
||||
End
|
||||
|
|
|
@ -5,28 +5,8 @@
|
|||
Arrangement = Arrange.Vertical
|
||||
Margin = True
|
||||
Spacing = True
|
||||
{ panStop WebContainer
|
||||
#MoveScaled(1,1,72,6)
|
||||
Background = Color.Red
|
||||
Arrangement = Arrange.Horizontal
|
||||
Spacing = True
|
||||
{ btnRadio WebButton
|
||||
#MoveScaled(1,1,16,4)
|
||||
Text = ("Stop radio")
|
||||
}
|
||||
{ btnLogout WebButton
|
||||
#MoveScaled(18,1,11,4)
|
||||
Text = ("Logout") & "..."
|
||||
Image = "favicon.png"
|
||||
}
|
||||
}
|
||||
{ WebTextBox1 WebTextBox
|
||||
#MoveScaled(1,8,72,4)
|
||||
ShowClear = True
|
||||
}
|
||||
{ WebComboBox1 WebComboBox
|
||||
#MoveScaled(1,13,72,4)
|
||||
#MoveScaled(1,1,72,4)
|
||||
List = [("Élément 1"), ("Élément 2"), ("Élément 3")]
|
||||
ReadOnly = False
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ Public _Loaded As Boolean
|
|||
Public _Window As Integer
|
||||
|
||||
Private $aJavascriptFiles As String[]
|
||||
Private $aJavascriptExternfiles As String[]
|
||||
|
||||
Private $sTitle As String
|
||||
Private $bResizable As Boolean
|
||||
|
@ -798,11 +799,22 @@ Public Sub _GetJavascriptFiles() As String[]
|
|||
|
||||
End
|
||||
|
||||
Public Sub _GetJavascriptExternFiles() As String[]
|
||||
|
||||
Return $aJavascriptExternFiles
|
||||
|
||||
End
|
||||
|
||||
Public Sub AddJavascriptFile(sFile As String)
|
||||
|
||||
If sFile Ends ".js" Then sFile = Left(sFile, -3)
|
||||
If Not $aJavascriptFiles Then $aJavascriptFiles = New String[]
|
||||
$aJavascriptFiles.Add(sFile)
|
||||
If sFile Begins "http://" Or If sFile Begins "https://" Then
|
||||
If Not $aJavascriptExternFiles Then $aJavascriptExternFiles = New String[]
|
||||
$aJavascriptExternFiles.Add(sFile)
|
||||
Else
|
||||
If sFile Ends ".js" Then sFile = Left(sFile, -3)
|
||||
If Not $aJavascriptFiles Then $aJavascriptFiles = New String[]
|
||||
$aJavascriptFiles.Add(sFile)
|
||||
Endif
|
||||
|
||||
End
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ Private $iScrollY As Integer
|
|||
Private $bNoScrolling As Boolean
|
||||
Private $bNoCheck As Boolean
|
||||
Private $bNoHeader As Boolean
|
||||
|
||||
Private $iEnsureVisible As Integer = -1
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
|
@ -170,7 +170,12 @@ Public Sub _Render()
|
|||
If $bNoScrolling Then
|
||||
$bNoScrolling = False
|
||||
Else
|
||||
WebForm._AddJavascript("gw.table.scroll(" & JS(Me.Name) & "," & JS($iScrollX) & "," & JS($iScrollY) & ")")
|
||||
If $iEnsureVisible > 0 Then
|
||||
WebForm._AddJavascript("gw.table.ensureVisible(" & JS(Me.Name) & "," & CStr($iEnsureVisible) & ")")
|
||||
$iEnsureVisible = -1
|
||||
Else
|
||||
WebForm._AddJavascript("gw.table.scroll(" & JS(Me.Name) & "," & JS($iScrollX) & "," & JS($iScrollY) & ")")
|
||||
Endif
|
||||
Endif
|
||||
|
||||
If $iMode = Select.Single Then WebForm._AddJavascript("$(" & JS(Me.Name) & ").gw_current = " & Current_Read())
|
||||
|
@ -532,6 +537,15 @@ Public Sub AddColumn(Text As String, Optional Width As String, Alignment As Inte
|
|||
hCol.Alignment = Alignment
|
||||
|
||||
Return hCol
|
||||
|
||||
|
||||
End
|
||||
|
||||
Public Sub EnsureVisible(Row As Integer)
|
||||
|
||||
If Row < 0 Or If Row >= $iCount Then Return
|
||||
|
||||
Me.Display = Min($iCount, Max($iStep, ((Row + $iStep - 1) \ $iStep) * $iStep))
|
||||
Me.Refresh
|
||||
$iEnsureVisible = Row
|
||||
|
||||
End
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Webform3
|
||||
Webform6
|
||||
|
||||
0
|
||||
0
|
||||
|
|
|
@ -44,6 +44,17 @@ Element.prototype.removeClass = function(klass)
|
|||
}
|
||||
};
|
||||
|
||||
/*Element.prototype.ensureVisible = function()
|
||||
{
|
||||
var parent = this.offsetParent;
|
||||
|
||||
while (parent && parent.clientHeight == parent.scrollHeight && parent.clientWidth == parent.scrollWidth)
|
||||
parent = parent.offsetParent;
|
||||
|
||||
if (parent)
|
||||
gw.ensureVisible(this.offsetParent, this.offsetLeft, this.offsetTop, this.offsetWidth, this.offsetHeight);
|
||||
};*/
|
||||
|
||||
gw = {
|
||||
|
||||
version: '0',
|
||||
|
@ -454,6 +465,95 @@ gw = {
|
|||
return { found: found, left: left, top: top, width: width, height: height, right: left + width, bottom: top + height };
|
||||
},
|
||||
|
||||
/*ensureVisible: function(id, x, y, w, h)
|
||||
{
|
||||
var elt = typeof(id) == 'string' ? $(id) : id;
|
||||
var pw, ph,cx, cy, cw, ch;
|
||||
var xx, yy, ww, hh;
|
||||
|
||||
// WW = W / 2
|
||||
ww = w / 2;
|
||||
//HH = H / 2
|
||||
hh = h / 2;
|
||||
// XX = X + WW
|
||||
xx = x + ww
|
||||
// YY = Y + HH
|
||||
yy = y + hh;
|
||||
|
||||
// PW = Me.ClientW
|
||||
// PH = Me.ClientH
|
||||
pw = elt.clientWidth;
|
||||
ph = elt.clientHeight;
|
||||
|
||||
cx = - elt.scrollLeft;
|
||||
cy = - elt.scrollTop;
|
||||
cw = elt.scrollWidth;
|
||||
ch = elt.scrollHeight;
|
||||
|
||||
//If PW < (WW * 2) Then WW = PW / 2
|
||||
//If PH < (HH * 2) Then HH = PH / 2
|
||||
if (pw < (ww * 2)) ww = pw / 2;
|
||||
if (ph < (hh * 2)) hh = ph / 2;
|
||||
|
||||
//If CW <= PW Then
|
||||
// WW = 0
|
||||
// CX = 0
|
||||
//Endif
|
||||
if (cw <= pw) { ww = 0; cx = 0; }
|
||||
|
||||
//If CH <= PH Then
|
||||
// HH = 0
|
||||
// CY = 0
|
||||
//Endif
|
||||
if (ch <= ph) { hh = 0; cy = 0 }
|
||||
|
||||
//If XX < (- CX + WW) Then
|
||||
// CX = Ceil(- XX + WW)
|
||||
//Else If XX >= (- CX + PW - WW) Then
|
||||
// CX = Floor(- XX + PW - WW)
|
||||
//Endif
|
||||
if (xx < (- cx + ww))
|
||||
cx = - xx + ww;
|
||||
else if (xx >= (- cx + pw - ww))
|
||||
cx = - xx + pw - ww;
|
||||
|
||||
//If YY < (- CY + HH) Then
|
||||
// CY = Ceil(- YY + HH)
|
||||
//Else If YY >= (- CY + PH - HH) Then
|
||||
// CY = Floor(- YY + PH - HH)
|
||||
//Endif
|
||||
|
||||
if (yy < (- cy + hh))
|
||||
cy = - yy + hh;
|
||||
else if (yy >= (- cy + ph - hh))
|
||||
cy = - yy + ph - hh;
|
||||
|
||||
//If CX > 0
|
||||
// CX = 0
|
||||
//Else If CX < (PW - CW) And If CW > PW Then
|
||||
// CX = PW - CW
|
||||
//Endif
|
||||
if (cx > 0)
|
||||
cx = 0;
|
||||
else if (cx < (pw - cw) && cw > pw)
|
||||
cx = pw - cw;
|
||||
|
||||
//If CY > 0 Then
|
||||
// CY = 0
|
||||
//Else If CY < (PH - CH) And If CH > PH Then
|
||||
// CY = PH - CH
|
||||
//Endif
|
||||
if (cy > 0)
|
||||
cy = 0;
|
||||
else if (cy < (ph - ch) && ch > ph)
|
||||
cy = ph - ch;
|
||||
|
||||
//If $hHBar.Value = - CX And If $hVBar.Value = - CY Then Return True
|
||||
//Scroll(- CX, - CY)
|
||||
elt.scrollLeft = - cx;
|
||||
elt.scrollTop = - cy;
|
||||
},*/
|
||||
|
||||
window:
|
||||
{
|
||||
zIndex: 0,
|
||||
|
@ -1026,6 +1126,12 @@ gw = {
|
|||
}
|
||||
if (x != sw.scrollLeft || y != sw.scrollTop)
|
||||
gw.update(id, '#scroll', [sw.scrollLeft, sw.scrollTop]);
|
||||
},
|
||||
|
||||
ensureVisible: function(id, row)
|
||||
{
|
||||
var sw = $(id).firstChild;
|
||||
gw.table.scroll(id, sw.scrollLeft, $(id + ':' + row).offsetTop - sw.clientHeight / 2);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1162,7 +1268,7 @@ gw = {
|
|||
xhr.send();
|
||||
},
|
||||
onSelect: function(e, term, item) {
|
||||
gw.update(id, 'text', $(id).value);
|
||||
gw.textbox.setText(id, gw.textbox.getText(id));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -1171,8 +1277,14 @@ gw = {
|
|||
{
|
||||
onactivate: function(id, e)
|
||||
{
|
||||
gw.log('textbox.onactivate');
|
||||
if (e.keyCode == 13)
|
||||
setTimeout(function() { gw.raise(id, 'activate'); }, 50);
|
||||
setTimeout(function() { gw.raise(id, 'activate', [], false); }, 50);
|
||||
},
|
||||
|
||||
getText: function(id)
|
||||
{
|
||||
return $(id + ':entry').value;
|
||||
},
|
||||
|
||||
setText: function(id, text)
|
||||
|
@ -1188,7 +1300,7 @@ gw = {
|
|||
{
|
||||
gw.textbox.setText(id, '');
|
||||
gw.setFocus(id);
|
||||
gw.raise(id, 'activate');
|
||||
gw.raise(id, 'activate', [], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue