@oat-sa/tao-core-ui 1.57.0 → 1.58.2
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/dist/actionbar.js +386 -395
- package/dist/adder.js +21 -19
- package/dist/animable/absorbable/absorbable.js +204 -213
- package/dist/animable/absorbable/css/absorb.css +1 -0
- package/dist/animable/absorbable/css/absorb.css.map +1 -1
- package/dist/animable/pulsable/pulsable.js +168 -177
- package/dist/autocomplete/css/autocomplete.css +1 -0
- package/dist/autocomplete/css/autocomplete.css.map +1 -1
- package/dist/autocomplete.js +68 -66
- package/dist/badge/badge.js +188 -197
- package/dist/badge/css/badge.css +1 -0
- package/dist/badge/css/badge.css.map +1 -1
- package/dist/breadcrumbs.js +275 -284
- package/dist/btngrouper.js +5 -5
- package/dist/bulkActionPopup.js +490 -495
- package/dist/button.js +283 -291
- package/dist/cascadingComboBox.js +249 -258
- package/dist/ckeditor/ckConfigurator.js +42 -20
- package/dist/ckeditor/dtdHandler.js +11 -9
- package/dist/class/selector.js +441 -450
- package/dist/component/resizable.js +1 -1
- package/dist/component/windowed.js +285 -294
- package/dist/component.js +419 -428
- package/dist/contextualPopup.js +417 -426
- package/dist/dashboard.js +300 -309
- package/dist/datalist.js +753 -762
- package/dist/datatable/filterStrategy/multiple.js +1 -1
- package/dist/datatable/filterStrategy/single.js +1 -1
- package/dist/datatable.js +1527 -1550
- package/dist/dateRange/dateRange.js +393 -402
- package/dist/datetime/picker.js +665 -672
- package/dist/deleter.js +368 -377
- package/dist/destination/selector.js +286 -295
- package/dist/dialog/alert.js +3 -3
- package/dist/dialog/confirm.js +1 -1
- package/dist/dialog/confirmDelete.js +216 -225
- package/dist/dialog.js +650 -654
- package/dist/disabler.js +8 -8
- package/dist/documentViewer/providers/pdfViewer/fallback/viewer.js +166 -175
- package/dist/documentViewer/providers/pdfViewer/pdfjs/findBar.js +518 -527
- package/dist/documentViewer/providers/pdfViewer/pdfjs/pageView.js +380 -389
- package/dist/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +539 -548
- package/dist/documentViewer/providers/pdfViewer/pdfjs/viewer.js +369 -378
- package/dist/documentViewer/providers/pdfViewer.js +184 -193
- package/dist/documentViewer.js +292 -301
- package/dist/dropdown.js +383 -392
- package/dist/durationer.js +5 -5
- package/dist/dynamicComponent.js +597 -598
- package/dist/feedback.js +356 -362
- package/dist/figure/FigureStateActive.js +117 -108
- package/dist/filesender.js +2 -2
- package/dist/filter.js +230 -239
- package/dist/form/dropdownForm.js +355 -357
- package/dist/form/form.js +919 -690
- package/dist/form/simpleForm.js +1 -1
- package/dist/form/validator/renderer.js +233 -235
- package/dist/form/validator/validator.js +257 -189
- package/dist/form/widget/definitions.js +1 -1
- package/dist/form/widget/providers/checkBox.js +254 -259
- package/dist/form/widget/providers/comboBox.js +187 -192
- package/dist/form/widget/providers/default.js +8 -9
- package/dist/form/widget/providers/hidden.js +170 -179
- package/dist/form/widget/providers/hiddenBox.js +262 -267
- package/dist/form/widget/providers/radioBox.js +216 -225
- package/dist/form/widget/providers/textArea.js +187 -196
- package/dist/form/widget/providers/textBox.js +2 -3
- package/dist/form/widget/widget.js +473 -475
- package/dist/formValidator/formValidator.js +1 -1
- package/dist/formValidator/highlighters/message.js +1 -1
- package/dist/generis/form/form.js +314 -323
- package/dist/generis/validator/validator.js +209 -218
- package/dist/generis/widget/checkBox/checkBox.js +218 -227
- package/dist/generis/widget/comboBox/comboBox.js +179 -188
- package/dist/generis/widget/hiddenBox/hiddenBox.js +220 -229
- package/dist/generis/widget/textBox/textBox.js +169 -178
- package/dist/generis/widget/widget.js +246 -255
- package/dist/groupedComboBox.js +222 -231
- package/dist/groupvalidator.js +2 -2
- package/dist/highlighter.js +967 -958
- package/dist/image/ImgStateActive/helper.js +7 -5
- package/dist/image/ImgStateActive/initHelper.js +49 -43
- package/dist/image/ImgStateActive/initMediaEditor.js +24 -20
- package/dist/image/ImgStateActive/mediaSizer.js +14 -12
- package/dist/image/ImgStateActive.js +72 -70
- package/dist/incrementer.js +6 -6
- package/dist/inplacer.js +6 -6
- package/dist/itemButtonList/css/item-button-list.css +1 -0
- package/dist/itemButtonList/css/item-button-list.css.map +1 -1
- package/dist/itemButtonList.js +439 -435
- package/dist/keyNavigation/navigableDomElement.js +51 -38
- package/dist/keyNavigation/navigator.js +85 -70
- package/dist/listbox.js +460 -469
- package/dist/liststyler.js +8 -8
- package/dist/loadingButton/loadingButton.js +209 -218
- package/dist/lock.js +476 -485
- package/dist/login/login.js +475 -484
- package/dist/maths/calculator/basicCalculator.js +235 -244
- package/dist/maths/calculator/calculatorComponent.js +3 -3
- package/dist/maths/calculator/core/board.js +772 -781
- package/dist/maths/calculator/core/expression.js +476 -485
- package/dist/maths/calculator/core/labels.js +228 -237
- package/dist/maths/calculator/core/tokenizer.js +1 -1
- package/dist/maths/calculator/core/tokens.js +163 -170
- package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +244 -253
- package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +279 -288
- package/dist/maths/calculator/scientificCalculator.js +327 -336
- package/dist/mediaEditor/mediaEditorComponent.js +238 -245
- package/dist/mediaEditor/plugins/mediaAlignment/helper.js +7 -7
- package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +229 -235
- package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +580 -589
- package/dist/mediaplayer/players/html5.js +666 -675
- package/dist/mediaplayer/players/youtube.js +419 -424
- package/dist/mediaplayer/support.js +11 -10
- package/dist/mediaplayer/utils/reminder.js +14 -13
- package/dist/mediaplayer/utils/timeObserver.js +10 -11
- package/dist/mediaplayer/youtubeManager.js +164 -145
- package/dist/mediaplayer.js +1565 -1520
- package/dist/mediasizer.js +669 -678
- package/dist/modal.js +10 -17
- package/dist/pageSizeSelector.js +219 -228
- package/dist/pagination/providers/pages.js +280 -289
- package/dist/pagination/providers/simple.js +192 -201
- package/dist/previewer.js +30 -30
- package/dist/progressbar.js +4 -4
- package/dist/report.js +347 -356
- package/dist/resource/filters.js +271 -280
- package/dist/resource/list.js +1264 -1273
- package/dist/resource/selector.js +865 -874
- package/dist/resource/tree.js +1483 -1492
- package/dist/resourcemgr/fileBrowser.js +564 -569
- package/dist/resourcemgr/filePreview.js +16 -16
- package/dist/resourcemgr/fileSelector.js +515 -524
- package/dist/resourcemgr/util/updatePermissions.js +2 -2
- package/dist/resourcemgr.js +306 -315
- package/dist/searchModal/advancedSearch.js +796 -767
- package/dist/searchModal.js +597 -549
- package/dist/switch/switch.js +298 -307
- package/dist/tabs.js +598 -575
- package/dist/taskQueue/status.js +312 -321
- package/dist/taskQueue/table.js +375 -384
- package/dist/taskQueue/taskQueueModel.js +488 -472
- package/dist/taskQueueButton/taskable.js +264 -273
- package/dist/taskQueueButton/treeButton.js +189 -198
- package/dist/themeLoader.js +24 -23
- package/dist/themes.js +1 -1
- package/dist/toggler.js +3 -3
- package/dist/tooltip.js +295 -304
- package/dist/transformer.js +2 -2
- package/dist/tristateCheckboxGroup.js +311 -320
- package/dist/uploader.js +687 -696
- package/dist/validator/Report.js +1 -1
- package/dist/validator/Validator.js +3 -3
- package/dist/validator/validators.js +9 -9
- package/dist/validator.js +240 -230
- package/dist/waitForMedia.js +1 -1
- package/package.json +3 -3
- package/scss/ckeditor/skins/tao/scss/inc/_menu.scss +51 -27
- package/scss/ckeditor/skins/tao/scss/inc/_panel.scss +16 -5
- package/scss/ckeditor/skins/tao/scss/inc/_richcombo.scss +0 -2
- package/scss/ckeditor/skins/tao/scss/inc/_toolbar.scss +15 -3
- package/src/animable/absorbable/css/absorb.css +1 -0
- package/src/animable/absorbable/css/absorb.css.map +1 -1
- package/src/autocomplete/css/autocomplete.css +1 -0
- package/src/autocomplete/css/autocomplete.css.map +1 -1
- package/src/badge/css/badge.css +1 -0
- package/src/badge/css/badge.css.map +1 -1
- package/src/ckeditor/ckConfigurator.js +24 -1
- package/src/itemButtonList/css/item-button-list.css +1 -0
- package/src/itemButtonList/css/item-button-list.css.map +1 -1
- package/scss/.DS_Store +0 -0
- package/src/.DS_Store +0 -0
package/dist/lock.js
CHANGED
|
@@ -1,556 +1,547 @@
|
|
|
1
1
|
define(['jquery', 'lodash', 'i18n', 'handlebars', 'lib/dompurify/purify', 'helpers', 'ui/feedback'], function ($$1, _, __, Handlebars, DOMPurify, helpers, feedback) { 'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
$$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
|
|
4
|
+
_ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
|
|
5
|
+
__ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
|
|
6
|
+
Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
|
|
7
|
+
DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
|
|
8
|
+
helpers = helpers && Object.prototype.hasOwnProperty.call(helpers, 'default') ? helpers['default'] : helpers;
|
|
9
|
+
feedback = feedback && Object.prototype.hasOwnProperty.call(feedback, 'default') ? feedback['default'] : feedback;
|
|
10
|
+
|
|
11
|
+
function _typeof(obj) {
|
|
12
|
+
"@babel/helpers - typeof";
|
|
13
|
+
|
|
14
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
15
|
+
return typeof obj;
|
|
16
|
+
} : function (obj) {
|
|
17
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
18
|
+
}, _typeof(obj);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function Helpers0 (hb) {
|
|
22
|
+
//register a i18n helper
|
|
23
|
+
hb.registerHelper('__', function (key) {
|
|
24
|
+
return __(key);
|
|
25
|
+
});
|
|
11
26
|
/**
|
|
12
|
-
*
|
|
13
|
-
* modify it under the terms of the GNU General Public License
|
|
14
|
-
* as published by the Free Software Foundation; under version 2
|
|
15
|
-
* of the License (non-upgradable).
|
|
16
|
-
*
|
|
17
|
-
* This program is distributed in the hope that it will be useful,
|
|
18
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20
|
-
* GNU General Public License for more details.
|
|
21
|
-
*
|
|
22
|
-
* You should have received a copy of the GNU General Public License
|
|
23
|
-
* along with this program; if not, write to the Free Software
|
|
24
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
25
|
-
*
|
|
26
|
-
* Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
|
|
27
|
-
*
|
|
27
|
+
* Register dompurify helper
|
|
28
28
|
*
|
|
29
|
+
* https://github.com/cure53/DOMPurify
|
|
30
|
+
* with config SAFE_FOR_TEMPLATES: true
|
|
31
|
+
* to make output safe for template systems
|
|
29
32
|
*/
|
|
30
|
-
function Helpers0 (hb) {
|
|
31
|
-
//register a i18n helper
|
|
32
|
-
hb.registerHelper('__', function (key) {
|
|
33
|
-
return __(key);
|
|
34
|
-
});
|
|
35
|
-
/**
|
|
36
|
-
* Register dompurify helper
|
|
37
|
-
*
|
|
38
|
-
* https://github.com/cure53/DOMPurify
|
|
39
|
-
* with config SAFE_FOR_TEMPLATES: true
|
|
40
|
-
* to make output safe for template systems
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
hb.registerHelper('dompurify', function (context) {
|
|
44
|
-
return DOMPurify.sanitize(context);
|
|
45
|
-
});
|
|
46
|
-
/**
|
|
47
|
-
* Register join helper
|
|
48
|
-
*
|
|
49
|
-
* Example :
|
|
50
|
-
* var values = {a:v1, b:v2, c:v3};
|
|
51
|
-
* Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
|
|
52
|
-
* Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
|
|
56
|
-
var fragments = [];
|
|
57
|
-
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
58
|
-
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
59
|
-
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
60
|
-
|
|
61
|
-
_.forIn(arr, function (value, key) {
|
|
62
|
-
var fragment = '';
|
|
63
|
-
|
|
64
|
-
if (value !== null || value !== undefined) {
|
|
65
|
-
if (typeof value === 'boolean') {
|
|
66
|
-
value = value ? 'true' : 'false';
|
|
67
|
-
} else if (typeof value === 'object') {
|
|
68
|
-
value = _.values(value).join(' ');
|
|
69
|
-
}
|
|
70
|
-
} else {
|
|
71
|
-
value = '';
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (keyValueGlue !== undefined) {
|
|
75
|
-
fragment += key + keyValueGlue;
|
|
76
|
-
}
|
|
77
33
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
34
|
+
hb.registerHelper('dompurify', function (context) {
|
|
35
|
+
return DOMPurify.sanitize(context);
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Register join helper
|
|
39
|
+
*
|
|
40
|
+
* Example :
|
|
41
|
+
* var values = {a:v1, b:v2, c:v3};
|
|
42
|
+
* Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
|
|
43
|
+
* Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
|
|
44
|
+
*/
|
|
85
45
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
46
|
+
hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
|
|
47
|
+
var fragments = [];
|
|
48
|
+
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
49
|
+
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
50
|
+
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
91
51
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
i: i
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
52
|
+
_.forIn(arr, function (value, key) {
|
|
53
|
+
var fragment = '';
|
|
97
54
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
55
|
+
if (value !== null || value !== undefined) {
|
|
56
|
+
if (typeof value === 'boolean') {
|
|
57
|
+
value = value ? 'true' : 'false';
|
|
58
|
+
} else if (_typeof(value) === 'object') {
|
|
59
|
+
value = _.values(value).join(' ');
|
|
60
|
+
}
|
|
103
61
|
} else {
|
|
104
|
-
|
|
62
|
+
value = '';
|
|
105
63
|
}
|
|
106
|
-
}); // register a "get property" helper
|
|
107
|
-
// it gets the named property from the provided context
|
|
108
|
-
|
|
109
|
-
hb.registerHelper('property', function (name, context) {
|
|
110
|
-
return context[name] || '';
|
|
111
|
-
}); // register an 'includes' helper
|
|
112
|
-
// it checks if value is in array
|
|
113
64
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return options.fn(this);
|
|
65
|
+
if (keyValueGlue !== undefined) {
|
|
66
|
+
fragment += key + keyValueGlue;
|
|
117
67
|
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
68
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
Helpers0.__initialized = true;
|
|
124
|
-
}
|
|
125
|
-
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
126
|
-
this.compilerInfo = [4,'>= 1.0.0'];
|
|
127
|
-
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
128
|
-
var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
buffer += "<div class=\"feedback-";
|
|
132
|
-
if (helper = helpers.level) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
133
|
-
else { helper = (depth0 && depth0.level); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
134
|
-
buffer += escapeExpression(stack1)
|
|
135
|
-
+ "\">\n<span class=\"icon-lock ";
|
|
136
|
-
if (helper = helpers.level) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
137
|
-
else { helper = (depth0 && depth0.level); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
138
|
-
buffer += escapeExpression(stack1)
|
|
139
|
-
+ "-color ";
|
|
140
|
-
if (helper = helpers.level) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
141
|
-
else { helper = (depth0 && depth0.level); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
142
|
-
buffer += escapeExpression(stack1)
|
|
143
|
-
+ "\"></span>\n ";
|
|
144
|
-
if (helper = helpers.msg) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
145
|
-
else { helper = (depth0 && depth0.msg); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
146
|
-
buffer += escapeExpression(stack1)
|
|
147
|
-
+ "\n <div class=\"txt-rgt button-container\">\n <button class=\"btn btn-info small check-in\"><span class=\"icon-unlock info\"></span>"
|
|
148
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Check-in", options) : helperMissing.call(depth0, "__", "Check-in", options)))
|
|
149
|
-
+ "</button>\n <button class=\"btn btn-info small release\"><span class=\"icon-result-nok info\"></span>"
|
|
150
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Release", options) : helperMissing.call(depth0, "__", "Release", options)))
|
|
151
|
-
+ "</button>\n </div>\n\n <div class=\"message-container button-container\" style=\"display: none;\">\n <label>\n "
|
|
152
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Message", options) : helperMissing.call(depth0, "__", "Message", options)))
|
|
153
|
-
+ "\n </label>\n <input type=\"text\" name=\"message\" class=\"message\">\n <button class=\"btn-info small commit\">"
|
|
154
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Commit", options) : helperMissing.call(depth0, "__", "Commit", options)))
|
|
155
|
-
+ "</button>\n </div>\n</div>\n";
|
|
156
|
-
return buffer;
|
|
69
|
+
fragment += wrapper + value + wrapper;
|
|
70
|
+
fragments.push(fragment);
|
|
157
71
|
});
|
|
158
|
-
function tpl(data, options, asString) {
|
|
159
|
-
var html = Template(data, options);
|
|
160
|
-
return (asString || true) ? html : $(html);
|
|
161
|
-
}
|
|
162
72
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
* as published by the Free Software Foundation; under version 2
|
|
167
|
-
* of the License (non-upgradable).
|
|
168
|
-
*
|
|
169
|
-
* This program is distributed in the hope that it will be useful,
|
|
170
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
171
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
172
|
-
* GNU General Public License for more details.
|
|
173
|
-
*
|
|
174
|
-
* You should have received a copy of the GNU General Public License
|
|
175
|
-
* along with this program; if not, write to the Free Software
|
|
176
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
177
|
-
*
|
|
178
|
-
* Copyright (c) 2015 (original work) Open Assessment Technologies SA;
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*/
|
|
73
|
+
return fragments.join(fragmentGlue);
|
|
74
|
+
}); //register a classic "for loop" helper
|
|
75
|
+
//it also adds a local variable "i" as the index in each iteration loop
|
|
182
76
|
|
|
183
|
-
|
|
77
|
+
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
78
|
+
var ret = '';
|
|
79
|
+
startIndex = parseInt(startIndex);
|
|
80
|
+
stopIndex = parseInt(stopIndex);
|
|
81
|
+
increment = parseInt(increment);
|
|
82
|
+
|
|
83
|
+
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
84
|
+
ret += options.fn(_.extend({}, this, {
|
|
85
|
+
i: i
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
184
88
|
|
|
185
|
-
|
|
89
|
+
return ret;
|
|
90
|
+
});
|
|
91
|
+
hb.registerHelper('equal', function (var1, var2, options) {
|
|
92
|
+
if (var1 == var2) {
|
|
93
|
+
return options.fn(this);
|
|
94
|
+
} else {
|
|
95
|
+
return options.inverse(this);
|
|
96
|
+
}
|
|
97
|
+
}); // register a "get property" helper
|
|
98
|
+
// it gets the named property from the provided context
|
|
186
99
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
100
|
+
hb.registerHelper('property', function (name, context) {
|
|
101
|
+
return context[name] || '';
|
|
102
|
+
}); // register an 'includes' helper
|
|
103
|
+
// it checks if value is in array
|
|
191
104
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
};
|
|
105
|
+
hb.registerHelper('includes', function (haystack, needle, options) {
|
|
106
|
+
if (_.contains(haystack, needle)) {
|
|
107
|
+
return options.fn(this);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!Helpers0.__initialized) {
|
|
113
|
+
Helpers0(Handlebars);
|
|
114
|
+
Helpers0.__initialized = true;
|
|
115
|
+
}
|
|
116
|
+
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
117
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
|
118
|
+
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
119
|
+
var buffer = "", stack1, helper, options, functionType="function", escapeExpression=this.escapeExpression, helperMissing=helpers.helperMissing;
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
buffer += "<div class=\"feedback-";
|
|
123
|
+
if (helper = helpers.level) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
124
|
+
else { helper = (depth0 && depth0.level); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
125
|
+
buffer += escapeExpression(stack1)
|
|
126
|
+
+ "\">\n<span class=\"icon-lock ";
|
|
127
|
+
if (helper = helpers.level) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
128
|
+
else { helper = (depth0 && depth0.level); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
129
|
+
buffer += escapeExpression(stack1)
|
|
130
|
+
+ "-color ";
|
|
131
|
+
if (helper = helpers.level) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
132
|
+
else { helper = (depth0 && depth0.level); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
133
|
+
buffer += escapeExpression(stack1)
|
|
134
|
+
+ "\"></span>\n ";
|
|
135
|
+
if (helper = helpers.msg) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
136
|
+
else { helper = (depth0 && depth0.msg); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
137
|
+
buffer += escapeExpression(stack1)
|
|
138
|
+
+ "\n <div class=\"txt-rgt button-container\">\n <button class=\"btn btn-info small check-in\"><span class=\"icon-unlock info\"></span>"
|
|
139
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Check-in", options) : helperMissing.call(depth0, "__", "Check-in", options)))
|
|
140
|
+
+ "</button>\n <button class=\"btn btn-info small release\"><span class=\"icon-result-nok info\"></span>"
|
|
141
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Release", options) : helperMissing.call(depth0, "__", "Release", options)))
|
|
142
|
+
+ "</button>\n </div>\n\n <div class=\"message-container button-container\" style=\"display: none;\">\n <label>\n "
|
|
143
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Message", options) : helperMissing.call(depth0, "__", "Message", options)))
|
|
144
|
+
+ "\n </label>\n <input type=\"text\" name=\"message\" class=\"message\">\n <button class=\"btn-info small commit\">"
|
|
145
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Commit", options) : helperMissing.call(depth0, "__", "Commit", options)))
|
|
146
|
+
+ "</button>\n </div>\n</div>\n";
|
|
147
|
+
return buffer;
|
|
148
|
+
});
|
|
149
|
+
function tpl(data, options, asString) {
|
|
150
|
+
var html = Template(data, options);
|
|
151
|
+
return (asString || true) ? html : $(html);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* This program is free software; you can redistribute it and/or
|
|
156
|
+
* modify it under the terms of the GNU General Public License
|
|
157
|
+
* as published by the Free Software Foundation; under version 2
|
|
158
|
+
* of the License (non-upgradable).
|
|
159
|
+
*
|
|
160
|
+
* This program is distributed in the hope that it will be useful,
|
|
161
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
162
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
163
|
+
* GNU General Public License for more details.
|
|
164
|
+
*
|
|
165
|
+
* You should have received a copy of the GNU General Public License
|
|
166
|
+
* along with this program; if not, write to the Free Software
|
|
167
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
168
|
+
*
|
|
169
|
+
* Copyright (c) 2015 (original work) Open Assessment Technologies SA;
|
|
170
|
+
*
|
|
171
|
+
*
|
|
172
|
+
*/
|
|
173
|
+
|
|
174
|
+
var currents = []; //contains the reference to the main lock box. We expect other containers to be only edge cases.
|
|
175
|
+
|
|
176
|
+
var $lockBox; //lock levels are divided into 2 categories
|
|
177
|
+
|
|
178
|
+
var categories = {
|
|
179
|
+
hasLock: 'info',
|
|
180
|
+
locked: 'error'
|
|
181
|
+
}; //lock's states
|
|
182
|
+
|
|
183
|
+
var states = {
|
|
184
|
+
created: 'created',
|
|
185
|
+
displayed: 'displayed',
|
|
186
|
+
closed: 'closed'
|
|
187
|
+
}; //the default options
|
|
188
|
+
|
|
189
|
+
var defaultOptions = {
|
|
190
|
+
msg: __('This resource is locked'),
|
|
191
|
+
releaseUrl: helpers._url('release', 'Lock', 'tao'),
|
|
192
|
+
commitUrl: helpers._url('commitResource', 'History', 'taoRevision')
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Object delegation. This enables us to separate the instance from Api.
|
|
196
|
+
* An instance can call methods from the API like it was it, so each object will not contain the function definition.
|
|
197
|
+
* @private
|
|
198
|
+
* @param {Object} receiver - the object that receive the methods
|
|
199
|
+
* @param {Object} provider - it provides the methods to the receiver
|
|
200
|
+
* @returns {Object} the receiver augmented by the provider's methods.
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
function delegate(receiver, provider) {
|
|
204
|
+
_(provider).functions().forEach(function delegateMethod(methodName) {
|
|
205
|
+
receiver[methodName] = function applyDelegated() {
|
|
206
|
+
return provider[methodName].apply(receiver, arguments);
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
return receiver;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* It provides the lock behavior
|
|
214
|
+
* @typedef lockApi
|
|
215
|
+
*
|
|
216
|
+
*
|
|
217
|
+
* @param {Object} [options] - the plugin options
|
|
218
|
+
* @param {String} [options.uri = ''] - The uri of the selected resource
|
|
219
|
+
* @param {String} [options.releaseUrl = ''] - The url to call to release the lock
|
|
220
|
+
* @param {String} [options.commitUrl = ''] - The url to call to commit the resource
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
var lockApi = {
|
|
225
|
+
level: null,
|
|
226
|
+
category: null,
|
|
197
227
|
|
|
198
|
-
var defaultOptions = {
|
|
199
|
-
msg: __('This resource is locked'),
|
|
200
|
-
releaseUrl: helpers._url('release', 'Lock', 'tao'),
|
|
201
|
-
commitUrl: helpers._url('commitResource', 'History', 'taoRevision')
|
|
202
|
-
};
|
|
203
228
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* @
|
|
207
|
-
* @param {
|
|
208
|
-
* @param {
|
|
209
|
-
* @
|
|
229
|
+
* generate the lock with the right options
|
|
230
|
+
*
|
|
231
|
+
* @example lock().message();
|
|
232
|
+
* @param {String} [category] - the category of the lock (hasLock or locked)
|
|
233
|
+
* @param {String} [msg] - the message to display
|
|
234
|
+
* @param {Object} [options] - the plugin options
|
|
235
|
+
* @fires create.lock
|
|
236
|
+
* @returns {lockApi}
|
|
210
237
|
*/
|
|
238
|
+
message: function message(category, msg, options) {
|
|
239
|
+
if (!category || !_.contains(_.keys(categories), category)) {
|
|
240
|
+
category = 'hasLock';
|
|
241
|
+
}
|
|
211
242
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
243
|
+
this.setState(states.created);
|
|
244
|
+
this.category = category;
|
|
245
|
+
this.level = _.result(categories, this.category);
|
|
246
|
+
this.options = _.defaults(options || {}, defaultOptions);
|
|
247
|
+
this.content = tpl({
|
|
248
|
+
level: this.level,
|
|
249
|
+
msg: msg
|
|
217
250
|
});
|
|
218
251
|
|
|
219
|
-
|
|
220
|
-
|
|
252
|
+
this._trigger('create');
|
|
253
|
+
|
|
254
|
+
return this;
|
|
255
|
+
},
|
|
256
|
+
|
|
221
257
|
/**
|
|
222
|
-
*
|
|
223
|
-
* @typedef lockApi
|
|
258
|
+
* generate the lock with the right options and open it
|
|
224
259
|
*
|
|
260
|
+
* @example lock().hasLock();
|
|
261
|
+
* @param {String} [msg] - the message to display
|
|
262
|
+
* @param {Object} [options] - the plugin options
|
|
263
|
+
* @returns {lockApi}
|
|
264
|
+
*/
|
|
265
|
+
hasLock: function hasLock(msg, options) {
|
|
266
|
+
return this.message('hasLock', msg, options).open();
|
|
267
|
+
},
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* generate the lock with the right options and open it
|
|
225
271
|
*
|
|
272
|
+
* @example lock().locked();
|
|
273
|
+
* @param {String} [msg] - the message to display
|
|
226
274
|
* @param {Object} [options] - the plugin options
|
|
227
|
-
* @
|
|
228
|
-
* @param {String} [options.releaseUrl = ''] - The url to call to release the lock
|
|
229
|
-
* @param {String} [options.commitUrl = ''] - The url to call to commit the resource
|
|
275
|
+
* @returns {lockApi}
|
|
230
276
|
*/
|
|
277
|
+
locked: function locked(msg, options) {
|
|
278
|
+
return this.message('locked', msg, options).open();
|
|
279
|
+
},
|
|
231
280
|
|
|
281
|
+
/**
|
|
282
|
+
* open the lock
|
|
283
|
+
* @example lock().message().open();
|
|
284
|
+
* @fires open.lock
|
|
285
|
+
* @returns {lockApi}
|
|
286
|
+
*/
|
|
287
|
+
open: function open() {
|
|
288
|
+
this._trigger('open'); // display me
|
|
232
289
|
|
|
233
|
-
var lockApi = {
|
|
234
|
-
level: null,
|
|
235
|
-
category: null,
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* generate the lock with the right options
|
|
239
|
-
*
|
|
240
|
-
* @example lock().message();
|
|
241
|
-
* @param {String} [category] - the category of the lock (hasLock or locked)
|
|
242
|
-
* @param {String} [msg] - the message to display
|
|
243
|
-
* @param {Object} [options] - the plugin options
|
|
244
|
-
* @fires create.lock
|
|
245
|
-
* @returns {lockApi}
|
|
246
|
-
*/
|
|
247
|
-
message: function message(category, msg, options) {
|
|
248
|
-
if (!category || !_.contains(_.keys(categories), category)) {
|
|
249
|
-
category = 'hasLock';
|
|
250
|
-
}
|
|
251
290
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
291
|
+
this.display();
|
|
292
|
+
return this;
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* close the lock
|
|
297
|
+
* @example lock().close();
|
|
298
|
+
* @fires close.lock
|
|
299
|
+
*/
|
|
300
|
+
close: function close() {
|
|
301
|
+
if (this.isInState(states.displayed)) {
|
|
302
|
+
this.setState(states.closed);
|
|
303
|
+
$$1('#' + this.id).remove();
|
|
304
|
+
|
|
305
|
+
this._trigger('close'); //clean up ref
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
_.remove(currents, {
|
|
309
|
+
_state: states.closed
|
|
259
310
|
});
|
|
311
|
+
}
|
|
312
|
+
},
|
|
260
313
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
* @example lock().hasLock();
|
|
270
|
-
* @param {String} [msg] - the message to display
|
|
271
|
-
* @param {Object} [options] - the plugin options
|
|
272
|
-
* @returns {lockApi}
|
|
273
|
-
*/
|
|
274
|
-
hasLock: function hasLock(msg, options) {
|
|
275
|
-
return this.message('hasLock', msg, options).open();
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* generate the lock with the right options and open it
|
|
280
|
-
*
|
|
281
|
-
* @example lock().locked();
|
|
282
|
-
* @param {String} [msg] - the message to display
|
|
283
|
-
* @param {Object} [options] - the plugin options
|
|
284
|
-
* @returns {lockApi}
|
|
285
|
-
*/
|
|
286
|
-
locked: function locked(msg, options) {
|
|
287
|
-
return this.message('locked', msg, options).open();
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* open the lock
|
|
292
|
-
* @example lock().message().open();
|
|
293
|
-
* @fires open.lock
|
|
294
|
-
* @returns {lockApi}
|
|
295
|
-
*/
|
|
296
|
-
open: function open() {
|
|
297
|
-
this._trigger('open'); // display me
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
this.display();
|
|
301
|
-
return this;
|
|
302
|
-
},
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* close the lock
|
|
306
|
-
* @example lock().close();
|
|
307
|
-
* @fires close.lock
|
|
308
|
-
*/
|
|
309
|
-
close: function close() {
|
|
310
|
-
if (this.isInState(states.displayed)) {
|
|
311
|
-
this.setState(states.closed);
|
|
312
|
-
$$1('#' + this.id).remove();
|
|
313
|
-
|
|
314
|
-
this._trigger('close'); //clean up ref
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
_.remove(currents, {
|
|
318
|
-
_state: states.closed
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* display the lock
|
|
325
|
-
* @example lock().display();
|
|
326
|
-
* @fires display.lock
|
|
327
|
-
* @returns {lockApi}
|
|
328
|
-
*/
|
|
329
|
-
display: function display() {
|
|
330
|
-
var self = this;
|
|
331
|
-
|
|
332
|
-
if (self.content) {
|
|
333
|
-
self.setState(states.displayed);
|
|
334
|
-
$$1(self.content).attr('id', self.id).appendTo(self._container);
|
|
335
|
-
|
|
336
|
-
self._trigger('display');
|
|
337
|
-
|
|
338
|
-
if (typeof this.options.uri === 'undefined') {
|
|
339
|
-
$$1('.release', self._container).hide();
|
|
340
|
-
$$1('.check-in', self._container).hide();
|
|
341
|
-
} else {
|
|
342
|
-
$$1('.release', self._container).on('click', function () {
|
|
343
|
-
self.release();
|
|
344
|
-
});
|
|
345
|
-
$$1('.check-in', self._container).on('click', function () {
|
|
346
|
-
self.commit();
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
}
|
|
314
|
+
/**
|
|
315
|
+
* display the lock
|
|
316
|
+
* @example lock().display();
|
|
317
|
+
* @fires display.lock
|
|
318
|
+
* @returns {lockApi}
|
|
319
|
+
*/
|
|
320
|
+
display: function display() {
|
|
321
|
+
var self = this;
|
|
350
322
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* call the url to release the lock
|
|
356
|
-
* @example lock().release();
|
|
357
|
-
* @fires released.lock
|
|
358
|
-
* @fires failed.lock
|
|
359
|
-
* @returns {lockApi}
|
|
360
|
-
*/
|
|
361
|
-
release: function release() {
|
|
362
|
-
var self = this;
|
|
363
|
-
|
|
364
|
-
if (self.options.releaseUrl !== '') {
|
|
365
|
-
$$1.ajax({
|
|
366
|
-
url: self.options.releaseUrl,
|
|
367
|
-
type: 'POST',
|
|
368
|
-
data: {
|
|
369
|
-
uri: self.options.uri
|
|
370
|
-
},
|
|
371
|
-
dataType: 'json',
|
|
372
|
-
success: function (response) {
|
|
373
|
-
if (response.success) {
|
|
374
|
-
self._trigger('released', response);
|
|
375
|
-
} else {
|
|
376
|
-
self._trigger('failed', response);
|
|
377
|
-
}
|
|
378
|
-
},
|
|
379
|
-
error: function () {
|
|
380
|
-
self._trigger('failed');
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
} else {
|
|
384
|
-
self._trigger('failed');
|
|
385
|
-
}
|
|
323
|
+
if (self.content) {
|
|
324
|
+
self.setState(states.displayed);
|
|
325
|
+
$$1(self.content).attr('id', self.id).appendTo(self._container);
|
|
386
326
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
* @example lock().commit();
|
|
393
|
-
* @fires commit.lock
|
|
394
|
-
* @returns {lockApi}
|
|
395
|
-
*/
|
|
396
|
-
commit: function commit() {
|
|
397
|
-
var self = this;
|
|
398
|
-
|
|
399
|
-
if (self.options.commitUrl !== '') {
|
|
400
|
-
$$1('.message-container', self._container).slideToggle();
|
|
401
|
-
$$1('.commit', self._container).off('click').on('click', function () {
|
|
402
|
-
var message = $$1('.message', self._container).val();
|
|
403
|
-
|
|
404
|
-
if (message !== '') {
|
|
405
|
-
$$1.ajax({
|
|
406
|
-
url: self.options.commitUrl,
|
|
407
|
-
type: 'POST',
|
|
408
|
-
data: {
|
|
409
|
-
id: self.options.uri,
|
|
410
|
-
message: message
|
|
411
|
-
},
|
|
412
|
-
dataType: 'json',
|
|
413
|
-
success: function (response) {
|
|
414
|
-
if (response.success) {
|
|
415
|
-
self._trigger('committed', response);
|
|
416
|
-
} else {
|
|
417
|
-
self._trigger('failed', response);
|
|
418
|
-
}
|
|
419
|
-
},
|
|
420
|
-
error: function () {
|
|
421
|
-
self._trigger('failed');
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
} else {
|
|
425
|
-
self._trigger('failed', {
|
|
426
|
-
message: __('Please give a message to your commit')
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
});
|
|
327
|
+
self._trigger('display');
|
|
328
|
+
|
|
329
|
+
if (typeof this.options.uri === 'undefined') {
|
|
330
|
+
$$1('.release', self._container).hide();
|
|
331
|
+
$$1('.check-in', self._container).hide();
|
|
430
332
|
} else {
|
|
431
|
-
self.
|
|
333
|
+
$$1('.release', self._container).on('click', function () {
|
|
334
|
+
self.release();
|
|
335
|
+
});
|
|
336
|
+
$$1('.check-in', self._container).on('click', function () {
|
|
337
|
+
self.commit();
|
|
338
|
+
});
|
|
432
339
|
}
|
|
340
|
+
}
|
|
433
341
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* Default behaviour
|
|
439
|
-
*/
|
|
440
|
-
register: function () {
|
|
441
|
-
var msg = this._container.data('msg') || defaultOptions.msg;
|
|
442
|
-
|
|
443
|
-
var id = this._container.data('id');
|
|
342
|
+
return self;
|
|
343
|
+
},
|
|
444
344
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
345
|
+
/**
|
|
346
|
+
* call the url to release the lock
|
|
347
|
+
* @example lock().release();
|
|
348
|
+
* @fires released.lock
|
|
349
|
+
* @fires failed.lock
|
|
350
|
+
* @returns {lockApi}
|
|
351
|
+
*/
|
|
352
|
+
release: function release() {
|
|
353
|
+
var self = this;
|
|
354
|
+
|
|
355
|
+
if (self.options.releaseUrl !== '') {
|
|
356
|
+
$$1.ajax({
|
|
357
|
+
url: self.options.releaseUrl,
|
|
358
|
+
type: 'POST',
|
|
359
|
+
data: {
|
|
360
|
+
uri: self.options.uri
|
|
454
361
|
},
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
362
|
+
dataType: 'json',
|
|
363
|
+
success: function success(response) {
|
|
364
|
+
if (response.success) {
|
|
365
|
+
self._trigger('released', response);
|
|
458
366
|
} else {
|
|
459
|
-
|
|
367
|
+
self._trigger('failed', response);
|
|
460
368
|
}
|
|
369
|
+
},
|
|
370
|
+
error: function error() {
|
|
371
|
+
self._trigger('failed');
|
|
461
372
|
}
|
|
462
|
-
})
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
* trigger the event and the callback if exists
|
|
467
|
-
* @param {String} [eventName] - the name of the event, use the caller name if not set
|
|
468
|
-
*/
|
|
469
|
-
_trigger: function _trigger(eventName, data) {
|
|
470
|
-
//trigger the related event
|
|
471
|
-
this._container.trigger(eventName + '.lock', [this]); //run the callback if set in options
|
|
373
|
+
});
|
|
374
|
+
} else {
|
|
375
|
+
self._trigger('failed');
|
|
376
|
+
}
|
|
472
377
|
|
|
378
|
+
return this;
|
|
379
|
+
},
|
|
473
380
|
|
|
474
|
-
if (_.isFunction(this.options[eventName])) {
|
|
475
|
-
this.options[eventName].call(this, data);
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
381
|
/**
|
|
480
|
-
*
|
|
481
|
-
* @
|
|
382
|
+
* ask a message and call the url to commit the resource
|
|
383
|
+
* @example lock().commit();
|
|
384
|
+
* @fires commit.lock
|
|
385
|
+
* @returns {lockApi}
|
|
482
386
|
*/
|
|
387
|
+
commit: function commit() {
|
|
388
|
+
var self = this;
|
|
389
|
+
|
|
390
|
+
if (self.options.commitUrl !== '') {
|
|
391
|
+
$$1('.message-container', self._container).slideToggle();
|
|
392
|
+
$$1('.commit', self._container).off('click').on('click', function () {
|
|
393
|
+
var message = $$1('.message', self._container).val();
|
|
394
|
+
|
|
395
|
+
if (message !== '') {
|
|
396
|
+
$$1.ajax({
|
|
397
|
+
url: self.options.commitUrl,
|
|
398
|
+
type: 'POST',
|
|
399
|
+
data: {
|
|
400
|
+
id: self.options.uri,
|
|
401
|
+
message: message
|
|
402
|
+
},
|
|
403
|
+
dataType: 'json',
|
|
404
|
+
success: function success(response) {
|
|
405
|
+
if (response.success) {
|
|
406
|
+
self._trigger('committed', response);
|
|
407
|
+
} else {
|
|
408
|
+
self._trigger('failed', response);
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
error: function error() {
|
|
412
|
+
self._trigger('failed');
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
} else {
|
|
416
|
+
self._trigger('failed', {
|
|
417
|
+
message: __('Please give a message to your commit')
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
} else {
|
|
422
|
+
self._trigger('failed');
|
|
423
|
+
}
|
|
483
424
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
_state: null,
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Check if the current state is one of the given values
|
|
490
|
-
* @param {String|Array} verify - the statue to check
|
|
491
|
-
* @returns {Boolean} true if the object is in the state to verify
|
|
492
|
-
*/
|
|
493
|
-
isInState: function isInState(verify) {
|
|
494
|
-
if (_.isString(verify)) {
|
|
495
|
-
verify = [verify];
|
|
496
|
-
}
|
|
425
|
+
return this;
|
|
426
|
+
},
|
|
497
427
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
428
|
+
/**
|
|
429
|
+
* Default behaviour
|
|
430
|
+
*/
|
|
431
|
+
register: function register() {
|
|
432
|
+
var msg = this._container.data('msg') || defaultOptions.msg;
|
|
433
|
+
|
|
434
|
+
var id = this._container.data('id');
|
|
435
|
+
|
|
436
|
+
return this.message('hasLock', msg, {
|
|
437
|
+
uri: id,
|
|
438
|
+
released: function released(response) {
|
|
439
|
+
feedback().success(response.message);
|
|
440
|
+
this.close();
|
|
441
|
+
},
|
|
442
|
+
committed: function committed(response) {
|
|
443
|
+
feedback().success(response.commitMessage);
|
|
444
|
+
this.close();
|
|
445
|
+
},
|
|
446
|
+
failed: function failed(response) {
|
|
447
|
+
if (typeof response !== 'undefined' && typeof response.message !== 'undefined') {
|
|
448
|
+
feedback().error(response.message);
|
|
449
|
+
} else {
|
|
450
|
+
feedback().error('Unknown Error');
|
|
451
|
+
}
|
|
509
452
|
}
|
|
453
|
+
}).open();
|
|
454
|
+
},
|
|
510
455
|
|
|
511
|
-
|
|
456
|
+
/**
|
|
457
|
+
* trigger the event and the callback if exists
|
|
458
|
+
* @param {String} [eventName] - the name of the event, use the caller name if not set
|
|
459
|
+
*/
|
|
460
|
+
_trigger: function _trigger(eventName, data) {
|
|
461
|
+
//trigger the related event
|
|
462
|
+
this._container.trigger(eventName + '.lock', [this]); //run the callback if set in options
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
if (_.isFunction(this.options[eventName])) {
|
|
466
|
+
this.options[eventName].call(this, data);
|
|
512
467
|
}
|
|
513
|
-
}
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
/**
|
|
471
|
+
* Contains the current state of the lock and accessors
|
|
472
|
+
* @typedef lockState
|
|
473
|
+
*/
|
|
474
|
+
|
|
475
|
+
var lockState = {
|
|
476
|
+
//the current state
|
|
477
|
+
_state: null,
|
|
478
|
+
|
|
514
479
|
/**
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
* @
|
|
518
|
-
* @param {jQUeryElement} [$container] - only to specify another container
|
|
519
|
-
* @returns {Object} the lock object
|
|
520
|
-
* @throws {Error} if the container isn't found
|
|
480
|
+
* Check if the current state is one of the given values
|
|
481
|
+
* @param {String|Array} verify - the statue to check
|
|
482
|
+
* @returns {Boolean} true if the object is in the state to verify
|
|
521
483
|
*/
|
|
484
|
+
isInState: function isInState(verify) {
|
|
485
|
+
if (_.isString(verify)) {
|
|
486
|
+
verify = [verify];
|
|
487
|
+
}
|
|
522
488
|
|
|
523
|
-
|
|
524
|
-
|
|
489
|
+
return _.contains(verify, this._state);
|
|
490
|
+
},
|
|
525
491
|
|
|
526
|
-
|
|
527
|
-
|
|
492
|
+
/**
|
|
493
|
+
* Change the current state
|
|
494
|
+
* @param {String} state - the new state
|
|
495
|
+
* @throws {Error} if we try to set an invalid state
|
|
496
|
+
*/
|
|
497
|
+
setState: function setState(state) {
|
|
498
|
+
if (!_.contains(states, state)) {
|
|
499
|
+
throw new Error('Unkown state ' + state);
|
|
528
500
|
}
|
|
529
501
|
|
|
530
|
-
|
|
502
|
+
this._state = state;
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
/**
|
|
506
|
+
* Enables you to create a new lock.
|
|
507
|
+
* example lock().error("content");
|
|
508
|
+
* @exports ui/lock
|
|
509
|
+
* @param {jQUeryElement} [$container] - only to specify another container
|
|
510
|
+
* @returns {Object} the lock object
|
|
511
|
+
* @throws {Error} if the container isn't found
|
|
512
|
+
*/
|
|
513
|
+
|
|
514
|
+
var lockFactory = function lockFactory($container) {
|
|
515
|
+
var _container;
|
|
516
|
+
|
|
517
|
+
if (!$container) {
|
|
518
|
+
$lockBox = $$1('#lock-box');
|
|
519
|
+
}
|
|
531
520
|
|
|
532
|
-
|
|
533
|
-
throw new Error('The lock needs to belong to an existing container');
|
|
534
|
-
} //if there is already a lock component in this container close it and open a new one
|
|
521
|
+
_container = $container || $lockBox;
|
|
535
522
|
|
|
523
|
+
if (!_container || !_container.length) {
|
|
524
|
+
throw new Error('The lock needs to belong to an existing container');
|
|
525
|
+
} //if there is already a lock component in this container close it and open a new one
|
|
536
526
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
}
|
|
527
|
+
|
|
528
|
+
_.forEach(currents, function (lockRef) {
|
|
529
|
+
if (lockRef !== null && lockRef._container.get(0) === _container.get(0)) {
|
|
530
|
+
lockRef.close();
|
|
531
|
+
}
|
|
532
|
+
}); //mixin the new object with the state object
|
|
542
533
|
|
|
543
534
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
535
|
+
var lk = _.extend({
|
|
536
|
+
id: 'lock-' + (currents.length + 1),
|
|
537
|
+
_container: _container
|
|
538
|
+
}, lockState);
|
|
548
539
|
|
|
549
|
-
|
|
540
|
+
currents.push(lk); //delegate the api calls to the new instance
|
|
550
541
|
|
|
551
|
-
|
|
552
|
-
|
|
542
|
+
return delegate(lk, lockApi);
|
|
543
|
+
};
|
|
553
544
|
|
|
554
|
-
|
|
545
|
+
return lockFactory;
|
|
555
546
|
|
|
556
547
|
});
|