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.
@@ -1,20 +0,0 @@
1
-
2
- // RSence client-side namespace initialization.
3
- // Current contents are a store for guiTrees and the serverConf method for setting up variables before starting.
4
- var
5
- RSence = {
6
-
7
- // Configuration method for the html document of the server
8
- serverConf: function(_clientPrefix,_helloUrl){
9
- COMM.ClientPrefix=_clientPrefix;
10
- COMM.Transporter.HelloUrl=_helloUrl;
11
- HThemeManager.themePath=_clientPrefix+'/themes';
12
- HThemeManager._start();
13
- COMM.AutoSyncStarter.start();
14
- },
15
-
16
- // Structure reserved for JSONRenderer instances remotely populated by the server
17
- guiTrees: {
18
-
19
- }
20
- };
@@ -1,410 +0,0 @@
1
-
2
- /** The default path where to look for themes.
3
- **/
4
- var//RSence.Foundation
5
- HDefaultThemePath = '/H/themes';
6
-
7
-
8
- /** Name of the default theme.
9
- **/
10
- var//RSence.Foundation
11
- HDefaultThemeName = 'default';
12
-
13
- /** List of themes without component-specific theme files.
14
- **/
15
- var//RSence.Foundation
16
- HNoComponentCSS = [];
17
-
18
- /** List of themes without a common.css file to load.
19
- **/
20
- var//RSence.Foundation
21
- HNoCommonCSS = [];
22
-
23
- /** List of IE6-savvy themes.
24
- **/
25
- var//RSence.Foundation
26
- HThemeHasIE6GifsInsteadOfPng = ['default'];
27
-
28
- /*** = Description
29
- ** A single instance class.
30
- ** The theme manager knows the name of the currently loaded theme and handles
31
- ** the loading of theme specific markup snippets and style declarations.
32
- **
33
- ** = Instance variables
34
- ** +themePath+:: Default root path of the themes path, should contain
35
- ** at least the default theme.
36
- ** +currentTheme+:: The name of the theme currently in use. Initially the
37
- ** default unnamed theme is used.
38
- **
39
- ***/
40
- var//RSence.Foundation
41
- HThemeManager = HClass.extend({
42
-
43
- constructor: null,
44
-
45
- init: function(){
46
- this.themePath = HDefaultThemePath;
47
- this._tmplCache = {};
48
- this._cssCache = {};
49
- this.currentTheme = HDefaultThemeName;
50
- },
51
-
52
- setThemePath: function( _path ){
53
- this.themePath = _path;
54
- },
55
-
56
- // Error messages, should be refined.
57
- _errTemplateNotFound: function( _url ) {
58
- console.log( "ERROR: Template Not Found: '" + _url + "' ");
59
- },
60
- _errTemplateFailure: function( _url ) {
61
- console.log( "ERROR: Template Failure: '" + _url + "' ");
62
- },
63
- _errTemplateException: function( _url ) {
64
- console.log( "ERROR: Template Exception: '" + _url + "' ");
65
- },
66
-
67
- /** = Description
68
- * Loads a template file and returns its contents.
69
- * If errors occurred, calls the error management functions.
70
- *
71
- * = Parameters
72
- * +_url+:: A valid local file path or http url pointing to the
73
- * resource to load.
74
- * +_contentType+:: An optional parameter, specifies the content type wanted,
75
- * defaults to text/html.
76
- *
77
- * = Returns
78
- * The contents of the path.
79
- **/
80
- fetch: function( _url, _contentType, _callBack, _async ) {
81
- var _callBackFun;
82
- if( !_contentType ){
83
- _contentType = 'text/html; charset=UTF-8';
84
- }
85
- if(_async){
86
- _callBackFun = function( resp ){
87
- _callBack( resp.X.responseText );
88
- };
89
- }
90
- else{
91
- // console.log('WARNING: Fetching synchronously using HThemeManager is not recommended. Use pre-packaged themes instead.');
92
- var _respText;
93
- _callBackFun = function( resp ){
94
- _respText = resp.X.responseText;
95
- };
96
- }
97
- COMM.request(
98
- _url, {
99
- onSuccess: _callBackFun,
100
- on404: function(resp){ HThemeManager._errTemplateNotFound( resp.url ); },
101
- onFailure: function(resp){ HThemeManager._errTemplateFailure( resp.url ); },
102
- onException: function(resp){ HThemeManager._errTemplateException( resp.url ); },
103
- method: 'GET',
104
- async: _async
105
- }
106
- );
107
- if(!_async){
108
- return _respText;
109
- }
110
- },
111
-
112
-
113
- /** Returns the theme/component -specific path, called from inside css
114
- * themes, a bit kludgy approach to tell the theme graphics file paths.
115
- **/
116
- getThemeGfxPath: function() {
117
- var _themeName = this._cssEvalParams[0],
118
- _componentName = this._cssEvalParams[1],
119
- _themePath = this._cssEvalParams[2],
120
- _urlPrefix = this._urlPrefix( _themeName, _componentName, _themePath );
121
- return this._joinPath( _urlPrefix, 'gfx' );
122
- },
123
-
124
- /** = Description
125
- * Returns the theme/component -specific graphics file path with proper css wrappers.
126
- * Used from inside css themes, a bit kludgy approach to tell the file name path.
127
- *
128
- * = Parameters
129
- * +_fileName+:: The File name to load.
130
- *
131
- **/
132
- getCssFilePath: function( _fileName ){
133
- var _themeName = this._cssEvalParams[0];
134
- if((~HThemeHasIE6GifsInsteadOfPng.indexOf(_themeName)) && (BROWSER_TYPE.ie6 || BROWSER_TYPE.symbian) ){
135
- return "url('"+this._joinPath( this.getThemeGfxPath(), _fileName.replace('.png','-ie6.gif') )+"')";
136
- }
137
- else {
138
- return "url('"+this._joinPath( this.getThemeGfxPath(), _fileName )+"')";
139
- }
140
- },
141
-
142
- /** = Description
143
- * Loads a css file based on the given url (or file path).
144
- * Evaluates the css data.
145
- * Makes sure the browser uses the data for component styles.
146
- *
147
- * = Parameter
148
- * +_url+:: A valid url that points to a valid css file.
149
- *
150
- * = Returns
151
- * The source of the url.
152
- *
153
- **/
154
- loadCSS: function( _url ) {
155
- var _contentType = 'text/css',
156
- _cssFun = function(_cssText){
157
- // Don't try to do anything with empty or invalid css data:
158
- if (!_cssText || _cssText === "") {
159
- return;
160
- }
161
- HThemeManager.useCSS( _cssText );
162
- };
163
- this.fetch( _url, _contentType, _cssFun, true );
164
- },
165
-
166
- useCSS: function( _cssText ){
167
- var _contentType = 'text/css';
168
- // Evaluate the css text
169
- _cssText = this._bindCSSVariables( _cssText );
170
-
171
- var _style, _styleSheet, _head;
172
-
173
- if(BROWSER_TYPE.ie) {
174
- // Internet Explorer (at least 6.x; check what 7.x does)
175
- _style = document.createStyleSheet();
176
- _style.cssText = _cssText;
177
- }
178
-
179
- else {
180
- // Common, standard <style> tag generation in <head>
181
- _style = document.createElement( "style" );
182
- _style.type = _contentType;
183
- _style.media = "all";
184
-
185
- _head = document.getElementsByTagName('head')[0];
186
- _head.appendChild(_style);
187
-
188
- if (BROWSER_TYPE.safari) {
189
- // Work-around for safari
190
- var _cssTextElement = document.createTextNode(_cssText);
191
- _style.appendChild(_cssTextElement);
192
- }
193
- else {
194
- // This works for others (add more checks, if problems with new browsers)
195
- _style.innerHTML = _cssText;
196
- }
197
- }
198
-
199
- },
200
-
201
- _addSlash: function( _str ){
202
- if( _str[ _str.length-1 ] !== '/' ){
203
- _str += '/';
204
- }
205
- return _str;
206
- },
207
-
208
- _joinPath: function( _str1, _str2 ){
209
- return this._addSlash( _str1 ) + _str2;
210
- },
211
-
212
- // Makes a common url prefix for template files
213
- _urlPrefix: function( _themeName, _componentName, _themePath ) {
214
-
215
- var _path = _themePath;
216
-
217
- // Usually null
218
- if( _themePath === null ) {
219
- _path = this.themePath;
220
- }
221
-
222
- _path = this._joinPath( _path, _themeName );
223
-
224
- return _path;
225
- },
226
-
227
- // Makes a valid css template url
228
- _cssUrl: function( _themeName, _componentName, _themePath ) {
229
- this._cssEvalParams = [_themeName, _componentName, _themePath];
230
- var _cssPrefix = this._urlPrefix( _themeName, _componentName, _themePath ),
231
- _cssSuffix = this._joinPath( 'css', _componentName+'.css' ),
232
- _cssUrl = this._joinPath( _cssPrefix, _cssSuffix );
233
- return _cssUrl;
234
- },
235
-
236
- // Makes a valid html template url
237
- _markupUrl: function( _themeName, _componentName, _themePath ) {
238
- var _htmlPrefix = this._urlPrefix( _themeName, _componentName, _themePath ),
239
- _htmlSuffix = this._joinPath( 'html', _componentName+'.html' ),
240
- _htmlUrl = this._joinPath( _htmlPrefix, _htmlSuffix );
241
- return _htmlUrl;
242
- },
243
-
244
- /** = Description
245
- * Loads HTML templates of components. Handles caching independently and
246
- * intelligently.
247
- *
248
- * = Parameters
249
- * +_themeName+:: The name of the template to use.
250
- * +_componentName+:: The name of the component template (css/html) to load.
251
- * +_themePath+:: Optional, parameter to override the global theme path.
252
- *
253
- * = Returns
254
- * The Pre-Evaluated HTML Template.
255
- *
256
- **/
257
- loadMarkup: function( _themeName, _componentName, _themePath ) {
258
- if( !this._tmplCache[_themeName] ){
259
- this._tmplCache[_themeName] = {};
260
- }
261
- var _cached = this._tmplCache[_themeName][_componentName];
262
-
263
- if (null === _cached || undefined === _cached) {
264
- var _markupUrl = this._markupUrl( _themeName, _componentName, _themePath ),
265
- _markup = this.fetch( _markupUrl, null, null, false );
266
- return this.setMarkup( _themeName, _componentName, _markup );
267
- }
268
- return _cached;
269
- },
270
-
271
- /** = Description
272
- * Sets the html template for the theme and component name combination.
273
- *
274
- * = Parameters
275
- * +_themeName+:: The name of the template to use..
276
- * +_componentName+:: The name of the component template.
277
- * +_markup+:: The content of the html markup.
278
- **/
279
- setMarkup: function( _themeName, _componentName, _markup ){
280
- // Save an empty string to template cache to prevent repeated failing
281
- // requests.
282
- if (null === _markup || undefined === _markup) {
283
- _markup = "";
284
- }
285
- if( this._tmplCache[_themeName] === undefined ){
286
- this._tmplCache[_themeName] = {};
287
- }
288
- this._tmplCache[_themeName][_componentName] = _markup;
289
- return _markup;
290
- },
291
-
292
- /** = Description
293
- * Loads CSS and HTML templates of components. Called from HView#_loadMarkup.
294
- * Returns the HTML Template as text.
295
- * Manages file caches independently and intelligently.
296
- *
297
- * = Parameters
298
- * +_themeName+:: The name of the template to use.
299
- * +_componentName+:: The name of the component template (css/html) to load.
300
- * +_themePath+:: Optional, parameter to override the global theme path.
301
- *
302
- * = Returns
303
- * The Pre-Evaluated HTML Template.
304
- *
305
- **/
306
- getMarkup: function( _themeName, _componentName, _themePath ) {
307
- /* Load Theme-Specific CSS: */
308
- if(!this._cssCache[_themeName]){
309
- this._cssCache[_themeName] = {};
310
- if(!~HNoCommonCSS.indexOf(_themeName)){
311
- var _commonCssUrl = this._cssUrl( _themeName, 'common', _themePath, null );
312
- this.loadCSS( _commonCssUrl );
313
- }
314
- }
315
-
316
- /* Load Component-Specific CSS, unless configured to only load the common css: */
317
- if(!~HNoComponentCSS.indexOf(_themeName)){
318
- if (!this._cssCache[_themeName][_componentName]){
319
- var _componentCssUrl = this._cssUrl( _themeName, _componentName, _themePath );
320
- this._cssCache[_themeName][_componentName] = true;
321
- this.loadCSS( _componentCssUrl );
322
- }
323
- }
324
-
325
- /* Load/Return Component-Specific HTML: */
326
- return this.loadMarkup( _themeName, _componentName, _themePath );
327
- },
328
-
329
-
330
- _componentGfxPath: function( _themeName, _componentName, _themePath ) {
331
- var _urlPrefix = this._urlPrefix( _themeName, _componentName, _themePath ),
332
- _url = this._joinPath( _urlPrefix, 'gfx' );
333
- return _url;
334
- },
335
- _componentGfxFile: function( _themeName, _componentName, _themePath, _fileName ){
336
- if((~HThemeHasIE6GifsInsteadOfPng.indexOf(_themeName)) && BROWSER_TYPE.ie6){
337
- return this._joinPath( this._componentGfxPath(_themeName, _componentName, _themePath), _fileName.replace('.png','-ie6.gif') );
338
- }
339
- return this._joinPath( this._componentGfxPath(_themeName, _componentName, _themePath), _fileName );
340
- },
341
-
342
-
343
- /** = Description
344
- * Returns the full path of the +_fileName+ given. Uses the default theme.
345
- **/
346
- getThemeGfxFile: function( _fileName ) {
347
- return this.getThemeGfxPath() + _fileName;
348
- },
349
-
350
-
351
- /** = Description
352
- * Sets the active theme.
353
- *
354
- * = Parameters
355
- * +_theme+:: The name of the theme to be set as the active theme.
356
- *
357
- **/
358
- setTheme: function(_theme) {
359
- this.currentTheme = _theme;
360
- },
361
-
362
- /** Sets the default theme ( HDefaultTheme ) to be the active theme.
363
- **/
364
- restoreDefaultTheme: function() {
365
- this.setTheme( HDefaultThemeName );
366
- },
367
-
368
- /** regexp: _variable_match
369
- * A regular expression to match the template evaluation syntax: #{stuff_to_evaluate}
370
- **/
371
- _variable_match: new RegExp(/#\{([^\}]*)\}/),
372
-
373
- /** = Description
374
- * Evaluates the _variable_match regular expression for the string _markup.
375
- *
376
- * = Parameters
377
- * +_cssTmpl+:: The css template file to be evaluated.
378
- *
379
- * = Returns
380
- * An evaluated CSS Template.
381
- **/
382
- _bindCSSVariables: function( _cssTmpl ) {
383
- while ( this._variable_match.test( _cssTmpl ) ) {
384
- _cssTmpl = _cssTmpl.replace( this._variable_match, eval( RegExp.$1 ) );
385
- }
386
- return _cssTmpl;
387
- },
388
-
389
- _initFns: [],
390
- _pushStarted: false,
391
- _pushStart: function( _fn ){
392
- if(this._pushStarted){
393
- _fn();
394
- }
395
- else{
396
- this._initFns.push( _fn );
397
- }
398
- },
399
- _start: function(){
400
- var
401
- _this = this,
402
- i = 0;
403
- _this._pushStarted = true;
404
- for( ; i<_this._initFns.length; i++){
405
- _this._initFns[i]();
406
- }
407
- _this._initFns = [];
408
- }
409
-
410
- });