qcobjects-sdk 2.4.6 → 2.4.9
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 +26 -21
- package/QCObjects-SDK.js +47 -47
- package/VERSION +1 -1
- package/demo-tests/test-component-grid.html +43 -30
- package/demo-tests/test-component-list.html +31 -23
- package/demo-tests/test-component-notifications.html +31 -12
- package/demo-tests/test-component-slider.html +47 -31
- package/js/org.qcobjects.cloud.auth.session.data.js +106 -47
- package/js/org.qcobjects.cloud.auth.session.usertoken.js +64 -54
- package/js/org.qcobjects.components.grid.js +46 -34
- package/js/org.qcobjects.components.js +137 -80
- package/js/org.qcobjects.components.list.js +27 -18
- package/js/org.qcobjects.components.notifications.js +73 -58
- package/js/org.qcobjects.components.slider.js +174 -151
- package/js/org.qcobjects.components.splashscreen.js +480 -460
- package/js/org.qcobjects.controllers.form.js +38 -20
- package/js/org.qcobjects.controllers.grid.js +46 -25
- package/js/org.qcobjects.controllers.js +38 -6
- package/js/org.qcobjects.controllers.list.js +169 -157
- package/js/org.qcobjects.controllers.slider.js +113 -97
- package/js/org.qcobjects.controllers.swagger.js +60 -51
- package/js/org.qcobjects.effects.js +149 -124
- package/js/org.qcobjects.i18n_messages.js +11 -6
- package/js/org.qcobjects.modal.controllers.js +14 -9
- package/js/org.qcobjects.modal.effects.js +25 -16
- package/js/org.qcobjects.models.js +19 -11
- package/js/org.qcobjects.tools.canvas.js +10 -6
- package/js/org.qcobjects.tools.js +17 -8
- package/js/org.qcobjects.tools.layouts.js +19 -8
- package/js/org.qcobjects.views.js +12 -7
- package/package.json +3 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* QCObjects SDK 2.
|
|
2
|
+
* QCObjects SDK 2.4
|
|
3
3
|
* ________________
|
|
4
4
|
*
|
|
5
5
|
* Author: Jean Machuca <correojean@gmail.com>
|
|
@@ -21,209 +21,221 @@
|
|
|
21
21
|
*
|
|
22
22
|
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
23
23
|
* license document, but changing it is not allowed.
|
|
24
|
-
*/
|
|
25
|
-
(function() {
|
|
26
|
-
"use strict";
|
|
27
|
-
Package("org.qcobjects.controllers.list",[
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
controller.labelField = controller.component.body.getAttribute("label-field");
|
|
37
|
-
controller.valueField = controller.component.body.getAttribute("value-field");
|
|
38
|
-
controller.rows=controller.component.body.getAttribute("rows");
|
|
39
|
-
controller.rows=(controller.rows !== null)?(controller.rows):(controller.component.rows);
|
|
40
|
-
controller.cols=1;
|
|
41
|
-
logger.debug("ListController INIT");
|
|
42
|
-
},
|
|
43
|
-
getPageIndex: function (page, totalPage, totalElements) {
|
|
44
|
-
page = new Number(page);
|
|
45
|
-
page = (page>0)?(page-1):(0);
|
|
46
|
-
totalPage = new Number(totalPage);
|
|
47
|
-
totalElements = new Number(totalElements);
|
|
48
|
-
return [totalElements*page/ totalPage, (totalElements*page/ totalPage) + totalElements/totalPage];
|
|
49
|
-
},
|
|
50
|
-
addSubcomponents:function (){
|
|
51
|
-
var controller = this;
|
|
52
|
-
controller.component.subcomponents = [];
|
|
53
|
-
var layout = controller.component.body.getAttribute("layout");
|
|
54
|
-
var basePath = CONFIG.get("listBasePath",CONFIG.get("remoteSDKPath"));
|
|
55
|
-
var cssLayout = "";
|
|
56
|
-
if (layout === "horizontal"){
|
|
57
|
-
cssLayout = `@import url("${basePath}css/components/horizontal-list.css");`;
|
|
58
|
-
} else {
|
|
59
|
-
cssLayout = `@import url("${basePath}css/components/list.css");`;
|
|
24
|
+
*/
|
|
25
|
+
(function () {
|
|
26
|
+
"use strict";
|
|
27
|
+
Package("org.qcobjects.controllers.list", [
|
|
28
|
+
|
|
29
|
+
class ListController extends Controller {
|
|
30
|
+
constructor() {
|
|
31
|
+
super();
|
|
32
|
+
this.dependencies = [];
|
|
33
|
+
this.component = null;
|
|
34
|
+
|
|
60
35
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
36
|
+
|
|
37
|
+
_new_(o) {
|
|
38
|
+
super.__new__(o);
|
|
39
|
+
var controller = this;
|
|
40
|
+
controller._componentRoot = (controller.component.shadowed) ? (controller.component.shadowRoot) : (controller.component.body);
|
|
41
|
+
|
|
42
|
+
controller.labelField = controller.component.body.getAttribute("label-field");
|
|
43
|
+
controller.valueField = controller.component.body.getAttribute("value-field");
|
|
44
|
+
controller.rows = controller.component.body.getAttribute("rows");
|
|
45
|
+
controller.rows = (controller.rows !== null) ? (controller.rows) : (controller.component.rows);
|
|
46
|
+
controller.cols = 1;
|
|
47
|
+
logger.debug("ListController INIT");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getPageIndex(page, totalPage, totalElements) {
|
|
51
|
+
page = new Number(page);
|
|
52
|
+
page = (page > 0) ? (page - 1) : (0);
|
|
53
|
+
totalPage = new Number(totalPage);
|
|
54
|
+
totalElements = new Number(totalElements);
|
|
55
|
+
return [totalElements * page / totalPage, (totalElements * page / totalPage) + totalElements / totalPage];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
addSubcomponents() {
|
|
59
|
+
var controller = this;
|
|
60
|
+
controller.component.subcomponents = [];
|
|
61
|
+
var layout = controller.component.body.getAttribute("layout");
|
|
62
|
+
var basePath = CONFIG.get("listBasePath", CONFIG.get("remoteSDKPath"));
|
|
63
|
+
var cssLayout = "";
|
|
64
|
+
if (layout === "horizontal") {
|
|
65
|
+
cssLayout = `@import url("${basePath}css/components/horizontal-list.css");`;
|
|
66
|
+
} else {
|
|
67
|
+
cssLayout = `@import url("${basePath}css/components/list.css");`;
|
|
68
|
+
}
|
|
69
|
+
controller._componentRoot.innerHTML = `<style>${cssLayout}</style><ul></ul>`;
|
|
70
|
+
logger.debug(_DataStringify(controller.component.data));
|
|
71
|
+
try {
|
|
72
|
+
var subcomponentClass = controller.component.body.getAttribute("subcomponentClass");
|
|
73
|
+
if (subcomponentClass != null) {
|
|
74
|
+
var offset;
|
|
75
|
+
var limit;
|
|
76
|
+
var pagesNumber;
|
|
77
|
+
var list = [...controller.component.data];
|
|
78
|
+
var paginateIn = controller.component.body.getAttribute("paginate-in");
|
|
79
|
+
paginateIn = (paginateIn !== null) ? (paginateIn) : ("client");
|
|
80
|
+
if (paginateIn === "client") {
|
|
81
|
+
var page = controller.component.body.getAttribute("page-number");
|
|
82
|
+
page = (isNaN(page) || page === null) ? (-1) : (page);
|
|
83
|
+
if (page !== -1) {
|
|
84
|
+
pagesNumber = controller.component.body.getAttribute("total-pages");
|
|
85
|
+
pagesNumber = (isNaN(pagesNumber)) ? (1) : (pagesNumber);
|
|
86
|
+
offset = controller.getPageIndex(page, pagesNumber, list.length)[0];
|
|
87
|
+
limit = controller.getPageIndex(page, pagesNumber, list.length)[1];
|
|
88
|
+
} else {
|
|
89
|
+
offset = 0;
|
|
90
|
+
limit = list.length;
|
|
91
|
+
pagesNumber = 1;
|
|
92
|
+
}
|
|
93
|
+
list = list.slice(offset, limit);
|
|
80
94
|
} else {
|
|
81
95
|
offset = 0;
|
|
82
96
|
limit = list.length;
|
|
83
97
|
pagesNumber = 1;
|
|
84
98
|
}
|
|
85
|
-
list
|
|
86
|
-
|
|
87
|
-
offset = 0;
|
|
88
|
-
limit = list.length;
|
|
89
|
-
pagesNumber = 1;
|
|
90
|
-
}
|
|
91
|
-
list.map(
|
|
92
|
-
function (record,dataIndex){
|
|
99
|
+
list.map(
|
|
100
|
+
function (record, dataIndex) {
|
|
93
101
|
try {
|
|
94
102
|
var _body = _DOMCreateElement("li");
|
|
95
103
|
record.label = record[controller.labelField];
|
|
96
104
|
record.value = record[controller.valueField];
|
|
97
|
-
var subcomponent = New(ClassFactory(subcomponentClass),{
|
|
98
|
-
data:{
|
|
99
|
-
label:record[controller.labelField],
|
|
100
|
-
value:record[controller.valueField],
|
|
101
|
-
__dataIndex:dataIndex,
|
|
102
|
-
__page:page,
|
|
103
|
-
__totalPages:pagesNumber,
|
|
104
|
-
__limit:limit,
|
|
105
|
-
__offset:offset
|
|
105
|
+
var subcomponent = New(ClassFactory(subcomponentClass), {
|
|
106
|
+
data: {
|
|
107
|
+
label: record[controller.labelField],
|
|
108
|
+
value: record[controller.valueField],
|
|
109
|
+
__dataIndex: dataIndex,
|
|
110
|
+
__page: page,
|
|
111
|
+
__totalPages: pagesNumber,
|
|
112
|
+
__limit: limit,
|
|
113
|
+
__offset: offset
|
|
106
114
|
},
|
|
107
|
-
templateURI:ComponentURI({
|
|
108
|
-
"COMPONENTS_BASE_PATH":CONFIG.get("componentsBasePath"),
|
|
109
|
-
"COMPONENT_NAME":ClassFactory(subcomponentClass).name,
|
|
110
|
-
"TPLEXTENSION":CONFIG.get("tplextension"),
|
|
111
|
-
"TPL_SOURCE":ClassFactory(subcomponentClass).tplsource
|
|
115
|
+
templateURI: ComponentURI({
|
|
116
|
+
"COMPONENTS_BASE_PATH": CONFIG.get("componentsBasePath"),
|
|
117
|
+
"COMPONENT_NAME": ClassFactory(subcomponentClass).name,
|
|
118
|
+
"TPLEXTENSION": CONFIG.get("tplextension"),
|
|
119
|
+
"TPL_SOURCE": ClassFactory(subcomponentClass).tplsource
|
|
112
120
|
}),
|
|
113
|
-
body:_body,
|
|
114
|
-
template:ClassFactory(subcomponentClass).template
|
|
121
|
+
body: _body,
|
|
122
|
+
template: ClassFactory(subcomponentClass).template
|
|
115
123
|
});
|
|
116
124
|
subcomponent.done = controller.component.done.bind(subcomponent);
|
|
117
125
|
try {
|
|
118
|
-
if (subcomponent){
|
|
126
|
+
if (subcomponent) {
|
|
119
127
|
subcomponent.data.__dataIndex = dataIndex;
|
|
120
|
-
if (controller.component.data.hasOwnProperty.call(controller.component.data,"length")){
|
|
128
|
+
if (controller.component.data.hasOwnProperty.call(controller.component.data, "length")) {
|
|
121
129
|
subcomponent.data.__dataLength = controller.component.data.length;
|
|
122
130
|
}
|
|
123
131
|
logger.debug("adding subcomponent to body");
|
|
124
|
-
controller._componentRoot.subelements("ul").map(ul=>ul.append(subcomponent));
|
|
132
|
+
controller._componentRoot.subelements("ul").map(ul => ul.append(subcomponent));
|
|
125
133
|
try {
|
|
126
134
|
controller.component.subcomponents.push(subcomponent);
|
|
127
|
-
}catch (e){
|
|
135
|
+
} catch (e) {
|
|
128
136
|
logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
129
137
|
}
|
|
130
138
|
} else {
|
|
131
139
|
logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
132
140
|
}
|
|
133
|
-
}catch (e){
|
|
141
|
+
} catch (e) {
|
|
134
142
|
logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
135
143
|
}
|
|
136
144
|
|
|
137
145
|
} catch (e) {
|
|
138
146
|
logger.debug("ERROR LOADING SUBCOMPONENT IN DATAGRID");
|
|
139
147
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
} else {
|
|
151
|
+
logger.debug("NO SUBCOMPONENT CLASS IN COMPONENT");
|
|
152
|
+
}
|
|
145
153
|
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
} catch (e) {
|
|
155
|
+
logger.debug("No data for component");
|
|
156
|
+
}
|
|
148
157
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
|
|
159
|
+
cssGrid() {
|
|
160
|
+
var controller = this;
|
|
161
|
+
var component = controller.component;
|
|
162
|
+
var _componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
163
|
+
if (typeof controller.rows !== "undefined" && typeof controller.cols !== "undefined") {
|
|
164
|
+
var s = _DOMCreateElement("style");
|
|
165
|
+
var templateRows = "auto ".repeat(controller.rows);
|
|
166
|
+
var templateCols = "auto ".repeat(controller.cols);
|
|
167
|
+
var className = "grid" + this.__instanceID.toString();
|
|
168
|
+
s.innerHTML = "." + className + " { \
|
|
160
169
|
display: grid; \
|
|
161
|
-
grid-template-rows: "+templateRows+"; \
|
|
162
|
-
grid-template-columns: "+templateCols+"; \
|
|
170
|
+
grid-template-rows: " + templateRows + "; \
|
|
171
|
+
grid-template-columns: " + templateCols + "; \
|
|
163
172
|
margin:0 auto; \
|
|
164
173
|
}";
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
done:function (){
|
|
170
|
-
var controller = this;
|
|
171
|
-
controller.cssGrid();
|
|
172
|
-
|
|
173
|
-
var componentInstance = controller.component;
|
|
174
|
-
logger.debug("ListController DONE");
|
|
175
|
-
var serviceClass = controller.component.body.getAttribute("serviceClass");
|
|
176
|
-
if (serviceClass != null){
|
|
177
|
-
var offset;
|
|
178
|
-
var limit;
|
|
179
|
-
var paginateIn = componentInstance.body.getAttribute("paginate-in");
|
|
180
|
-
paginateIn = (paginateIn !== null)?(paginateIn):("client");
|
|
181
|
-
if (paginateIn === "server"){
|
|
182
|
-
var page = componentInstance.body.getAttribute("page-number");
|
|
183
|
-
page = (isNaN(page) || page === null)?(-1):(page);
|
|
184
|
-
var pagesNumber;
|
|
185
|
-
if (page !== -1){
|
|
186
|
-
var serverDataCount = (controller.component.body.getAttribute("server-data-count")!==null)?(controller.component.body.getAttribute("server-data-count")):(1);
|
|
187
|
-
pagesNumber = controller.component.body.getAttribute("total-pages");
|
|
188
|
-
pagesNumber = (isNaN(pagesNumber))?(1):(pagesNumber);
|
|
189
|
-
offset = controller.getPageIndex(page, pagesNumber, serverDataCount)[0];
|
|
190
|
-
limit = controller.getPageIndex(page, pagesNumber, serverDataCount)[1];
|
|
191
|
-
// send params in jsonrpc 2.0 style
|
|
192
|
-
componentInstance.serviceData = (typeof componentInstance.serviceData !== "undefined")?(componentInstance.serviceData):({});
|
|
193
|
-
componentInstance.serviceData.params = (typeof componentInstance.serviceData.params !== "undefined")?(componentInstance.serviceData.params):({});
|
|
194
|
-
componentInstance.serviceData.params.offset = offset;
|
|
195
|
-
componentInstance.serviceData.params.limit = limit;
|
|
196
|
-
}
|
|
174
|
+
_componentRoot.append(s);
|
|
175
|
+
_componentRoot.classList.add(className);
|
|
197
176
|
}
|
|
177
|
+
}
|
|
198
178
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
179
|
+
done() {
|
|
180
|
+
var controller = this;
|
|
181
|
+
controller.cssGrid();
|
|
182
|
+
|
|
183
|
+
var componentInstance = controller.component;
|
|
184
|
+
logger.debug("ListController DONE");
|
|
185
|
+
var serviceClass = controller.component.body.getAttribute("serviceClass");
|
|
186
|
+
if (serviceClass != null) {
|
|
187
|
+
var offset;
|
|
188
|
+
var limit;
|
|
189
|
+
var paginateIn = componentInstance.body.getAttribute("paginate-in");
|
|
190
|
+
paginateIn = (paginateIn !== null) ? (paginateIn) : ("client");
|
|
191
|
+
if (paginateIn === "server") {
|
|
192
|
+
var page = componentInstance.body.getAttribute("page-number");
|
|
193
|
+
page = (isNaN(page) || page === null) ? (-1) : (page);
|
|
194
|
+
var pagesNumber;
|
|
195
|
+
if (page !== -1) {
|
|
196
|
+
var serverDataCount = (controller.component.body.getAttribute("server-data-count") !== null) ? (controller.component.body.getAttribute("server-data-count")) : (1);
|
|
197
|
+
pagesNumber = controller.component.body.getAttribute("total-pages");
|
|
198
|
+
pagesNumber = (isNaN(pagesNumber)) ? (1) : (pagesNumber);
|
|
199
|
+
offset = controller.getPageIndex(page, pagesNumber, serverDataCount)[0];
|
|
200
|
+
limit = controller.getPageIndex(page, pagesNumber, serverDataCount)[1];
|
|
201
|
+
// send params in jsonrpc 2.0 style
|
|
202
|
+
componentInstance.serviceData = (typeof componentInstance.serviceData !== "undefined") ? (componentInstance.serviceData) : ({});
|
|
203
|
+
componentInstance.serviceData.params = (typeof componentInstance.serviceData.params !== "undefined") ? (componentInstance.serviceData.params) : ({});
|
|
204
|
+
componentInstance.serviceData.params.offset = offset;
|
|
205
|
+
componentInstance.serviceData.params.limit = limit;
|
|
211
206
|
}
|
|
212
|
-
|
|
207
|
+
}
|
|
213
208
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
209
|
+
serviceLoader(New(ClassFactory(serviceClass), {
|
|
210
|
+
data: componentInstance.serviceData
|
|
211
|
+
})).then(
|
|
212
|
+
(successfulResponse) => {
|
|
213
|
+
// This will show the service response as a plain text
|
|
214
|
+
logger.debug("DONE SERVICE COMPONENT");
|
|
215
|
+
successfulResponse.service.JSONresponse = JSON.parse(successfulResponse.service.template);
|
|
216
|
+
if (typeof successfulResponse.service.JSONresponse.result !== "undefined") {
|
|
217
|
+
logger.debug(_DataStringify(successfulResponse.service.JSONresponse.result));
|
|
218
|
+
componentInstance.data = successfulResponse.service.JSONresponse.result;
|
|
219
|
+
} else {
|
|
220
|
+
componentInstance.data = successfulResponse.service.JSONresponse;
|
|
221
|
+
}
|
|
222
|
+
controller.addSubcomponents();
|
|
223
|
+
|
|
224
|
+
},
|
|
225
|
+
(failedResponse) => {
|
|
226
|
+
logger.debug(failedResponse);
|
|
227
|
+
}).catch((e) => {
|
|
228
|
+
logger.debug("Something went wrong when calling the service from: " + serviceClass);
|
|
219
229
|
logger.debug(e.message);
|
|
220
230
|
});
|
|
221
231
|
|
|
232
|
+
}
|
|
233
|
+
|
|
222
234
|
}
|
|
223
235
|
|
|
236
|
+
|
|
224
237
|
}
|
|
225
238
|
|
|
226
|
-
|
|
227
|
-
]);
|
|
239
|
+
]);
|
|
228
240
|
|
|
229
241
|
}).call(null);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* QCObjects SDK 2.
|
|
2
|
+
* QCObjects SDK 2.4
|
|
3
3
|
* ________________
|
|
4
4
|
*
|
|
5
5
|
* Author: Jean Machuca <correojean@gmail.com>
|
|
@@ -21,112 +21,128 @@
|
|
|
21
21
|
*
|
|
22
22
|
* Everyone is permitted to copy and distribute verbatim copies of this
|
|
23
23
|
* license document, but changing it is not allowed.
|
|
24
|
-
*/
|
|
25
|
-
(function() {
|
|
26
|
-
"use strict";
|
|
27
|
-
Package("org.qcobjects.controllers.slider",[
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
//TODO: Implement
|
|
41
|
-
controller.sliderHandlerName = "slider_"+controller.component.__instanceID.toString();
|
|
42
|
-
global.set(controller.sliderHandlerName,this);
|
|
43
|
-
},
|
|
44
|
-
stop: function (){
|
|
45
|
-
if (this.interval != null){
|
|
46
|
-
clearInterval(this.interval);
|
|
24
|
+
*/
|
|
25
|
+
(function () {
|
|
26
|
+
"use strict";
|
|
27
|
+
Package("org.qcobjects.controllers.slider", [
|
|
28
|
+
|
|
29
|
+
class SliderController extends Controller {
|
|
30
|
+
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
this.dependencies = [];
|
|
34
|
+
this.component = null;
|
|
35
|
+
this.slideIndex = 0;
|
|
36
|
+
this.duration = 7100;
|
|
37
|
+
this.interval = null;
|
|
38
|
+
this.sliderHandlerName = null;
|
|
39
|
+
|
|
47
40
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.stop();
|
|
58
|
-
this.showSlides(this.slideIndex = n);
|
|
59
|
-
},
|
|
60
|
-
automate: function (){
|
|
61
|
-
var controller = this;
|
|
62
|
-
controller.interval = setInterval(function (){
|
|
63
|
-
controller.plusSlides(1);
|
|
64
|
-
},controller.duration);
|
|
65
|
-
},
|
|
66
|
-
showSlides: function (n) {
|
|
67
|
-
var controller = this;
|
|
68
|
-
var slides = controller._componentRoot.subelements(".qcoSlides");
|
|
69
|
-
var dots = controller._componentRoot.subelements(".qcoSlider__dots--dot");
|
|
70
|
-
|
|
71
|
-
if (n > (slides.length-1)) {
|
|
72
|
-
controller.slideIndex = 0;
|
|
41
|
+
|
|
42
|
+
_new_(o) {
|
|
43
|
+
super.__new__(o);
|
|
44
|
+
var controller = this;
|
|
45
|
+
var component = controller.component;
|
|
46
|
+
controller._componentRoot = (component.shadowed) ? (component.shadowRoot) : (component.body);
|
|
47
|
+
//TODO: Implement
|
|
48
|
+
controller.sliderHandlerName = "slider_" + controller.component.__instanceID.toString();
|
|
49
|
+
global.set(controller.sliderHandlerName, this);
|
|
73
50
|
}
|
|
74
|
-
|
|
75
|
-
|
|
51
|
+
|
|
52
|
+
stop() {
|
|
53
|
+
if (this.interval != null) {
|
|
54
|
+
clearInterval(this.interval);
|
|
55
|
+
}
|
|
76
56
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
dot.classList.remove("active");
|
|
82
|
-
});
|
|
83
|
-
try {
|
|
84
|
-
dots[controller.slideIndex].classList.add("active");
|
|
85
|
-
}catch (e){
|
|
86
|
-
logger.debug("Something went wrong when trying to activate a slide");
|
|
87
|
-
logger.debug(e.message);
|
|
57
|
+
|
|
58
|
+
plusSlidesAndStop(n) {
|
|
59
|
+
this.stop();
|
|
60
|
+
this.plusSlides(n);
|
|
88
61
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
62
|
+
|
|
63
|
+
plusSlides(n) {
|
|
64
|
+
this.showSlides(this.slideIndex += n);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
currentSlide(n) {
|
|
68
|
+
this.stop();
|
|
69
|
+
this.showSlides(this.slideIndex = n);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
automate() {
|
|
73
|
+
var controller = this;
|
|
74
|
+
controller.interval = setInterval(function () {
|
|
75
|
+
controller.plusSlides(1);
|
|
76
|
+
}, controller.duration);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
showSlides(n) {
|
|
80
|
+
var controller = this;
|
|
81
|
+
var slides = controller._componentRoot.subelements(".qcoSlides");
|
|
82
|
+
var dots = controller._componentRoot.subelements(".qcoSlider__dots--dot");
|
|
83
|
+
|
|
84
|
+
if (n > (slides.length - 1)) {
|
|
85
|
+
controller.slideIndex = 0;
|
|
86
|
+
}
|
|
87
|
+
if (n < 0) {
|
|
88
|
+
controller.slideIndex = 0;
|
|
89
|
+
}
|
|
90
|
+
slides.map((slide) => {
|
|
91
|
+
Fade.apply(slide, 1, 0);
|
|
92
|
+
});
|
|
93
|
+
dots.map((dot) => {
|
|
94
|
+
dot.classList.remove("active");
|
|
92
95
|
});
|
|
93
96
|
try {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}catch (e){
|
|
98
|
-
logger.debug("Something went wrong when trying to show a slide");
|
|
97
|
+
dots[controller.slideIndex].classList.add("active");
|
|
98
|
+
} catch (e) {
|
|
99
|
+
logger.debug("Something went wrong when trying to activate a slide");
|
|
99
100
|
logger.debug(e.message);
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
102
|
+
setTimeout(function () {
|
|
103
|
+
slides.map((slide) => {
|
|
104
|
+
slide.style.display = "none";
|
|
105
|
+
});
|
|
106
|
+
try {
|
|
107
|
+
slides[controller.slideIndex].style.display = "block";
|
|
108
|
+
Fade.apply(slides[controller.slideIndex], 0, 1);
|
|
109
|
+
|
|
110
|
+
} catch (e) {
|
|
111
|
+
logger.debug("Something went wrong when trying to show a slide");
|
|
112
|
+
logger.debug(e.message);
|
|
113
|
+
}
|
|
114
|
+
}, 700);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
fillDots() {
|
|
118
|
+
var controller = this;
|
|
119
|
+
var slides = controller._componentRoot.subelements(".qcoSlides");
|
|
120
|
+
slides.map((slide, index) => {
|
|
121
|
+
var dotHTML = document.createElement("span");
|
|
122
|
+
var dotContent = `<span class="qcoSlider__dots--dot" onclick="global.get('${controller.sliderHandlerName}').currentSlide(${index})"></span>`;
|
|
123
|
+
dotHTML.innerHTML = dotContent;
|
|
124
|
+
controller._componentRoot.subelements(".qcoSlider__dots")[0].append(dotHTML);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
done() {
|
|
130
|
+
var controller = this;
|
|
131
|
+
var slides = controller._componentRoot.subelements(".qcoSlides");
|
|
132
|
+
slides.map((slide) => {
|
|
133
|
+
slide.style.display = "none";
|
|
134
|
+
});
|
|
135
|
+
setTimeout(function () {
|
|
136
|
+
controller.fillDots();
|
|
137
|
+
controller.slideIndex = 0;
|
|
138
|
+
controller.showSlides(this.slideIndex);
|
|
139
|
+
controller.automate();
|
|
140
|
+
}, 3000);
|
|
141
|
+
|
|
142
|
+
}
|
|
126
143
|
|
|
127
144
|
}
|
|
128
|
-
})
|
|
129
145
|
|
|
130
|
-
]);
|
|
146
|
+
]);
|
|
131
147
|
|
|
132
148
|
}).call(null);
|