rsence-pre 2.3.0.19 → 2.3.0.20

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/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.0.19.pre
1
+ 2.3.0.20.pre
@@ -258,5 +258,3 @@
258
258
  #
259
259
  # Entered by code, empty container
260
260
  :broker_urls: { }
261
-
262
-
@@ -14,7 +14,7 @@ HImageView = HControl.extend({
14
14
  getImgSrc: function(){
15
15
  var _value = (this.value!==null)?this.value:(this.options.valueObj?this.options.valueObj.value:this.options.value);
16
16
  if (!_value){
17
- _value = this.getThemeGfxPath() + "/blank.gif";
17
+ _value = this.getThemeGfxFile("blank.gif");
18
18
  }
19
19
  return _value;
20
20
  },
@@ -62,9 +62,9 @@ HTab = HControl.extend({
62
62
  // overridden in the template
63
63
  fontStyle: 'font-family:Arial,sans-serif;font-size:13px;',
64
64
 
65
- tabLabelHTMLPrefix1: '<div class="edge-left"></div><div class="tablabel" style="width:',
65
+ tabLabelHTMLPrefix1: '<div class="edge_left"></div><div class="tablabel" style="width:',
66
66
  tabLabelHTMLPrefix2: 'px">',
67
- tabLabelHTMLSuffix: '</div><div class="edge-right"></div>',
67
+ tabLabelHTMLSuffix: '</div><div class="edge_right"></div>',
68
68
  tabLabelParentElem: 'label',
69
69
  tabLabelElementTagName: 'div',
70
70
  tabLabelAlign: 'left',
@@ -113,15 +113,15 @@ HTab = HControl.extend({
113
113
  if(~this.selectIdx){
114
114
  var _tabSelectElemId = this.tabLabels[this.selectIdx],
115
115
  _tabSelectViewId = this.tabs[this.selectIdx];
116
- ELEM.delClassName(_tabSelectElemId,'item-fg');
117
- ELEM.addClassName(_tabSelectElemId,'item-bg');
116
+ ELEM.delClassName(_tabSelectElemId,'item_fg');
117
+ ELEM.addClassName(_tabSelectElemId,'item_bg');
118
118
  HSystem.views[_tabSelectViewId].hide();
119
119
  }
120
120
  if(~_tabIdx){
121
121
  var _tabLabelElemId = this.tabLabels[_tabIdx],
122
122
  _tabViewId = this.tabs[_tabIdx];
123
- ELEM.delClassName(_tabLabelElemId,'item-bg');
124
- ELEM.addClassName(_tabLabelElemId,'item-fg');
123
+ ELEM.delClassName(_tabLabelElemId,'item_bg');
124
+ ELEM.addClassName(_tabLabelElemId,'item_fg');
125
125
  HSystem.views[_tabViewId].show();
126
126
  }
127
127
  this.selectIdx = _tabIdx;
@@ -158,7 +158,7 @@ HTab = HControl.extend({
158
158
  _tabLabelHTML = this.tabLabelHTMLPrefix1+_labelTextWidth+this.tabLabelHTMLPrefix2+_tabLabel+this.tabLabelHTMLSuffix;
159
159
  }
160
160
  _tab.hide();
161
- ELEM.addClassName(_tabLabelElemId,'item-bg');
161
+ ELEM.addClassName(_tabLabelElemId,'item_bg');
162
162
  ELEM.setStyle(_tabLabelElemId,'width',_labelWidth+'px');
163
163
  ELEM.setStyle(_tabLabelElemId,this.tabLabelAlign,this.rightmostPx+'px');
164
164
  ELEM.setHTML(_tabLabelElemId,_tabLabelHTML);
@@ -6,15 +6,15 @@
6
6
  }
7
7
 
8
8
  /* set left and width manually */
9
- .tab_label .item-fg,
10
- .tab_label .item-bg {
9
+ .tab_label .item_fg,
10
+ .tab_label .item_bg {
11
11
  position: absolute;
12
12
  top: 0px; height: 24px;
13
13
  background-repeat: repeat-x;
14
14
  }
15
15
  .tab_label,
16
- .tab_label .edge-left,
17
- .tab_label .edge-right,
16
+ .tab_label .edge_left,
17
+ .tab_label .edge_right,
18
18
  .tab_label .tablabel,
19
19
  .tab_label_fill_bg {
20
20
  background-repeat: no-repeat;
@@ -27,21 +27,21 @@
27
27
  background-repeat: repeat-x;
28
28
  }
29
29
 
30
- .tab_label .edge-left {
30
+ .tab_label .edge_left {
31
31
  position: absolute;
32
32
  top: 0px; left: 0px; width: 12px; height: 24px;
33
33
  background-position: 0px 0px;
34
34
  }
35
- .tab_label .item-bg .edge-left {
35
+ .tab_label .item_bg .edge_left {
36
36
  background-position: -24px 0px;
37
37
  }
38
38
 
39
- .tab_label .edge-right {
39
+ .tab_label .edge_right {
40
40
  position: absolute;
41
41
  top: 0px; right: 0px; width: 9px; height: 24px;
42
42
  background-position: -12px 0px;
43
43
  }
44
- .tab_label .item-bg .edge-right {
44
+ .tab_label .item_bg .edge_right {
45
45
  background-position: -36px 0px;
46
46
  }
47
47
 
@@ -60,7 +60,7 @@
60
60
  font-size: 12px; font-weight: bold;
61
61
  color: #333;
62
62
  }
63
- .tab_label .item-bg .tablabel {
63
+ .tab_label .item_bg .tablabel {
64
64
  background-position: 0px -48px;
65
65
  color: #666;
66
66
  }
@@ -309,7 +309,7 @@ HClass.implement = function(_interface) {
309
309
  //var Base = HClass;
310
310
 
311
311
  // Array fix
312
- if ([]['indexOf']===undefined) {
312
+ if (![].indexOf) {
313
313
  // Object.extend = function(_destination, _source) {
314
314
  // for (var _property in _source) {
315
315
  // _destination[_property] = _source[_property];
@@ -337,14 +337,34 @@ if(typeof String.prototype.trim !== 'function') {
337
337
 
338
338
  // ff version 3.0.3 fails on this, when firebug installed: try/catch block
339
339
  try {
340
+ // console.log surrogate for browsers without a console
341
+ if(!window.console){
342
+ window.console = {
343
+ log: function(){},
344
+ warn: function(){}
345
+ };
346
+ }
347
+ } catch(e) {}
340
348
 
341
- // console.log surrogate for browsers without a console
342
- if(window['console']===undefined){
343
- window.console = {
344
- log: function(){},
345
- warn: function(){}
349
+ // Mozilla reference bind workaround (bind was introduced in JS 1.8.5)
350
+ if (!Function.prototype.bind) {
351
+ Function.prototype.bind = function (oThis) {
352
+ if (typeof this !== "function") {
353
+ // closest thing possible to the ECMAScript 5 internal IsCallable function
354
+ throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
355
+ }
356
+ var aArgs = Array.prototype.slice.call(arguments, 1),
357
+ fToBind = this,
358
+ fNOP = function () {},
359
+ fBound = function () {
360
+ return fToBind.apply(
361
+ this instanceof fNOP && oThis ? this : oThis,
362
+ aArgs.concat(Array.prototype.slice.call(arguments))
363
+ );
364
+ };
365
+
366
+ fNOP.prototype = this.prototype;
367
+ fBound.prototype = new fNOP();
368
+ return fBound;
346
369
  };
347
370
  }
348
-
349
-
350
- } catch(e) {}
@@ -26,8 +26,7 @@ RSence =
26
26
  # Call this method from the index page for
27
27
  # client-only features
28
28
  clientConf: (_clientPrefix)->
29
- HThemeManager.themePath = _clientPrefix+'/themes'
30
- HThemeManager._start()
29
+ HThemeManager.setThemePath( _clientPrefix+'/themes' )
31
30
  @loadUnselectable()
32
31
 
33
32
  # Call this method from the index page to
@@ -0,0 +1,203 @@
1
+ HThemeManager = HClass.extend
2
+
3
+ allInOneCSS: true # temporary solution until new theme is crafted
4
+
5
+ currentTheme: 'default'
6
+
7
+ constructor: null
8
+
9
+ # Properties by theme name
10
+ currentThemePath: null
11
+ themePaths: {}
12
+ themes: []
13
+
14
+ # Set the graphics loading path of the the themeName
15
+ setThemePath: (_clientPrefix)->
16
+ @currentThemePath = _clientPrefix
17
+ for _themeName in @themes
18
+ @setupThemePath( _themeName )
19
+
20
+ setupAllInOneCSS: (_themeName)->
21
+ _cssText = ''
22
+ for _componentName of @themeCSSTemplates[_themeName]
23
+ _cssText += @buildCSSTemplate(@, _themeName, _componentName)
24
+ _style = @useCSS( _cssText )
25
+ _cssTitle = 'rsence/'+_themeName
26
+ _style.title = _cssTitle
27
+
28
+ setupThemePath: (_themeName)->
29
+ return unless @currentThemePath?
30
+ return if @themePaths[_themeName]?
31
+ _clientThemePath = [ @currentThemePath, _themeName ].join('/') + '/gfx/'
32
+ @themePaths[_themeName] = _clientThemePath
33
+ @setupAllInOneCSS(_themeName) if @allInOneCSS
34
+
35
+ # CSS Templates and CSS Template methods per theme name
36
+ themeCSSTemplates: {}
37
+
38
+ # Sets the css template data per theme, all at once
39
+ setThemeCSSTemplates: (_themeName, _themeCSS)->
40
+ @themeCSSTemplates[_themeName] = _themeCSS
41
+
42
+ # HTML Templates and HTML Template methods per theme name
43
+ themeHTMLTemplates: {}
44
+
45
+ # Sets the css template data per theme, all at once
46
+ setThemeHTMLTemplates: (_themeName, _themeHTML)->
47
+ @themeHTMLTemplates[_themeName] = _themeHTML
48
+
49
+ # Set the theme data, this is called by the serverside client_pkg suite
50
+ installThemeData: (_themeName, _themeCSS, _themeHTML)->
51
+ @themes << _themeName unless ~@themes.indexOf(_themeName)
52
+ @setThemeCSSTemplates(_themeName, _themeCSS)
53
+ @setThemeHTMLTemplates(_themeName, _themeHTML)
54
+ @setupThemePath(_themeName)
55
+
56
+ # Simple reference counting by theme name and component name, when 0, clear the style sheet
57
+ cssCountUsedBy: {}
58
+ cssByThemeAndComponentName: {}
59
+ incrementCSSUseCount: (_themeName, _componentName)->
60
+ @cssCountUsedBy[_themeName] = {} unless @cssCountUsedBy[_themeName]?
61
+ _themeCollection = @cssCountUsedBy[_themeName]
62
+ if _themeCollection[_componentName]?
63
+ _themeCollection[_componentName] += 1
64
+ else
65
+ _themeCollection[_componentName] = 1
66
+
67
+ decrementCSSUseCount: (_themeName, _componentName)->
68
+ unless @cssCountUsedBy[_themeName]?
69
+ console.log("Warning in decrementCSSUseCount; the theme #{_themeName} wasn't initialized (called with componentName: #{_componentName})")
70
+ return
71
+ _themeCollection = @cssCountUsedby[_themeName]
72
+ unless _themeCollection[_componentName]?
73
+ console.log("Warning in decrementCSSUseCount; the componentName #{_componentName} wasn't initialized (called with themeName: #{_themeName})")
74
+ return
75
+ if _themeCollection[_componentName] == 1
76
+ _style = @cssByThemeAndComponentName[_themeName][_componentName]
77
+ _style.parentNode.removeChild( _style )
78
+ delete _themeCollection[_componentName]
79
+ else
80
+ _themeCollection[_componentName] -= 1
81
+
82
+ _buildThemePath: (_fileName,_themeName)->
83
+ _fileName = _fileName.substring(1) while _fileName[0] == '/'
84
+ @themePaths[_themeName]+_fileName
85
+ _variableMatch: /#\{([a-z0-9]+?)\}/
86
+ _assignmentMatch: /\$\{([a-z0-9]+?)\}/
87
+ buildHTMLTemplate: ( _view, _themeName, _componentName )->
88
+ unless @themeHTMLTemplates[_themeName]?
89
+ console.log('Theme not installed:',_themeName)
90
+ return ''
91
+ return '' unless @themeHTMLTemplates[_themeName][_componentName]?
92
+ [_tmplJS, _tmplHTML] = @themeHTMLTemplates[_themeName][_componentName]
93
+ # console.log( 'tmplJS:', _tmplJS )
94
+ # console.log( 'tmplHTML:', _tmplHTML )
95
+ _rect = _view.rect
96
+ _callArgs = [_view.elemId.toString(), _rect.width, _rect.height]
97
+ _tmplHTML = _tmplHTML.replace(/\]I\[/g,_callArgs[0]).replace(/\]W\[/g,_callArgs[1]).replace(/\]H\[/g,_callArgs[2])
98
+ return _tmplHTML if _tmplJS.length == 0
99
+ [_variableMatch, _assignmentMatch] = [@_variableMatch, @_assignmentMatch]
100
+ # _ID = _view.elemId.toString()
101
+ # _WIDTH = _rect.width
102
+ # _HEIGHT = _rect.height
103
+ _callValue = (_id,_isAssign)->
104
+ _id = parseInt(_id,36)-10
105
+ try
106
+ _out = _tmplJS[_id].apply(_view,_callArgs)
107
+ return '' if _isAssign
108
+ return _out
109
+ catch e
110
+ console.log "HTML Template error(#{e}) in #{_themeName}/#{_componentName}: #{_tmplJS[_id]}"
111
+ return ''
112
+ while _assignmentMatch.test(_tmplHTML)
113
+ _tmplHTML = _tmplHTML.replace( _assignmentMatch, _callValue( RegExp.$1, true ) )
114
+ while _variableMatch.test(_tmplHTML)
115
+ _tmplHTML = _tmplHTML.replace( _variableMatch, _callValue( RegExp.$1 ) )
116
+ # console.log('tmplHTML:',_tmplHTML) if _componentName == 'tab'
117
+ return _tmplHTML
118
+
119
+ buildCSSTemplate: ( _context, _themeName, _componentName )->
120
+ unless @themeCSSTemplates[_themeName]?
121
+ console.log('Theme not installed:',_themeName)
122
+ return ''
123
+ return '' unless @themeCSSTemplates[_themeName][_componentName]?
124
+ [_tmplJS, _tmplCSS] = @themeCSSTemplates[_themeName][_componentName]
125
+ return _tmplCSS if _tmplJS.length == 0
126
+ [_variableMatch, _assignmentMatch] = [@_variableMatch, @_assignmentMatch]
127
+ # console.log( 'tmplJS:', _tmplJS )
128
+ # console.log( 'tmplCSS:', _tmplCSS )
129
+ @getThemeGfxFile = (_fileName)-> @_buildThemePath(_fileName,_themeName)
130
+ @getCssFilePath = (_fileName)->
131
+ "url(#{@_buildThemePath(_fileName,_themeName)})"
132
+ _callValue = (_id,_isAssign)->
133
+ _oid = _id
134
+ _id = parseInt(_id,36)-10
135
+ try
136
+ _out = _tmplJS[_id].apply(_context)
137
+ return '' if _isAssign
138
+ catch e
139
+ console.log "CSS Template error(#{e}) in #{_themeName}/#{_componentName}: #{_tmplJS[_id]}"
140
+ _out = ''
141
+ return _out
142
+ while _assignmentMatch.test(_tmplCSS)
143
+ _tmplCSS = _tmplCSS.replace( _assignmentMatch, _callValue( RegExp.$1, false ) )
144
+ while _variableMatch.test(_tmplCSS)
145
+ _tmplCSS = _tmplCSS.replace( _variableMatch, _callValue( RegExp.$1 ) )
146
+ delete @getCssFilePath
147
+ delete @getThemeGfxFile
148
+ # console.log('tmplCSS:',_tmplCSS)
149
+ return _tmplCSS
150
+
151
+ resourcesFor: (_view, _themeName, _noHTML)->
152
+ @setupThemePath(_themeName) unless @themePaths[_themeName]?
153
+ _themeName = @currentTheme unless _themeName?
154
+ return '' unless _view.componentName?
155
+ _componentName = _view.componentName
156
+ unless @allInOneCSS # temporarily disabled until theme refactored
157
+ @cssByThemeAndComponentName[_themeName] = {} unless @cssByThemeAndComponentName[_themeName]?
158
+ _themeCollection = @cssByThemeAndComponentName[_themeName]
159
+ unless _themeCollection[_componentName]?
160
+ _style = @useCSS( @buildCSSTemplate(@, _themeName, _componentName) )
161
+ _cssTitle = 'rsence/'+_themeName+'/'+_componentName
162
+ _style.title = _cssTitle
163
+ _themeCollection[_componentName] = _style
164
+ @incrementCSSUseCount(_themeName, _componentName)
165
+ return if _noHTML
166
+ for _ancestor in _view.ancestors
167
+ break unless _ancestor.componentName?
168
+ @resourcesFor( _ancestor, _themeName, true )
169
+ return @buildHTMLTemplate( _view, _themeName, _componentName )
170
+
171
+ freeResourcesFor: (_view, _themeName, _noRecursion)->
172
+ _themeName = @currentTheme unless _themeName?
173
+ return unless _view.componentName?
174
+ _componentName = _view.componentName
175
+ @decrementCSSUseCount( _themeName, _componentName )
176
+ return if _noRectursion
177
+ for _ancestor in _view.ancestors
178
+ break unless _ancestor.componentName?
179
+ @freeResourcesFor( _ancestor, _themeName )
180
+
181
+ # Creates a new cascading style sheet element and set its content with css. Returns the element.
182
+ useCSS: (_cssText)->
183
+ if BROWSER_TYPE.ie
184
+ # Internet Explorer (at least 6.x; check what 7.x does)
185
+ _style = document.createStyleSheet()
186
+ _style.cssText = _cssText
187
+ else
188
+ # Common, standard <style> tag generation in <head>
189
+ _style = document.createElement('style')
190
+ _style.type = 'text/css'
191
+ _style.media = 'all'
192
+
193
+ _head = document.getElementsByTagName('head')[0]
194
+ _head.appendChild(_style)
195
+
196
+ if BROWSER_TYPE.safari
197
+ # This is how to do it in KHTML browsers
198
+ _style.appendChild( document.createTextNode(_cssText) )
199
+ else
200
+ # This works for others (add more checks, if problems with new browsers)
201
+ _style.textContent = _cssText
202
+
203
+ _style
@@ -19,59 +19,47 @@ HMarkupView = HClass.extend({
19
19
  * Places the resulting markup in the instance variable.
20
20
  *
21
21
  **/
22
- bindMarkupVariables: function() {
22
+ // bindMarkupVariables: function() {
23
+ // var
24
+ // _this = this,
25
+ // _ID = _this.elemId.toString(),
26
+ // _rect = _this.rect,
27
+ // _WIDTH = _rect.width,
28
+ // _HEIGHT = _rect.height,
29
+ // _markup = _this.markup,
30
+ // _fns = _this.markupFns,
31
+ // _callValue = function(_id,_isAssign){
32
+ // console.log('callValue',_id);
33
+ // var _preId = _id;
34
+ // _id = parseInt(_id,36)-10;
35
+ // console.log('id:',_id,'->',_preId);
36
+ // try{
37
+ // var
38
+ // _out = _fns[_id].call(_this);
39
+ // if(_isAssign){
40
+ // return '';
41
+ // }
42
+ // else {
43
+ // return _out;
44
+ // }
45
+ // }
46
+ // catch(e){
47
+ // console.log('Markup Error: ',e);
48
+ // return '';
49
+ // }
50
+ // };
23
51
 
24
- var _markup = this.markup;
52
+ // while ( HMarkupView._assignment_match.test(_markup) ) {
53
+ // _markup = _markup.replace( HMarkupView._assignment_match, _callValue(RegExp.$1, false) );
54
+ // }
55
+ // while ( HMarkupView._variable_match.test(_markup) ) {
56
+ // _markup = _markup.replace( HMarkupView._variable_match, _callValue(RegExp.$1) );
57
+ // }
25
58
 
26
- while ( HMarkupView._assignment_match.test(_markup) ) {
27
- _markup = _markup.replace( HMarkupView._assignment_match, this.evalMarkupVariable(RegExp.$1,true) );
28
- }
29
- while ( HMarkupView._variable_match.test(_markup) ) {
30
- _markup = _markup.replace( HMarkupView._variable_match, this.evalMarkupVariable(RegExp.$1) );
31
- }
32
-
33
- this.markup = _markup;
59
+ // this.markup = _markup;
34
60
 
35
- return this;
36
- },
37
- /** = Description
38
- * Evaluates a string and throws an error into console.log
39
- * if the string doesn't pass evaluation.
40
- * If _isAssignment flag is set to true returns empty string.
41
- * if _isAssignment is set to false will return string if it passes
42
- * evaluation.
43
- *
44
- * = Parameters
45
- * +_strToEval+:: A String to evaluate.
46
- *
47
- * +_isAssignment+:: Flag to indicate return the String upon passed
48
- * evaluation(false) or return of an empty String(true).
49
- *
50
- * = Returns
51
- * +String+
52
- *
53
- **/
54
- evalMarkupVariable: function(_strToEval,_isAssignment){
55
- try {
56
- var _ID = this.elemId.toString(),
57
- _WIDTH = this.rect.width,
58
- _HEIGHT = this.rect.height,
59
- _result = eval(_strToEval);
60
- if(_isAssignment){
61
- return '';
62
- }
63
- if(_result===undefined){
64
- return '';
65
- }
66
- else {
67
- return _result;
68
- }
69
- }
70
- catch(e) {
71
- console.log("Warning, the markup string '"+_strToEval+"' failed evaluation. Reason:"+e+' '+e.description);
72
- return '';
73
- }
74
- },
61
+ // return this;
62
+ // },
75
63
 
76
64
  /** = Description
77
65
  * Sets or unsets the _cssClass into a DOM element that goes by the ID
@@ -100,8 +88,8 @@ HMarkupView = HClass.extend({
100
88
  return this;
101
89
  }
102
90
 
103
- },{
104
- _variable_match: new RegExp(/#\{([^\}]*)\}/),
105
- _assignment_match: new RegExp(/\$\{([^\}]*)\}/)
91
+ // },{
92
+ // _variable_match: new RegExp(/#\{([^\}]*)\}/),
93
+ // _assignment_match: new RegExp(/\$\{([^\}]*)\}/)
106
94
  });
107
95