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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/client/conf/client_pkg.yaml +6 -2
- data/client/js/comm/queue/queue.js +32 -44
- data/client/js/comm/transporter/transporter.js +24 -16
- data/client/js/comm/values/values.js +27 -15
- data/client/js/controls/button/button.coffee +14 -5
- data/client/js/controls/button/themes/default/button.css +4 -2
- data/client/js/controls/checkbox/checkbox.js +4 -4
- data/client/js/controls/dialogs/sheet/sheet.js +11 -11
- data/client/js/controls/dialogs/sheet/themes/default/sheet.html +1 -1
- data/client/js/controls/imageview/imageview.js +15 -15
- data/client/js/controls/numerictextcontrol/numerictextcontrol.coffee +32 -10
- data/client/js/controls/onoffbutton/onoffbutton.coffee +5 -5
- data/client/js/controls/progress/progressbar/progressbar.js +6 -7
- data/client/js/controls/progress/progressbar/themes/default/progressbar.css +4 -4
- data/client/js/controls/progress/progressbar/themes/default/progressbar.html +1 -2
- data/client/js/controls/sliders/slider/slider.js +74 -79
- data/client/js/controls/stepper/stepper.js +31 -31
- data/client/js/controls/stringview/stringview.js +20 -8
- data/client/js/controls/tab/tab.js +57 -63
- data/client/js/controls/tab/themes/default/tab.html +4 -1
- data/client/js/controls/textcontrol/textcontrol.coffee +13 -3
- data/client/js/controls/validatorview/validatorview.js +4 -4
- data/client/js/controls/window/window.js +43 -56
- data/client/js/core/class/class.js +25 -23
- data/client/js/core/elem/elem.coffee +8 -1
- data/client/js/core/rsence_ns/rsence_ns.coffee +6 -2
- data/client/js/core/util/util_methods/util_methods.coffee +57 -15
- data/client/js/datetime/calendar/calendar.coffee +196 -199
- data/client/js/datetime/calendar/themes/default/calendar.css +81 -159
- data/client/js/datetime/calendar/themes/default/calendar.html +9 -18
- data/client/js/datetime/datepicker/datepicker.coffee +18 -3
- data/client/js/datetime/datetimepicker/datetimepicker.coffee +6 -1
- data/client/js/datetime/datetimevalue/datetimevalue.coffee +194 -0
- data/client/js/datetime/momentjs/momentjs.js +310 -76
- data/client/js/datetime/timepicker/timepicker.coffee +6 -1
- data/client/js/datetime/timesheet/timesheet.js +59 -61
- data/client/js/foundation/control/control.js +45 -44
- data/client/js/foundation/control/controldefaults/controldefaults.js +13 -9
- data/client/js/foundation/control/dyncontrol/dyncontrol.js +45 -57
- data/client/js/foundation/control/eventresponder/eventresponder.js +97 -97
- data/client/js/foundation/control/valuematrix/valuematrix.js +13 -13
- data/client/js/foundation/eventmanager/eventmanager.coffee +50 -32
- data/client/js/foundation/geom/rect/rect.js +43 -32
- data/client/js/foundation/locale_settings/locale_settings.js +36 -25
- data/client/js/foundation/system/system.js +79 -67
- data/client/js/foundation/thememanager/thememanager.coffee +11 -1
- data/client/js/foundation/value/pullvalue/pullvalue.coffee +7 -0
- data/client/js/foundation/value/pushvalue/pushvalue.coffee +25 -0
- data/client/js/foundation/value/value.js +22 -15
- data/client/js/foundation/view/view.js +94 -55
- data/client/js/foundation/view/viewdefaults/viewdefaults.js +5 -1
- data/client/js/lists/listitems/listitems.js +26 -4
- data/client/js/menus/combobox/combobox.coffee +55 -0
- data/client/js/menus/minimenu/minimenu.js +61 -30
- data/client/js/menus/minimenu/themes/default/minimenu.css +1 -6
- data/client/js/menus/minimenu/themes/default/minimenu.html +5 -4
- data/client/js/menus/minimenuitem/minimenuitem.js +6 -6
- data/client/js/menus/popupmenu/themes/default/popupmenu.css +1 -6
- data/client/js/menus/popupmenu/themes/default/popupmenu.html +5 -4
- data/client/js/tables/table/table.coffee +109 -64
- data/client/js/tables/table/themes/default/table.css +4 -0
- data/lib/rsence/msg.rb +64 -64
- data/lib/rsence/plugins/plugin.rb +68 -52
- data/lib/rsence/session/sequel_sessionstorage.rb +5 -5
- data/lib/rsence/value.rb +79 -59
- data/plugins/client_pkg/lib/client_pkg_build.rb +5 -1
- data/plugins/client_pkg/lib/client_pkg_serve.rb +40 -32
- data/plugins/main/js/main.js +46 -28
- metadata +6 -8
- data/client/js/datetime/calendar/themes/default/calendar_arrows.png +0 -0
- data/client/js/datetime/calendar/themes/default/calendar_bg.png +0 -0
- data/client/js/datetime/calendar/themes/default/calendar_parts1.png +0 -0
- data/client/js/datetime/calendar/themes/default/calendar_parts2.png +0 -0
- data/client/js/datetime/datetimepicker/datetimepicker.js +0 -210
- data/client/js/datetime/datetimevalue/datetimevalue.js +0 -265
@@ -9,13 +9,13 @@
|
|
9
9
|
***/
|
10
10
|
var//RSence.Controls
|
11
11
|
HWindow = HDynControl.extend({
|
12
|
-
|
12
|
+
|
13
13
|
componentName: 'window',
|
14
|
-
|
14
|
+
|
15
15
|
/** = Description
|
16
16
|
* In addition to the standard HControl#constructor options,
|
17
17
|
* the following properties can be set:
|
18
|
-
*
|
18
|
+
*
|
19
19
|
* Key:: Description
|
20
20
|
* +minX+:: The minimum X-coordinate allowed to be dragged or resized to.
|
21
21
|
* Defaults to +0+.
|
@@ -45,7 +45,7 @@ HWindow = HDynControl.extend({
|
|
45
45
|
* Defaults to +[ 16, 16 ]+
|
46
46
|
* +noResize+:: A flag (when true) disables all resizing and only allows
|
47
47
|
* moving. Does not disable the (-) and (+) buttons.
|
48
|
-
* +fullWindowMove+:: A flag (when true) enables the full HWindow area
|
48
|
+
* +fullWindowMove+:: A flag (when true) enables the full HWindow area
|
49
49
|
* responds to drag events. By default it's false,
|
50
50
|
* meaning only the title bar is draggable.
|
51
51
|
* +closeButton+:: A flag (when true) enables the close button of HWindow.
|
@@ -54,13 +54,13 @@ HWindow = HDynControl.extend({
|
|
54
54
|
* the HWindow instance.
|
55
55
|
* +collapseButton+:: A flag (when true) enables the collapse (or minimize)
|
56
56
|
* button of the HWindow instance. By default it's
|
57
|
-
* disabled. When enabled, extend the
|
57
|
+
* disabled. When enabled, extend the
|
58
58
|
* HWindow#windowCollapse method, which by default
|
59
59
|
* zooms the window to its +minSize+.
|
60
60
|
* +minimizeButton+:: An alias for +collapseButton+
|
61
61
|
* +zoomButton+:: A flag (when true) enables the zoom (or maximize)
|
62
62
|
* button of the HWindow instance. By default it's
|
63
|
-
* disabled. When enabled, extend the
|
63
|
+
* disabled. When enabled, extend the
|
64
64
|
* HWindow#windowZoom method, which by default zooms the
|
65
65
|
* contents of the HWindow to fit or the +maxSize+ depending
|
66
66
|
* on which is smaller.
|
@@ -68,41 +68,7 @@ HWindow = HDynControl.extend({
|
|
68
68
|
* +maximizeButton+:: An alias for +zoomButton+
|
69
69
|
*
|
70
70
|
**/
|
71
|
-
controlDefaults:
|
72
|
-
constructor: function(_ctrl){
|
73
|
-
var _winSize = ELEM.windowSize(),
|
74
|
-
_winWidth = _winSize[0],
|
75
|
-
_winHeight = _winSize[1];
|
76
|
-
if(!this.minSize){
|
77
|
-
this.minSize = [96,54];
|
78
|
-
}
|
79
|
-
if(!this.maxSize){
|
80
|
-
this.maxSize = _winSize;
|
81
|
-
}
|
82
|
-
if(!this.maxX){
|
83
|
-
this.maxX = _winWidth-this.minSize[0];
|
84
|
-
}
|
85
|
-
if(!this.maxY){
|
86
|
-
this.maxY = _winHeight-this.minSize[1];
|
87
|
-
}
|
88
|
-
if(!this.events){
|
89
|
-
this.events = {
|
90
|
-
draggable: true
|
91
|
-
};
|
92
|
-
}
|
93
|
-
if(!this.resizeNW){
|
94
|
-
this.resizeNW = [ 6, 6 ];
|
95
|
-
}
|
96
|
-
if(!this.resizeNE){
|
97
|
-
this.resizeNE = [ 6, 6 ];
|
98
|
-
}
|
99
|
-
if(!this.resizeSW){
|
100
|
-
this.resizeSW = [ 6, 6 ];
|
101
|
-
}
|
102
|
-
if(!this.resizeSE){
|
103
|
-
this.resizeSE = [ 25, 25 ];
|
104
|
-
}
|
105
|
-
},
|
71
|
+
controlDefaults: HDynControl.prototype.controlDefaults.extend({
|
106
72
|
maxX: 'auto',
|
107
73
|
maxY: 'auto',
|
108
74
|
maxSize: 'auto',
|
@@ -117,8 +83,29 @@ HWindow = HDynControl.extend({
|
|
117
83
|
zoomButton: false,
|
118
84
|
resizeButton: false,
|
119
85
|
maximizeButton: false
|
120
|
-
})
|
121
|
-
|
86
|
+
}),
|
87
|
+
|
88
|
+
customOptions: function(_options){
|
89
|
+
var
|
90
|
+
_winSize = ELEM.windowSize(),
|
91
|
+
_winWidth = _winSize[0],
|
92
|
+
_winHeight = _winSize[1];
|
93
|
+
if(!_options.minSize){ _options.minSize = [96,54]; }
|
94
|
+
|
95
|
+
if(!_options.maxSize){ _options.maxSize = _winSize; }
|
96
|
+
if(!_options.maxX ){ _options.maxX = _winWidth-_options.minSize[0]; }
|
97
|
+
if(!_options.maxY ){ _options.maxY = _winHeight-_options.minSize[1]; }
|
98
|
+
|
99
|
+
if(!_options.resizeNW){ _options.resizeNW = [ 6, 6 ]; }
|
100
|
+
if(!_options.resizeNE){ _options.resizeNE = [ 6, 6 ]; }
|
101
|
+
if(!_options.resizeSW){ _options.resizeSW = [ 6, 6 ]; }
|
102
|
+
if(!_options.resizeSE){ _options.resizeSE = [ 25, 25 ]; }
|
103
|
+
},
|
104
|
+
|
105
|
+
defaultEvents: {
|
106
|
+
draggable: true
|
107
|
+
},
|
108
|
+
|
122
109
|
draw: function(){
|
123
110
|
var _drawn = this.drawn;
|
124
111
|
this.base();
|
@@ -181,7 +168,7 @@ HWindow = HDynControl.extend({
|
|
181
168
|
this.base(_state);
|
182
169
|
this.refreshWidgetStates();
|
183
170
|
},
|
184
|
-
|
171
|
+
|
185
172
|
// -- overrides the drag rules to adapt to the !fullWindowMove as well
|
186
173
|
// as disabling draggability in window button areas. ++
|
187
174
|
|
@@ -210,7 +197,7 @@ HWindow = HDynControl.extend({
|
|
210
197
|
}
|
211
198
|
return _rectRules;
|
212
199
|
},
|
213
|
-
|
200
|
+
|
214
201
|
maxRect: function(){
|
215
202
|
var _rect = this.base(), _opts = this.options;
|
216
203
|
if(_rect[2]<_opts.minSize[0]){
|
@@ -230,29 +217,29 @@ HWindow = HDynControl.extend({
|
|
230
217
|
|
231
218
|
hasWindowFocus: false,
|
232
219
|
|
233
|
-
/** Reports to HSystem that this window has the focus and the
|
234
|
-
* previously active window needs to blur
|
220
|
+
/** Reports to HSystem that this window has the focus and the
|
221
|
+
* previously active window needs to blur
|
235
222
|
**/
|
236
223
|
gainedActiveStatus: function(){
|
237
224
|
HSystem.windowFocus(this);
|
238
225
|
},
|
239
|
-
|
226
|
+
|
240
227
|
/** HSystem calls this method, whenever this window is allowed to be focused
|
241
228
|
**/
|
242
229
|
windowFocus: function(){
|
243
230
|
this.hasWindowFocus = true;
|
244
231
|
this.toggleCSSClass(this.elemId, 'inactive', false);
|
245
232
|
},
|
246
|
-
|
247
|
-
/** HSystem calls this method, whenever this window needs to lose its
|
248
|
-
* focus (another window focused)
|
233
|
+
|
234
|
+
/** HSystem calls this method, whenever this window needs to lose its
|
235
|
+
* focus (another window focused)
|
249
236
|
**/
|
250
237
|
windowBlur: function(){
|
251
238
|
this.hasWindowFocus = false;
|
252
239
|
this.toggleCSSClass(this.elemId, 'inactive', true);
|
253
240
|
this.setStyle('cursor','default');
|
254
241
|
},
|
255
|
-
|
242
|
+
|
256
243
|
/** This method gets called, whenever the close button has been clicked
|
257
244
|
**/
|
258
245
|
windowClose: function(){
|
@@ -274,8 +261,8 @@ HWindow = HDynControl.extend({
|
|
274
261
|
}
|
275
262
|
this.makeRectRules();
|
276
263
|
},
|
277
|
-
|
278
|
-
/** This method gets called, whenever the collapse (minimize) button has
|
264
|
+
|
265
|
+
/** This method gets called, whenever the collapse (minimize) button has
|
279
266
|
* been clicked
|
280
267
|
**/
|
281
268
|
windowCollapse: function(_rectOnly){
|
@@ -308,8 +295,8 @@ HWindow = HDynControl.extend({
|
|
308
295
|
}
|
309
296
|
this.makeRectRules();
|
310
297
|
},
|
311
|
-
|
312
|
-
/** This method gets called, whenever the zoom (maximize/restore)
|
298
|
+
|
299
|
+
/** This method gets called, whenever the zoom (maximize/restore)
|
313
300
|
* button has been clicked
|
314
301
|
**/
|
315
302
|
windowZoom: function(){
|
@@ -18,7 +18,7 @@
|
|
18
18
|
* * To achieve the above without resorting to global functions to build prototype chains
|
19
19
|
* * To achieve the above without affecting Object.prototype
|
20
20
|
*
|
21
|
-
* The HClass class extends the 'Object' object by adding one instance method (base)
|
21
|
+
* The HClass class extends the 'Object' object by adding one instance method (base)
|
22
22
|
* and two class methods (extend, implement). Instance method extend can be also called directly.
|
23
23
|
*
|
24
24
|
* == Example:
|
@@ -30,10 +30,10 @@
|
|
30
30
|
* this.foo = foo;
|
31
31
|
* }
|
32
32
|
* });
|
33
|
-
*
|
33
|
+
*
|
34
34
|
* myClassInstance1 = MyClass.nu( 'rabbids' );
|
35
35
|
* myClassInstance2 = new MyClass( 'ribbit' );
|
36
|
-
*
|
36
|
+
*
|
37
37
|
* MyEqualsClass = MyClass.extend({
|
38
38
|
* testFoo: function( that ){
|
39
39
|
* return this.foo === that.foo;
|
@@ -68,10 +68,10 @@ HClass.prototype = {
|
|
68
68
|
for (prop in e) {
|
69
69
|
err[prop] = e[prop];
|
70
70
|
}
|
71
|
-
err
|
71
|
+
err.string = e.toString();
|
72
72
|
return err;
|
73
73
|
},
|
74
|
-
|
74
|
+
|
75
75
|
/* The property copying method. */
|
76
76
|
extend: function(_source, _value) {
|
77
77
|
var _extend = HClass.prototype.extend,
|
@@ -79,7 +79,7 @@ HClass.prototype = {
|
|
79
79
|
if (arguments.length === 2) {
|
80
80
|
_ancestor = this[_source];
|
81
81
|
// only methods are inherited
|
82
|
-
if ((_ancestor
|
82
|
+
if ((typeof _ancestor === 'function') && (typeof _value === 'function') &&
|
83
83
|
_ancestor.valueOf() !== _value.valueOf() && (/\bbase\b/).test(_value)) {
|
84
84
|
_method = _value;
|
85
85
|
_value = function() {
|
@@ -96,7 +96,7 @@ HClass.prototype = {
|
|
96
96
|
_returnValue = _method.apply(this, arguments);
|
97
97
|
}
|
98
98
|
catch(e){
|
99
|
-
!this.isProduction && console.warn("An exception occurred while calling base: ",HClass.prototype._exceptionProperties(e)," object: ",
|
99
|
+
!this.isProduction && console.warn("An exception occurred while calling base: ",HClass.prototype._exceptionProperties(e)," object: ",_method);
|
100
100
|
_returnValue = null;
|
101
101
|
}
|
102
102
|
// then because event this function can be called from child method
|
@@ -133,21 +133,23 @@ HClass.prototype = {
|
|
133
133
|
}
|
134
134
|
}
|
135
135
|
}
|
136
|
-
|
136
|
+
|
137
137
|
// alternative constructor (use instead of the new keywoard)
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
138
|
+
var
|
139
|
+
_nu = function(){
|
140
|
+
try{
|
141
|
+
return new (this.extend({ constructor: function( _args ){ this.base.apply( this, _args ); } } ))( arguments );
|
142
|
+
}
|
143
|
+
catch(e){
|
144
|
+
console.log(e,this);
|
145
|
+
return {};
|
146
|
+
}
|
146
147
|
};
|
148
|
+
this.nu = _nu;
|
149
|
+
this['new'] = _nu;
|
147
150
|
this.hasAncestor = function( _obj ){
|
148
151
|
return !!~this.ancestors.indexOf( _obj );
|
149
152
|
};
|
150
|
-
this['new'] = this.nu;
|
151
153
|
return this;
|
152
154
|
},
|
153
155
|
/** = Description
|
@@ -224,7 +226,7 @@ HClass.extend = function(_instance, _static) {
|
|
224
226
|
_constructor = _prototype.constructor;
|
225
227
|
_prototype.constructor = this;
|
226
228
|
delete HClass._prototyping;
|
227
|
-
|
229
|
+
|
228
230
|
_ancestors = [];
|
229
231
|
_klass = function() {
|
230
232
|
if (!HClass._prototyping) {
|
@@ -268,7 +270,7 @@ HClass.ancestors = [ HClass ];
|
|
268
270
|
*
|
269
271
|
* = Usage:
|
270
272
|
* Defines an interface:
|
271
|
-
*
|
273
|
+
*
|
272
274
|
* AreaInterface = HClass.extend({
|
273
275
|
* constructor: null,
|
274
276
|
* // implement
|
@@ -279,7 +281,7 @@ HClass.ancestors = [ HClass ];
|
|
279
281
|
* return this.getWidth() * this.getHeight();
|
280
282
|
* }
|
281
283
|
* });
|
282
|
-
*
|
284
|
+
*
|
283
285
|
* Rectangle = HClass.extend({
|
284
286
|
* constructor: function(x, y, width, height) {
|
285
287
|
* this.x = x;
|
@@ -294,7 +296,7 @@ HClass.ancestors = [ HClass ];
|
|
294
296
|
* return this.height;
|
295
297
|
* }
|
296
298
|
* });
|
297
|
-
*
|
299
|
+
*
|
298
300
|
* Rectangle.implement(AreaInterface);
|
299
301
|
*
|
300
302
|
**/
|
@@ -353,8 +355,8 @@ if (!Function.prototype.bind) {
|
|
353
355
|
// closest thing possible to the ECMAScript 5 internal IsCallable function
|
354
356
|
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
355
357
|
}
|
356
|
-
var aArgs = Array.prototype.slice.call(arguments, 1),
|
357
|
-
fToBind = this,
|
358
|
+
var aArgs = Array.prototype.slice.call(arguments, 1),
|
359
|
+
fToBind = this,
|
358
360
|
fNOP = function () {},
|
359
361
|
fBound = function () {
|
360
362
|
return fToBind.apply(
|
@@ -435,6 +435,13 @@ ELEM = HClass.extend
|
|
435
435
|
flush: ->
|
436
436
|
@flushLoop()
|
437
437
|
|
438
|
+
flushElem: (_elemIds)->
|
439
|
+
_elemIds = [_elemIds] if typeof _elemIds == 'number'
|
440
|
+
for _id in _elemIds
|
441
|
+
continue unless @_elemTodoH[_id]
|
442
|
+
@_elemTodoH[_id] = false
|
443
|
+
@_flushStyleCache(_id)
|
444
|
+
@_flushAttrCache(_id)
|
438
445
|
###
|
439
446
|
Performs the flush of flushLoop
|
440
447
|
###
|
@@ -932,7 +939,7 @@ ELEM = HClass.extend
|
|
932
939
|
@_init()
|
933
940
|
else
|
934
941
|
ELEM._domLoadTimer = setTimeout( =>
|
935
|
-
|
942
|
+
@._domWaiter()
|
936
943
|
, 10 )
|
937
944
|
null
|
938
945
|
ELEM.reset()
|
@@ -22,7 +22,7 @@ RSence =
|
|
22
22
|
user-select: text;
|
23
23
|
}
|
24
24
|
''')
|
25
|
-
|
25
|
+
|
26
26
|
# Call this method from the index page for
|
27
27
|
# client-only features
|
28
28
|
clientConf: (_clientPrefix)->
|
@@ -38,7 +38,7 @@ RSence =
|
|
38
38
|
RSence.clientConf( _clientPrefix )
|
39
39
|
COMM.AutoSyncStarter.start()
|
40
40
|
null
|
41
|
-
|
41
|
+
|
42
42
|
# Storage for guiTrees, cantains
|
43
43
|
# JSONRenderer instances by plugin name.
|
44
44
|
guiTrees: {}
|
@@ -50,3 +50,7 @@ RSence =
|
|
50
50
|
_guiTree.die()
|
51
51
|
_guiTrees[_guiName] = null
|
52
52
|
delete _guiTrees[_guiName]
|
53
|
+
|
54
|
+
# Passthrough hook for setting locale data
|
55
|
+
setLocaleData: (_localeData)->
|
56
|
+
HLocale.setData(_localeData)
|
@@ -10,9 +10,28 @@ UtilMethods = (->
|
|
10
10
|
's' # string
|
11
11
|
]
|
12
12
|
|
13
|
+
pushTask: (_fn)->
|
14
|
+
COMM.Queue.push(_fn)
|
15
|
+
|
16
|
+
unshiftTask: (_fn)->
|
17
|
+
COMM.Queue.unshift(_fn)
|
18
|
+
|
19
|
+
msNow: ->
|
20
|
+
new Date().getTime()
|
21
|
+
|
13
22
|
getValueById: (_id)->
|
14
23
|
COMM.Values.values[_id]
|
15
24
|
|
25
|
+
isFloat: (_num)-> ( Math.round(_num) != _num )
|
26
|
+
|
27
|
+
moment: (_date,_format)->
|
28
|
+
if @options
|
29
|
+
if @options.useUTC == true or (@options.useUTC == null and HLocale.dateTime.defaultOptions.useUTC == true)
|
30
|
+
return moment.utc(_date,_format)
|
31
|
+
else if HLocale.dateTime.defaultOptions.useUTC == true
|
32
|
+
return moment.utc(_date,_format)
|
33
|
+
moment(_date,_format)
|
34
|
+
|
16
35
|
###
|
17
36
|
# Returns object type as a single-char string.
|
18
37
|
# Use this method to detect the type of the object given.
|
@@ -26,8 +45,9 @@ UtilMethods = (->
|
|
26
45
|
# - 'h': Hash (Generic Object)
|
27
46
|
# - 'd': Date
|
28
47
|
# - 'b': Boolean (true/false)
|
29
|
-
# - 'n': Number (
|
48
|
+
# - 'n': Number (integer or float, use #isFloat to see whether it's a float or integer )
|
30
49
|
# - 's': String
|
50
|
+
# - '>': Function
|
31
51
|
# - '~': Null
|
32
52
|
# - '-': Undefined
|
33
53
|
# - false: unknown
|
@@ -35,12 +55,13 @@ UtilMethods = (->
|
|
35
55
|
typeChr: (_obj)->
|
36
56
|
return '~' if _obj == null
|
37
57
|
return '-' unless _obj?
|
58
|
+
return '>' if _obj instanceof Function
|
38
59
|
_typeChr = (typeof _obj).slice(0,1)
|
39
60
|
return _typeChr if @arrIncludes(@_builtinTypeChr,_typeChr)
|
40
61
|
if _typeChr == 'o'
|
41
|
-
return 'a' if _obj
|
62
|
+
return 'a' if _obj instanceof Array
|
63
|
+
return 'd' if _obj instanceof Date
|
42
64
|
return 'h' if _obj.constructor == Object
|
43
|
-
return 'd' if _obj.constructor == Date
|
44
65
|
return false
|
45
66
|
|
46
67
|
baseStrToNum: (_str, _base)->
|
@@ -61,10 +82,10 @@ UtilMethods = (->
|
|
61
82
|
|
62
83
|
base36ToNum: (_base36)->
|
63
84
|
@baseStrToNum(_base36,36)
|
64
|
-
|
85
|
+
|
65
86
|
numToBase36: (_num)->
|
66
87
|
@baseIntToStr(_num,36)
|
67
|
-
|
88
|
+
|
68
89
|
_hexColorLengths: [3,4,6,7]
|
69
90
|
_hexCharacters: ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f']
|
70
91
|
_hex3To6Ratio: 4097 # parseInt('1001',16)
|
@@ -132,6 +153,27 @@ UtilMethods = (->
|
|
132
153
|
catch e
|
133
154
|
console.log('_'+'decodeString failed for _'+'str: ',_str)
|
134
155
|
return _str
|
156
|
+
# Recursively merges two objects of identical structure (array or object)
|
157
|
+
updateObject: (_src,_dst)->
|
158
|
+
_typeSrc = @typeChr(_src)
|
159
|
+
_typeDst = @typeChr(_dst)
|
160
|
+
_merge = (_item,_src,_dst,i)=>
|
161
|
+
_itemType = @typeChr(_item)
|
162
|
+
if _itemType == @typeChr(_dst[i])
|
163
|
+
if _itemType == 'a' or _itemType == 'h'
|
164
|
+
@updateObjects( _item, _dst[i] )
|
165
|
+
else
|
166
|
+
_dst[i] = _item
|
167
|
+
else if !@isProduction
|
168
|
+
console.warn('updateObject; mismatching item type: ', _itemType, ' (', _item, ') vs ', @_typeChr(_dst[i]), ' (',_dst[i], ')')
|
169
|
+
if _typeSrc == _typeDst
|
170
|
+
if _typeSrc == 'a'
|
171
|
+
for _item, i in _src
|
172
|
+
_merge(_item,_src,_dst,i)
|
173
|
+
else if _typeSrc == 'h'
|
174
|
+
for i, _item of _src
|
175
|
+
_itemType = @typeChr(_item)
|
176
|
+
_merge(_itemType,_src,_dst,i)
|
135
177
|
# Returns a decoded Array with the decoded content of Array _arr
|
136
178
|
_decodeArr: (_arr)->
|
137
179
|
_output = []
|
@@ -146,13 +188,13 @@ UtilMethods = (->
|
|
146
188
|
_output
|
147
189
|
## = Description
|
148
190
|
# Decodes a JSON object. Decodes the url-encoded strings within.
|
149
|
-
#
|
191
|
+
#
|
150
192
|
# = Parameters
|
151
193
|
# +_ibj+:: A raw object with special characters contained.
|
152
|
-
#
|
194
|
+
#
|
153
195
|
# = Returns
|
154
196
|
# A version of the object with the contained strings decoded to unicode.
|
155
|
-
#
|
197
|
+
#
|
156
198
|
##
|
157
199
|
decodeObject: (_obj)->
|
158
200
|
return null unless _obj?
|
@@ -178,7 +220,7 @@ UtilMethods = (->
|
|
178
220
|
catch e
|
179
221
|
console.log('invalid json:',_obj)
|
180
222
|
return "{}"
|
181
|
-
|
223
|
+
|
182
224
|
# decodeObject: (_obj)->
|
183
225
|
# return null unless _obj?
|
184
226
|
# _type = @typeChr(_obj)
|
@@ -192,7 +234,7 @@ UtilMethods = (->
|
|
192
234
|
# catch e
|
193
235
|
# console.log e, _obj
|
194
236
|
# _obj
|
195
|
-
|
237
|
+
|
196
238
|
cloneObject: ( _obj )->
|
197
239
|
unless _obj?
|
198
240
|
console.log 'WARNING: clone of undefined returns null.' if _obj == undefined
|
@@ -217,10 +259,10 @@ UtilMethods = (->
|
|
217
259
|
'{'+_output.join(',')+'}'
|
218
260
|
## = Description
|
219
261
|
# Encodes any object into an ASCII string. Special characters are url-encoded.
|
220
|
-
#
|
262
|
+
#
|
221
263
|
# = Parameters
|
222
264
|
# +_obj+:: Any object (including primary types)
|
223
|
-
#
|
265
|
+
#
|
224
266
|
# = Returns
|
225
267
|
# A +String+ representation of +_obj+
|
226
268
|
##
|
@@ -240,14 +282,14 @@ UtilMethods = (->
|
|
240
282
|
'null'
|
241
283
|
## = Description
|
242
284
|
# Makes a deep copy of the object.
|
243
|
-
#
|
285
|
+
#
|
244
286
|
# When you use assignment of a js object, only primitive object
|
245
287
|
# types (strings, numbers and booleans) are copied. This method
|
246
288
|
# makes a deep (nested) clone of the input object.
|
247
|
-
#
|
289
|
+
#
|
248
290
|
# = Parameters
|
249
291
|
# +_obj+:: Any object
|
250
|
-
#
|
292
|
+
#
|
251
293
|
# = Returns
|
252
294
|
# A copy of the object
|
253
295
|
##
|