sws 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/doc/DOC.otl +34 -0
- data/doc/Makefile +13 -0
- data/doc/architecture.dia +0 -0
- data/doc/docbook/architecture.png +0 -0
- data/doc/docbook/concepts.docbook +474 -0
- data/doc/docbook/installation.docbook +57 -0
- data/doc/docbook/introduction.docbook +130 -0
- data/doc/docbook/sws_manual.docbook +35 -0
- data/doc/docbook/todo.docbook +38 -0
- data/doc/docbook/tutorial.docbook +594 -0
- data/examples/README +1 -0
- data/examples/addressbook/CardBrowse/CardBrowse.html +43 -0
- data/examples/addressbook/CardBrowse/CardBrowse.rb +65 -0
- data/examples/addressbook/CardBrowse/CardBrowse.sws +92 -0
- data/examples/addressbook/Login/LoginPage.html +12 -0
- data/examples/addressbook/Login/LoginPage.rb +19 -0
- data/examples/addressbook/Login/LoginPage.sws +15 -0
- data/examples/addressbook/README +1 -0
- data/examples/addressbook/addressbook.rb +70 -0
- data/examples/addressbook/application.yaml +8 -0
- data/examples/addressbook/db.yaml +7 -0
- data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.html +11 -0
- data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.rb +21 -0
- data/examples/component_demo/CheckBoxDemo/CheckBoxDemo.sws +25 -0
- data/examples/component_demo/ComponentDemo.rb +21 -0
- data/examples/component_demo/ConditionalDemo/ConditionalDemo.html +18 -0
- data/examples/component_demo/ConditionalDemo/ConditionalDemo.rb +2 -0
- data/examples/component_demo/ConditionalDemo/ConditionalDemo.sws +22 -0
- data/examples/component_demo/FileUploadDemo/FileUploadDemo.html +10 -0
- data/examples/component_demo/FileUploadDemo/FileUploadDemo.rb +9 -0
- data/examples/component_demo/FileUploadDemo/FileUploadDemo.sws +33 -0
- data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.html +12 -0
- data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.rb +21 -0
- data/examples/component_demo/FormFieldsDemo/FormFieldsDemo.sws +40 -0
- data/examples/component_demo/FormListsDemo/FormListsDemo.html +11 -0
- data/examples/component_demo/FormListsDemo/FormListsDemo.rb +37 -0
- data/examples/component_demo/FormListsDemo/FormListsDemo.sws +47 -0
- data/examples/component_demo/GenericDemo/GenericDemo.html +4 -0
- data/examples/component_demo/GenericDemo/GenericDemo.rb +2 -0
- data/examples/component_demo/GenericDemo/GenericDemo.sws +10 -0
- data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.html +8 -0
- data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.rb +20 -0
- data/examples/component_demo/HyperlinkDemo/HyperlinkDemo.sws +19 -0
- data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.html +11 -0
- data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.rb +2 -0
- data/examples/component_demo/ImageLinkDemo/ImageLinkDemo.sws +14 -0
- data/examples/component_demo/PageWrapper/PageWrapper.html +23 -0
- data/examples/component_demo/PageWrapper/PageWrapper.rb +2 -0
- data/examples/component_demo/PageWrapper/PageWrapper.sws +42 -0
- data/examples/component_demo/README +1 -0
- data/examples/component_demo/RepetitionDemo/RepetitionDemo.html +13 -0
- data/examples/component_demo/RepetitionDemo/RepetitionDemo.rb +19 -0
- data/examples/component_demo/RepetitionDemo/RepetitionDemo.sws +20 -0
- data/examples/component_demo/StringDemo/StringDemo.html +5 -0
- data/examples/component_demo/StringDemo/StringDemo.rb +16 -0
- data/examples/component_demo/StringDemo/StringDemo.sws +14 -0
- data/examples/component_demo/application.yaml +28 -0
- data/examples/component_demo/poweredby.jpg +0 -0
- data/examples/component_demo/style.css +1 -0
- data/examples/movies/Menu/Menu.html +3 -0
- data/examples/movies/Menu/Menu.rb +7 -0
- data/examples/movies/Menu/Menu.sws +7 -0
- data/examples/movies/MovieBrowse/MovieBrowse.html +68 -0
- data/examples/movies/MovieBrowse/MovieBrowse.rb +178 -0
- data/examples/movies/MovieBrowse/MovieBrowse.sws +127 -0
- data/examples/movies/README +1 -0
- data/examples/movies/UserBrowse/UserBrowse.html +50 -0
- data/examples/movies/UserBrowse/UserBrowse.rb +69 -0
- data/examples/movies/UserBrowse/UserBrowse.sws +49 -0
- data/examples/movies/application.yaml +11 -0
- data/examples/movies/da.rb +36 -0
- data/examples/movies/dbmovies.rb +44 -0
- data/examples/movies/frameworks/TestFramework/framework.yaml +4 -0
- data/examples/movies/frameworks/TestFramework/resources/im1.jpg +0 -0
- data/examples/movies/images/pbr1b.jpg +0 -0
- data/examples/movies/movies.rb +28 -0
- data/examples/movies/movies.sds +119 -0
- data/examples/movies/movies.sqlite +0 -0
- data/examples/movies/movies_mysql.sql +28 -0
- data/examples/movies/movies_postgres.sql +27 -0
- data/examples/movies/movies_sqlite.sql +28 -0
- data/lib/sws.rb +89 -0
- data/lib/sws/Core/components/CheckBox/CheckBox.api +5 -0
- data/lib/sws/Core/components/CheckBox/CheckBox.rb +45 -0
- data/lib/sws/Core/components/CheckBoxList/CheckBoxList.api +13 -0
- data/lib/sws/Core/components/CheckBoxList/CheckBoxList.rb +54 -0
- data/lib/sws/Core/components/Conditional/Conditional.api +3 -0
- data/lib/sws/Core/components/Conditional/Conditional.html +1 -0
- data/lib/sws/Core/components/Conditional/Conditional.rb +39 -0
- data/lib/sws/Core/components/Conditional/Conditional.sws +2 -0
- data/lib/sws/Core/components/Content/Content.rb +18 -0
- data/lib/sws/Core/components/ExceptionPage/ExceptionPage.html +13 -0
- data/lib/sws/Core/components/ExceptionPage/ExceptionPage.rb +18 -0
- data/lib/sws/Core/components/ExceptionPage/ExceptionPage.sws +16 -0
- data/lib/sws/Core/components/FileUpload/FileUpload.api +16 -0
- data/lib/sws/Core/components/FileUpload/FileUpload.rb +62 -0
- data/lib/sws/Core/components/Form/Form.api +9 -0
- data/lib/sws/Core/components/Form/Form.html +3 -0
- data/lib/sws/Core/components/Form/Form.rb +55 -0
- data/lib/sws/Core/components/Form/Form.sws +12 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.api +10 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.html +1 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.rb +39 -0
- data/lib/sws/Core/components/GenericContainer/GenericContainer.sws +12 -0
- data/lib/sws/Core/components/GenericElement/GenericElement.api +10 -0
- data/lib/sws/Core/components/GenericElement/GenericElement.rb +34 -0
- data/lib/sws/Core/components/HiddenField/HiddenField.api +7 -0
- data/lib/sws/Core/components/HiddenField/HiddenField.rb +37 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.api +13 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.html +1 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.rb +102 -0
- data/lib/sws/Core/components/Hyperlink/Hyperlink.sws +12 -0
- data/lib/sws/Core/components/Image/Image.api +11 -0
- data/lib/sws/Core/components/Image/Image.rb +49 -0
- data/lib/sws/Core/components/ImageButton/ImageButton.api +16 -0
- data/lib/sws/Core/components/ImageButton/ImageButton.rb +76 -0
- data/lib/sws/Core/components/Link/Link.api +11 -0
- data/lib/sws/Core/components/Link/Link.rb +39 -0
- data/lib/sws/Core/components/PasswordField/PasswordField.api +7 -0
- data/lib/sws/Core/components/PasswordField/PasswordField.rb +41 -0
- data/lib/sws/Core/components/RadioButton/RadioButton.api +7 -0
- data/lib/sws/Core/components/RadioButton/RadioButton.rb +44 -0
- data/lib/sws/Core/components/RadioButtonList/RadioButtonList.api +20 -0
- data/lib/sws/Core/components/RadioButtonList/RadioButtonList.rb +76 -0
- data/lib/sws/Core/components/Repetition/Repetition.api +10 -0
- data/lib/sws/Core/components/Repetition/Repetition.html +1 -0
- data/lib/sws/Core/components/Repetition/Repetition.rb +137 -0
- data/lib/sws/Core/components/Repetition/Repetition.sws +2 -0
- data/lib/sws/Core/components/ResetButton/ResetButton.api +5 -0
- data/lib/sws/Core/components/ResetButton/ResetButton.rb +28 -0
- data/lib/sws/Core/components/Select/Select.api +24 -0
- data/lib/sws/Core/components/Select/Select.rb +57 -0
- data/lib/sws/Core/components/String/String.api +5 -0
- data/lib/sws/Core/components/String/String.rb +28 -0
- data/lib/sws/Core/components/SubmitButton/SubmitButton.api +6 -0
- data/lib/sws/Core/components/SubmitButton/SubmitButton.rb +53 -0
- data/lib/sws/Core/components/TextArea/TextArea.api +9 -0
- data/lib/sws/Core/components/TextArea/TextArea.rb +28 -0
- data/lib/sws/Core/components/TextField/TextField.api +9 -0
- data/lib/sws/Core/components/TextField/TextField.rb +46 -0
- data/lib/sws/Core/framework.yaml +25 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.api +5 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.html +58 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.rb +34 -0
- data/lib/sws/JSComponents/components/JSMenu/JSMenu.sws +37 -0
- data/lib/sws/JSComponents/framework.yaml +3 -0
- data/lib/sws/adaptor.rb +334 -0
- data/lib/sws/application.rb +604 -0
- data/lib/sws/component.rb +656 -0
- data/lib/sws/cookie.rb +27 -0
- data/lib/sws/direct_action.rb +38 -0
- data/lib/sws/extensions.rb +49 -0
- data/lib/sws/parsers.rb +374 -0
- data/lib/sws/request.rb +308 -0
- data/lib/sws/response.rb +70 -0
- data/lib/sws/session.rb +195 -0
- data/lib/sws/slot.rb +198 -0
- metadata +263 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module SWS
|
|
2
|
+
|
|
3
|
+
# Represents <INPUT type=reset tag
|
|
4
|
+
# Bindings:
|
|
5
|
+
# - value (required, default: "Reset") - string to display on the button
|
|
6
|
+
# - other_tag_string - generic string to add to the tag
|
|
7
|
+
class ResetButton < FormElement
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Appends #generate_html() output to response
|
|
11
|
+
def append_to_response ( response )
|
|
12
|
+
response << generate_html()
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# Generates HTML code for Reset button
|
|
17
|
+
def generate_html ()
|
|
18
|
+
|
|
19
|
+
string = "<INPUT type=\"reset\""
|
|
20
|
+
string << bound_slot_string( "value" )
|
|
21
|
+
string << generic_attr_string() << ">"
|
|
22
|
+
return string
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
list:
|
|
2
|
+
required: true
|
|
3
|
+
|
|
4
|
+
item:
|
|
5
|
+
required: true
|
|
6
|
+
settable: true
|
|
7
|
+
|
|
8
|
+
display_string:
|
|
9
|
+
|
|
10
|
+
selections:
|
|
11
|
+
required: true
|
|
12
|
+
settable: true
|
|
13
|
+
|
|
14
|
+
size:
|
|
15
|
+
default: 5
|
|
16
|
+
|
|
17
|
+
multiple:
|
|
18
|
+
required: true
|
|
19
|
+
|
|
20
|
+
empty_string:
|
|
21
|
+
|
|
22
|
+
disabled:
|
|
23
|
+
|
|
24
|
+
other_tag_string:
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module SWS
|
|
2
|
+
|
|
3
|
+
# Represents <SELECT> HTML tag
|
|
4
|
+
# Bindings:
|
|
5
|
+
# - list (required) - array of object to be displayed in the form of
|
|
6
|
+
# options
|
|
7
|
+
# - item (required,settable) - an object to use as list iterator
|
|
8
|
+
# - selections (required,settable) - object(s) selected from this element (if
|
|
9
|
+
# multiple objects are selected, array is returned here - otherwise the
|
|
10
|
+
# selected object itself)
|
|
11
|
+
# - display_string - string to display (if not set, the item itself will be
|
|
12
|
+
# used)
|
|
13
|
+
# - disabled - if true, the tag will be inactive
|
|
14
|
+
# - size (default: 5) - size attribute of the tag
|
|
15
|
+
# - multiple (required) - if true, multiple object can be selected
|
|
16
|
+
# - other_tag_string - generic string to add to the tag
|
|
17
|
+
class Select < MultipleSelectionList
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def generate_html ()
|
|
21
|
+
|
|
22
|
+
string = "<SELECT name=\"#{element_name()}.selections\" "
|
|
23
|
+
string << @slots["size"].to_tag_attribute()
|
|
24
|
+
if ( @slots["multiple"].value() == true )
|
|
25
|
+
string << " multiple"
|
|
26
|
+
end
|
|
27
|
+
if ( slot_bound?( "disabled" ) && @slots["disabled"].value() == true )
|
|
28
|
+
string << " disabled"
|
|
29
|
+
end
|
|
30
|
+
string << generic_attr_string() << ">"
|
|
31
|
+
if ( slot_bound?( "empty_string" ) )
|
|
32
|
+
string << "<OPTION value=__empty_string>"
|
|
33
|
+
string << @slots["empty_string"].value()
|
|
34
|
+
string << "</OPTION>"
|
|
35
|
+
end
|
|
36
|
+
list().each_index do |index|
|
|
37
|
+
item = list[index]
|
|
38
|
+
@slots["item"].value = item
|
|
39
|
+
if ( slot_bound?( "display_string" ) )
|
|
40
|
+
display_string = @slots["display_string"].value()
|
|
41
|
+
else
|
|
42
|
+
display_string = item
|
|
43
|
+
end
|
|
44
|
+
string << "<OPTION value=#{index}"
|
|
45
|
+
if ( (selections().is_a?(Array) && selections().include?(item)) || (selections() == item) )
|
|
46
|
+
string << " selected"
|
|
47
|
+
end
|
|
48
|
+
string << ">#{display_string}</OPTION>"
|
|
49
|
+
end
|
|
50
|
+
string << "</SELECT>"
|
|
51
|
+
return string
|
|
52
|
+
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module SWS
|
|
2
|
+
|
|
3
|
+
# Represents some text to be rendered literally in HTML. Very commonly used
|
|
4
|
+
# component.
|
|
5
|
+
# Bindings:
|
|
6
|
+
# - value (required) - string to display
|
|
7
|
+
class String < Component
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def append_to_response ( response )
|
|
11
|
+
|
|
12
|
+
value = @slots["value"].value.to_s
|
|
13
|
+
if ( @slots["escape_html"].value )
|
|
14
|
+
value.gsub!( /</,"<" )
|
|
15
|
+
value.gsub!( />/,">" )
|
|
16
|
+
end
|
|
17
|
+
response << value
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def container? ()
|
|
23
|
+
return false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module SWS
|
|
2
|
+
|
|
3
|
+
# Represents <INPUT type=submit HTML tag
|
|
4
|
+
# Bindings:
|
|
5
|
+
# - value (required,default: "Submit") - string to be displayed on the button.
|
|
6
|
+
# - action - method to be called on button click
|
|
7
|
+
# - other_tag_string - generic string to add to the tag
|
|
8
|
+
class SubmitButton < FormElement
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def initialize (*args)
|
|
12
|
+
super
|
|
13
|
+
@action = nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Overriden method from Component class - sets the action to perform if
|
|
17
|
+
# the "value" parameter is not empty
|
|
18
|
+
def update_binding ( key, value )
|
|
19
|
+
|
|
20
|
+
if ( key == "value" )
|
|
21
|
+
@action = @slots["action"].bound_object()
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# If the action has been set up (see #update_binding( key,value )) it is
|
|
28
|
+
# called now. Otherwise just nil is returned.
|
|
29
|
+
def perform_action ()
|
|
30
|
+
|
|
31
|
+
if ( @action )
|
|
32
|
+
return @action.call()
|
|
33
|
+
else
|
|
34
|
+
return nil
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# Appends #generate_html() output to response
|
|
41
|
+
def append_to_response ( response )
|
|
42
|
+
response << generate_html()
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# Generates HTML output containing <INPUT type="submit" tag
|
|
47
|
+
def generate_html ()
|
|
48
|
+
return "<INPUT TYPE=\"submit\" NAME=\"#{element_name()}.value\" VALUE=\"#{@slots["value"].value}\"#{generic_attr_string()}>"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module SWS
|
|
2
|
+
|
|
3
|
+
# Represents <TEXTAREA> tag<br>
|
|
4
|
+
# Bindings:
|
|
5
|
+
# - value (required,settable) - contents of the tag
|
|
6
|
+
# - cols - number of textarea cols
|
|
7
|
+
# - rows - number of textarea rows
|
|
8
|
+
# - other_tag_string - generic string to add to the tag
|
|
9
|
+
class TextArea < FormElement
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def append_to_response ( response )
|
|
13
|
+
response << generate_html()
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def generate_html ()
|
|
18
|
+
|
|
19
|
+
string = "<TEXTAREA name=\"#{element_name()}.value\""
|
|
20
|
+
string << bound_slot_string( "cols","rows" )
|
|
21
|
+
string << "#{generic_attr_string()}>#{@slots["value"].value}</TEXTAREA>"
|
|
22
|
+
return string
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module SWS
|
|
2
|
+
|
|
3
|
+
# Represents tag <INPUT type=text
|
|
4
|
+
# Bindings:
|
|
5
|
+
# - value (required,settable) - contents of the textfield
|
|
6
|
+
# - format - method of "value" object to be used before updating it (eg. for a
|
|
7
|
+
# Float you can use to_i() method here to get Fixnum object)
|
|
8
|
+
# - other_tag_string - generic string to add to the tag
|
|
9
|
+
class TextField < FormElement
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def generate_html ()
|
|
13
|
+
|
|
14
|
+
string = "<INPUT TYPE=\"text\" NAME=\"#{element_name()}.value\" VALUE=\"#{@slots["value"].value}\""
|
|
15
|
+
string << bound_slot_string( "size" )
|
|
16
|
+
string << "#{generic_attr_string()}>"
|
|
17
|
+
return string
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def append_to_response ( response )
|
|
23
|
+
response << generate_html()
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# If the "format" slot value has been set, uses it to format "value" slot
|
|
28
|
+
# value
|
|
29
|
+
def update_binding ( key,value )
|
|
30
|
+
|
|
31
|
+
if ( key == "value" )
|
|
32
|
+
if ( slot_bound?("format") )
|
|
33
|
+
@slots["value"].value = value.method( @slots["format"].value ).call()
|
|
34
|
+
else
|
|
35
|
+
@slots["value"].value = value
|
|
36
|
+
end
|
|
37
|
+
else
|
|
38
|
+
#TODO: not sure if necessary - there are no more settable slots beside "value"
|
|
39
|
+
super
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
components:
|
|
2
|
+
SWS::CheckBox: components/CheckBox
|
|
3
|
+
SWS::CheckBoxList: components/CheckBoxList
|
|
4
|
+
SWS::Conditional: components/Conditional
|
|
5
|
+
SWS::Content: components/Content
|
|
6
|
+
SWS::FileUpload: components/FileUpload
|
|
7
|
+
SWS::Form: components/Form
|
|
8
|
+
SWS::GenericContainer: components/GenericContainer
|
|
9
|
+
SWS::GenericElement: components/GenericElement
|
|
10
|
+
SWS::HiddenField: components/HiddenField
|
|
11
|
+
SWS::Hyperlink: components/Hyperlink
|
|
12
|
+
SWS::Image: components/Image
|
|
13
|
+
SWS::ImageButton: components/ImageButton
|
|
14
|
+
SWS::Link: components/Link
|
|
15
|
+
SWS::PasswordField: components/PasswordField
|
|
16
|
+
SWS::RadioButton: components/RadioButton
|
|
17
|
+
SWS::RadioButtonList: components/RadioButtonList
|
|
18
|
+
SWS::Repetition: components/Repetition
|
|
19
|
+
SWS::ResetButton: components/ResetButton
|
|
20
|
+
SWS::Select: components/Select
|
|
21
|
+
SWS::String: components/String
|
|
22
|
+
SWS::SubmitButton: components/SubmitButton
|
|
23
|
+
SWS::TextArea: components/TextArea
|
|
24
|
+
SWS::TextField: components/TextField
|
|
25
|
+
SWS::ExceptionPage: components/ExceptionPage
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script language="javascript">
|
|
2
|
+
function doPopupMenu<span sws="menu_id_string"/>(event) {
|
|
3
|
+
if( document.menu_opened != 1 )
|
|
4
|
+
{
|
|
5
|
+
document.onmousedown = null;
|
|
6
|
+
document.menu_opened = 1;
|
|
7
|
+
var menu = document.getElementById("menu<span sws="menu_id_string"/>");
|
|
8
|
+
|
|
9
|
+
var X = 0;
|
|
10
|
+
var Y = 0;
|
|
11
|
+
// Gecko part
|
|
12
|
+
if( event.pageX != 0 )
|
|
13
|
+
X = event.pageX;
|
|
14
|
+
if( event.pageY != 0 )
|
|
15
|
+
X = event.pageY;
|
|
16
|
+
// IE part
|
|
17
|
+
// TODO: test it on IE ! (only tested on Firefox and Opera)
|
|
18
|
+
if( event.x != 0 )
|
|
19
|
+
X = event.x;
|
|
20
|
+
if( event.y != 0 )
|
|
21
|
+
Y = event.y;
|
|
22
|
+
|
|
23
|
+
menu.style.top = event.pageY+15;
|
|
24
|
+
menu.style.left = event.pageX;
|
|
25
|
+
menu.style.visibility = "visible";
|
|
26
|
+
document.menu_opened = 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function doCloseMenu<span sws="menu_id_string"/>() {
|
|
31
|
+
if ( document.menu_opened == 1 )
|
|
32
|
+
{
|
|
33
|
+
var menu = document.getElementById("menu<span sws="menu_id_string"/>");
|
|
34
|
+
|
|
35
|
+
menu.style.visibility = "hidden";
|
|
36
|
+
document.menu_opened = 0;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function toggleCloseMenu<span sws="menu_id_string"/>() {
|
|
41
|
+
if( document.menu_opened == 1) {
|
|
42
|
+
document.onmousedown = doCloseMenu<span sws="menu_id_string"/>
|
|
43
|
+
}
|
|
44
|
+
else
|
|
45
|
+
document.onmousedown = null;
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<a sws="menu_link"><span sws="contento"></span></a>
|
|
50
|
+
<span sws="menu_div">
|
|
51
|
+
<table sws="menu_table">
|
|
52
|
+
<span sws="actions_repetition">
|
|
53
|
+
<tr><td>
|
|
54
|
+
<a sws="action_link"><span sws="action_string"></span></a>
|
|
55
|
+
</td></tr>
|
|
56
|
+
</span>
|
|
57
|
+
</table>
|
|
58
|
+
</span>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module JSComponents
|
|
2
|
+
|
|
3
|
+
class JSMenu < SWS::Component
|
|
4
|
+
|
|
5
|
+
synchronize_slot :actions
|
|
6
|
+
synchronize_slot :menu_class
|
|
7
|
+
|
|
8
|
+
attr_reader :actions, :menu_class
|
|
9
|
+
|
|
10
|
+
attr_accessor :action_cursor
|
|
11
|
+
|
|
12
|
+
def action_for_cursor
|
|
13
|
+
return action_cursor["action"].call()
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def name_for_cursor
|
|
17
|
+
return action_cursor["name"]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def menu_link_js_events
|
|
21
|
+
return "onMouseDown=\"doPopupMenu#{menu_id()}(event);\" onMouseUp=\"toggleCloseMenu#{menu_id()}();\""
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def menu_id
|
|
25
|
+
return self.object_id.abs
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def menu_div_id
|
|
29
|
+
return "menu#{menu_id()}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|