@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/contextualPopup.js
CHANGED
|
@@ -1,483 +1,474 @@
|
|
|
1
1
|
define(['jquery', 'lodash', 'handlebars', 'i18n', 'lib/dompurify/purify', 'css!ui/contextualPopup/css/contextualPopup.css'], function ($$1, _, Handlebars, __, DOMPurify, contextualPopup_css) { 'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
$$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
|
|
4
|
+
_ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
|
|
5
|
+
Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
|
|
6
|
+
__ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
|
|
7
|
+
DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
|
|
8
|
+
|
|
9
|
+
function _typeof(obj) {
|
|
10
|
+
"@babel/helpers - typeof";
|
|
11
|
+
|
|
12
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
13
|
+
return typeof obj;
|
|
14
|
+
} : function (obj) {
|
|
15
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
16
|
+
}, _typeof(obj);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function Helpers0 (hb) {
|
|
20
|
+
//register a i18n helper
|
|
21
|
+
hb.registerHelper('__', function (key) {
|
|
22
|
+
return __(key);
|
|
23
|
+
});
|
|
9
24
|
/**
|
|
10
|
-
*
|
|
11
|
-
* modify it under the terms of the GNU General Public License
|
|
12
|
-
* as published by the Free Software Foundation; under version 2
|
|
13
|
-
* of the License (non-upgradable).
|
|
14
|
-
*
|
|
15
|
-
* This program is distributed in the hope that it will be useful,
|
|
16
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18
|
-
* GNU General Public License for more details.
|
|
19
|
-
*
|
|
20
|
-
* You should have received a copy of the GNU General Public License
|
|
21
|
-
* along with this program; if not, write to the Free Software
|
|
22
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
23
|
-
*
|
|
24
|
-
* Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
|
|
25
|
+
* Register dompurify helper
|
|
25
26
|
*
|
|
27
|
+
* https://github.com/cure53/DOMPurify
|
|
28
|
+
* with config SAFE_FOR_TEMPLATES: true
|
|
29
|
+
* to make output safe for template systems
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
hb.registerHelper('dompurify', function (context) {
|
|
33
|
+
return DOMPurify.sanitize(context);
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Register join helper
|
|
26
37
|
*
|
|
38
|
+
* Example :
|
|
39
|
+
* var values = {a:v1, b:v2, c:v3};
|
|
40
|
+
* Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
|
|
41
|
+
* Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
|
|
27
42
|
*/
|
|
28
|
-
function Helpers0 (hb) {
|
|
29
|
-
//register a i18n helper
|
|
30
|
-
hb.registerHelper('__', function (key) {
|
|
31
|
-
return __(key);
|
|
32
|
-
});
|
|
33
|
-
/**
|
|
34
|
-
* Register dompurify helper
|
|
35
|
-
*
|
|
36
|
-
* https://github.com/cure53/DOMPurify
|
|
37
|
-
* with config SAFE_FOR_TEMPLATES: true
|
|
38
|
-
* to make output safe for template systems
|
|
39
|
-
*/
|
|
40
43
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
*
|
|
47
|
-
* Example :
|
|
48
|
-
* var values = {a:v1, b:v2, c:v3};
|
|
49
|
-
* Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
|
|
50
|
-
* Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
|
|
51
|
-
*/
|
|
44
|
+
hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
|
|
45
|
+
var fragments = [];
|
|
46
|
+
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
47
|
+
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
48
|
+
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
56
|
-
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
57
|
-
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
58
|
-
|
|
59
|
-
_.forIn(arr, function (value, key) {
|
|
60
|
-
var fragment = '';
|
|
61
|
-
|
|
62
|
-
if (value !== null || value !== undefined) {
|
|
63
|
-
if (typeof value === 'boolean') {
|
|
64
|
-
value = value ? 'true' : 'false';
|
|
65
|
-
} else if (typeof value === 'object') {
|
|
66
|
-
value = _.values(value).join(' ');
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
value = '';
|
|
70
|
-
}
|
|
50
|
+
_.forIn(arr, function (value, key) {
|
|
51
|
+
var fragment = '';
|
|
71
52
|
|
|
72
|
-
|
|
73
|
-
|
|
53
|
+
if (value !== null || value !== undefined) {
|
|
54
|
+
if (typeof value === 'boolean') {
|
|
55
|
+
value = value ? 'true' : 'false';
|
|
56
|
+
} else if (_typeof(value) === 'object') {
|
|
57
|
+
value = _.values(value).join(' ');
|
|
74
58
|
}
|
|
59
|
+
} else {
|
|
60
|
+
value = '';
|
|
61
|
+
}
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
return fragments.join(fragmentGlue);
|
|
81
|
-
}); //register a classic "for loop" helper
|
|
82
|
-
//it also adds a local variable "i" as the index in each iteration loop
|
|
83
|
-
|
|
84
|
-
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
85
|
-
var ret = '';
|
|
86
|
-
startIndex = parseInt(startIndex);
|
|
87
|
-
stopIndex = parseInt(stopIndex);
|
|
88
|
-
increment = parseInt(increment);
|
|
89
|
-
|
|
90
|
-
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
91
|
-
ret += options.fn(_.extend({}, this, {
|
|
92
|
-
i: i
|
|
93
|
-
}));
|
|
63
|
+
if (keyValueGlue !== undefined) {
|
|
64
|
+
fragment += key + keyValueGlue;
|
|
94
65
|
}
|
|
95
66
|
|
|
96
|
-
|
|
67
|
+
fragment += wrapper + value + wrapper;
|
|
68
|
+
fragments.push(fragment);
|
|
97
69
|
});
|
|
98
|
-
hb.registerHelper('equal', function (var1, var2, options) {
|
|
99
|
-
if (var1 == var2) {
|
|
100
|
-
return options.fn(this);
|
|
101
|
-
} else {
|
|
102
|
-
return options.inverse(this);
|
|
103
|
-
}
|
|
104
|
-
}); // register a "get property" helper
|
|
105
|
-
// it gets the named property from the provided context
|
|
106
70
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// it checks if value is in array
|
|
71
|
+
return fragments.join(fragmentGlue);
|
|
72
|
+
}); //register a classic "for loop" helper
|
|
73
|
+
//it also adds a local variable "i" as the index in each iteration loop
|
|
111
74
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
75
|
+
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
76
|
+
var ret = '';
|
|
77
|
+
startIndex = parseInt(startIndex);
|
|
78
|
+
stopIndex = parseInt(stopIndex);
|
|
79
|
+
increment = parseInt(increment);
|
|
118
80
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
124
|
-
this.compilerInfo = [4,'>= 1.0.0'];
|
|
125
|
-
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
126
|
-
var buffer = "", stack1, helper, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, self=this, functionType="function";
|
|
127
|
-
|
|
128
|
-
function program1(depth0,data) {
|
|
129
|
-
|
|
130
|
-
var buffer = "", stack1;
|
|
131
|
-
buffer += "\n ";
|
|
132
|
-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.controls)),stack1 == null || stack1 === false ? stack1 : stack1.done), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
|
|
133
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
134
|
-
buffer += "\n ";
|
|
135
|
-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.controls)),stack1 == null || stack1 === false ? stack1 : stack1.cancel), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
|
|
136
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
137
|
-
buffer += "\n ";
|
|
138
|
-
return buffer;
|
|
81
|
+
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
82
|
+
ret += options.fn(_.extend({}, this, {
|
|
83
|
+
i: i
|
|
84
|
+
}));
|
|
139
85
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
86
|
+
|
|
87
|
+
return ret;
|
|
88
|
+
});
|
|
89
|
+
hb.registerHelper('equal', function (var1, var2, options) {
|
|
90
|
+
if (var1 == var2) {
|
|
91
|
+
return options.fn(this);
|
|
92
|
+
} else {
|
|
93
|
+
return options.inverse(this);
|
|
144
94
|
}
|
|
95
|
+
}); // register a "get property" helper
|
|
96
|
+
// it gets the named property from the provided context
|
|
97
|
+
|
|
98
|
+
hb.registerHelper('property', function (name, context) {
|
|
99
|
+
return context[name] || '';
|
|
100
|
+
}); // register an 'includes' helper
|
|
101
|
+
// it checks if value is in array
|
|
145
102
|
|
|
146
|
-
function
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
buffer += "<a href=\"#\" class=\"btn cancel\" title=\""
|
|
150
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "cancel", options) : helperMissing.call(depth0, "__", "cancel", options)))
|
|
151
|
-
+ "\">cancel</a>";
|
|
152
|
-
return buffer;
|
|
103
|
+
hb.registerHelper('includes', function (haystack, needle, options) {
|
|
104
|
+
if (_.contains(haystack, needle)) {
|
|
105
|
+
return options.fn(this);
|
|
153
106
|
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!Helpers0.__initialized) {
|
|
111
|
+
Helpers0(Handlebars);
|
|
112
|
+
Helpers0.__initialized = true;
|
|
113
|
+
}
|
|
114
|
+
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
115
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
|
116
|
+
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
117
|
+
var buffer = "", stack1, helper, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, self=this, functionType="function";
|
|
118
|
+
|
|
119
|
+
function program1(depth0,data) {
|
|
120
|
+
|
|
121
|
+
var buffer = "", stack1;
|
|
122
|
+
buffer += "\n ";
|
|
123
|
+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.controls)),stack1 == null || stack1 === false ? stack1 : stack1.done), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
|
|
124
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
125
|
+
buffer += "\n ";
|
|
126
|
+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 && depth0.controls)),stack1 == null || stack1 === false ? stack1 : stack1.cancel), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
|
|
127
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
128
|
+
buffer += "\n ";
|
|
129
|
+
return buffer;
|
|
130
|
+
}
|
|
131
|
+
function program2(depth0,data) {
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
return "<button class=\"btn btn-info small done\">done</button>";
|
|
135
|
+
}
|
|
154
136
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.arrow)),stack1 == null || stack1 === false ? stack1 : stack1.leftCover)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
163
|
-
+ "px\"></div>\n <div class=\"popup-content\">";
|
|
164
|
-
if (helper = helpers.content) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
165
|
-
else { helper = (depth0 && depth0.content); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
166
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
167
|
-
buffer += "</div>\n <div class=\"footer\">\n ";
|
|
168
|
-
stack1 = helpers['if'].call(depth0, (depth0 && depth0.controls), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
|
|
169
|
-
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
170
|
-
buffer += "\n </div>\n</div>";
|
|
171
|
-
return buffer;
|
|
172
|
-
});
|
|
173
|
-
function popupTpl(data, options, asString) {
|
|
174
|
-
var html = Template(data, options);
|
|
175
|
-
return (asString || true) ? html : $(html);
|
|
137
|
+
function program4(depth0,data) {
|
|
138
|
+
|
|
139
|
+
var buffer = "", helper, options;
|
|
140
|
+
buffer += "<a href=\"#\" class=\"btn cancel\" title=\""
|
|
141
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "cancel", options) : helperMissing.call(depth0, "__", "cancel", options)))
|
|
142
|
+
+ "\">cancel</a>";
|
|
143
|
+
return buffer;
|
|
176
144
|
}
|
|
177
145
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
146
|
+
buffer += "<div class=\"contextual-popup\" style=\"top:"
|
|
147
|
+
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.popup)),stack1 == null || stack1 === false ? stack1 : stack1.top)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
148
|
+
+ "px; left:"
|
|
149
|
+
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.popup)),stack1 == null || stack1 === false ? stack1 : stack1.left)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
150
|
+
+ "px\">\n <div class=\"arrow\" style=\"left:"
|
|
151
|
+
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.arrow)),stack1 == null || stack1 === false ? stack1 : stack1.left)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
152
|
+
+ "px\"></div>\n <div class=\"arrow-cover\" style=\"left:"
|
|
153
|
+
+ escapeExpression(((stack1 = ((stack1 = (depth0 && depth0.arrow)),stack1 == null || stack1 === false ? stack1 : stack1.leftCover)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
|
|
154
|
+
+ "px\"></div>\n <div class=\"popup-content\">";
|
|
155
|
+
if (helper = helpers.content) { stack1 = helper.call(depth0, {hash:{},data:data}); }
|
|
156
|
+
else { helper = (depth0 && depth0.content); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
|
|
157
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
158
|
+
buffer += "</div>\n <div class=\"footer\">\n ";
|
|
159
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.controls), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
|
|
160
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
161
|
+
buffer += "\n </div>\n</div>";
|
|
162
|
+
return buffer;
|
|
163
|
+
});
|
|
164
|
+
function popupTpl(data, options, asString) {
|
|
165
|
+
var html = Template(data, options);
|
|
166
|
+
return (asString || true) ? html : $(html);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/*
|
|
170
|
+
* This program is free software; you can redistribute it and/or
|
|
171
|
+
* modify it under the terms of the GNU General Public License
|
|
172
|
+
* as published by the Free Software Foundation; under version 2
|
|
173
|
+
* of the License (non-upgradable).
|
|
174
|
+
*
|
|
175
|
+
* This program is distributed in the hope that it will be useful,
|
|
176
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
177
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
178
|
+
* GNU General Public License for more details.
|
|
179
|
+
*
|
|
180
|
+
* You should have received a copy of the GNU General Public License
|
|
181
|
+
* along with this program; if not, write to the Free Software
|
|
182
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
183
|
+
*
|
|
184
|
+
* Copyright (c) 2015 (original work) Open Assessment Technologies SA ;
|
|
185
|
+
*
|
|
186
|
+
*/
|
|
187
|
+
var _ns = '.contextual-popup';
|
|
188
|
+
var _defaults = {
|
|
189
|
+
controls: false,
|
|
190
|
+
style: {},
|
|
191
|
+
position: 'bottom',
|
|
192
|
+
callbacks: {}
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Create an element selector reltive to the $anchor and contained in the $container
|
|
196
|
+
*
|
|
197
|
+
* @param {JQuery} $anchor
|
|
198
|
+
* @param {JQuery} $container
|
|
199
|
+
* @param {Object} options
|
|
200
|
+
* @param {JQuery|String} [options.content] - the inital content of the popup
|
|
201
|
+
* @param {Boolean} [options.controls] - add cancel/done button
|
|
202
|
+
* @param {Function} [options.callbacks.beforeDone] - Triggered when a dialog is about to close. If returned <i>false</i>, the dialog will not close.
|
|
203
|
+
* @param {Function} [options.callbacks.beforeCancel] - Triggered when a dialog is about to close. If returned <i>false</i>, the dialog will not close.
|
|
204
|
+
* @param {Function} [options.callbacks.beforeDestroy] - Triggered when a dialog is about to destroy.
|
|
205
|
+
* @returns {Object} the new selector instance
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
function create($anchor, $container, options) {
|
|
209
|
+
var destroyed = false;
|
|
210
|
+
options = _.defaults(options, _defaults);
|
|
211
|
+
$anchor.data('contextual-popup-options', options); //anchor must be positioned in css
|
|
212
|
+
|
|
213
|
+
var positions = _computePosition($anchor, $container);
|
|
214
|
+
|
|
215
|
+
var $element = $$1(popupTpl({
|
|
216
|
+
popup: positions.popup,
|
|
217
|
+
arrow: positions.arrow,
|
|
218
|
+
controls: options.controls
|
|
219
|
+
})); //only one
|
|
220
|
+
|
|
221
|
+
$anchor.find('.contextual-popup').remove(); //attach the popup
|
|
222
|
+
|
|
223
|
+
$element.addClass(options.position);
|
|
224
|
+
$element.css('width', options.style.popupWidth);
|
|
225
|
+
$anchor.append($element);
|
|
226
|
+
$element.off(_ns).on('click' + _ns, '.done', function () {
|
|
227
|
+
if (runCallback('beforeDone')) {
|
|
228
|
+
_done($element);
|
|
229
|
+
}
|
|
230
|
+
}).on('click' + _ns, '.cancel', function () {
|
|
231
|
+
if (runCallback('beforeCancel')) {
|
|
232
|
+
_cancel($element);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
if (options.content) {
|
|
237
|
+
setContent(options.content);
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Set the popup content
|
|
241
|
+
* @param {JQuery|String} content
|
|
242
|
+
* @returns {undefined}
|
|
195
243
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
function setContent(content) {
|
|
247
|
+
if (content instanceof $$1 || _.isString(content)) {
|
|
248
|
+
$element.find('.popup-content').empty().append(content);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
203
251
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* @
|
|
207
|
-
* @param {JQuery} $container
|
|
208
|
-
* @param {Object} options
|
|
209
|
-
* @param {JQuery|String} [options.content] - the inital content of the popup
|
|
210
|
-
* @param {Boolean} [options.controls] - add cancel/done button
|
|
211
|
-
* @param {Function} [options.callbacks.beforeDone] - Triggered when a dialog is about to close. If returned <i>false</i>, the dialog will not close.
|
|
212
|
-
* @param {Function} [options.callbacks.beforeCancel] - Triggered when a dialog is about to close. If returned <i>false</i>, the dialog will not close.
|
|
213
|
-
* @param {Function} [options.callbacks.beforeDestroy] - Triggered when a dialog is about to destroy.
|
|
214
|
-
* @returns {Object} the new selector instance
|
|
252
|
+
* Run callback function before action. If returned <i>false</i>, action will not be executed.
|
|
253
|
+
* @param {string} name - callback name
|
|
254
|
+
* @returns {boolean}
|
|
215
255
|
*/
|
|
216
256
|
|
|
217
|
-
function create($anchor, $container, options) {
|
|
218
|
-
var destroyed = false;
|
|
219
|
-
options = _.defaults(options, _defaults);
|
|
220
|
-
$anchor.data('contextual-popup-options', options); //anchor must be positioned in css
|
|
221
257
|
|
|
222
|
-
|
|
258
|
+
function runCallback(name) {
|
|
259
|
+
var result = true;
|
|
223
260
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
controls: options.controls
|
|
228
|
-
})); //only one
|
|
261
|
+
if (options.callbacks[name] && _.isFunction(options.callbacks[name])) {
|
|
262
|
+
result = options.callbacks[name]();
|
|
263
|
+
}
|
|
229
264
|
|
|
230
|
-
|
|
265
|
+
return result;
|
|
266
|
+
}
|
|
231
267
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
});
|
|
268
|
+
var popup = {
|
|
269
|
+
/**
|
|
270
|
+
* Get the popup JQuery container
|
|
271
|
+
*
|
|
272
|
+
* @returns {jQuery}
|
|
273
|
+
*/
|
|
274
|
+
getPopup: function getPopup() {
|
|
275
|
+
return $element;
|
|
276
|
+
},
|
|
277
|
+
setContent: setContent,
|
|
244
278
|
|
|
245
|
-
if (options.content) {
|
|
246
|
-
setContent(options.content);
|
|
247
|
-
}
|
|
248
279
|
/**
|
|
249
|
-
*
|
|
250
|
-
*
|
|
280
|
+
* Recalculates the position of the popup relative to the anchor
|
|
281
|
+
* Useful after any changes in layout
|
|
282
|
+
*
|
|
251
283
|
* @returns {undefined}
|
|
252
284
|
*/
|
|
285
|
+
reposition: function reposition() {
|
|
286
|
+
var pos = _computePosition($anchor, $container);
|
|
253
287
|
|
|
288
|
+
$element.css({
|
|
289
|
+
top: pos.popup.top,
|
|
290
|
+
left: pos.popup.left
|
|
291
|
+
});
|
|
292
|
+
$element.children('.arrow').css('left', pos.arrow.left);
|
|
293
|
+
$element.children('.arrow-cover').css('left', pos.arrow.leftCover);
|
|
294
|
+
},
|
|
254
295
|
|
|
255
|
-
function setContent(content) {
|
|
256
|
-
if (content instanceof $$1 || _.isString(content)) {
|
|
257
|
-
$element.find('.popup-content').empty().append(content);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
296
|
/**
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
* @returns {
|
|
297
|
+
* Manually triggers "done"
|
|
298
|
+
*
|
|
299
|
+
* @returns {undefined}
|
|
264
300
|
*/
|
|
301
|
+
done: function done() {
|
|
302
|
+
_done($element);
|
|
303
|
+
},
|
|
265
304
|
|
|
305
|
+
/**
|
|
306
|
+
* Manually triggers "cancel"
|
|
307
|
+
*
|
|
308
|
+
* @returns {undefined}
|
|
309
|
+
*/
|
|
310
|
+
cancel: function cancel() {
|
|
311
|
+
_cancel($element);
|
|
312
|
+
},
|
|
266
313
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Manually triggers "hide"
|
|
316
|
+
*
|
|
317
|
+
* @returns {undefined}
|
|
318
|
+
*/
|
|
319
|
+
hide: function hide() {
|
|
320
|
+
_hide($element);
|
|
321
|
+
},
|
|
273
322
|
|
|
274
|
-
|
|
275
|
-
|
|
323
|
+
/**
|
|
324
|
+
* Manually triggers "show"
|
|
325
|
+
*
|
|
326
|
+
* @fires show.contextual-popup
|
|
327
|
+
* @returns {undefined}
|
|
328
|
+
*/
|
|
329
|
+
show: function show() {
|
|
330
|
+
$element.show();
|
|
331
|
+
$element.trigger('show' + _ns);
|
|
332
|
+
},
|
|
276
333
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
* Recalculates the position of the popup relative to the anchor
|
|
290
|
-
* Useful after any changes in layout
|
|
291
|
-
*
|
|
292
|
-
* @returns {undefined}
|
|
293
|
-
*/
|
|
294
|
-
reposition: function reposition() {
|
|
295
|
-
var pos = _computePosition($anchor, $container);
|
|
296
|
-
|
|
297
|
-
$element.css({
|
|
298
|
-
top: pos.popup.top,
|
|
299
|
-
left: pos.popup.left
|
|
300
|
-
});
|
|
301
|
-
$element.children('.arrow').css('left', pos.arrow.left);
|
|
302
|
-
$element.children('.arrow-cover').css('left', pos.arrow.leftCover);
|
|
303
|
-
},
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Manually triggers "done"
|
|
307
|
-
*
|
|
308
|
-
* @returns {undefined}
|
|
309
|
-
*/
|
|
310
|
-
done: function done() {
|
|
311
|
-
_done($element);
|
|
312
|
-
},
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Manually triggers "cancel"
|
|
316
|
-
*
|
|
317
|
-
* @returns {undefined}
|
|
318
|
-
*/
|
|
319
|
-
cancel: function cancel() {
|
|
320
|
-
_cancel($element);
|
|
321
|
-
},
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Manually triggers "hide"
|
|
325
|
-
*
|
|
326
|
-
* @returns {undefined}
|
|
327
|
-
*/
|
|
328
|
-
hide: function hide() {
|
|
329
|
-
_hide($element);
|
|
330
|
-
},
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* Manually triggers "show"
|
|
334
|
-
*
|
|
335
|
-
* @fires show.contextual-popup
|
|
336
|
-
* @returns {undefined}
|
|
337
|
-
*/
|
|
338
|
-
show: function show() {
|
|
339
|
-
$element.show();
|
|
340
|
-
$element.trigger('show' + _ns);
|
|
341
|
-
},
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Manually triggers "destroy"
|
|
345
|
-
*
|
|
346
|
-
* @fires destroy.contextual-popup
|
|
347
|
-
* @returns {undefined}
|
|
348
|
-
*/
|
|
349
|
-
destroy: function destroy() {
|
|
350
|
-
if (!destroyed) {
|
|
351
|
-
runCallback('beforeDestroy');
|
|
352
|
-
destroyed = true;
|
|
353
|
-
$element.remove();
|
|
354
|
-
$element.trigger('destroy' + _ns);
|
|
355
|
-
}
|
|
356
|
-
},
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Tells if the popup is currently hidden or visible
|
|
360
|
-
* @returns {boolean}
|
|
361
|
-
*/
|
|
362
|
-
isVisible: function () {
|
|
363
|
-
return $element.is(':visible');
|
|
334
|
+
/**
|
|
335
|
+
* Manually triggers "destroy"
|
|
336
|
+
*
|
|
337
|
+
* @fires destroy.contextual-popup
|
|
338
|
+
* @returns {undefined}
|
|
339
|
+
*/
|
|
340
|
+
destroy: function destroy() {
|
|
341
|
+
if (!destroyed) {
|
|
342
|
+
runCallback('beforeDestroy');
|
|
343
|
+
destroyed = true;
|
|
344
|
+
$element.remove();
|
|
345
|
+
$element.trigger('destroy' + _ns);
|
|
364
346
|
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
popup.reposition();
|
|
368
|
-
return popup;
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Hide
|
|
372
|
-
*
|
|
373
|
-
* @fires hide.contextual-popup
|
|
374
|
-
* @param {JQuery} $element
|
|
375
|
-
*/
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
function _hide($element) {
|
|
379
|
-
$element.hide();
|
|
380
|
-
$element.trigger('hide' + _ns);
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Callback when the "done" button is clicked
|
|
384
|
-
*
|
|
385
|
-
* @fires done.contextual-popup
|
|
386
|
-
* @param {JQuery} $element
|
|
387
|
-
*/
|
|
347
|
+
},
|
|
388
348
|
|
|
349
|
+
/**
|
|
350
|
+
* Tells if the popup is currently hidden or visible
|
|
351
|
+
* @returns {boolean}
|
|
352
|
+
*/
|
|
353
|
+
isVisible: function isVisible() {
|
|
354
|
+
return $element.is(':visible');
|
|
355
|
+
}
|
|
356
|
+
}; //need to reposition the popup after this has been attached to the dom
|
|
357
|
+
|
|
358
|
+
popup.reposition();
|
|
359
|
+
return popup;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Hide
|
|
363
|
+
*
|
|
364
|
+
* @fires hide.contextual-popup
|
|
365
|
+
* @param {JQuery} $element
|
|
366
|
+
*/
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
function _hide($element) {
|
|
370
|
+
$element.hide();
|
|
371
|
+
$element.trigger('hide' + _ns);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Callback when the "done" button is clicked
|
|
375
|
+
*
|
|
376
|
+
* @fires done.contextual-popup
|
|
377
|
+
* @param {JQuery} $element
|
|
378
|
+
*/
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
function _done($element) {
|
|
382
|
+
_hide($element);
|
|
383
|
+
|
|
384
|
+
$element.trigger('done' + _ns);
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Callback when the "cancel" button is clicked
|
|
388
|
+
*
|
|
389
|
+
* @fires cancel.contextual-popup
|
|
390
|
+
* @param {JQuery} $element
|
|
391
|
+
*/
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
function _cancel($element) {
|
|
395
|
+
_hide($element);
|
|
396
|
+
|
|
397
|
+
$element.trigger('cancel' + _ns);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
var _styleDefaults = {
|
|
401
|
+
popupWidth: 500,
|
|
402
|
+
arrowWidth: 6,
|
|
403
|
+
marginTop: 15,
|
|
404
|
+
marginLeft: 15
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* Calculate the position of the popup and arrow relative to the anchor and container elements
|
|
408
|
+
*
|
|
409
|
+
* @param {JQuery} $anchor
|
|
410
|
+
* @param {JQuery} $container
|
|
411
|
+
* @returns {Object} - Object containing the positioning data
|
|
412
|
+
*/
|
|
413
|
+
|
|
414
|
+
function _computePosition($anchor, $container) {
|
|
415
|
+
var $contextualPopup = $anchor.children('.contextual-popup');
|
|
416
|
+
var options = $anchor.data('contextual-popup-options');
|
|
417
|
+
|
|
418
|
+
var styleOpts = _.defaults(options.style || {}, _styleDefaults);
|
|
419
|
+
|
|
420
|
+
var popupWidth = styleOpts.popupWidth;
|
|
421
|
+
var popupHeight = $contextualPopup.outerHeight();
|
|
422
|
+
var arrowWidth = styleOpts.arrowWidth;
|
|
423
|
+
var marginTop = styleOpts.marginTop;
|
|
424
|
+
var marginLeft = styleOpts.marginLeft;
|
|
425
|
+
var _anchor = {
|
|
426
|
+
top: $anchor.offset().top,
|
|
427
|
+
left: $anchor.offset().left,
|
|
428
|
+
w: $anchor.innerWidth(),
|
|
429
|
+
h: $anchor.innerHeight()
|
|
430
|
+
};
|
|
431
|
+
var _container = {
|
|
432
|
+
top: $container.offset().top,
|
|
433
|
+
left: $container.offset().left,
|
|
434
|
+
w: $container.innerWidth()
|
|
435
|
+
};
|
|
436
|
+
var _popup = {
|
|
437
|
+
top: _anchor.h + marginTop,
|
|
438
|
+
left: -popupWidth / 2 + _anchor.w / 2,
|
|
439
|
+
w: popupWidth
|
|
440
|
+
};
|
|
389
441
|
|
|
390
|
-
|
|
391
|
-
|
|
442
|
+
switch (options.position) {
|
|
443
|
+
case 'top':
|
|
444
|
+
_popup.top = -marginTop - popupHeight;
|
|
445
|
+
$contextualPopup.removeClass('bottom').addClass('top');
|
|
446
|
+
break;
|
|
392
447
|
|
|
393
|
-
|
|
448
|
+
case 'bottom':
|
|
449
|
+
_popup.top = _anchor.h + marginTop;
|
|
450
|
+
$contextualPopup.removeClass('top').addClass('bottom');
|
|
451
|
+
break;
|
|
394
452
|
}
|
|
395
|
-
/**
|
|
396
|
-
* Callback when the "cancel" button is clicked
|
|
397
|
-
*
|
|
398
|
-
* @fires cancel.contextual-popup
|
|
399
|
-
* @param {JQuery} $element
|
|
400
|
-
*/
|
|
401
453
|
|
|
454
|
+
var offset = _anchor.left - _container.left; //do we have enough space on the left ?
|
|
402
455
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
456
|
+
if (offset + marginLeft + _anchor.w / 2 < _popup.w / 2) {
|
|
457
|
+
_popup.left = -offset + marginLeft;
|
|
458
|
+
} else if (_container.w - (offset + _anchor.w / 2 + marginLeft) < _popup.w / 2) {
|
|
459
|
+
_popup.left = -offset + _container.w - marginLeft - _popup.w;
|
|
407
460
|
}
|
|
408
461
|
|
|
409
|
-
var
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
marginTop: 15,
|
|
413
|
-
marginLeft: 15
|
|
462
|
+
var _arrow = {
|
|
463
|
+
left: -_popup.left + _anchor.w / 2 - arrowWidth,
|
|
464
|
+
leftCover: -_popup.left + _anchor.w / 2 - arrowWidth - 6
|
|
414
465
|
};
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
* @returns {Object} - Object containing the positioning data
|
|
421
|
-
*/
|
|
422
|
-
|
|
423
|
-
function _computePosition($anchor, $container) {
|
|
424
|
-
var $contextualPopup = $anchor.children('.contextual-popup');
|
|
425
|
-
var options = $anchor.data('contextual-popup-options');
|
|
426
|
-
|
|
427
|
-
var styleOpts = _.defaults(options.style || {}, _styleDefaults);
|
|
428
|
-
|
|
429
|
-
var popupWidth = styleOpts.popupWidth;
|
|
430
|
-
var popupHeight = $contextualPopup.outerHeight();
|
|
431
|
-
var arrowWidth = styleOpts.arrowWidth;
|
|
432
|
-
var marginTop = styleOpts.marginTop;
|
|
433
|
-
var marginLeft = styleOpts.marginLeft;
|
|
434
|
-
var _anchor = {
|
|
435
|
-
top: $anchor.offset().top,
|
|
436
|
-
left: $anchor.offset().left,
|
|
437
|
-
w: $anchor.innerWidth(),
|
|
438
|
-
h: $anchor.innerHeight()
|
|
439
|
-
};
|
|
440
|
-
var _container = {
|
|
441
|
-
top: $container.offset().top,
|
|
442
|
-
left: $container.offset().left,
|
|
443
|
-
w: $container.innerWidth()
|
|
444
|
-
};
|
|
445
|
-
var _popup = {
|
|
446
|
-
top: _anchor.h + marginTop,
|
|
447
|
-
left: -popupWidth / 2 + _anchor.w / 2,
|
|
448
|
-
w: popupWidth
|
|
449
|
-
};
|
|
450
|
-
|
|
451
|
-
switch (options.position) {
|
|
452
|
-
case 'top':
|
|
453
|
-
_popup.top = -marginTop - popupHeight;
|
|
454
|
-
$contextualPopup.removeClass('bottom').addClass('top');
|
|
455
|
-
break;
|
|
456
|
-
|
|
457
|
-
case 'bottom':
|
|
458
|
-
_popup.top = _anchor.h + marginTop;
|
|
459
|
-
$contextualPopup.removeClass('top').addClass('bottom');
|
|
460
|
-
break;
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
var offset = _anchor.left - _container.left; //do we have enough space on the left ?
|
|
464
|
-
|
|
465
|
-
if (offset + marginLeft + _anchor.w / 2 < _popup.w / 2) {
|
|
466
|
-
_popup.left = -offset + marginLeft;
|
|
467
|
-
} else if (_container.w - (offset + _anchor.w / 2 + marginLeft) < _popup.w / 2) {
|
|
468
|
-
_popup.left = -offset + _container.w - marginLeft - _popup.w;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
var _arrow = {
|
|
472
|
-
left: -_popup.left + _anchor.w / 2 - arrowWidth,
|
|
473
|
-
leftCover: -_popup.left + _anchor.w / 2 - arrowWidth - 6
|
|
474
|
-
};
|
|
475
|
-
return {
|
|
476
|
-
popup: _popup,
|
|
477
|
-
arrow: _arrow
|
|
478
|
-
};
|
|
479
|
-
}
|
|
466
|
+
return {
|
|
467
|
+
popup: _popup,
|
|
468
|
+
arrow: _arrow
|
|
469
|
+
};
|
|
470
|
+
}
|
|
480
471
|
|
|
481
|
-
|
|
472
|
+
return create;
|
|
482
473
|
|
|
483
474
|
});
|