@oat-sa/tao-core-ui 1.58.1 → 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 +26 -19
- 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 +114 -91
- 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/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 +4 -0
- package/src/itemButtonList/css/item-button-list.css +1 -0
- package/src/itemButtonList/css/item-button-list.css.map +1 -1
- package/src/.DS_Store +0 -0
- package/src/css/basic.css +0 -7826
- package/src/css/basic.css.map +0 -1
- package/src/css/ckeditor/skins/tao/css/dialog.css +0 -950
- package/src/css/ckeditor/skins/tao/css/dialog.css.map +0 -1
- package/src/css/ckeditor/skins/tao/css/editor.css +0 -1850
- package/src/css/ckeditor/skins/tao/css/editor.css.map +0 -1
- package/src/scss/.DS_Store +0 -0
- package/src/scss/basic.scss +0 -16
- package/src/scss/ckeditor/skins/tao/scss/dialog.scss +0 -763
- package/src/scss/ckeditor/skins/tao/scss/editor.scss +0 -111
- package/src/scss/ckeditor/skins/tao/scss/inc/_ck-icons.scss +0 -59
- package/src/scss/ckeditor/skins/tao/scss/inc/_colorpanel.scss +0 -118
- package/src/scss/ckeditor/skins/tao/scss/inc/_elementspath.scss +0 -69
- package/src/scss/ckeditor/skins/tao/scss/inc/_mainui.scss +0 -194
- package/src/scss/ckeditor/skins/tao/scss/inc/_menu.scss +0 -181
- package/src/scss/ckeditor/skins/tao/scss/inc/_panel.scss +0 -200
- package/src/scss/ckeditor/skins/tao/scss/inc/_presets.scss +0 -32
- package/src/scss/ckeditor/skins/tao/scss/inc/_reset.scss +0 -101
- package/src/scss/ckeditor/skins/tao/scss/inc/_richcombo.scss +0 -213
- package/src/scss/ckeditor/skins/tao/scss/inc/_tao.scss +0 -59
- package/src/scss/ckeditor/skins/tao/scss/inc/_toolbar.scss +0 -301
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot.b64 +0 -1
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff +0 -0
- package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff.b64 +0 -1
- package/src/scss/font/tao/tao.eot +0 -0
- package/src/scss/font/tao/tao.svg +0 -235
- package/src/scss/font/tao/tao.ttf +0 -0
- package/src/scss/font/tao/tao.woff +0 -0
- package/src/scss/inc/_base.scss +0 -496
- package/src/scss/inc/_bootstrap.scss +0 -6
- package/src/scss/inc/_buttons.scss +0 -114
- package/src/scss/inc/_colors.scss +0 -88
- package/src/scss/inc/_feedback.scss +0 -150
- package/src/scss/inc/_flex-grid.scss +0 -15
- package/src/scss/inc/_fonts.scss +0 -4
- package/src/scss/inc/_forms.scss +0 -827
- package/src/scss/inc/_functions.scss +0 -283
- package/src/scss/inc/_grid.scss +0 -66
- package/src/scss/inc/_jquery.nouislider.scss +0 -254
- package/src/scss/inc/_normalize.scss +0 -528
- package/src/scss/inc/_report.scss +0 -68
- package/src/scss/inc/_secondary-properties.scss +0 -89
- package/src/scss/inc/_select2.scss +0 -634
- package/src/scss/inc/_toolbars.scss +0 -155
- package/src/scss/inc/_tooltip.scss +0 -312
- package/src/scss/inc/_variables.scss +0 -21
- package/src/scss/inc/base/_highlight.scss +0 -5
- package/src/scss/inc/base/_list-style.scss +0 -59
- package/src/scss/inc/base/_svg.scss +0 -3
- package/src/scss/inc/base/_table.scss +0 -63
- package/src/scss/inc/fonts/_source-sans-pro.scss +0 -29
- package/src/scss/inc/fonts/_tao-icon-classes.scss +0 -226
- package/src/scss/inc/fonts/_tao-icon-def.scss +0 -12
- package/src/scss/inc/fonts/_tao-icon-vars.scss +0 -240
package/dist/deleter.js
CHANGED
|
@@ -1,440 +1,431 @@
|
|
|
1
1
|
define(['jquery', 'lodash', 'i18n', 'core/pluginifier', 'core/dataattrhandler', 'handlebars', 'lib/dompurify/purify'], function ($$1, _, __, Pluginifier, DataAttrHandler, Handlebars, DOMPurify) { '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
|
+
Pluginifier = Pluginifier && Object.prototype.hasOwnProperty.call(Pluginifier, 'default') ? Pluginifier['default'] : Pluginifier;
|
|
7
|
+
DataAttrHandler = DataAttrHandler && Object.prototype.hasOwnProperty.call(DataAttrHandler, 'default') ? DataAttrHandler['default'] : DataAttrHandler;
|
|
8
|
+
Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
|
|
9
|
+
DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
|
|
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
33
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
*/
|
|
77
45
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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 : '"';
|
|
81
51
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//it also adds a local variable "i" as the index in each iteration loop
|
|
52
|
+
_.forIn(arr, function (value, key) {
|
|
53
|
+
var fragment = '';
|
|
85
54
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
value = '';
|
|
63
|
+
}
|
|
91
64
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
i: i
|
|
95
|
-
}));
|
|
65
|
+
if (keyValueGlue !== undefined) {
|
|
66
|
+
fragment += key + keyValueGlue;
|
|
96
67
|
}
|
|
97
68
|
|
|
98
|
-
|
|
69
|
+
fragment += wrapper + value + wrapper;
|
|
70
|
+
fragments.push(fragment);
|
|
99
71
|
});
|
|
100
|
-
hb.registerHelper('equal', function (var1, var2, options) {
|
|
101
|
-
if (var1 == var2) {
|
|
102
|
-
return options.fn(this);
|
|
103
|
-
} else {
|
|
104
|
-
return options.inverse(this);
|
|
105
|
-
}
|
|
106
|
-
}); // register a "get property" helper
|
|
107
|
-
// it gets the named property from the provided context
|
|
108
72
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
// it checks if value is in array
|
|
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
|
|
113
76
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
77
|
+
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
78
|
+
var ret = '';
|
|
79
|
+
startIndex = parseInt(startIndex);
|
|
80
|
+
stopIndex = parseInt(stopIndex);
|
|
81
|
+
increment = parseInt(increment);
|
|
120
82
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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=\"undobox\">\n <span class=\"icon-info\"></span>\n ";
|
|
132
|
-
if (helper = helpers.undoMessage) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
133
|
-
else { helper = (depth0 && depth0.undoMessage); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
134
|
-
buffer += escapeExpression(stack1)
|
|
135
|
-
+ "\n <a class=\"undo\" href=\"#\">"
|
|
136
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Undo", options) : helperMissing.call(depth0, "__", "Undo", options)))
|
|
137
|
-
+ "</a>\n <span title=\""
|
|
138
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Remove Message", options) : helperMissing.call(depth0, "__", "Remove Message", options)))
|
|
139
|
-
+ "\" class=\"icon-close\" data-close=\":parent .undobox\"></span>\n</div>\n";
|
|
140
|
-
return buffer;
|
|
141
|
-
});
|
|
142
|
-
function undoTmpl(data, options, asString) {
|
|
143
|
-
var html = Template(data, options);
|
|
144
|
-
return (asString || true) ? html : $(html);
|
|
145
|
-
}
|
|
83
|
+
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
84
|
+
ret += options.fn(_.extend({}, this, {
|
|
85
|
+
i: i
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
146
88
|
|
|
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
|
|
99
|
+
|
|
100
|
+
hb.registerHelper('property', function (name, context) {
|
|
101
|
+
return context[name] || '';
|
|
102
|
+
}); // register an 'includes' helper
|
|
103
|
+
// it checks if value is in array
|
|
104
|
+
|
|
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=\"undobox\">\n <span class=\"icon-info\"></span>\n ";
|
|
123
|
+
if (helper = helpers.undoMessage) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
124
|
+
else { helper = (depth0 && depth0.undoMessage); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
125
|
+
buffer += escapeExpression(stack1)
|
|
126
|
+
+ "\n <a class=\"undo\" href=\"#\">"
|
|
127
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Undo", options) : helperMissing.call(depth0, "__", "Undo", options)))
|
|
128
|
+
+ "</a>\n <span title=\""
|
|
129
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Remove Message", options) : helperMissing.call(depth0, "__", "Remove Message", options)))
|
|
130
|
+
+ "\" class=\"icon-close\" data-close=\":parent .undobox\"></span>\n</div>\n";
|
|
131
|
+
return buffer;
|
|
132
|
+
});
|
|
133
|
+
function undoTmpl(data, options, asString) {
|
|
134
|
+
var html = Template(data, options);
|
|
135
|
+
return (asString || true) ? html : $(html);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @author Bertrand Chevrier <bertrand@taotesting.com>
|
|
140
|
+
* @requires jquery
|
|
141
|
+
* @requires core/pluginifier
|
|
142
|
+
* @requires core/dataattrhandler
|
|
143
|
+
*/
|
|
144
|
+
var ns = 'deleter';
|
|
145
|
+
var dataNs = 'ui.' + ns;
|
|
146
|
+
var defaults = {
|
|
147
|
+
bindEvent: 'click',
|
|
148
|
+
undo: false,
|
|
149
|
+
undoTimeout: 5000,
|
|
150
|
+
undoMessage: __('Element deleted.'),
|
|
151
|
+
undoContainer: false,
|
|
152
|
+
confirm: false,
|
|
153
|
+
confirmMessage: __('Are you sure you want to delete it?'),
|
|
154
|
+
disableClass: 'disabled'
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* The deleter component, that helps you to close a new element.
|
|
158
|
+
* @exports ui/deleter
|
|
159
|
+
*/
|
|
160
|
+
|
|
161
|
+
var deleter = {
|
|
147
162
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* @
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
* The deleter component, that helps you to close a new element.
|
|
167
|
-
* @exports ui/deleter
|
|
163
|
+
* Initialize the plugin.
|
|
164
|
+
*
|
|
165
|
+
* Called the jQuery way once registered by the Pluginifier.
|
|
166
|
+
* @example $('selector').deleter({target : $('target')});
|
|
167
|
+
* @public
|
|
168
|
+
*
|
|
169
|
+
* @constructor
|
|
170
|
+
* @param {Object} options - the plugin options
|
|
171
|
+
* @param {jQueryElement} options.target - the element to close
|
|
172
|
+
* @param {string|boolean} [options.bindEvent = 'click'] - the event that trigger the close
|
|
173
|
+
* @param {Boolean} [options.undo = false] - enable to undo the deletion
|
|
174
|
+
* @param {Number} [options.undoTimeout = 5000] - the time the undo remains available
|
|
175
|
+
* @param {String} [options.undoMessage = '...'] - the message to display in the undo box
|
|
176
|
+
* @param {String|jQueryElement} [options.undoContainer = 'body'] - the element that will contain the undo box
|
|
177
|
+
* @param {boolean} [options.confirm = false] - display a popup to confirm the closing
|
|
178
|
+
* @param {string} [options.confirmMessage = '...'] - the confirmation message
|
|
179
|
+
* @fires deleter#create.deleter
|
|
180
|
+
* @returns {jQueryElement} for chaining
|
|
168
181
|
*/
|
|
182
|
+
init: function init(options) {
|
|
183
|
+
options = _.defaults(options, defaults);
|
|
184
|
+
return this.each(function () {
|
|
185
|
+
var $elt = $$1(this);
|
|
169
186
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
* Called the jQuery way once registered by the Pluginifier.
|
|
175
|
-
* @example $('selector').deleter({target : $('target')});
|
|
176
|
-
* @public
|
|
177
|
-
*
|
|
178
|
-
* @constructor
|
|
179
|
-
* @param {Object} options - the plugin options
|
|
180
|
-
* @param {jQueryElement} options.target - the element to close
|
|
181
|
-
* @param {string|boolean} [options.bindEvent = 'click'] - the event that trigger the close
|
|
182
|
-
* @param {Boolean} [options.undo = false] - enable to undo the deletion
|
|
183
|
-
* @param {Number} [options.undoTimeout = 5000] - the time the undo remains available
|
|
184
|
-
* @param {String} [options.undoMessage = '...'] - the message to display in the undo box
|
|
185
|
-
* @param {String|jQueryElement} [options.undoContainer = 'body'] - the element that will contain the undo box
|
|
186
|
-
* @param {boolean} [options.confirm = false] - display a popup to confirm the closing
|
|
187
|
-
* @param {string} [options.confirmMessage = '...'] - the confirmation message
|
|
188
|
-
* @fires deleter#create.deleter
|
|
189
|
-
* @returns {jQueryElement} for chaining
|
|
190
|
-
*/
|
|
191
|
-
init: function (options) {
|
|
192
|
-
options = _.defaults(options, defaults);
|
|
193
|
-
return this.each(function () {
|
|
194
|
-
var $elt = $$1(this);
|
|
195
|
-
|
|
196
|
-
if (!$elt.data(dataNs)) {
|
|
197
|
-
//add data to the element
|
|
198
|
-
$elt.data(dataNs, options); //bind an event to trigger the close
|
|
199
|
-
|
|
200
|
-
if (options.bindEvent !== false) {
|
|
201
|
-
$elt.on(options.bindEvent, function (e) {
|
|
202
|
-
e.preventDefault();
|
|
203
|
-
|
|
204
|
-
deleter._delete($elt);
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* The plugin have been created.
|
|
209
|
-
* @event deleter#create.deleter
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
$elt.trigger('create.' + ns);
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Trigger the delete.
|
|
220
|
-
*
|
|
221
|
-
* Called the jQuery way once registered by the Pluginifier.
|
|
222
|
-
* @example $('selector').closer('close');
|
|
223
|
-
* @param {jQueryElement} $elt - plugin's element
|
|
224
|
-
* @fires deleter#delete.deleter
|
|
225
|
-
* @fires delete
|
|
226
|
-
* @fires deleter#deleted.deleter
|
|
227
|
-
* @fires deleted
|
|
228
|
-
* @fires deleter#undo.deleter
|
|
229
|
-
*/
|
|
230
|
-
_delete: function ($elt) {
|
|
231
|
-
var self = deleter;
|
|
232
|
-
var performDelete = true;
|
|
233
|
-
var $target, $parent, $evtTrigger, $placeholder, $undoBox;
|
|
234
|
-
var options = $elt.data(dataNs);
|
|
235
|
-
var undoRemove, timeout;
|
|
187
|
+
if (!$elt.data(dataNs)) {
|
|
188
|
+
//add data to the element
|
|
189
|
+
$elt.data(dataNs, options); //bind an event to trigger the close
|
|
236
190
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* The target has been closed/removed.
|
|
242
|
-
* @event deleter#deleted.deleter
|
|
243
|
-
*/
|
|
191
|
+
if (options.bindEvent !== false) {
|
|
192
|
+
$elt.on(options.bindEvent, function (e) {
|
|
193
|
+
e.preventDefault();
|
|
244
194
|
|
|
245
|
-
|
|
195
|
+
deleter._delete($elt);
|
|
196
|
+
});
|
|
246
197
|
}
|
|
247
|
-
|
|
198
|
+
/**
|
|
199
|
+
* The plugin have been created.
|
|
200
|
+
* @event deleter#create.deleter
|
|
201
|
+
*/
|
|
248
202
|
|
|
249
|
-
if (options && !$elt.hasClass(options.disableClass)) {
|
|
250
|
-
$target = options.target;
|
|
251
203
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
204
|
+
$elt.trigger('create.' + ns);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
},
|
|
255
208
|
|
|
256
|
-
|
|
257
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Trigger the delete.
|
|
211
|
+
*
|
|
212
|
+
* Called the jQuery way once registered by the Pluginifier.
|
|
213
|
+
* @example $('selector').closer('close');
|
|
214
|
+
* @param {jQueryElement} $elt - plugin's element
|
|
215
|
+
* @fires deleter#delete.deleter
|
|
216
|
+
* @fires delete
|
|
217
|
+
* @fires deleter#deleted.deleter
|
|
218
|
+
* @fires deleted
|
|
219
|
+
* @fires deleter#undo.deleter
|
|
220
|
+
*/
|
|
221
|
+
_delete: function _delete($elt) {
|
|
222
|
+
var self = deleter;
|
|
223
|
+
var performDelete = true;
|
|
224
|
+
var $target, $parent, $evtTrigger, $placeholder, $undoBox;
|
|
225
|
+
var options = $elt.data(dataNs);
|
|
226
|
+
var undoRemove, timeout;
|
|
227
|
+
|
|
228
|
+
var realRemove = function realRemove() {
|
|
229
|
+
if (performDelete && $target) {
|
|
230
|
+
$target.remove();
|
|
231
|
+
/**
|
|
232
|
+
* The target has been closed/removed.
|
|
233
|
+
* @event deleter#deleted.deleter
|
|
234
|
+
*/
|
|
258
235
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
* Those eventes are fired just before the removal
|
|
263
|
-
* to be able to listen them
|
|
264
|
-
* (if $elt is inside the closed elt for instance)
|
|
265
|
-
* @event deleter#deleted.deleter
|
|
266
|
-
* @param {jQueryElement} $target - the element being closed/removed
|
|
267
|
-
*/
|
|
236
|
+
$evtTrigger.trigger('deleted.' + ns, [$target]);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
268
239
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
//create a placeholder to retrieve the target position in case of undo
|
|
240
|
+
if (options && !$elt.hasClass(options.disableClass)) {
|
|
241
|
+
$target = options.target;
|
|
272
242
|
|
|
273
|
-
|
|
274
|
-
|
|
243
|
+
if (options.confirm === true) {
|
|
244
|
+
performDelete = window.confirm(options.confirmMessage);
|
|
245
|
+
}
|
|
275
246
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
$$1(document).off('.unundo.' + ns);
|
|
279
|
-
$undoBox = self._createUndoBox(options);
|
|
280
|
-
$undoBox.find('.undo').click(function (e) {
|
|
281
|
-
e.preventDefault();
|
|
247
|
+
if (performDelete) {
|
|
248
|
+
$parent = $target.parent(); //if elt is inside target, we get the parent to simulate the bubbing
|
|
282
249
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
250
|
+
$evtTrigger = $target.has($elt).length > 0 ? $parent : $elt;
|
|
251
|
+
/**
|
|
252
|
+
* The plugin is removing the target.
|
|
253
|
+
* Those eventes are fired just before the removal
|
|
254
|
+
* to be able to listen them
|
|
255
|
+
* (if $elt is inside the closed elt for instance)
|
|
256
|
+
* @event deleter#deleted.deleter
|
|
257
|
+
* @param {jQueryElement} $target - the element being closed/removed
|
|
258
|
+
*/
|
|
286
259
|
|
|
287
|
-
|
|
260
|
+
$elt.trigger('delete.' + ns, [$target]);
|
|
261
|
+
$target.trigger('delete', [options.undo]); //global event for consistensy
|
|
262
|
+
//create a placeholder to retrieve the target position in case of undo
|
|
263
|
+
|
|
264
|
+
$placeholder = $$1('<span style="display:none;" />').insertAfter($target);
|
|
265
|
+
$target.detach();
|
|
266
|
+
|
|
267
|
+
if (options.undo) {
|
|
268
|
+
//show the feedback
|
|
269
|
+
$$1(document).off('.unundo.' + ns);
|
|
270
|
+
$undoBox = self._createUndoBox(options);
|
|
271
|
+
$undoBox.find('.undo').click(function (e) {
|
|
272
|
+
e.preventDefault();
|
|
273
|
+
|
|
274
|
+
if (typeof timeout === 'number') {
|
|
275
|
+
clearTimeout(timeout);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
performDelete = false;
|
|
279
|
+
$undoBox.remove();
|
|
280
|
+
$target.insertBefore($placeholder);
|
|
281
|
+
$placeholder.remove();
|
|
282
|
+
/**
|
|
283
|
+
* The delete has been undone
|
|
284
|
+
* @event deleter#undo.deleter
|
|
285
|
+
*/
|
|
286
|
+
|
|
287
|
+
$elt.trigger('undo.' + ns, [$target]);
|
|
288
|
+
$target.trigger('undo.' + ns);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
undoRemove = function undoRemove() {
|
|
292
|
+
if ($undoBox && $undoBox.length) {
|
|
288
293
|
$undoBox.remove();
|
|
289
|
-
$target.insertBefore($placeholder);
|
|
290
294
|
$placeholder.remove();
|
|
291
|
-
|
|
292
|
-
* The delete has been undone
|
|
293
|
-
* @event deleter#undo.deleter
|
|
294
|
-
*/
|
|
295
|
-
|
|
296
|
-
$elt.trigger('undo.' + ns, [$target]);
|
|
297
|
-
$target.trigger('undo.' + ns);
|
|
298
|
-
});
|
|
295
|
+
}
|
|
299
296
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
$placeholder.remove();
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
realRemove();
|
|
307
|
-
$$1(document).off('.unundo.' + ns);
|
|
308
|
-
}; //clicking on the document force the delete
|
|
297
|
+
realRemove();
|
|
298
|
+
$$1(document).off('.unundo.' + ns);
|
|
299
|
+
}; //clicking on the document force the delete
|
|
309
300
|
|
|
310
301
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
302
|
+
$$1(document).one('mousedown.unundo.' + ns, function (e) {
|
|
303
|
+
e.preventDefault();
|
|
304
|
+
e.stopImmediatePropagation();
|
|
314
305
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
306
|
+
if (($undoBox.find(e.target).length === 0 || !$$1(e.target).hasClass('undo')) && typeof timeout === 'number') {
|
|
307
|
+
clearTimeout(timeout);
|
|
308
|
+
undoRemove();
|
|
309
|
+
} //retrigger the click then
|
|
319
310
|
|
|
320
311
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
312
|
+
_.delay(function () {
|
|
313
|
+
$$1(e.target).trigger('mousedown');
|
|
314
|
+
}, 10);
|
|
324
315
|
|
|
325
|
-
|
|
326
|
-
|
|
316
|
+
return false;
|
|
317
|
+
}); //remove the target once the atteched events may be terminated (no guaranty, this happens after in the event loop)
|
|
327
318
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
319
|
+
timeout = setTimeout(function () {
|
|
320
|
+
undoRemove();
|
|
321
|
+
}, options.undoTimeout);
|
|
322
|
+
} else {
|
|
323
|
+
realRemove();
|
|
334
324
|
}
|
|
335
325
|
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Create the undo message box
|
|
340
|
-
* @private
|
|
341
|
-
* @param {Object} options - the plugin options
|
|
342
|
-
* @returns {jQueryElement} the undo box
|
|
343
|
-
*/
|
|
344
|
-
_createUndoBox: function (options) {
|
|
345
|
-
var $undoContainer = options.undoContainer || $$1('#feedback-messages-main');
|
|
346
|
-
|
|
347
|
-
if (!$undoContainer.length) {
|
|
348
|
-
//create a global feedback container
|
|
349
|
-
$undoContainer = $$1('<div id="feedback-messages-main" class="tao-scope"></div>').appendTo('body');
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return $$1(undoTmpl(options)).appendTo($undoContainer);
|
|
353
|
-
},
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Destroy completely the plugin.
|
|
357
|
-
*
|
|
358
|
-
* Called the jQuery way once registered by the Pluginifier.
|
|
359
|
-
* @example $('selector').deleter('destroy');
|
|
360
|
-
* @public
|
|
361
|
-
* @fires deleter#destroy.deleter
|
|
362
|
-
*/
|
|
363
|
-
destroy: function () {
|
|
364
|
-
this.each(function () {
|
|
365
|
-
var $elt = $$1(this);
|
|
366
|
-
var options = $elt.data(dataNs);
|
|
367
|
-
|
|
368
|
-
if (options.bindEvent !== false) {
|
|
369
|
-
$elt.off(options.bindEvent);
|
|
370
|
-
}
|
|
326
|
+
}
|
|
327
|
+
},
|
|
371
328
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
329
|
+
/**
|
|
330
|
+
* Create the undo message box
|
|
331
|
+
* @private
|
|
332
|
+
* @param {Object} options - the plugin options
|
|
333
|
+
* @returns {jQueryElement} the undo box
|
|
334
|
+
*/
|
|
335
|
+
_createUndoBox: function _createUndoBox(options) {
|
|
336
|
+
var $undoContainer = options.undoContainer || $$1('#feedback-messages-main');
|
|
377
337
|
|
|
378
|
-
|
|
379
|
-
|
|
338
|
+
if (!$undoContainer.length) {
|
|
339
|
+
//create a global feedback container
|
|
340
|
+
$undoContainer = $$1('<div id="feedback-messages-main" class="tao-scope"></div>').appendTo('body');
|
|
380
341
|
}
|
|
381
|
-
}; //Register the toggler to behave as a jQuery plugin.
|
|
382
342
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
343
|
+
return $$1(undoTmpl(options)).appendTo($undoContainer);
|
|
344
|
+
},
|
|
345
|
+
|
|
386
346
|
/**
|
|
387
|
-
*
|
|
347
|
+
* Destroy completely the plugin.
|
|
388
348
|
*
|
|
349
|
+
* Called the jQuery way once registered by the Pluginifier.
|
|
350
|
+
* @example $('selector').deleter('destroy');
|
|
389
351
|
* @public
|
|
390
|
-
* @
|
|
391
|
-
* @param {jQueryElement} $container - the root context to listen in
|
|
352
|
+
* @fires deleter#destroy.deleter
|
|
392
353
|
*/
|
|
354
|
+
destroy: function destroy() {
|
|
355
|
+
this.each(function () {
|
|
356
|
+
var $elt = $$1(this);
|
|
357
|
+
var options = $elt.data(dataNs);
|
|
393
358
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
container: $container,
|
|
398
|
-
listenerEvent: 'click',
|
|
399
|
-
namespace: dataNs,
|
|
400
|
-
bubbled: true
|
|
401
|
-
}).init(function ($elt, $target) {
|
|
402
|
-
var options = {
|
|
403
|
-
target: $target,
|
|
404
|
-
bindEvent: false,
|
|
405
|
-
undo: true
|
|
406
|
-
};
|
|
407
|
-
var confirm = $elt.data('delete-confirm');
|
|
408
|
-
var undo = $elt.data('delete-undo');
|
|
409
|
-
|
|
410
|
-
if (confirm) {
|
|
411
|
-
options.confirm = true;
|
|
412
|
-
options.undo = false;
|
|
359
|
+
if (options.bindEvent !== false) {
|
|
360
|
+
$elt.off(options.bindEvent);
|
|
361
|
+
}
|
|
413
362
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
363
|
+
$elt.removeData(dataNs);
|
|
364
|
+
/**
|
|
365
|
+
* The plugin have been destroyed.
|
|
366
|
+
* @event deleter#destroy.deleter
|
|
367
|
+
*/
|
|
368
|
+
|
|
369
|
+
$elt.trigger('destroy.' + ns);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}; //Register the toggler to behave as a jQuery plugin.
|
|
373
|
+
|
|
374
|
+
Pluginifier.register(ns, deleter, {
|
|
375
|
+
expose: ['delete']
|
|
376
|
+
});
|
|
377
|
+
/**
|
|
378
|
+
* The only exposed function is used to start listening on data-attr
|
|
379
|
+
*
|
|
380
|
+
* @public
|
|
381
|
+
* @example define(['ui/deleter'], function(deleter){ deleter($('rootContainer')); });
|
|
382
|
+
* @param {jQueryElement} $container - the root context to listen in
|
|
383
|
+
*/
|
|
384
|
+
|
|
385
|
+
function listenDataAttr($container) {
|
|
386
|
+
//handle data-delete
|
|
387
|
+
new DataAttrHandler('delete', {
|
|
388
|
+
container: $container,
|
|
389
|
+
listenerEvent: 'click',
|
|
390
|
+
namespace: dataNs,
|
|
391
|
+
bubbled: true
|
|
392
|
+
}).init(function ($elt, $target) {
|
|
393
|
+
var options = {
|
|
394
|
+
target: $target,
|
|
395
|
+
bindEvent: false,
|
|
396
|
+
undo: true
|
|
397
|
+
};
|
|
398
|
+
var confirm = $elt.data('delete-confirm');
|
|
399
|
+
var undo = $elt.data('delete-undo');
|
|
400
|
+
|
|
401
|
+
if (confirm) {
|
|
402
|
+
options.confirm = true;
|
|
403
|
+
options.undo = false;
|
|
404
|
+
|
|
405
|
+
if (confirm.length > 0) {
|
|
406
|
+
options.confirmMessage = confirm;
|
|
417
407
|
}
|
|
408
|
+
}
|
|
418
409
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
410
|
+
if (undo !== null && undo !== undefined) {
|
|
411
|
+
if (undo === false) {
|
|
412
|
+
options.undo = false;
|
|
413
|
+
} else {
|
|
414
|
+
options.confirm = false;
|
|
415
|
+
options.undo = true;
|
|
425
416
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
}
|
|
417
|
+
if (undo.length > 0) {
|
|
418
|
+
options.undoMessage = undo;
|
|
429
419
|
}
|
|
430
420
|
}
|
|
421
|
+
}
|
|
431
422
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
423
|
+
$elt.deleter(options);
|
|
424
|
+
}).trigger(function ($elt) {
|
|
425
|
+
$elt.deleter('delete');
|
|
426
|
+
});
|
|
427
|
+
}
|
|
437
428
|
|
|
438
|
-
|
|
429
|
+
return listenDataAttr;
|
|
439
430
|
|
|
440
431
|
});
|