qcobjects-sdk 2.3.24
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.
- package/.eslintrc.json +23 -0
- package/.github/FUNDING.yml +12 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/custom.md +10 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/ISSUE_TEMPLATE/issue-template.md +33 -0
- package/.github/workflows/npmpublish.yml +36 -0
- package/CHANGELOG.md +47 -0
- package/CNAME +1 -0
- package/QCObjects-SDK.js +95 -0
- package/README.md +864 -0
- package/README.rst +398 -0
- package/VERSION +1 -0
- package/_config.yml +1 -0
- package/css/base-modal.css +43 -0
- package/css/basic-layout-embedded-nav.css +14 -0
- package/css/basic-layout.css +76 -0
- package/css/components/horizontal-list.css +64 -0
- package/css/components/list.css +57 -0
- package/css/components/splashscreen.css +111 -0
- package/css/modal.css +46 -0
- package/demo-tests/test-component-grid.html +50 -0
- package/demo-tests/test-component-list.html +40 -0
- package/demo-tests/test-component-notifications.html +30 -0
- package/demo-tests/test-component-slider.html +52 -0
- package/favicon.ico +0 -0
- package/index.rst +398 -0
- package/js/org.qcobjects.cloud.auth.session.data.js +72 -0
- package/js/org.qcobjects.cloud.auth.session.usertoken.js +95 -0
- package/js/org.qcobjects.components.grid.js +59 -0
- package/js/org.qcobjects.components.js +226 -0
- package/js/org.qcobjects.components.list.js +48 -0
- package/js/org.qcobjects.components.notifications.js +168 -0
- package/js/org.qcobjects.components.slider.js +194 -0
- package/js/org.qcobjects.components.splashscreen.js +565 -0
- package/js/org.qcobjects.controllers.form.js +196 -0
- package/js/org.qcobjects.controllers.grid.js +268 -0
- package/js/org.qcobjects.controllers.js +10 -0
- package/js/org.qcobjects.controllers.list.js +229 -0
- package/js/org.qcobjects.controllers.slider.js +132 -0
- package/js/org.qcobjects.controllers.swagger.js +77 -0
- package/js/org.qcobjects.effects.js +262 -0
- package/js/org.qcobjects.i18n_messages.js +55 -0
- package/js/org.qcobjects.modal.controllers.js +42 -0
- package/js/org.qcobjects.modal.effects.js +48 -0
- package/js/org.qcobjects.models.js +40 -0
- package/js/org.qcobjects.tools.canvas.js +52 -0
- package/js/org.qcobjects.tools.js +59 -0
- package/js/org.qcobjects.tools.layouts.js +71 -0
- package/js/org.qcobjects.views.js +37 -0
- package/package.json +48 -0
- package/spec/support/jasmine.json +16 -0
- package/spec/testsSpec.js +9 -0
- package/templates/components/modalyoulose.tpl.html +3 -0
- package/templates/components/modalyouwin.tpl.html +4 -0
- package/templates/components/splashscreen.tpl.html +128 -0
- package/templates/components/swagger-ui.tpl.html +22 -0
package/index.rst
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
.. figure:: qcobjects_01.png
|
|
2
|
+
:alt: logo
|
|
3
|
+
|
|
4
|
+
logo
|
|
5
|
+
|
|
6
|
+
QCObjects
|
|
7
|
+
=========
|
|
8
|
+
|
|
9
|
+
Copyright (c) Jean Machuca and QuickCorp info@quickcorp.cl
|
|
10
|
+
|
|
11
|
+
See a demo using Foundation components here:
|
|
12
|
+
https://github.com/QuickCorp/quickobjects_sample1foundation
|
|
13
|
+
|
|
14
|
+
Please fork this project or make a link to this project into your
|
|
15
|
+
README.md file. Read the LICENSE.txt file before you use this code.
|
|
16
|
+
|
|
17
|
+
Cross Browser Javascript Framework for MVC Patterns
|
|
18
|
+
===================================================
|
|
19
|
+
|
|
20
|
+
QCObjects is a javascript framework designed to make easier everything
|
|
21
|
+
about the MVC patterns implementation into the pure javascript scope.
|
|
22
|
+
You don’t need to use typescript nor any transpiler to run QCObjects. It
|
|
23
|
+
runs directly on the browser and it uses pure javascript with no extra
|
|
24
|
+
dependencies of code. You can make your own components expressed in real
|
|
25
|
+
native javascript objects or extend a native DOM object to use in your
|
|
26
|
+
own way. You can also use QCObjects in conjunction with CSS3 frameworks
|
|
27
|
+
like [Foundation] (https://foundation.zurb.com), [Bootstrap]
|
|
28
|
+
(http://getbootstrap.com) and mobile javascript frameworks like
|
|
29
|
+
[PhoneGap] (https://phonegap.com) and OnsenUI (https://onsen.io)
|
|
30
|
+
|
|
31
|
+
If you like this code please
|
|
32
|
+
`DONATE <https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UUTDBUQHCS4PU&source=url>`__!
|
|
33
|
+
|
|
34
|
+
If you like more code samples feel free to write your questions to
|
|
35
|
+
info@quickcorp.cl
|
|
36
|
+
|
|
37
|
+
Installing with NPM:
|
|
38
|
+
====================
|
|
39
|
+
|
|
40
|
+
.. code:: shell
|
|
41
|
+
|
|
42
|
+
> npm install qcobjects
|
|
43
|
+
|
|
44
|
+
Using the code in the straight way into HTML5:
|
|
45
|
+
==============================================
|
|
46
|
+
|
|
47
|
+
.. code:: html
|
|
48
|
+
|
|
49
|
+
<script type="text/javascript" src="https://quickcorp.github.io/QCObjects/QCObjects.js"></script>
|
|
50
|
+
|
|
51
|
+
Step 1: Start creating a main import file and name it like: cl.quickcorp.js. Put it into packages/js/ file directory.
|
|
52
|
+
=====================================================================================================================
|
|
53
|
+
|
|
54
|
+
.. code:: javascript
|
|
55
|
+
|
|
56
|
+
"use strict";
|
|
57
|
+
/*
|
|
58
|
+
* QuickCorp/QCObjects is licensed under the
|
|
59
|
+
* GNU Lesser General Public License v3.0
|
|
60
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
61
|
+
*
|
|
62
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
63
|
+
* complete source code of licensed works and modifications under the same
|
|
64
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
65
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
66
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
67
|
+
* work may be distributed under different terms and without source code for
|
|
68
|
+
* the larger work.
|
|
69
|
+
*
|
|
70
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
71
|
+
*
|
|
72
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
73
|
+
* license document, but changing it is not allowed.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
Import ('external/libs');
|
|
78
|
+
Import ('cl.quickcorp.model');
|
|
79
|
+
Import ('cl.quickcorp.components');
|
|
80
|
+
Import ('cl.quickcorp.controller');
|
|
81
|
+
Import ('cl.quickcorp.view');
|
|
82
|
+
|
|
83
|
+
Package('cl.quickcorp',[
|
|
84
|
+
Class('FormValidator',Object,{
|
|
85
|
+
|
|
86
|
+
}),
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
Step 2: Then create some services inhereting classes into the file js/packages/cl.quickcorp.services.js :
|
|
90
|
+
=========================================================================================================
|
|
91
|
+
|
|
92
|
+
.. code:: javascript
|
|
93
|
+
|
|
94
|
+
"use strict";
|
|
95
|
+
/*
|
|
96
|
+
* QuickCorp/QCObjects is licensed under the
|
|
97
|
+
* GNU Lesser General Public License v3.0
|
|
98
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
99
|
+
*
|
|
100
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
101
|
+
* complete source code of licensed works and modifications under the same
|
|
102
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
103
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
104
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
105
|
+
* work may be distributed under different terms and without source code for
|
|
106
|
+
* the larger work.
|
|
107
|
+
*
|
|
108
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
109
|
+
*
|
|
110
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
111
|
+
* license document, but changing it is not allowed.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
Package('cl.quickcorp.service',[
|
|
116
|
+
Class('JsonService',{
|
|
117
|
+
method:"GET",
|
|
118
|
+
cached:false,
|
|
119
|
+
headers: {
|
|
120
|
+
"Content-Type":"application/json",
|
|
121
|
+
"charset":"utf-8"
|
|
122
|
+
},
|
|
123
|
+
JSONresponse: null,
|
|
124
|
+
done:function(result){
|
|
125
|
+
console.log("***** RECEIVED RESPONSE:");
|
|
126
|
+
console.log(result.service.template);
|
|
127
|
+
this.JSONresponse = JSON.parse(result.service.template);
|
|
128
|
+
alert(this.template);
|
|
129
|
+
}
|
|
130
|
+
}),
|
|
131
|
+
Class('FormSubmitService',{
|
|
132
|
+
method:"POST",
|
|
133
|
+
cached:false,
|
|
134
|
+
headers: {
|
|
135
|
+
"Content-Type":"application/json"
|
|
136
|
+
},
|
|
137
|
+
JSONresponse: null,
|
|
138
|
+
done: function(result) {
|
|
139
|
+
console.log("***** CALLED FormSubmitService");
|
|
140
|
+
this.JSONresponse = JSON.parse(result.service.template);
|
|
141
|
+
//TODO success case
|
|
142
|
+
console.log("***** SUCCESS!")
|
|
143
|
+
console.log(this.JSONresponse);
|
|
144
|
+
},
|
|
145
|
+
fail: function(result) {
|
|
146
|
+
//TODO negative case
|
|
147
|
+
console.log("***** ERROR");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
])
|
|
153
|
+
|
|
154
|
+
Step 3: Now it’s time to create the components (cl.quickcorp.components.js)
|
|
155
|
+
===========================================================================
|
|
156
|
+
|
|
157
|
+
.. code:: javascript
|
|
158
|
+
|
|
159
|
+
"use strict";
|
|
160
|
+
/*
|
|
161
|
+
* QuickCorp/QCObjects is licensed under the
|
|
162
|
+
* GNU Lesser General Public License v3.0
|
|
163
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
164
|
+
*
|
|
165
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
166
|
+
* complete source code of licensed works and modifications under the same
|
|
167
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
168
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
169
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
170
|
+
* work may be distributed under different terms and without source code for
|
|
171
|
+
* the larger work.
|
|
172
|
+
*
|
|
173
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
174
|
+
*
|
|
175
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
176
|
+
* license document, but changing it is not allowed.
|
|
177
|
+
*/
|
|
178
|
+
Package('cl.quickcorp.components',[
|
|
179
|
+
Class('FormField',Component,{
|
|
180
|
+
cached:false,
|
|
181
|
+
reload:true,
|
|
182
|
+
createBindingEvents:function (){
|
|
183
|
+
var _executeBinding = this.executeBinding;
|
|
184
|
+
var thisobj = this;
|
|
185
|
+
var _objList = this.body.querySelectorAll(this.fieldType);
|
|
186
|
+
for (var _datak=0;_datak<_objList.length;_datak++){
|
|
187
|
+
var _obj = _objList[_datak];
|
|
188
|
+
_obj.addEventListener('change',function(e){
|
|
189
|
+
logger.debug('Executing change event binding');
|
|
190
|
+
thisobj.executeBindings();
|
|
191
|
+
});
|
|
192
|
+
_obj.addEventListener('keydown',function(e){
|
|
193
|
+
logger.debug('Executing keydown event binding');
|
|
194
|
+
thisobj.executeBindings();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
executeBinding:function (_obj){
|
|
199
|
+
var _datamodel = _obj.getAttribute('data-field');
|
|
200
|
+
logger.debug('Binding '+_datamodel+' for '+this.name);
|
|
201
|
+
this.data[_datamodel]=_obj.value;
|
|
202
|
+
},
|
|
203
|
+
executeBindings:function (){
|
|
204
|
+
var _objList = this.body.querySelectorAll(this.fieldType);
|
|
205
|
+
for (var _datak=0;_datak<_objList.length;_datak++){
|
|
206
|
+
var _obj = _objList[_datak];
|
|
207
|
+
var _datamodel = _obj.getAttribute('data-field');
|
|
208
|
+
logger.debug('Binding '+_datamodel+' for '+this.name);
|
|
209
|
+
this.data[_datamodel]=_obj.value;
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
done:function (){
|
|
213
|
+
var thisobj = this;
|
|
214
|
+
thisobj.executeBindings();
|
|
215
|
+
thisobj.createBindingEvents();
|
|
216
|
+
logger.debug('Field loaded: '+thisobj.fieldType+'[name='+thisobj.name+']');
|
|
217
|
+
}
|
|
218
|
+
}),
|
|
219
|
+
Class('ButtonField',FormField,{
|
|
220
|
+
fieldType:'button'
|
|
221
|
+
}),
|
|
222
|
+
Class('InputField',FormField,{
|
|
223
|
+
fieldType:'input'
|
|
224
|
+
}),
|
|
225
|
+
Class('TextField',FormField,{
|
|
226
|
+
fieldType:'textarea'
|
|
227
|
+
}),
|
|
228
|
+
Class('EmailField',FormField,{
|
|
229
|
+
fieldType:'input'
|
|
230
|
+
})
|
|
231
|
+
]);
|
|
232
|
+
|
|
233
|
+
Step 4: Once you have done the above components declaration, you will now want to code your controllers (cl.quickcorp.controller.js)
|
|
234
|
+
====================================================================================================================================
|
|
235
|
+
|
|
236
|
+
.. code:: javascript
|
|
237
|
+
|
|
238
|
+
"use strict";
|
|
239
|
+
/*
|
|
240
|
+
* QuickCorp/QCObjects is licensed under the
|
|
241
|
+
* GNU Lesser General Public License v3.0
|
|
242
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
243
|
+
*
|
|
244
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
245
|
+
* complete source code of licensed works and modifications under the same
|
|
246
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
247
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
248
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
249
|
+
* work may be distributed under different terms and without source code for
|
|
250
|
+
* the larger work.
|
|
251
|
+
*
|
|
252
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
253
|
+
*
|
|
254
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
255
|
+
* license document, but changing it is not allowed.
|
|
256
|
+
*/
|
|
257
|
+
"use strict";
|
|
258
|
+
Package('cl.quickcorp.controller',[
|
|
259
|
+
Class('MainController',Object,{
|
|
260
|
+
_new_:function (){
|
|
261
|
+
//TODO: Implement
|
|
262
|
+
logger.debug('MainController Element Initialized');
|
|
263
|
+
}
|
|
264
|
+
}),
|
|
265
|
+
Class('MyAccountController',Object,{
|
|
266
|
+
component: null,
|
|
267
|
+
done:function (){
|
|
268
|
+
var controller = this;
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
logger.debug('MyAccountController Element Initialized');
|
|
273
|
+
this.component.body.setAttribute('loaded',true);
|
|
274
|
+
|
|
275
|
+
},
|
|
276
|
+
_new_:function (o){
|
|
277
|
+
//TODO: Implement
|
|
278
|
+
this.component = o.component;
|
|
279
|
+
|
|
280
|
+
}
|
|
281
|
+
}),
|
|
282
|
+
]);
|
|
283
|
+
|
|
284
|
+
# Step 5: To use into the HTML5 code you only need to do some settings
|
|
285
|
+
between
|
|
286
|
+
|
|
287
|
+
.. raw:: html
|
|
288
|
+
|
|
289
|
+
<script> tags:
|
|
290
|
+
|
|
291
|
+
```html
|
|
292
|
+
<script>
|
|
293
|
+
CONFIG.set('relativeImportPath','js/packages/');
|
|
294
|
+
CONFIG.set('componentsBasePath','templates/components/');
|
|
295
|
+
CONFIG.set('delayForReady',1); // delay to wait before executing the first ready event, it includes imports
|
|
296
|
+
CONFIG.set('preserveComponentBodyTag',false); // don't use <componentBody></componentBody> tag
|
|
297
|
+
|
|
298
|
+
Import('cl.quickcorp'); # this will import your main file: cl.quickcorp.js into js/packages/ file path
|
|
299
|
+
</script>
|
|
300
|
+
|
|
301
|
+
\``\`
|
|
302
|
+
|
|
303
|
+
Demo example: The simpliest demo example:
|
|
304
|
+
=========================================
|
|
305
|
+
|
|
306
|
+
.. code:: html
|
|
307
|
+
|
|
308
|
+
<!DOCTYPE html>
|
|
309
|
+
<html>
|
|
310
|
+
<head>
|
|
311
|
+
<title>Demo</title>
|
|
312
|
+
<script type="text/javascript" src="QCObjects.js"></script>
|
|
313
|
+
<script type="text/javascript">
|
|
314
|
+
var canvas1,canvas2,canvas3,container;
|
|
315
|
+
CONFIG.set('relativeImportPath','src/');
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Main import sentence.
|
|
319
|
+
*/
|
|
320
|
+
Import('cl.quickcorp',function (){
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* Super Container MyOwnBody
|
|
324
|
+
*/
|
|
325
|
+
Class('MyOwnBody',HTMLBodyElement,{
|
|
326
|
+
customAttr:'custom',
|
|
327
|
+
body:document.body // breakes default body element and replace with them
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Another custom class definition
|
|
332
|
+
*/
|
|
333
|
+
Class('MyContainer',HTMLElement,{
|
|
334
|
+
width:400,
|
|
335
|
+
height:400,
|
|
336
|
+
customAttr:'custom attr container'
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Another custom class definition
|
|
342
|
+
*/
|
|
343
|
+
Class('canvas',HTMLCanvasElement,{
|
|
344
|
+
customAttr:'custom'
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Another custom class definition
|
|
349
|
+
*/
|
|
350
|
+
Class('MyCanvas2',HTMLCanvasElement,{});
|
|
351
|
+
|
|
352
|
+
body = New(MyOwnBody); // binds to body
|
|
353
|
+
body.css({backgroundColor:'#ccc'});
|
|
354
|
+
|
|
355
|
+
container = document.getElementsByTagName('container')[0].Cast(MyContainer); // cast any javascript dom object to QC_Object class
|
|
356
|
+
container.css({backgroundColor:'red'}); // access binding in two directions to dom objects
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Instance a new custom canvas
|
|
360
|
+
*/
|
|
361
|
+
canvas1 = New(canvas,{
|
|
362
|
+
width:100,
|
|
363
|
+
height:100,
|
|
364
|
+
});
|
|
365
|
+
canvas2 = New(canvas,{
|
|
366
|
+
width:200,
|
|
367
|
+
height:100,
|
|
368
|
+
});
|
|
369
|
+
canvas3 = New(canvas,{
|
|
370
|
+
width:300,
|
|
371
|
+
height:50,
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
canvas1.css({backgroundColor:'#000000'}); // like jquery and another style access
|
|
375
|
+
canvas1.body.style.backgroundColor='#000000'; // standard javascript style access
|
|
376
|
+
canvas2.body.style.backgroundColor='#0044AA'; // standard javascript style access
|
|
377
|
+
canvas3.body.style.backgroundColor='green'; // standard javascript style access
|
|
378
|
+
|
|
379
|
+
canvas1.append(); //append canvas1 to body
|
|
380
|
+
canvas2.attachIn('container'); // attach or append to specific tag containers
|
|
381
|
+
container.append(canvas3); // append canvas3 to custom tag binding
|
|
382
|
+
|
|
383
|
+
// canvas1.body.remove(); // remove canvas1 from dom
|
|
384
|
+
body.append(canvas3); // append canvas3 to body
|
|
385
|
+
|
|
386
|
+
// using components
|
|
387
|
+
var c1 = New(Component,{'templateURI':'templatesample.html',cached:false});
|
|
388
|
+
document.body.append(c1); // appends the c1 to the body
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
</script>
|
|
394
|
+
</head>
|
|
395
|
+
<body>
|
|
396
|
+
<container id="contentLoader" ></container>
|
|
397
|
+
</body>
|
|
398
|
+
</html>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects SDK 2.3
|
|
3
|
+
* ________________
|
|
4
|
+
*
|
|
5
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
6
|
+
*
|
|
7
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
8
|
+
* QuickCorp/QCObjects is licensed under the
|
|
9
|
+
* GNU Lesser General Public License v3.0
|
|
10
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
11
|
+
*
|
|
12
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
13
|
+
* complete source code of licensed works and modifications under the same
|
|
14
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
15
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
16
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
17
|
+
* work may be distributed under different terms and without source code for
|
|
18
|
+
* the larger work.
|
|
19
|
+
*
|
|
20
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
21
|
+
*
|
|
22
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
23
|
+
* license document, but changing it is not allowed.
|
|
24
|
+
*/
|
|
25
|
+
(function() {
|
|
26
|
+
"use strict";
|
|
27
|
+
|
|
28
|
+
Package("org.qcobjects.cloud.auth.session.data",[
|
|
29
|
+
Class ("SessionData",Object, {
|
|
30
|
+
__session_container__: null,
|
|
31
|
+
setSessionContainer () {
|
|
32
|
+
this.__session_container__ = [...arguments];
|
|
33
|
+
},
|
|
34
|
+
getSessionContainer () {
|
|
35
|
+
if (typeof this.__session_container__ === "undefined" || this.__session_container__ === null){
|
|
36
|
+
throw new Error("You need to set a session container first: sessionData.setSessionContainer(...arguments)");
|
|
37
|
+
}
|
|
38
|
+
return this.__session_container__;
|
|
39
|
+
},
|
|
40
|
+
getSessionData () {
|
|
41
|
+
var __instance__ = this;
|
|
42
|
+
var s = sessionStorage.getItem(`${__instance__.index(...arguments)}`);
|
|
43
|
+
var sessionData = JSON.parse(s);
|
|
44
|
+
return sessionData;
|
|
45
|
+
},
|
|
46
|
+
index () {
|
|
47
|
+
if (typeof SessionUserToken === "undefined") {
|
|
48
|
+
throw new Error("You need to import SessionUserToken first: Import (\"org.qcobjects.cloud.auth.session.usertoken\")");
|
|
49
|
+
}
|
|
50
|
+
return `session_${btoa(SessionUserToken.getGlobalUserToken(...arguments))}`;
|
|
51
|
+
},
|
|
52
|
+
save () {
|
|
53
|
+
var __instance__ = this;
|
|
54
|
+
var s = _DataStringify(__instance__.sessionData);
|
|
55
|
+
sessionStorage.setItem(`${__instance__.index(...arguments)}`, s);
|
|
56
|
+
},
|
|
57
|
+
get (name) {
|
|
58
|
+
var __instance__ = this;
|
|
59
|
+
var sessionData = __instance__.getSessionData(__instance__.getSessionContainer());
|
|
60
|
+
return sessionData[name];
|
|
61
|
+
},
|
|
62
|
+
set (name, value) {
|
|
63
|
+
var __instance__ = this;
|
|
64
|
+
var __session_container__ = __instance__.getSessionContainer();
|
|
65
|
+
var sessionData = __instance__.getSessionData(__session_container__);
|
|
66
|
+
sessionData[name] = value;
|
|
67
|
+
__instance__.save(__session_container__);
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
}).call(null);
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects SDK 2.3
|
|
3
|
+
* ________________
|
|
4
|
+
*
|
|
5
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
6
|
+
*
|
|
7
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
8
|
+
* QuickCorp/QCObjects is licensed under the
|
|
9
|
+
* GNU Lesser General Public License v3.0
|
|
10
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
11
|
+
*
|
|
12
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
13
|
+
* complete source code of licensed works and modifications under the same
|
|
14
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
15
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
16
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
17
|
+
* work may be distributed under different terms and without source code for
|
|
18
|
+
* the larger work.
|
|
19
|
+
*
|
|
20
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
21
|
+
*
|
|
22
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
23
|
+
* license document, but changing it is not allowed.
|
|
24
|
+
*/
|
|
25
|
+
(function() {
|
|
26
|
+
"use strict";
|
|
27
|
+
|
|
28
|
+
Package("org.qcobjects.cloud.auth.session.usertoken",[
|
|
29
|
+
Class ("SessionUserToken",Object, {
|
|
30
|
+
user: {},
|
|
31
|
+
__cache__: null,
|
|
32
|
+
_new_ (o) {
|
|
33
|
+
var __instance__ = this;
|
|
34
|
+
this.__cache__ = new ComplexStorageCache(
|
|
35
|
+
{
|
|
36
|
+
index: __instance__.__instanceID.toString(),
|
|
37
|
+
load () {
|
|
38
|
+
var __token__;
|
|
39
|
+
if (typeof navigator !== "undefined" && typeof origin !== "undefined"){
|
|
40
|
+
__token__ = _Crypt.encrypt(`${navigator.userAgent}|${o.username}|${(+(new Date())).toString()}`,origin);
|
|
41
|
+
} else {
|
|
42
|
+
__token__ = _Crypt.encrypt(`${o.username}|${(+(new Date())).toString()}`,CONFIG.get("domain", "localhost"));
|
|
43
|
+
}
|
|
44
|
+
__instance__.user = {
|
|
45
|
+
priority:__instance__.__instanceID.toString(),
|
|
46
|
+
token: __token__
|
|
47
|
+
};
|
|
48
|
+
return __instance__.user;
|
|
49
|
+
},
|
|
50
|
+
alternate (cacheController) {
|
|
51
|
+
__instance__.user = cacheController.cache.getCached(__instance__.__instanceID.toString()); // setting dataObject with the cached value
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
generateIndex (s) {
|
|
57
|
+
return (typeof Buffer !== "undefined")?(Buffer.from(s, "ascii").toString("base64")):(btoa(s));
|
|
58
|
+
},
|
|
59
|
+
getGlobalUser () {
|
|
60
|
+
var username = [...arguments].join("|");
|
|
61
|
+
var __index__ = "userToken_"+SessionUserToken.generateIndex(username);
|
|
62
|
+
if (typeof global.get(__index__) === "undefined" || global.get(__index__) === null){
|
|
63
|
+
global.set(__index__, New(SessionUserToken, {
|
|
64
|
+
username: username
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
SessionUserToken.user = global.get(__index__).user;
|
|
68
|
+
return global.get(__index__).user;
|
|
69
|
+
},
|
|
70
|
+
getGlobalUserToken () {
|
|
71
|
+
return this.getGlobalUser(...arguments).token;
|
|
72
|
+
},
|
|
73
|
+
getGlobalUserId () {
|
|
74
|
+
return this.getGlobalUser(...arguments).id;
|
|
75
|
+
},
|
|
76
|
+
getGlobalUserPriority () {
|
|
77
|
+
return this.getGlobalUser(...arguments).priority;
|
|
78
|
+
},
|
|
79
|
+
getLoginCredentialsToken (username, password) {
|
|
80
|
+
return _Crypt.encrypt(`${username}${password}`, this.getGlobalUserToken(username));
|
|
81
|
+
},
|
|
82
|
+
closeGlobalSession () {
|
|
83
|
+
this.getGlobalUser(...arguments);
|
|
84
|
+
var username = [...arguments].join("|");
|
|
85
|
+
var __index__ = "userToken_"+SessionUserToken.generateIndex(username);
|
|
86
|
+
if (typeof global.get(__index__) !== "undefined"){
|
|
87
|
+
global.get(__index__).__cache__.clear();
|
|
88
|
+
global.set(__index__, null);
|
|
89
|
+
SessionUserToken.user = {};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
]);
|
|
94
|
+
|
|
95
|
+
}).call(null);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QCObjects SDK 2.3
|
|
3
|
+
* ________________
|
|
4
|
+
*
|
|
5
|
+
* Author: Jean Machuca <correojean@gmail.com>
|
|
6
|
+
*
|
|
7
|
+
* Cross Browser Javascript Framework for MVC Patterns
|
|
8
|
+
* QuickCorp/QCObjects is licensed under the
|
|
9
|
+
* GNU Lesser General Public License v3.0
|
|
10
|
+
* [LICENSE] (https://github.com/QuickCorp/QCObjects/blob/master/LICENSE.txt)
|
|
11
|
+
*
|
|
12
|
+
* Permissions of this copyleft license are conditioned on making available
|
|
13
|
+
* complete source code of licensed works and modifications under the same
|
|
14
|
+
* license or the GNU GPLv3. Copyright and license notices must be preserved.
|
|
15
|
+
* Contributors provide an express grant of patent rights. However, a larger
|
|
16
|
+
* work using the licensed work through interfaces provided by the licensed
|
|
17
|
+
* work may be distributed under different terms and without source code for
|
|
18
|
+
* the larger work.
|
|
19
|
+
*
|
|
20
|
+
* Copyright (C) 2015 Jean Machuca,<correojean@gmail.com>
|
|
21
|
+
*
|
|
22
|
+
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
23
|
+
* license document, but changing it is not allowed.
|
|
24
|
+
*/
|
|
25
|
+
(function() {
|
|
26
|
+
"use strict";
|
|
27
|
+
Package("org.qcobjects.components.grid",[
|
|
28
|
+
Class("GridItemComponent",Component,{
|
|
29
|
+
name:"grid-item",
|
|
30
|
+
shadowed: true,
|
|
31
|
+
tplsource: "inline",
|
|
32
|
+
template:`
|
|
33
|
+
<img src="{{image}}" />
|
|
34
|
+
<p>{{description}}</p>
|
|
35
|
+
`,
|
|
36
|
+
cached: false
|
|
37
|
+
}),
|
|
38
|
+
Class("GridComponent",Component,{
|
|
39
|
+
name:"grid",
|
|
40
|
+
cached:false,
|
|
41
|
+
view:null,
|
|
42
|
+
shadowed: true,
|
|
43
|
+
rows:3,
|
|
44
|
+
cols:3,
|
|
45
|
+
templateURI:"",
|
|
46
|
+
data:{},
|
|
47
|
+
tplsource: "inline",
|
|
48
|
+
template: "<p>Loading...</p>",
|
|
49
|
+
_new_ (o){
|
|
50
|
+
o.body.setAttribute("controllerClass","DataGridController");
|
|
51
|
+
var subcomponentClass = (o.body.getAttribute("subcomponentClass") !== null)?(o.body.getAttribute("subcomponentClass")):("GridItemComponent");
|
|
52
|
+
o.body.setAttribute("subcomponentClass",subcomponentClass);
|
|
53
|
+
_super_("Component","_new_").call(this,o);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
})
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
}).call(null);
|