@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
|
@@ -1,438 +1,429 @@
|
|
|
1
1
|
define(['jquery', 'lodash', 'core/eventifier', 'ui/documentViewer/providers/pdfViewer/pdfjs/areaBroker', 'ui/documentViewer/providers/pdfViewer/pdfjs/findBar', 'ui/documentViewer/providers/pdfViewer/pdfjs/wrapper', 'handlebars', 'i18n', 'lib/dompurify/purify'], function ($$1, _, eventifier, areaBroker, findBarFactory, wrapperFactory, Handlebars, __, DOMPurify) { 'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
$$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
|
|
4
|
+
_ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
|
|
5
|
+
eventifier = eventifier && Object.prototype.hasOwnProperty.call(eventifier, 'default') ? eventifier['default'] : eventifier;
|
|
6
|
+
areaBroker = areaBroker && Object.prototype.hasOwnProperty.call(areaBroker, 'default') ? areaBroker['default'] : areaBroker;
|
|
7
|
+
findBarFactory = findBarFactory && Object.prototype.hasOwnProperty.call(findBarFactory, 'default') ? findBarFactory['default'] : findBarFactory;
|
|
8
|
+
wrapperFactory = wrapperFactory && Object.prototype.hasOwnProperty.call(wrapperFactory, 'default') ? wrapperFactory['default'] : wrapperFactory;
|
|
9
|
+
Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
|
|
10
|
+
__ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
|
|
11
|
+
DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
|
|
12
|
+
|
|
13
|
+
function _typeof(obj) {
|
|
14
|
+
"@babel/helpers - typeof";
|
|
15
|
+
|
|
16
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
17
|
+
return typeof obj;
|
|
18
|
+
} : function (obj) {
|
|
19
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
20
|
+
}, _typeof(obj);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function Helpers0 (hb) {
|
|
24
|
+
//register a i18n helper
|
|
25
|
+
hb.registerHelper('__', function (key) {
|
|
26
|
+
return __(key);
|
|
27
|
+
});
|
|
13
28
|
/**
|
|
14
|
-
*
|
|
15
|
-
* modify it under the terms of the GNU General Public License
|
|
16
|
-
* as published by the Free Software Foundation; under version 2
|
|
17
|
-
* of the License (non-upgradable).
|
|
18
|
-
*
|
|
19
|
-
* This program is distributed in the hope that it will be useful,
|
|
20
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22
|
-
* GNU General Public License for more details.
|
|
23
|
-
*
|
|
24
|
-
* You should have received a copy of the GNU General Public License
|
|
25
|
-
* along with this program; if not, write to the Free Software
|
|
26
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
27
|
-
*
|
|
28
|
-
* Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
|
|
29
|
+
* Register dompurify helper
|
|
29
30
|
*
|
|
31
|
+
* https://github.com/cure53/DOMPurify
|
|
32
|
+
* with config SAFE_FOR_TEMPLATES: true
|
|
33
|
+
* to make output safe for template systems
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
hb.registerHelper('dompurify', function (context) {
|
|
37
|
+
return DOMPurify.sanitize(context);
|
|
38
|
+
});
|
|
39
|
+
/**
|
|
40
|
+
* Register join helper
|
|
30
41
|
*
|
|
42
|
+
* Example :
|
|
43
|
+
* var values = {a:v1, b:v2, c:v3};
|
|
44
|
+
* Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
|
|
45
|
+
* Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
|
|
31
46
|
*/
|
|
32
|
-
function Helpers0 (hb) {
|
|
33
|
-
//register a i18n helper
|
|
34
|
-
hb.registerHelper('__', function (key) {
|
|
35
|
-
return __(key);
|
|
36
|
-
});
|
|
37
|
-
/**
|
|
38
|
-
* Register dompurify helper
|
|
39
|
-
*
|
|
40
|
-
* https://github.com/cure53/DOMPurify
|
|
41
|
-
* with config SAFE_FOR_TEMPLATES: true
|
|
42
|
-
* to make output safe for template systems
|
|
43
|
-
*/
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
* Example :
|
|
52
|
-
* var values = {a:v1, b:v2, c:v3};
|
|
53
|
-
* Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
|
|
54
|
-
* Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
|
|
55
|
-
*/
|
|
48
|
+
hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
|
|
49
|
+
var fragments = [];
|
|
50
|
+
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
51
|
+
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
52
|
+
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
56
53
|
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
|
|
60
|
-
fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
|
|
61
|
-
wrapper = typeof wrapper === 'string' ? wrapper : '"';
|
|
62
|
-
|
|
63
|
-
_.forIn(arr, function (value, key) {
|
|
64
|
-
var fragment = '';
|
|
65
|
-
|
|
66
|
-
if (value !== null || value !== undefined) {
|
|
67
|
-
if (typeof value === 'boolean') {
|
|
68
|
-
value = value ? 'true' : 'false';
|
|
69
|
-
} else if (typeof value === 'object') {
|
|
70
|
-
value = _.values(value).join(' ');
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
value = '';
|
|
74
|
-
}
|
|
54
|
+
_.forIn(arr, function (value, key) {
|
|
55
|
+
var fragment = '';
|
|
75
56
|
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
if (value !== null || value !== undefined) {
|
|
58
|
+
if (typeof value === 'boolean') {
|
|
59
|
+
value = value ? 'true' : 'false';
|
|
60
|
+
} else if (_typeof(value) === 'object') {
|
|
61
|
+
value = _.values(value).join(' ');
|
|
78
62
|
}
|
|
63
|
+
} else {
|
|
64
|
+
value = '';
|
|
65
|
+
}
|
|
79
66
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
return fragments.join(fragmentGlue);
|
|
85
|
-
}); //register a classic "for loop" helper
|
|
86
|
-
//it also adds a local variable "i" as the index in each iteration loop
|
|
87
|
-
|
|
88
|
-
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
89
|
-
var ret = '';
|
|
90
|
-
startIndex = parseInt(startIndex);
|
|
91
|
-
stopIndex = parseInt(stopIndex);
|
|
92
|
-
increment = parseInt(increment);
|
|
93
|
-
|
|
94
|
-
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
95
|
-
ret += options.fn(_.extend({}, this, {
|
|
96
|
-
i: i
|
|
97
|
-
}));
|
|
67
|
+
if (keyValueGlue !== undefined) {
|
|
68
|
+
fragment += key + keyValueGlue;
|
|
98
69
|
}
|
|
99
70
|
|
|
100
|
-
|
|
71
|
+
fragment += wrapper + value + wrapper;
|
|
72
|
+
fragments.push(fragment);
|
|
101
73
|
});
|
|
102
|
-
hb.registerHelper('equal', function (var1, var2, options) {
|
|
103
|
-
if (var1 == var2) {
|
|
104
|
-
return options.fn(this);
|
|
105
|
-
} else {
|
|
106
|
-
return options.inverse(this);
|
|
107
|
-
}
|
|
108
|
-
}); // register a "get property" helper
|
|
109
|
-
// it gets the named property from the provided context
|
|
110
74
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// it checks if value is in array
|
|
75
|
+
return fragments.join(fragmentGlue);
|
|
76
|
+
}); //register a classic "for loop" helper
|
|
77
|
+
//it also adds a local variable "i" as the index in each iteration loop
|
|
115
78
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
79
|
+
hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
|
|
80
|
+
var ret = '';
|
|
81
|
+
startIndex = parseInt(startIndex);
|
|
82
|
+
stopIndex = parseInt(stopIndex);
|
|
83
|
+
increment = parseInt(increment);
|
|
122
84
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
128
|
-
this.compilerInfo = [4,'>= 1.0.0'];
|
|
129
|
-
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
130
|
-
var buffer = "", stack1, helper, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, self=this;
|
|
131
|
-
|
|
132
|
-
function program1(depth0,data) {
|
|
133
|
-
|
|
134
|
-
var buffer = "", helper, options;
|
|
135
|
-
buffer += "\n <input type=\"checkbox\" id=\"fit-to-width\" data-control=\"fit-to-width\" value=\"1\" checked /> <label for=\"fit-to-width\">"
|
|
136
|
-
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Fit to width", options) : helperMissing.call(depth0, "__", "Fit to width", options)))
|
|
137
|
-
+ "</label>\n ";
|
|
138
|
-
return buffer;
|
|
85
|
+
for (var i = startIndex; i < stopIndex; i += increment) {
|
|
86
|
+
ret += options.fn(_.extend({}, this, {
|
|
87
|
+
i: i
|
|
88
|
+
}));
|
|
139
89
|
}
|
|
140
90
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
91
|
+
return ret;
|
|
92
|
+
});
|
|
93
|
+
hb.registerHelper('equal', function (var1, var2, options) {
|
|
94
|
+
if (var1 == var2) {
|
|
95
|
+
return options.fn(this);
|
|
96
|
+
} else {
|
|
97
|
+
return options.inverse(this);
|
|
98
|
+
}
|
|
99
|
+
}); // register a "get property" helper
|
|
100
|
+
// it gets the named property from the provided context
|
|
101
|
+
|
|
102
|
+
hb.registerHelper('property', function (name, context) {
|
|
103
|
+
return context[name] || '';
|
|
104
|
+
}); // register an 'includes' helper
|
|
105
|
+
// it checks if value is in array
|
|
106
|
+
|
|
107
|
+
hb.registerHelper('includes', function (haystack, needle, options) {
|
|
108
|
+
if (_.contains(haystack, needle)) {
|
|
109
|
+
return options.fn(this);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!Helpers0.__initialized) {
|
|
115
|
+
Helpers0(Handlebars);
|
|
116
|
+
Helpers0.__initialized = true;
|
|
117
|
+
}
|
|
118
|
+
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
|
|
119
|
+
this.compilerInfo = [4,'>= 1.0.0'];
|
|
120
|
+
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|
121
|
+
var buffer = "", stack1, helper, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, self=this;
|
|
122
|
+
|
|
123
|
+
function program1(depth0,data) {
|
|
124
|
+
|
|
125
|
+
var buffer = "", helper, options;
|
|
126
|
+
buffer += "\n <input type=\"checkbox\" id=\"fit-to-width\" data-control=\"fit-to-width\" value=\"1\" checked /> <label for=\"fit-to-width\">"
|
|
127
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Fit to width", options) : helperMissing.call(depth0, "__", "Fit to width", options)))
|
|
128
|
+
+ "</label>\n ";
|
|
129
|
+
return buffer;
|
|
162
130
|
}
|
|
163
131
|
|
|
132
|
+
buffer += "<div class=\"pdf-bar\">\n <div class=\"pdf-actions\">\n <button class=\"small navigation\" data-control=\"pdf-page-prev\" data-direction=\"-1\" title=\""
|
|
133
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Previous page", options) : helperMissing.call(depth0, "__", "Previous page", options)))
|
|
134
|
+
+ "\"><span class=\"icon icon-step-backward\"></span><span class=\"text\">"
|
|
135
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Previous", options) : helperMissing.call(depth0, "__", "Previous", options)))
|
|
136
|
+
+ "</span></button>\n <button class=\"small navigation\" data-control=\"pdf-page-next\" data-direction=\"1\" title=\""
|
|
137
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Next page", options) : helperMissing.call(depth0, "__", "Next page", options)))
|
|
138
|
+
+ "\"><span class=\"icon icon-step-forward\"></span><span class=\"text\">"
|
|
139
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Next", options) : helperMissing.call(depth0, "__", "Next", options)))
|
|
140
|
+
+ "</span></button>\n ";
|
|
141
|
+
stack1 = helpers['if'].call(depth0, (depth0 && depth0.fitToWidth), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
|
|
142
|
+
if(stack1 || stack1 === 0) { buffer += stack1; }
|
|
143
|
+
buffer += "\n </div>\n <div class=\"pdf-info\">\n <label for=\"pdf-page-num\">"
|
|
144
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Page", options) : helperMissing.call(depth0, "__", "Page", options)))
|
|
145
|
+
+ ":</label>\n <input class=\"info\" id=\"pdf-page-num\" data-control=\"pdf-page-num\" value=\"1\" />\n <label>"
|
|
146
|
+
+ escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "of", options) : helperMissing.call(depth0, "__", "of", options)))
|
|
147
|
+
+ "</label>\n <span class=\"info\" data-control=\"pdf-page-count\">1</span>\n </div>\n</div>\n<div class=\"pdf-container\"></div>\n";
|
|
148
|
+
return buffer;
|
|
149
|
+
});
|
|
150
|
+
function viewerTpl(data, options, asString) {
|
|
151
|
+
var html = Template(data, options);
|
|
152
|
+
return (asString || true) ? html : $(html);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* This program is free software; you can redistribute it and/or
|
|
157
|
+
* modify it under the terms of the GNU General Public License
|
|
158
|
+
* as published by the Free Software Foundation; under version 2
|
|
159
|
+
* of the License (non-upgradable).
|
|
160
|
+
*
|
|
161
|
+
* This program is distributed in the hope that it will be useful,
|
|
162
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
163
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
164
|
+
* GNU General Public License for more details.
|
|
165
|
+
*
|
|
166
|
+
* You should have received a copy of the GNU General Public License
|
|
167
|
+
* along with this program; if not, write to the Free Software
|
|
168
|
+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
169
|
+
*
|
|
170
|
+
* Copyright (c) 2016 (original work) Open Assessment Technologies SA ;
|
|
171
|
+
*/
|
|
172
|
+
/**
|
|
173
|
+
* Enable/disable an element
|
|
174
|
+
* @param {jQuery} $element
|
|
175
|
+
* @param {Boolean} enabled
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
function toggleState($element, enabled) {
|
|
179
|
+
if (enabled) {
|
|
180
|
+
$element.removeAttr('disabled');
|
|
181
|
+
} else {
|
|
182
|
+
$element.attr('disabled', true);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Wraps the component that use the PDF.js lib to render a PDF.
|
|
187
|
+
* @param {jQuery} $container
|
|
188
|
+
* @param {Object} config
|
|
189
|
+
* @param {Object} config.PDFJS - The PDFJS entry point
|
|
190
|
+
* @param {Boolean} [config.fitToWidth] - Fit the page to the available width, a scroll bar may appear
|
|
191
|
+
* @param {Boolean} [config.allowSearch] - Allow to search within the displayed PDF
|
|
192
|
+
* @param {Boolean} [config.caseSensitiveSearch] - Use a case sensitive search when the search feature is available
|
|
193
|
+
* @param {Boolean} [config.highlightAllMatches] - Highlight all matches to see all of them at a glance
|
|
194
|
+
* @returns {Object}
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
function pdfjsViewerFactory($container, config) {
|
|
199
|
+
var template = viewerTpl(config);
|
|
200
|
+
var events = eventifier();
|
|
201
|
+
var controls = {};
|
|
202
|
+
var broker = null;
|
|
203
|
+
var findBar = null;
|
|
204
|
+
var pdfConfig = null;
|
|
205
|
+
var pdf = null;
|
|
206
|
+
var PDFJS = null;
|
|
207
|
+
var enabled = true;
|
|
164
208
|
/**
|
|
165
|
-
*
|
|
166
|
-
* modify it under the terms of the GNU General Public License
|
|
167
|
-
* as published by the Free Software Foundation; under version 2
|
|
168
|
-
* of the License (non-upgradable).
|
|
169
|
-
*
|
|
170
|
-
* This program is distributed in the hope that it will be useful,
|
|
171
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
172
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
173
|
-
* GNU General Public License for more details.
|
|
174
|
-
*
|
|
175
|
-
* You should have received a copy of the GNU General Public License
|
|
176
|
-
* along with this program; if not, write to the Free Software
|
|
177
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
178
|
-
*
|
|
179
|
-
* Copyright (c) 2016 (original work) Open Assessment Technologies SA ;
|
|
180
|
-
*/
|
|
181
|
-
/**
|
|
182
|
-
* Enable/disable an element
|
|
183
|
-
* @param {jQuery} $element
|
|
184
|
-
* @param {Boolean} enabled
|
|
209
|
+
* Will update the displayed controls according to the current PDF
|
|
185
210
|
*/
|
|
186
211
|
|
|
187
|
-
function
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
212
|
+
function updateControls() {
|
|
213
|
+
var page = pdf.getPage();
|
|
214
|
+
var pageCount = pdf.getPageCount();
|
|
215
|
+
|
|
216
|
+
if (page !== parseInt(controls.$pageNum.val(), 10)) {
|
|
217
|
+
controls.$pageNum.val(page);
|
|
192
218
|
}
|
|
219
|
+
|
|
220
|
+
toggleState(controls.$pagePrev, enabled && page > 1);
|
|
221
|
+
toggleState(controls.$pageNext, enabled && page < pageCount);
|
|
222
|
+
toggleState(controls.$pageNum, enabled && pageCount > 1);
|
|
193
223
|
}
|
|
194
224
|
/**
|
|
195
|
-
*
|
|
196
|
-
* @param {jQuery} $container
|
|
197
|
-
* @param {Object} config
|
|
198
|
-
* @param {Object} config.PDFJS - The PDFJS entry point
|
|
199
|
-
* @param {Boolean} [config.fitToWidth] - Fit the page to the available width, a scroll bar may appear
|
|
200
|
-
* @param {Boolean} [config.allowSearch] - Allow to search within the displayed PDF
|
|
201
|
-
* @param {Boolean} [config.caseSensitiveSearch] - Use a case sensitive search when the search feature is available
|
|
202
|
-
* @param {Boolean} [config.highlightAllMatches] - Highlight all matches to see all of them at a glance
|
|
203
|
-
* @returns {Object}
|
|
225
|
+
* Enables the controls
|
|
204
226
|
*/
|
|
205
227
|
|
|
206
228
|
|
|
207
|
-
function
|
|
208
|
-
var template = viewerTpl(config);
|
|
209
|
-
var events = eventifier();
|
|
210
|
-
var controls = {};
|
|
211
|
-
var broker = null;
|
|
212
|
-
var findBar = null;
|
|
213
|
-
var pdfConfig = null;
|
|
214
|
-
var pdf = null;
|
|
215
|
-
var PDFJS = null;
|
|
216
|
-
var enabled = true;
|
|
229
|
+
function enable() {
|
|
217
230
|
/**
|
|
218
|
-
*
|
|
231
|
+
* Requests an enabling
|
|
232
|
+
* @event enable
|
|
219
233
|
*/
|
|
234
|
+
events.trigger('enable');
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Disable the controls
|
|
238
|
+
*/
|
|
220
239
|
|
|
221
|
-
function updateControls() {
|
|
222
|
-
var page = pdf.getPage();
|
|
223
|
-
var pageCount = pdf.getPageCount();
|
|
224
|
-
|
|
225
|
-
if (page !== parseInt(controls.$pageNum.val(), 10)) {
|
|
226
|
-
controls.$pageNum.val(page);
|
|
227
|
-
}
|
|
228
240
|
|
|
229
|
-
|
|
230
|
-
toggleState(controls.$pageNext, enabled && page < pageCount);
|
|
231
|
-
toggleState(controls.$pageNum, enabled && pageCount > 1);
|
|
232
|
-
}
|
|
241
|
+
function disable() {
|
|
233
242
|
/**
|
|
234
|
-
*
|
|
243
|
+
* Requests a disabling
|
|
244
|
+
* @event disable
|
|
235
245
|
*/
|
|
246
|
+
events.trigger('disable');
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Will refresh the page
|
|
250
|
+
*/
|
|
236
251
|
|
|
237
252
|
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Requests an enabling
|
|
241
|
-
* @event enable
|
|
242
|
-
*/
|
|
243
|
-
events.trigger('enable');
|
|
244
|
-
}
|
|
253
|
+
function refresh() {
|
|
245
254
|
/**
|
|
246
|
-
*
|
|
255
|
+
* Requests a page refresh
|
|
256
|
+
* @event refresh
|
|
247
257
|
*/
|
|
258
|
+
events.trigger('refresh');
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Go to a particular page
|
|
262
|
+
* @param page
|
|
263
|
+
*/
|
|
248
264
|
|
|
249
265
|
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Requests a disabling
|
|
253
|
-
* @event disable
|
|
254
|
-
*/
|
|
255
|
-
events.trigger('disable');
|
|
256
|
-
}
|
|
266
|
+
function jumpPage(page) {
|
|
257
267
|
/**
|
|
258
|
-
*
|
|
268
|
+
* Requests a page change
|
|
269
|
+
* @event setpage
|
|
270
|
+
* @param {Number} pageNum
|
|
259
271
|
*/
|
|
272
|
+
events.trigger('setpage', page);
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Move the current page by step
|
|
276
|
+
* @param step
|
|
277
|
+
*/
|
|
260
278
|
|
|
261
279
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
* @event refresh
|
|
266
|
-
*/
|
|
267
|
-
events.trigger('refresh');
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* Go to a particular page
|
|
271
|
-
* @param page
|
|
272
|
-
*/
|
|
280
|
+
function movePage(step) {
|
|
281
|
+
jumpPage(pdf.getPage() + step);
|
|
282
|
+
}
|
|
273
283
|
|
|
284
|
+
config = config || {};
|
|
285
|
+
PDFJS = config.PDFJS;
|
|
286
|
+
pdfConfig = _.merge({
|
|
287
|
+
events: events
|
|
288
|
+
}, _.pick(config, ['PDFJS', 'fitToWidth']));
|
|
274
289
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
*/
|
|
281
|
-
events.trigger('setpage', page);
|
|
282
|
-
}
|
|
290
|
+
if (!_.isPlainObject(PDFJS)) {
|
|
291
|
+
throw new TypeError('You must provide the entry point to the PDF.js library! [config.PDFJS is missing]');
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return {
|
|
283
295
|
/**
|
|
284
|
-
*
|
|
285
|
-
* @param
|
|
296
|
+
* Loads and displays the document
|
|
297
|
+
* @param {String} url
|
|
298
|
+
* @returns {Promise}
|
|
286
299
|
*/
|
|
300
|
+
load: function load(url) {
|
|
301
|
+
// PDF.js installed
|
|
302
|
+
$container.html(template); // Disable the streaming mode: the file needs to be fully loaded before display.
|
|
303
|
+
// This will prevent "Bad offset" error under Chrome and IE, but will slow down the first display.
|
|
304
|
+
// Other approach would be to provide a range loader callback, but need a lot of work.
|
|
305
|
+
|
|
306
|
+
PDFJS.PDFJS.disableRange = true;
|
|
307
|
+
events.on('enable', function () {
|
|
308
|
+
enabled = true;
|
|
309
|
+
updateControls();
|
|
310
|
+
}).on('disable', function () {
|
|
311
|
+
enabled = false;
|
|
312
|
+
updateControls();
|
|
313
|
+
}).on('loaded', function () {
|
|
314
|
+
controls.$pageCount.html(pdf.getPageCount());
|
|
315
|
+
enable();
|
|
316
|
+
}).on('pagechange rendered', function () {
|
|
317
|
+
updateControls();
|
|
318
|
+
});
|
|
319
|
+
broker = areaBroker($container, {
|
|
320
|
+
bar: $$1('.pdf-bar', $container),
|
|
321
|
+
actions: $$1('.pdf-actions', $container),
|
|
322
|
+
info: $$1('.pdf-info', $container),
|
|
323
|
+
content: $$1('.pdf-container', $container)
|
|
324
|
+
});
|
|
325
|
+
controls = {
|
|
326
|
+
$navigation: $container.find('.navigation'),
|
|
327
|
+
$pagePrev: $container.find('[data-control="pdf-page-prev"]'),
|
|
328
|
+
$pageNext: $container.find('[data-control="pdf-page-next"]'),
|
|
329
|
+
$pageNum: $container.find('[data-control="pdf-page-num"]'),
|
|
330
|
+
$pageCount: $container.find('[data-control="pdf-page-count"]'),
|
|
331
|
+
$fitToWidth: $container.find('[data-control="fit-to-width"]')
|
|
332
|
+
};
|
|
333
|
+
pdf = wrapperFactory(broker.getContentArea(), pdfConfig);
|
|
334
|
+
|
|
335
|
+
if (config.allowSearch) {
|
|
336
|
+
findBar = findBarFactory({
|
|
337
|
+
events: events,
|
|
338
|
+
areaBroker: broker,
|
|
339
|
+
textManager: pdf.getTextManager(),
|
|
340
|
+
caseSensitive: config.caseSensitiveSearch,
|
|
341
|
+
highlightAll: config.highlightAllMatches
|
|
342
|
+
});
|
|
343
|
+
}
|
|
287
344
|
|
|
345
|
+
this.setSize($container.width(), $container.height());
|
|
346
|
+
controls.$fitToWidth.on('change', function () {
|
|
347
|
+
pdfConfig.fitToWidth = controls.$fitToWidth.is(':checked');
|
|
348
|
+
refresh();
|
|
349
|
+
});
|
|
350
|
+
controls.$navigation.on('click', function () {
|
|
351
|
+
movePage(parseInt($$1(this).data('direction'), 10) || 1);
|
|
352
|
+
});
|
|
353
|
+
controls.$pageNum.on('change', function () {
|
|
354
|
+
jumpPage(parseInt(controls.$pageNum.val(), 10) || pdf.getPage());
|
|
355
|
+
}).on('keydown', function (event) {
|
|
356
|
+
switch (event.keyCode) {
|
|
357
|
+
case 38:
|
|
358
|
+
movePage(1);
|
|
359
|
+
event.stopPropagation();
|
|
360
|
+
event.preventDefault();
|
|
361
|
+
break;
|
|
362
|
+
|
|
363
|
+
case 40:
|
|
364
|
+
movePage(-1);
|
|
365
|
+
event.stopPropagation();
|
|
366
|
+
event.preventDefault();
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
disable();
|
|
371
|
+
return pdf.load(url);
|
|
372
|
+
},
|
|
288
373
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
PDFJS = config.PDFJS;
|
|
295
|
-
pdfConfig = _.merge({
|
|
296
|
-
events: events
|
|
297
|
-
}, _.pick(config, ['PDFJS', 'fitToWidth']));
|
|
298
|
-
|
|
299
|
-
if (!_.isPlainObject(PDFJS)) {
|
|
300
|
-
throw new TypeError('You must provide the entry point to the PDF.js library! [config.PDFJS is missing]');
|
|
301
|
-
}
|
|
374
|
+
/**
|
|
375
|
+
* Destroys the component
|
|
376
|
+
*/
|
|
377
|
+
unload: function unload() {
|
|
378
|
+
disable();
|
|
302
379
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
* @param {String} url
|
|
307
|
-
* @returns {Promise}
|
|
308
|
-
*/
|
|
309
|
-
load: function load(url) {
|
|
310
|
-
// PDF.js installed
|
|
311
|
-
$container.html(template); // Disable the streaming mode: the file needs to be fully loaded before display.
|
|
312
|
-
// This will prevent "Bad offset" error under Chrome and IE, but will slow down the first display.
|
|
313
|
-
// Other approach would be to provide a range loader callback, but need a lot of work.
|
|
314
|
-
|
|
315
|
-
PDFJS.PDFJS.disableRange = true;
|
|
316
|
-
events.on('enable', function () {
|
|
317
|
-
enabled = true;
|
|
318
|
-
updateControls();
|
|
319
|
-
}).on('disable', function () {
|
|
320
|
-
enabled = false;
|
|
321
|
-
updateControls();
|
|
322
|
-
}).on('loaded', function () {
|
|
323
|
-
controls.$pageCount.html(pdf.getPageCount());
|
|
324
|
-
enable();
|
|
325
|
-
}).on('pagechange rendered', function () {
|
|
326
|
-
updateControls();
|
|
327
|
-
});
|
|
328
|
-
broker = areaBroker($container, {
|
|
329
|
-
bar: $$1('.pdf-bar', $container),
|
|
330
|
-
actions: $$1('.pdf-actions', $container),
|
|
331
|
-
info: $$1('.pdf-info', $container),
|
|
332
|
-
content: $$1('.pdf-container', $container)
|
|
333
|
-
});
|
|
334
|
-
controls = {
|
|
335
|
-
$navigation: $container.find('.navigation'),
|
|
336
|
-
$pagePrev: $container.find('[data-control="pdf-page-prev"]'),
|
|
337
|
-
$pageNext: $container.find('[data-control="pdf-page-next"]'),
|
|
338
|
-
$pageNum: $container.find('[data-control="pdf-page-num"]'),
|
|
339
|
-
$pageCount: $container.find('[data-control="pdf-page-count"]'),
|
|
340
|
-
$fitToWidth: $container.find('[data-control="fit-to-width"]')
|
|
341
|
-
};
|
|
342
|
-
pdf = wrapperFactory(broker.getContentArea(), pdfConfig);
|
|
343
|
-
|
|
344
|
-
if (config.allowSearch) {
|
|
345
|
-
findBar = findBarFactory({
|
|
346
|
-
events: events,
|
|
347
|
-
areaBroker: broker,
|
|
348
|
-
textManager: pdf.getTextManager(),
|
|
349
|
-
caseSensitive: config.caseSensitiveSearch,
|
|
350
|
-
highlightAll: config.highlightAllMatches
|
|
351
|
-
});
|
|
352
|
-
}
|
|
380
|
+
if (findBar) {
|
|
381
|
+
findBar.destroy();
|
|
382
|
+
}
|
|
353
383
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
refresh();
|
|
358
|
-
});
|
|
359
|
-
controls.$navigation.on('click', function () {
|
|
360
|
-
movePage(parseInt($$1(this).data('direction'), 10) || 1);
|
|
361
|
-
});
|
|
362
|
-
controls.$pageNum.on('change', function () {
|
|
363
|
-
jumpPage(parseInt(controls.$pageNum.val(), 10) || pdf.getPage());
|
|
364
|
-
}).on('keydown', function (event) {
|
|
365
|
-
switch (event.keyCode) {
|
|
366
|
-
case 38:
|
|
367
|
-
movePage(1);
|
|
368
|
-
event.stopPropagation();
|
|
369
|
-
event.preventDefault();
|
|
370
|
-
break;
|
|
371
|
-
|
|
372
|
-
case 40:
|
|
373
|
-
movePage(-1);
|
|
374
|
-
event.stopPropagation();
|
|
375
|
-
event.preventDefault();
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
disable();
|
|
380
|
-
return pdf.load(url);
|
|
381
|
-
},
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Destroys the component
|
|
385
|
-
*/
|
|
386
|
-
unload: function unload() {
|
|
387
|
-
disable();
|
|
388
|
-
|
|
389
|
-
if (findBar) {
|
|
390
|
-
findBar.destroy();
|
|
391
|
-
}
|
|
384
|
+
if (pdf) {
|
|
385
|
+
pdf.destroy();
|
|
386
|
+
}
|
|
392
387
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
388
|
+
events.removeAllListeners();
|
|
389
|
+
$container.empty();
|
|
390
|
+
controls = {};
|
|
391
|
+
pdfConfig = null;
|
|
392
|
+
pdf = null;
|
|
393
|
+
findBar = null;
|
|
394
|
+
broker = null;
|
|
395
|
+
},
|
|
396
396
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
* @event resized
|
|
423
|
-
* @param {Number} width
|
|
424
|
-
* @param {Number} height
|
|
425
|
-
* @param {Number} contentHeight
|
|
426
|
-
*/
|
|
427
|
-
|
|
428
|
-
events.trigger('resized', width, height, contentHeight); // force the repaint of the current page, the PDF wrapper will take care of its container's size
|
|
429
|
-
|
|
430
|
-
return pdf.refresh();
|
|
431
|
-
}
|
|
397
|
+
/**
|
|
398
|
+
* Sets the size of the component
|
|
399
|
+
* @param {Number} width
|
|
400
|
+
* @param {Number} height
|
|
401
|
+
*/
|
|
402
|
+
setSize: function setSize(width, height) {
|
|
403
|
+
var contentHeight, $bar, $content; // only adjust the action bar width, and let the PDF viewer manage its size with the remaining space
|
|
404
|
+
|
|
405
|
+
if (pdf) {
|
|
406
|
+
$bar = broker.getBarArea();
|
|
407
|
+
$content = broker.getContentArea();
|
|
408
|
+
contentHeight = height - $bar.outerHeight();
|
|
409
|
+
$bar.width(width);
|
|
410
|
+
$content.width(width).height(contentHeight);
|
|
411
|
+
/**
|
|
412
|
+
* Notifies a resize
|
|
413
|
+
* @event resized
|
|
414
|
+
* @param {Number} width
|
|
415
|
+
* @param {Number} height
|
|
416
|
+
* @param {Number} contentHeight
|
|
417
|
+
*/
|
|
418
|
+
|
|
419
|
+
events.trigger('resized', width, height, contentHeight); // force the repaint of the current page, the PDF wrapper will take care of its container's size
|
|
420
|
+
|
|
421
|
+
return pdf.refresh();
|
|
432
422
|
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
}
|
|
435
426
|
|
|
436
|
-
|
|
427
|
+
return pdfjsViewerFactory;
|
|
437
428
|
|
|
438
429
|
});
|