netzke-core 0.7.7 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/.travis.yml +1 -2
  2. data/CHANGELOG.md +572 -0
  3. data/LICENSE +7 -1
  4. data/README.md +345 -29
  5. data/Rakefile +3 -3
  6. data/app/controllers/netzke_controller.rb +37 -48
  7. data/config/ci/before-travis.sh +3 -4
  8. data/javascripts/base.js +86 -150
  9. data/javascripts/ext.js +180 -210
  10. data/javascripts/{core_extensions.js → js_extensions.js} +0 -0
  11. data/lib/netzke-core.rb +16 -6
  12. data/lib/netzke/base.rb +84 -107
  13. data/lib/netzke/core.rb +7 -41
  14. data/lib/netzke/core/action_config.rb +37 -0
  15. data/lib/netzke/core/actions.rb +123 -0
  16. data/lib/netzke/core/client_class.rb +252 -0
  17. data/lib/netzke/core/component_config.rb +12 -0
  18. data/lib/netzke/core/composition.rb +274 -0
  19. data/lib/netzke/core/config_to_dsl_delegator.rb +69 -0
  20. data/lib/netzke/core/configuration.rb +63 -0
  21. data/lib/netzke/core/css_config.rb +51 -0
  22. data/lib/netzke/core/dynamic_assets.rb +19 -49
  23. data/lib/netzke/{embedding.rb → core/embedding.rb} +4 -6
  24. data/lib/netzke/core/endpoint_response.rb +15 -0
  25. data/lib/netzke/core/javascript.rb +111 -0
  26. data/lib/netzke/core/panel.rb +11 -0
  27. data/lib/netzke/{plugins.rb → core/plugins.rb} +10 -5
  28. data/lib/netzke/core/railz.rb +4 -0
  29. data/lib/netzke/{railz → core/railz}/action_view_ext.rb +22 -18
  30. data/lib/netzke/core/railz/action_view_ext/ext.rb +49 -0
  31. data/lib/netzke/core/railz/controller_extensions.rb +17 -0
  32. data/lib/netzke/core/railz/engine.rb +16 -0
  33. data/lib/netzke/core/railz/routes.rb +10 -0
  34. data/lib/netzke/core/ruby_ext.rb +5 -0
  35. data/lib/netzke/core/ruby_ext/array.rb +23 -0
  36. data/lib/netzke/core/ruby_ext/hash.rb +47 -0
  37. data/lib/netzke/{core_ext → core/ruby_ext}/string.rb +2 -7
  38. data/lib/netzke/core/ruby_ext/symbol.rb +13 -0
  39. data/lib/netzke/{core_ext → core/ruby_ext}/time_with_zone.rb +0 -0
  40. data/lib/netzke/core/services.rb +130 -0
  41. data/lib/netzke/core/session.rb +15 -19
  42. data/lib/netzke/core/state.rb +40 -0
  43. data/lib/netzke/core/stylesheets.rb +48 -0
  44. data/lib/netzke/core/version.rb +2 -2
  45. data/lib/netzke/plugin.rb +8 -11
  46. data/netzke-core.gemspec +69 -59
  47. data/test/core_test_app/Gemfile +2 -20
  48. data/test/core_test_app/Gemfile.lock +65 -74
  49. data/test/core_test_app/app/components/card_component_loader.rb +4 -4
  50. data/test/core_test_app/app/components/component_loader.rb +40 -120
  51. data/test/core_test_app/app/components/component_loader/javascripts/component_loader.js +49 -0
  52. data/test/core_test_app/app/components/component_with_actions.rb +61 -47
  53. data/test/core_test_app/app/components/component_with_custom_css.rb +8 -5
  54. data/test/core_test_app/app/components/component_with_js_mixin.rb +11 -5
  55. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_one.js +1 -1
  56. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_two.js +1 -1
  57. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/method_set_one.js +1 -1
  58. data/test/core_test_app/app/components/component_with_nested_through.rb +2 -2
  59. data/test/core_test_app/app/components/component_with_prebuilt_toolbar_control.rb +12 -0
  60. data/test/core_test_app/app/components/component_with_prebuilt_toolbar_control/javascripts/component_with_prebuilt_toolbar_control.js +12 -0
  61. data/test/core_test_app/app/components/component_with_required_js.rb +24 -0
  62. data/test/core_test_app/app/components/configurable_on_class_level.rb +8 -0
  63. data/test/core_test_app/app/components/dsl_delegated_properties.rb +4 -0
  64. data/test/core_test_app/app/components/dsl_delegated_properties_base.rb +5 -0
  65. data/test/core_test_app/app/components/dynamic_tab_panel/javascripts/dynamic_tab_panel.js +2 -2
  66. data/test/core_test_app/app/components/ext_direct/composite.rb +32 -33
  67. data/test/core_test_app/app/components/ext_direct/details.rb +2 -4
  68. data/test/core_test_app/app/components/ext_direct/selector.rb +20 -22
  69. data/test/core_test_app/app/components/ext_direct/statistics.rb +2 -4
  70. data/test/core_test_app/app/components/extended_component_with_actions.rb +7 -3
  71. data/test/core_test_app/app/components/extended_component_with_js_mixin.rb +7 -4
  72. data/test/core_test_app/app/components/extended_component_with_js_mixin/javascripts/some_method_set.js +1 -1
  73. data/test/core_test_app/app/components/extended_server_caller.rb +20 -14
  74. data/test/core_test_app/app/components/hello_world.rb +23 -0
  75. data/test/core_test_app/app/components/hello_world/javascripts/hello_world.js +12 -0
  76. data/test/core_test_app/app/components/included.js +2 -2
  77. data/test/core_test_app/app/components/kinda_complex_component.rb +1 -3
  78. data/test/core_test_app/app/components/kinda_complex_component/basic_stuff.rb +15 -17
  79. data/test/core_test_app/app/components/kinda_complex_component/extra_stuff.rb +4 -5
  80. data/test/core_test_app/app/components/loader_of_component_with_custom_css.rb +14 -5
  81. data/test/core_test_app/app/components/localized_panel.rb +23 -25
  82. data/test/core_test_app/app/components/multipane_component_loader.rb +19 -20
  83. data/test/core_test_app/app/components/nested_component.rb +4 -5
  84. data/test/core_test_app/app/components/panel_with_plugin.rb +8 -3
  85. data/test/core_test_app/app/components/panel_with_tools.rb +15 -14
  86. data/test/core_test_app/app/components/plugin_with_components.rb +20 -12
  87. data/test/core_test_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb +5 -2
  88. data/test/core_test_app/app/components/scoped_components/extended_scoped_component.rb +5 -2
  89. data/test/core_test_app/app/components/scoped_components/some_scoped_component.rb +5 -2
  90. data/test/core_test_app/app/components/server_caller.rb +39 -17
  91. data/test/core_test_app/app/components/server_caller/javascripts/server_caller.js +42 -0
  92. data/test/core_test_app/app/components/server_counter.rb +18 -82
  93. data/test/core_test_app/app/components/server_counter/javascripts/server_counter.js +53 -0
  94. data/test/core_test_app/app/components/simple_authentication_component.rb +46 -0
  95. data/test/core_test_app/app/components/simple_component.rb +8 -3
  96. data/test/core_test_app/app/components/simple_composite.rb +12 -0
  97. data/test/core_test_app/app/components/simple_form_with_file_upload.rb +49 -0
  98. data/test/core_test_app/app/components/simple_panel.rb +2 -2
  99. data/test/core_test_app/app/components/simple_tab_panel.rb +24 -3
  100. data/test/core_test_app/app/components/simple_window.rb +4 -2
  101. data/test/core_test_app/app/components/some_composite.rb +77 -48
  102. data/test/core_test_app/app/components/some_plugin.rb +31 -30
  103. data/test/core_test_app/app/components/stateful_component.rb +46 -0
  104. data/test/core_test_app/app/components/stateful_component_with_shared_state.rb +11 -0
  105. data/test/core_test_app/app/components/window_with_simple_component.rb +14 -0
  106. data/test/core_test_app/app/views/layouts/application.html.erb +1 -1
  107. data/test/core_test_app/app/views/simple_rails/multiple_nested.html.erb +7 -19
  108. data/test/core_test_app/app/views/simple_rails/panel.html.erb +1 -0
  109. data/test/core_test_app/config/database.yml.travis +3 -5
  110. data/test/core_test_app/config/environments/production.rb +1 -1
  111. data/test/core_test_app/config/initializers/netzke.rb +3 -1
  112. data/test/core_test_app/config/locales/en.yml +9 -4
  113. data/test/core_test_app/config/locales/es.yml +4 -2
  114. data/test/core_test_app/config/routes.rb +2 -8
  115. data/test/core_test_app/db/schema.rb +3 -11
  116. data/test/core_test_app/features/actions_and_tools.feature +1 -0
  117. data/test/core_test_app/features/client-server.feature +7 -0
  118. data/test/core_test_app/features/component_loader.feature +13 -13
  119. data/test/core_test_app/features/composition.feature +14 -0
  120. data/test/core_test_app/features/config_to_dsl_delegation.feature +10 -0
  121. data/test/core_test_app/features/file_inclusion.feature +1 -1
  122. data/test/core_test_app/features/i18n.feature +4 -4
  123. data/test/core_test_app/features/js_include.feature +1 -1
  124. data/test/core_test_app/features/persistence.feature +21 -5
  125. data/test/core_test_app/features/step_definitions/generic_steps.rb +14 -0
  126. data/test/core_test_app/features/support/paths.rb +0 -3
  127. data/test/core_test_app/public/images/icons/accept.png +0 -0
  128. data/test/core_test_app/public/images/icons/anchor.png +0 -0
  129. data/test/core_test_app/public/images/icons/tick.png +0 -0
  130. data/test/core_test_app/spec/action_config_spec.rb +15 -0
  131. data/test/core_test_app/spec/{component/actions_spec.rb → actions_spec.rb} +38 -36
  132. data/test/core_test_app/spec/base_spec.rb +35 -0
  133. data/test/core_test_app/spec/client_class_spec.rb +17 -0
  134. data/test/core_test_app/spec/component +0 -0
  135. data/test/core_test_app/spec/composition_spec.rb +118 -0
  136. data/test/core_test_app/spec/core_ext_spec.rb +3 -14
  137. data/test/core_test_app/spec/endpoint_response_spec.rb +17 -0
  138. data/test/core_test_app/spec/javascript_spec.rb +33 -0
  139. data/test/core_test_app/spec/js_class_config_scope.rb +37 -0
  140. data/test/core_test_app/spec/panel_spec.rb +11 -0
  141. data/test/core_test_app/spec/services_spec.rb +16 -0
  142. data/test/core_test_app/spec/state_spec.rb +20 -0
  143. data/test/unit/core_ext_test.rb +0 -53
  144. data/test/unit/netzke_core_test.rb +11 -11
  145. metadata +76 -62
  146. data/CHANGELOG.rdoc +0 -325
  147. data/javascripts/touch.js +0 -58
  148. data/lib/netzke/actions.rb +0 -107
  149. data/lib/netzke/composition.rb +0 -224
  150. data/lib/netzke/config_to_dsl_delegator.rb +0 -43
  151. data/lib/netzke/configuration.rb +0 -195
  152. data/lib/netzke/core/masquerading.rb +0 -34
  153. data/lib/netzke/core_ext.rb +0 -6
  154. data/lib/netzke/core_ext/array.rb +0 -30
  155. data/lib/netzke/core_ext/hash.rb +0 -86
  156. data/lib/netzke/core_ext/symbol.rb +0 -21
  157. data/lib/netzke/ext_component.rb +0 -25
  158. data/lib/netzke/inheritance.rb +0 -31
  159. data/lib/netzke/javascript.rb +0 -382
  160. data/lib/netzke/javascript/scopes.rb +0 -39
  161. data/lib/netzke/railz.rb +0 -4
  162. data/lib/netzke/railz/action_view_ext/ext.rb +0 -64
  163. data/lib/netzke/railz/action_view_ext/touch.rb +0 -52
  164. data/lib/netzke/railz/controller_extensions.rb +0 -33
  165. data/lib/netzke/railz/engine.rb +0 -48
  166. data/lib/netzke/railz/routes.rb +0 -7
  167. data/lib/netzke/services.rb +0 -101
  168. data/lib/netzke/session.rb +0 -54
  169. data/lib/netzke/state.rb +0 -91
  170. data/lib/netzke/stylesheets.rb +0 -65
  171. data/test/core_test_app/app/components/component_with_included_js.rb +0 -16
  172. data/test/core_test_app/app/components/component_with_session_persistence.rb +0 -35
  173. data/test/core_test_app/app/components/deprecated/server_caller.rb +0 -20
  174. data/test/core_test_app/app/components/dynamic_tab_panel.rb +0 -19
  175. data/test/core_test_app/app/components/hello_world_component.rb +0 -31
  176. data/test/core_test_app/app/components/touch/hello_world_component.rb +0 -25
  177. data/test/core_test_app/app/components/touch/server_caller.rb +0 -28
  178. data/test/core_test_app/app/components/touch/simple_carousel.rb +0 -17
  179. data/test/core_test_app/app/controllers/touch_controller.rb +0 -6
  180. data/test/core_test_app/app/helpers/touch_helper.rb +0 -2
  181. data/test/core_test_app/app/views/layouts/touch.html.erb +0 -13
  182. data/test/core_test_app/db/migrate/20110110132720_create_netzke_component_states.rb +0 -20
  183. data/test/core_test_app/features/step_definitions/touch_steps.rb +0 -3
  184. data/test/core_test_app/features/touch.feature +0 -10
  185. data/test/core_test_app/gemfiles/rails3_1.gemfile +0 -16
  186. data/test/core_test_app/gemfiles/rails3_2.gemfile +0 -16
  187. data/test/core_test_app/spec/component/base_spec.rb +0 -36
  188. data/test/core_test_app/spec/component/component_spec.rb +0 -20
  189. data/test/core_test_app/spec/component/composition_spec.rb +0 -132
  190. data/test/core_test_app/spec/component/configuration_spec.rb +0 -61
  191. data/test/core_test_app/spec/component/javascript_spec.rb +0 -16
  192. data/test/core_test_app/spec/component/state_spec.rb +0 -18
@@ -4,7 +4,7 @@ class CardComponentLoader < Netzke::Base
4
4
  action :load_server_caller
5
5
  action :load_extended_server_caller
6
6
 
7
- js_property :bbar, [:load_server_caller.action, :load_extended_server_caller.action]
7
+ js_property :bbar, [:load_server_caller, :load_extended_server_caller]
8
8
 
9
9
  component :server_caller
10
10
  component :extended_server_caller
@@ -12,14 +12,14 @@ class CardComponentLoader < Netzke::Base
12
12
  js_method :on_load_server_caller, <<-JS
13
13
  function(){
14
14
  var existing = this.items.findBy(function(i){ return i.getId() == this.getId() + "__server_caller"}, this);
15
- if (existing) this.getLayout().setActiveItem(existing); else this.loadNetzkeComponent({name: 'server_caller', container: this, append: true, callback: function(el){this.getLayout().setActiveItem(el)}, scope: this});
15
+ if (existing) this.getLayout().setActiveItem(existing); else this.netzkeLoadComponent({name: 'server_caller', container: this, append: true, callback: function(el){this.getLayout().setActiveItem(el)}, scope: this});
16
16
  }
17
17
  JS
18
18
 
19
19
  js_method :on_load_extended_server_caller, <<-JS
20
20
  function(){
21
21
  var existing = this.items.findBy(function(i){ return i.getId() == this.getId() + "__extended_server_caller"}, this);
22
- if (existing) this.getLayout().setActiveItem(existing); else this.loadNetzkeComponent({name: 'extended_server_caller', container: this, append: true, callback: function(el){this.getLayout().setActiveItem(el)}, scope: this});
22
+ if (existing) this.getLayout().setActiveItem(existing); else this.netzkeLoadComponent({name: 'extended_server_caller', container: this, append: true, callback: function(el){this.getLayout().setActiveItem(el)}, scope: this});
23
23
  }
24
24
  JS
25
- end
25
+ end
@@ -1,139 +1,59 @@
1
1
  # TODO: some functionality (one that is calling doNothing) does not belong here, as it loads no componens, but rather to ServerCaller. Move it there.
2
2
  class ComponentLoader < Netzke::Base
3
- component :simple_component, :title => "Simple Component", :lazy_loading => true
4
-
5
- component :component_loaded_in_window, {
6
- :class_name => "SimpleComponent",
7
- :title => "Component loaded in window",
8
- :lazy_loading => true
9
- }
10
-
11
- component :window_with_simple_component, {
12
- :class_name => "SimpleWindow",
13
- :width => 400,
14
- :height => 300,
15
- :items => [{
16
- :class_name => "SimpleComponent",
17
- :title => "Simple Component Inside Window"
18
- }],
19
- :lazy_loading => true
20
- }
21
-
22
- component :some_composite, :lazy_loading => true
23
-
24
- # this action is using loadNetzkeComponent "special" callback
25
- js_method :on_load_with_feedback, <<-JS
26
- function(){
27
- this.loadNetzkeComponent({name: 'simple_component', callback: function(){
28
- this.setTitle("Callback" + " invoked!");
29
- }, scope: this});
30
- }
31
- JS
32
-
33
- # this action is using generic endpoint callback
34
- action :load_with_generic_callback
35
- js_method :on_load_with_generic_callback, <<-JS
36
- function(){
37
- this.doNothing({}, function () {
38
- this.setTitle("Generic callback invoked!");
39
- });
40
- }
41
- JS
42
-
43
- # this action is using generic endpoint callback with scope
44
- action :load_with_generic_callback_and_scope
45
- js_method :on_load_with_generic_callback_and_scope, <<-JS
46
- function(){
47
- var that=this;
48
- var fancyScope={
49
- setFancyTitle: function () {
50
- that.setTitle("Fancy title set!");
51
- }
52
- };
53
- this.doNothing({}, function () {
54
- this.setFancyTitle();
55
- }, fancyScope);
56
- }
57
- JS
58
-
59
- endpoint :do_nothing do |params|
60
- # here be tumbleweed
61
- # {}
3
+ js_configure do |c|
4
+ c.mixin
62
5
  end
63
6
 
64
- action :load_component
7
+ component :simple_component
65
8
 
66
- action :load_in_window
9
+ component :component_loaded_in_window do |c|
10
+ c.klass = SimpleComponent
11
+ c.title = "Component loaded in window"
12
+ end
13
+
14
+ component :window_with_simple_component do |c|
15
+ c.width = 400
16
+ c.height = 300
17
+ end
18
+
19
+ component :some_composite
67
20
 
21
+ component :inaccessible do |c|
22
+ c.klass = Netzke::Core::Panel
23
+ c.excluded = true
24
+ end
25
+
26
+
27
+ # this action is using netzkeLoadComponent "special" callback
68
28
  action :load_with_feedback
69
29
 
30
+ action :load_component
31
+
32
+ action :load_in_window
33
+
70
34
  action :load_window_with_simple_component
71
35
 
72
36
  action :load_composite
73
37
 
74
38
  action :load_with_params
75
39
 
76
- action :non_existing_component, :text => "Non-existing component"
77
-
78
- js_properties(
79
- :title => "Component Loader",
80
- :layout => "fit",
81
- :bbar => [:load_component.action, :load_in_window.action, :load_with_feedback.action, :load_window_with_simple_component.action, :load_composite.action, :load_with_params.action, :load_with_generic_callback.action, :load_with_generic_callback_and_scope.action, :non_existing_component.action]
82
- )
83
-
84
- js_method :on_load_window_with_simple_component, <<-JS
85
- function(params){
86
- this.loadNetzkeComponent({name: "window_with_simple_component", callback: function(w){
87
- w.show();
88
- }});
89
- }
90
- JS
91
-
92
- js_method :on_load_composite, <<-JS
93
- function(params){
94
- this.loadNetzkeComponent({name: "some_composite", container: this});
95
- }
96
- JS
97
-
98
- js_method :on_load_with_params, <<-JS
99
- function(params){
100
- this.loadNetzkeComponent({name: "simple_component", params: {html: "Simple Component" + " with changed HTML"}, container: this});
101
- }
102
- JS
103
-
104
- js_method :on_load_component, <<-JS
105
- function(){
106
- this.loadNetzkeComponent({name: 'simple_component', container: this});
107
- }
108
- JS
109
-
110
- js_method :on_non_existing_component, <<-JS
111
- function(){
112
- this.loadNetzkeComponent({name: 'non_existing_component', container: this});
113
- }
114
- JS
115
-
116
- js_method :on_load_in_window, <<-JS
117
- function(){
118
- var w = new Ext.window.Window({
119
- width: 500, height: 400, modal: false, layout:'fit', title: 'A window'
120
- });
121
- w.show();
122
- this.loadNetzkeComponent({name: 'component_loaded_in_window', container: w});
123
- }
124
- JS
125
-
126
- def deliver_component_endpoint(params)
40
+ action :config_only
41
+
42
+ action :non_existing_component do |a|
43
+ a.text = "Non-existing component"
44
+ end
45
+
46
+ action :inaccessible
47
+
48
+ def configure(c)
49
+ super
50
+ c.bbar = [:load_component, :load_in_window, :load_with_feedback, :load_window_with_simple_component, :load_composite, :load_with_params, :non_existing_component, :inaccessible, :config_only]
51
+ end
52
+
53
+ endpoint :deliver_component do |params, this|
127
54
  if params[:name] == "simple_component" && params[:html]
128
55
  components[:simple_component].merge!(:html => params[:html])
129
56
  end
130
- super
57
+ super(params, this)
131
58
  end
132
-
133
- # For visual testing purposes
134
- # def deliver_component_endpoint(params)
135
- # sleep 2
136
- # super
137
- # end
138
-
139
59
  end
@@ -0,0 +1,49 @@
1
+ {
2
+ title: "Component Loader",
3
+ layout: "fit",
4
+
5
+ onLoadComponent: function(){
6
+ this.netzkeLoadComponent('simple_component');
7
+ },
8
+
9
+ onLoadWithFeedback: function(){
10
+ this.netzkeLoadComponent('simple_component', {callback: function() { this.setTitle("Callback" + " invoked!"); }, scope: this});
11
+ },
12
+
13
+ onLoadWindowWithSimpleComponent: function(params){
14
+ this.netzkeLoadComponent('window_with_simple_component', {callback: function(w){ w.show(); }});
15
+ },
16
+
17
+ onLoadComposite: function(params){
18
+ this.netzkeLoadComponent('some_composite');
19
+ },
20
+
21
+ onLoadWithParams: function(params){
22
+ this.netzkeLoadComponent("simple_component", {params: {html: "Simple Component" + " with changed HTML"}, container: this});
23
+ },
24
+
25
+ onNonExistingComponent: function(){
26
+ this.netzkeLoadComponent('non_existing_component');
27
+ },
28
+
29
+ onLoadInWindow: function(){
30
+ var w = new Ext.window.Window({
31
+ width: 500, height: 400, modal: false, layout:'fit', title: 'A window'
32
+ });
33
+ w.show();
34
+ this.netzkeLoadComponent('component_loaded_in_window', {container: w});
35
+ },
36
+
37
+ onInaccessible: function() {
38
+ this.netzkeLoadComponent('inaccessible');
39
+ },
40
+
41
+ onConfigOnly: function() {
42
+ this.netzkeLoadComponent('simple_component', {configOnly: true, callback: function(config) {
43
+ this.removeAll();
44
+ config.title = config.title + " (overridden)";
45
+ var instance = Ext.ComponentManager.create(config);
46
+ this.add(instance);
47
+ }, scope: this});
48
+ }
49
+ }
@@ -1,59 +1,73 @@
1
1
  class ComponentWithActions < Netzke::Base
2
- title "Panel that has actions"
3
-
4
- # Define actions as a hash
5
- action :another_action, :disabled => true, :text => "Disabled action", :icon => :accept
6
-
7
- # ... or as a block returning hash
8
- action :some_action do
9
- {:text => "Some Cool Action", :icon => Netzke::Core.icons_uri + "/delete.png"}
2
+ action :some_action do |a|
3
+ a.text = "Some Cool Action"
4
+ a.icon = Netzke::Core.icons_uri + "/tick.png" # specify full icon uri
10
5
  end
11
6
 
12
- # ... or directly as a method
13
- def _my_action_action
14
- {:text => "Not used"}
7
+ action :another_action do |a|
8
+ a.disabled = true
9
+ a.text = "Disabled action"
10
+ a.icon = :accept # accept.png icon will be looked for in Netzke::Core.icons_uri
15
11
  end
16
12
 
13
+ action :action_with_custom_handler do |c|
14
+ c.text = "Action with custom handler"
15
+ c.handler = :custom_action_handler
16
+ end
17
17
 
18
- js_property :bbar, [:some_action.action, :another_action.action]
18
+ action :excluded_action do |c|
19
+ c.excluded = true
20
+ end
19
21
 
20
- js_property :tbar, [{
21
- :xtype => 'buttongroup',
22
- :columns => 3,
23
- :title => 'A group',
24
- :items => [{
25
- :text => 'Paste',
26
- :scale => 'large',
27
- :rowspan => 3, :iconCls => 'add',
28
- :iconAlign => 'top',
29
- :cls => 'x-btn-as-arrow'
30
- },{
31
- :xtype => 'splitbutton',
32
- :text => 'Menu Button',
33
- :scale => 'large',
34
- :rowspan => 3,
35
- :iconCls => 'add',
36
- :iconAlign => 'top',
37
- :arrowAlign => 'bottom',
38
- :menu => [:some_action.action]
39
- },{
40
- :xtype => 'splitbutton', :text => 'Cut', :menu => [:another_action.action]
41
- }, :another_action.action,
42
- {
43
- :menu => [:some_action.action], :text => 'Format'
22
+ def configure(c)
23
+ super
24
+ c.title = "Panel that has actions"
25
+ c.bbar = [:some_action, :another_action, :action_with_custom_handler, :excluded_action]
26
+ c.tbar = [{
27
+ :xtype => 'buttongroup',
28
+ :columns => 3,
29
+ :title => 'A group',
30
+ :items => [{
31
+ :text => 'Paste',
32
+ :scale => 'large',
33
+ :rowspan => 3, :iconCls => 'add',
34
+ :iconAlign => 'top',
35
+ :cls => 'x-btn-as-arrow'
36
+ },{
37
+ :xtype => 'splitbutton',
38
+ :text => 'Menu Button',
39
+ :scale => 'large',
40
+ :rowspan => 3,
41
+ icon: uri_to_icon(:anchor), # use uri_to_icon helper to get the full icon uri
42
+ :arrowAlign => 'bottom',
43
+ :menu => [:some_action]
44
+ },{
45
+ :xtype => 'splitbutton', :text => 'Cut', :menu => [:another_action]
46
+ }, :another_action,
47
+ {
48
+ :menu => [:some_action], :text => 'Format'
49
+ }]
44
50
  }]
45
- }]
51
+ end
46
52
 
47
- js_method :on_some_action, <<-JS
48
- function(){
49
- this.update("Some action was triggered");
50
- }
51
- JS
53
+ js_configure do |c|
54
+ c.on_some_action = <<-JS
55
+ function(){
56
+ this.update("Some action was triggered");
57
+ this.netzke.testik();
58
+ }
59
+ JS
52
60
 
53
- js_method :on_another_action, <<-JS
54
- function(){
55
- this.update("Another action was triggered");
56
- }
57
- JS
61
+ c.on_another_action = <<-JS
62
+ function(){
63
+ this.update("Another action was triggered");
64
+ }
65
+ JS
58
66
 
67
+ c.custom_action_handler = <<-JS
68
+ function(){
69
+ this.update("Custom action handler was called");
70
+ }
71
+ JS
72
+ end
59
73
  end
@@ -1,8 +1,11 @@
1
1
  # This component has the header hidden by custom CSS
2
2
  class ComponentWithCustomCss < Netzke::Base
3
- title "ComponentWithCustomCss"
3
+ js_configure do |c|
4
+ c.html = "A component with the body hidden by means of custom CSS"
5
+ c.title = "ComponentWithCustomCss"
6
+ end
4
7
 
5
- js_property :html, "A component with the body hidden by means of custom CSS"
6
-
7
- css_include :custom
8
- end
8
+ css_configure do |c|
9
+ c.require :custom
10
+ end
11
+ end
@@ -1,11 +1,17 @@
1
1
  class ComponentWithJsMixin < Netzke::Base
2
- title "ComponentWithJsMixin"
2
+ js_configure do |c|
3
+ c.require :extra_one, :extra_two
4
+ c.mixin :method_set_one, :method_set_two
5
+ c.mixin # with no parameters, it'll assume :component_with_js_mixin
6
+ end
3
7
 
4
- js_include :extra_one, :extra_two
5
- js_mixin :method_set_one, :method_set_two
6
- js_mixin # with no parameters, it'll assume :component_with_js_mixin
7
8
  action :action_one
8
9
  action :action_two
9
10
  action :action_three
10
- js_property :bbar, [:action_one.action, :action_two.action, :action_three.action]
11
+
12
+ def configure(c)
13
+ super
14
+ c.bbar = [:action_one, :action_two, :action_three]
15
+ c.title = "ComponentWithJsMixin"
16
+ end
11
17
  end
@@ -1,2 +1,2 @@
1
1
  // Some included JS code
2
- actionOneMessage = "Action " + "One triggered!";
2
+ actionOneMessage = "Action " + "One triggered!";
@@ -1,2 +1,2 @@
1
1
  // Some included JS code
2
- actionTwoMessage = "Action " + "Two triggered!";
2
+ actionTwoMessage = "Action " + "Two triggered!";
@@ -1,5 +1,5 @@
1
- // Some comments should be ok here
2
1
  {
2
+ // Some comments should be fine here
3
3
  onActionTwo: function() {
4
4
  this.setTitle(actionTwoMessage);
5
5
  }
@@ -19,10 +19,10 @@ class ComponentWithNestedThrough < Netzke::Base
19
19
 
20
20
  js_method :on_gear, <<-JS
21
21
  function(){
22
- this.loadNetzkeComponent({name: 'some_window', callback: function(w){
22
+ this.netzkeLoadComponent({name: 'some_window', callback: function(w){
23
23
  w.show();
24
24
  }});
25
25
  }
26
26
  JS
27
27
 
28
- end
28
+ end