rsence-pre 3.0.0.8 → 3.0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/client/conf/client_pkg.yaml +6 -2
  4. data/client/js/comm/queue/queue.js +32 -44
  5. data/client/js/comm/transporter/transporter.js +24 -16
  6. data/client/js/comm/values/values.js +27 -15
  7. data/client/js/controls/button/button.coffee +14 -5
  8. data/client/js/controls/button/themes/default/button.css +4 -2
  9. data/client/js/controls/checkbox/checkbox.js +4 -4
  10. data/client/js/controls/dialogs/sheet/sheet.js +11 -11
  11. data/client/js/controls/dialogs/sheet/themes/default/sheet.html +1 -1
  12. data/client/js/controls/imageview/imageview.js +15 -15
  13. data/client/js/controls/numerictextcontrol/numerictextcontrol.coffee +32 -10
  14. data/client/js/controls/onoffbutton/onoffbutton.coffee +5 -5
  15. data/client/js/controls/progress/progressbar/progressbar.js +6 -7
  16. data/client/js/controls/progress/progressbar/themes/default/progressbar.css +4 -4
  17. data/client/js/controls/progress/progressbar/themes/default/progressbar.html +1 -2
  18. data/client/js/controls/sliders/slider/slider.js +74 -79
  19. data/client/js/controls/stepper/stepper.js +31 -31
  20. data/client/js/controls/stringview/stringview.js +20 -8
  21. data/client/js/controls/tab/tab.js +57 -63
  22. data/client/js/controls/tab/themes/default/tab.html +4 -1
  23. data/client/js/controls/textcontrol/textcontrol.coffee +13 -3
  24. data/client/js/controls/validatorview/validatorview.js +4 -4
  25. data/client/js/controls/window/window.js +43 -56
  26. data/client/js/core/class/class.js +25 -23
  27. data/client/js/core/elem/elem.coffee +8 -1
  28. data/client/js/core/rsence_ns/rsence_ns.coffee +6 -2
  29. data/client/js/core/util/util_methods/util_methods.coffee +57 -15
  30. data/client/js/datetime/calendar/calendar.coffee +196 -199
  31. data/client/js/datetime/calendar/themes/default/calendar.css +81 -159
  32. data/client/js/datetime/calendar/themes/default/calendar.html +9 -18
  33. data/client/js/datetime/datepicker/datepicker.coffee +18 -3
  34. data/client/js/datetime/datetimepicker/datetimepicker.coffee +6 -1
  35. data/client/js/datetime/datetimevalue/datetimevalue.coffee +194 -0
  36. data/client/js/datetime/momentjs/momentjs.js +310 -76
  37. data/client/js/datetime/timepicker/timepicker.coffee +6 -1
  38. data/client/js/datetime/timesheet/timesheet.js +59 -61
  39. data/client/js/foundation/control/control.js +45 -44
  40. data/client/js/foundation/control/controldefaults/controldefaults.js +13 -9
  41. data/client/js/foundation/control/dyncontrol/dyncontrol.js +45 -57
  42. data/client/js/foundation/control/eventresponder/eventresponder.js +97 -97
  43. data/client/js/foundation/control/valuematrix/valuematrix.js +13 -13
  44. data/client/js/foundation/eventmanager/eventmanager.coffee +50 -32
  45. data/client/js/foundation/geom/rect/rect.js +43 -32
  46. data/client/js/foundation/locale_settings/locale_settings.js +36 -25
  47. data/client/js/foundation/system/system.js +79 -67
  48. data/client/js/foundation/thememanager/thememanager.coffee +11 -1
  49. data/client/js/foundation/value/pullvalue/pullvalue.coffee +7 -0
  50. data/client/js/foundation/value/pushvalue/pushvalue.coffee +25 -0
  51. data/client/js/foundation/value/value.js +22 -15
  52. data/client/js/foundation/view/view.js +94 -55
  53. data/client/js/foundation/view/viewdefaults/viewdefaults.js +5 -1
  54. data/client/js/lists/listitems/listitems.js +26 -4
  55. data/client/js/menus/combobox/combobox.coffee +55 -0
  56. data/client/js/menus/minimenu/minimenu.js +61 -30
  57. data/client/js/menus/minimenu/themes/default/minimenu.css +1 -6
  58. data/client/js/menus/minimenu/themes/default/minimenu.html +5 -4
  59. data/client/js/menus/minimenuitem/minimenuitem.js +6 -6
  60. data/client/js/menus/popupmenu/themes/default/popupmenu.css +1 -6
  61. data/client/js/menus/popupmenu/themes/default/popupmenu.html +5 -4
  62. data/client/js/tables/table/table.coffee +109 -64
  63. data/client/js/tables/table/themes/default/table.css +4 -0
  64. data/lib/rsence/msg.rb +64 -64
  65. data/lib/rsence/plugins/plugin.rb +68 -52
  66. data/lib/rsence/session/sequel_sessionstorage.rb +5 -5
  67. data/lib/rsence/value.rb +79 -59
  68. data/plugins/client_pkg/lib/client_pkg_build.rb +5 -1
  69. data/plugins/client_pkg/lib/client_pkg_serve.rb +40 -32
  70. data/plugins/main/js/main.js +46 -28
  71. metadata +6 -8
  72. data/client/js/datetime/calendar/themes/default/calendar_arrows.png +0 -0
  73. data/client/js/datetime/calendar/themes/default/calendar_bg.png +0 -0
  74. data/client/js/datetime/calendar/themes/default/calendar_parts1.png +0 -0
  75. data/client/js/datetime/calendar/themes/default/calendar_parts2.png +0 -0
  76. data/client/js/datetime/datetimepicker/datetimepicker.js +0 -210
  77. data/client/js/datetime/datetimevalue/datetimevalue.js +0 -265
@@ -1,24 +1,24 @@
1
1
 
2
2
  module RSence
3
3
  module Plugins
4
-
4
+
5
5
  # The Plugin__ is actually available as +Plugin+ from plugin bundles using the {RSence::Plugins::Plugin} class mimic method.
6
- #
6
+ #
7
7
  # The Plugin class is the base class for extending server logic. A single Plugin instance serves the requests of all sessions, which makes them very cpu and memory efficient compared to systems, where the server classes are constructed and destructed for each request.
8
- #
8
+ #
9
9
  # Plugins are designed to be contained in a plugin directory bundle and to be loaded by the main {PluginManager}, which is also responsible for delegating the events and other calls throughout the system.
10
10
  #
11
- #
11
+ #
12
12
  # == Anatomy of a plugin bundle
13
13
  #
14
14
  # First read about the {file:PluginBundles Plugin Bundles}.
15
15
  #
16
16
  # The plugin bundle contains all data needed to run the plugin. Design your plugin without any hard-coded paths, remember that it's intended to be installed by moving or copying the whole plugin into one of the "plugins" directories. Use {#bundle_path} to construct paths.
17
- #
17
+ #
18
18
  # The {PluginManager} looks for these bundles and evaluates them into an anonymous +Module+ namespace. The contents of the ruby source file is then responsible for including its libraries, constructing an instance of itself and registering itself as a part of the system.
19
- #
19
+ #
20
20
  # Use the {GUIPlugin__ GUIPlugin} class for plugins that handle user interfaces. Use the {Plugin__ Plugin} class for plugin bundles that provide supplemental functionality, value responders and other utilities that supplement the user interface.
21
- #
21
+ #
22
22
  # = Extension hooks for server events
23
23
  # These methods are provided as the basic server event hooks:
24
24
  # * {#init +#init+} -- Use instead of +initialize+
@@ -30,12 +30,12 @@ module RSence
30
30
  # * {#idle +#idle+} -- Extend to implement logic for each client data synchronization and "idle poll" request.
31
31
  # * {#init_ses +#init_ses+} -- Extend to implement logic when a new session is created. A new session is created, when a user enters accesses the server the first time, or the first time after the previous session expired.
32
32
  # * {#restore_ses +#restore_ses+} -- Extend to implement logic when an old session is restored. A session is restored, when the user returns to the page or reloads the page before the session is expired.
33
- #
33
+ #
34
34
  # == Extension hooks for session events, If the server is configured to restore and clone previous sessions (default):
35
35
  # When sessions are cloned, the previous session is not invalidated and exists until timing out as a result of the web browser window being closed or client computer losing network connectivity for a certain (configurable) time frame.
36
36
  # * {#cloned_target +#cloned_target+} -- Extend to implement logic in the request when session is a clone of the original session.
37
37
  # * {#cloned_source +#cloned_source+} -- Extend to implement logic in the next request of the original session after it has been cloned.
38
- #
38
+ #
39
39
  # == If the server is configured to not clone sessions:
40
40
  # When the user accesses the same page using the same browser (in different tabs or windows), only the most recently restored one is valid, while the previous ones are immediately invalidated. This is a more secure mode of operation, but has several drawback to usability, so it's not enabled by default.
41
41
  #
@@ -63,26 +63,26 @@ module RSence
63
63
  # * {Servlet__ Servlet} -- The Servlet base class
64
64
  # * {GUIPlugin__ GUIPlugin} -- The GUIPlugin base class
65
65
  class Plugin__
66
-
67
-
66
+
67
+
68
68
  include PluginBase
69
-
69
+
70
70
  # @private Class type identifier for the PluginManager.
71
71
  # @return [:Plugin]
72
72
  def self.bundle_type; :Plugin; end
73
-
73
+
74
74
  # @return [Symbol] The name of the plugin bundle
75
75
  attr_reader :name
76
-
76
+
77
77
  # @return [String] The absolute path of the plugin bundle.
78
78
  attr_reader :path
79
-
79
+
80
80
  # @return [Hash] The {file:PluginBundleInfo meta-information} of the plugin bundle.
81
81
  attr_reader :info
82
-
82
+
83
83
  # @private State of the plugin.
84
84
  attr_reader :inited
85
-
85
+
86
86
  # @private The constructor should not be accessed from anywhere else than the PluginManager, which does it automatically.
87
87
  def initialize( bundle_name, bundle_info, bundle_path, plugin_manager )
88
88
  @inited = false
@@ -92,7 +92,7 @@ module RSence
92
92
  @plugins = plugin_manager
93
93
  register unless @info[:inits_self]
94
94
  end
95
-
95
+
96
96
  # Extend this method to do any initial tasks before other methods are called.
97
97
  #
98
98
  # By default {#init_values} is called to load the {file:Values +values.yaml+} configuration file.
@@ -103,7 +103,7 @@ module RSence
103
103
  def init
104
104
  @values = init_values
105
105
  end
106
-
106
+
107
107
  # Extend this method to do any tasks every time the client makes a request.
108
108
  #
109
109
  # @param [Message] msg The message is supplied by the system.
@@ -111,7 +111,7 @@ module RSence
111
111
  # @return [nil]
112
112
  def idle( msg )
113
113
  end
114
-
114
+
115
115
  # Extend this method to invoke actions, when a new session is created.
116
116
  #
117
117
  # By default {#init_ses_values} is called to initialize values defined in the {file:Values +values.yaml+} configuration file.
@@ -122,7 +122,7 @@ module RSence
122
122
  def init_ses( msg )
123
123
  init_ses_values( msg )
124
124
  end
125
-
125
+
126
126
  # Extend this method to invoke actions, when a previous session is restored.
127
127
  #
128
128
  # By default +#restore_ses_values+ is called to perform actions on values as defined in the {file:Values +values.yaml+} configuration file.
@@ -133,7 +133,7 @@ module RSence
133
133
  def restore_ses( msg )
134
134
  restore_ses_values( msg )
135
135
  end
136
-
136
+
137
137
  # Extend this method to invoke actions, when the session is a clone of another session. It's called once, just before {#restore_ses} is called.
138
138
  #
139
139
  # A session is cloned, when a user opens a another browser window or tab, while the previous session is still active.
@@ -144,7 +144,7 @@ module RSence
144
144
  # @return [nil]
145
145
  def cloned_target( msg, source_session )
146
146
  end
147
-
147
+
148
148
  # Extend this method to invoke actions, when the session has been cloned to another session. It's called once, just before {#restore_ses} is called on the first request after the cloning happened.
149
149
  #
150
150
  # A session is cloned, when a user opens a another browser window or tab, while the previous session is still active.
@@ -155,7 +155,7 @@ module RSence
155
155
  # @return [nil]
156
156
  def cloned_source( msg, target_sessions )
157
157
  end
158
-
158
+
159
159
  # @private This method must be called to register the plugin instance into the system. Otherwise, it's subject to destruction and garbage collection. Use the +name+ parameter to give the (unique) name of your plugin.
160
160
  def register( name=false )
161
161
  if @inited
@@ -170,7 +170,7 @@ module RSence
170
170
  @inited = true
171
171
  end
172
172
  end
173
-
173
+
174
174
  def name_with_manager_s
175
175
  if @info[:manager]
176
176
  return "#{@info[:manager].to_s}:#{@name.to_s}"
@@ -178,7 +178,7 @@ module RSence
178
178
  return @name.to_s
179
179
  end
180
180
  end
181
-
181
+
182
182
  # This method returns (or creates and returns) the entry in the session based on the name your plugin is registered as. It's advised to use this call instead of manually managing {Message#session msg#session} in most cases.
183
183
  #
184
184
  # Uses the first name registered for the plugin and converts it to a symbol.
@@ -255,7 +255,7 @@ module RSence
255
255
  def squeezed_js( path )
256
256
  client_pkg.squeeze( file_read( path ) )
257
257
  end
258
-
258
+
259
259
  # Returns the source code of the javascript file +js_name+ in the 'js' subdirectory of the plugin bundle. Use it to send raw javascript command code to the client. Use {#read_js_once} for libraries.
260
260
  #
261
261
  # @param [String] js_name Javascript source file name without the '.js' suffix.
@@ -273,7 +273,7 @@ module RSence
273
273
  return file_read( path ) if type == :js
274
274
  warn "read_js: unknown type #{type.inspect}"
275
275
  end
276
-
276
+
277
277
  # Like {#read_js}, but reads the file only once per session. Use for inclusion of custom library code.
278
278
  #
279
279
  # @param [Message] msg The message is supplied by the system.
@@ -295,14 +295,14 @@ module RSence
295
295
  return ''
296
296
  end
297
297
  end
298
-
298
+
299
299
  # Extracts +HValue+ references as javascript from the session Hash.
300
300
  #
301
301
  # @param [Message] msg The message is supplied by the system.
302
302
  # @param [Hash] ses Used for supplying a Hash with the {HValue} instances. It's optional and defaults to the current plugin node in the active session.
303
- #
303
+ #
304
304
  # @return [String] A string representing a javascript object similar to the ruby Hash +ses+.
305
- #
305
+ #
306
306
  # @example
307
307
  # values_js( msg, get_ses(msg) )
308
308
  def values_js( msg, ses=false )
@@ -318,8 +318,8 @@ module RSence
318
318
  end
319
319
  return "{#{js_references.join(',')}}"
320
320
  end
321
-
322
-
321
+
322
+
323
323
  # Tells the js client framework to load a list of pre-packaged client libraries.
324
324
  #
325
325
  # It keeps track of what's loaded, so nothing library loaded twice.
@@ -354,7 +354,7 @@ module RSence
354
354
  end
355
355
  end
356
356
  end
357
-
357
+
358
358
  # @private Returns a hash with valid symbol keys for +#value_call+.
359
359
  def sanitize_value_call_hash( hash_dirty )
360
360
  if hash_dirty.class == Symbol
@@ -394,7 +394,7 @@ module RSence
394
394
  end
395
395
  return hash_clean
396
396
  end
397
-
397
+
398
398
  # @private Returns a sanitized copy of a single responder specification.
399
399
  def sanitize_value_responders( responders_dirty )
400
400
  if responders_dirty.class != Array
@@ -437,7 +437,7 @@ module RSence
437
437
  end
438
438
  return responders_clean
439
439
  end
440
-
440
+
441
441
  # @private Returns a sanitized copy of a single value item.
442
442
  def sanitize_value_item( value_item_dirty )
443
443
  unless value_item_dirty.class == Hash
@@ -446,7 +446,9 @@ module RSence
446
446
  :restore_default => false
447
447
  }
448
448
  end
449
- value_item_clean = {}
449
+ value_item_clean = {
450
+ :type => 0
451
+ }
450
452
  value_item_dirty.each do | key, value |
451
453
  if key.to_sym == :value or key.to_sym == :data
452
454
  if [Array, Hash, String, TrueClass, FalseClass, Fixnum, Bignum, Float, NilClass].include? value.class
@@ -470,13 +472,27 @@ module RSence
470
472
  elsif key.to_sym == :responders or key.to_sym == :responder
471
473
  sanitized_responders = sanitize_value_responders( value )
472
474
  value_item_clean[:responders] = sanitized_responders unless sanitized_responders.empty?
475
+ elsif key.to_sym == :type
476
+ if [0,1,2].include? value
477
+ value_type = value
478
+ elsif ['normal',:normal,'push',:push,'pull',:pull].include? value
479
+ # server concept of push and pull are reversed relative to the client
480
+ value_type = {
481
+ 'normal' => 0, :normal => 0,
482
+ 'pull' => 1, :pull => 1,
483
+ 'push' => 2, :push => 2
484
+ }[value]
485
+ else
486
+ warn "Unsupported value type: #{value}"
487
+ end
488
+ value_item_clean[:type] = value_type
473
489
  else
474
490
  warn "Unsupported value specification key: #{key.inspect}."
475
491
  end
476
492
  end
477
493
  return value_item_clean
478
494
  end
479
-
495
+
480
496
  # @private Returns sanitized hash of the structure specified in values.yaml
481
497
  def sanitize_values_yaml( values_path )
482
498
  values_dirty = yaml_read( values_path )
@@ -502,7 +518,7 @@ module RSence
502
518
  end
503
519
  return false
504
520
  end
505
-
521
+
506
522
  # @private This method looks looks for a file called "values.yaml" in the plugin's bundle directory.
507
523
  # If this file is found, it loads it for initial value definitions.
508
524
  # These definitions are accessible as the +@values+ attribute.
@@ -510,7 +526,7 @@ module RSence
510
526
  values_path = bundle_path( 'values.yaml' )
511
527
  return sanitize_values_yaml( values_path )
512
528
  end
513
-
529
+
514
530
  # @private Creates a new instance of HValue, assigns it as +value_name+ into the
515
531
  # session and uses the +value_properties+ Hash to define the default
516
532
  # value and value responders.
@@ -525,7 +541,7 @@ module RSence
525
541
  # {
526
542
  # # Default value; defaults to 0
527
543
  # :value => 'foo',
528
- #
544
+ #
529
545
  # # A plugin method to call to define the default value instead of the one defined in :value
530
546
  # :value_call => {
531
547
  # :plugin => 'plugin_name', # defaults to the plugin where defined
@@ -533,10 +549,10 @@ module RSence
533
549
  # :args => [ 1, 'foo', 3 ], # optional, list of parameter values for the :method
534
550
  # :uses_msg => true # defaults to true; when false, doesn't pass the msg as the first parameter
535
551
  # },
536
- #
552
+ #
537
553
  # # Restore the default, when the session is restored; defaults to true
538
554
  # :restore_default => false,
539
- #
555
+ #
540
556
  # # List of value responder methods to bind.
541
557
  # :responders => [
542
558
  # {
@@ -558,12 +574,12 @@ module RSence
558
574
  default_value = 0
559
575
  end
560
576
  name = name_with_manager_s
561
- ses[value_name] = HValue.new( msg, default_value, { :name => "#{name}.#{value_name}" } )
577
+ ses[value_name] = HValue.new( msg, default_value, { :name => "#{name}.#{value_name}", :type => value_properties[:type] } )
562
578
  if value_properties.has_key?(:responders)
563
579
  init_responders( msg, ses[value_name], value_properties[:responders] )
564
580
  end
565
581
  end
566
-
582
+
567
583
  # @private Initialize a responder for a value.
568
584
  def init_responder( msg, value, responder )
569
585
  name = name_with_manager_s
@@ -579,7 +595,7 @@ module RSence
579
595
  end
580
596
  end
581
597
  end
582
-
598
+
583
599
  # @private Initialize several responders for a value
584
600
  def init_responders( msg, value, responders )
585
601
  members = value.members
@@ -614,7 +630,7 @@ module RSence
614
630
  init_responder( msg, value, responder )
615
631
  end
616
632
  end
617
-
633
+
618
634
  # @private Releases all responders of a value
619
635
  def release_responders( msg, value )
620
636
  members = value.members
@@ -624,8 +640,8 @@ module RSence
624
640
  end
625
641
  end
626
642
  end
627
-
628
- # @private Initializes session values, if the contents of the +values.yaml+
643
+
644
+ # @private Initializes session values, if the contents of the +values.yaml+
629
645
  # file is defined in the bundle directory and loaded in +#init_values+.
630
646
  def init_ses_values( msg )
631
647
  return unless @values
@@ -641,7 +657,7 @@ module RSence
641
657
  end
642
658
  end
643
659
  end
644
-
660
+
645
661
  # @private Returns a value based on the :method and :plugin members of the
646
662
  # +value_call+ hash.
647
663
  #
@@ -693,7 +709,7 @@ module RSence
693
709
  end
694
710
  end
695
711
  end
696
-
712
+
697
713
  def restore_ses_value( msg, value_name, value_properties )
698
714
  ses = get_ses( msg )
699
715
  if ses.has_key?( value_name ) and ses[ value_name ].class == HValue
@@ -716,7 +732,7 @@ module RSence
716
732
  init_ses_value( msg, value_name, value_properties )
717
733
  end
718
734
  end
719
-
735
+
720
736
  # @private Restores session values to default, unless specified otherwise.
721
737
  #
722
738
  # Called from +#restore_ses+
@@ -117,14 +117,14 @@ class SequelSessionStorage
117
117
 
118
118
  ## Checks database connectivity and loads stored sessions from the database
119
119
  def db_init
120
-
120
+
121
121
  create_session_table
122
122
  create_version_table
123
123
  create_uploads_table
124
-
124
+
125
125
  ## Used for future upgrades:
126
126
  # version = table_version
127
-
127
+
128
128
  return true
129
129
  end
130
130
 
@@ -163,7 +163,7 @@ class SequelSessionStorage
163
163
  :cookie_key => ses_data[:cookie_key],
164
164
  :ses_key => ses_data[:ses_key],
165
165
  :user_id => ses_data[:user_id],
166
- :ses_data => ses_data_dump.to_sequel_blob,
166
+ :ses_data => Sequel.blob( ses_data_dump ),
167
167
  :ses_timeout => ses_data[:timeout],
168
168
  :ses_stored => Time.now.to_i
169
169
  )
@@ -195,7 +195,7 @@ class SequelSessionStorage
195
195
  def set_upload_data( upload_id, file_data )
196
196
  db_open
197
197
  @db[:rsence_uploads].filter(:id => upload_id).update( {
198
- :file_data => file_data.to_sequel_blob,
198
+ :file_data => Sequel.blob( file_data ),
199
199
  :upload_done => true
200
200
  } )
201
201
  db_close