@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.
Files changed (233) hide show
  1. package/dist/actionbar.js +386 -395
  2. package/dist/adder.js +21 -19
  3. package/dist/animable/absorbable/absorbable.js +204 -213
  4. package/dist/animable/absorbable/css/absorb.css +1 -0
  5. package/dist/animable/absorbable/css/absorb.css.map +1 -1
  6. package/dist/animable/pulsable/pulsable.js +168 -177
  7. package/dist/autocomplete/css/autocomplete.css +1 -0
  8. package/dist/autocomplete/css/autocomplete.css.map +1 -1
  9. package/dist/autocomplete.js +68 -66
  10. package/dist/badge/badge.js +188 -197
  11. package/dist/badge/css/badge.css +1 -0
  12. package/dist/badge/css/badge.css.map +1 -1
  13. package/dist/breadcrumbs.js +275 -284
  14. package/dist/btngrouper.js +5 -5
  15. package/dist/bulkActionPopup.js +490 -495
  16. package/dist/button.js +283 -291
  17. package/dist/cascadingComboBox.js +249 -258
  18. package/dist/ckeditor/ckConfigurator.js +26 -19
  19. package/dist/ckeditor/dtdHandler.js +11 -9
  20. package/dist/class/selector.js +441 -450
  21. package/dist/component/resizable.js +1 -1
  22. package/dist/component/windowed.js +285 -294
  23. package/dist/component.js +419 -428
  24. package/dist/contextualPopup.js +417 -426
  25. package/dist/dashboard.js +300 -309
  26. package/dist/datalist.js +753 -762
  27. package/dist/datatable/filterStrategy/multiple.js +1 -1
  28. package/dist/datatable/filterStrategy/single.js +1 -1
  29. package/dist/datatable.js +1527 -1550
  30. package/dist/dateRange/dateRange.js +393 -402
  31. package/dist/datetime/picker.js +665 -672
  32. package/dist/deleter.js +368 -377
  33. package/dist/destination/selector.js +286 -295
  34. package/dist/dialog/alert.js +3 -3
  35. package/dist/dialog/confirm.js +1 -1
  36. package/dist/dialog/confirmDelete.js +216 -225
  37. package/dist/dialog.js +650 -654
  38. package/dist/disabler.js +8 -8
  39. package/dist/documentViewer/providers/pdfViewer/fallback/viewer.js +166 -175
  40. package/dist/documentViewer/providers/pdfViewer/pdfjs/findBar.js +518 -527
  41. package/dist/documentViewer/providers/pdfViewer/pdfjs/pageView.js +380 -389
  42. package/dist/documentViewer/providers/pdfViewer/pdfjs/searchEngine.js +539 -548
  43. package/dist/documentViewer/providers/pdfViewer/pdfjs/viewer.js +369 -378
  44. package/dist/documentViewer/providers/pdfViewer.js +184 -193
  45. package/dist/documentViewer.js +292 -301
  46. package/dist/dropdown.js +383 -392
  47. package/dist/durationer.js +5 -5
  48. package/dist/dynamicComponent.js +597 -598
  49. package/dist/feedback.js +356 -362
  50. package/dist/figure/FigureStateActive.js +117 -108
  51. package/dist/filesender.js +2 -2
  52. package/dist/filter.js +230 -239
  53. package/dist/form/dropdownForm.js +355 -357
  54. package/dist/form/form.js +919 -690
  55. package/dist/form/simpleForm.js +1 -1
  56. package/dist/form/validator/renderer.js +233 -235
  57. package/dist/form/validator/validator.js +257 -189
  58. package/dist/form/widget/definitions.js +1 -1
  59. package/dist/form/widget/providers/checkBox.js +254 -259
  60. package/dist/form/widget/providers/comboBox.js +187 -192
  61. package/dist/form/widget/providers/default.js +8 -9
  62. package/dist/form/widget/providers/hidden.js +170 -179
  63. package/dist/form/widget/providers/hiddenBox.js +262 -267
  64. package/dist/form/widget/providers/radioBox.js +216 -225
  65. package/dist/form/widget/providers/textArea.js +187 -196
  66. package/dist/form/widget/providers/textBox.js +2 -3
  67. package/dist/form/widget/widget.js +473 -475
  68. package/dist/formValidator/formValidator.js +1 -1
  69. package/dist/formValidator/highlighters/message.js +1 -1
  70. package/dist/generis/form/form.js +314 -323
  71. package/dist/generis/validator/validator.js +209 -218
  72. package/dist/generis/widget/checkBox/checkBox.js +218 -227
  73. package/dist/generis/widget/comboBox/comboBox.js +179 -188
  74. package/dist/generis/widget/hiddenBox/hiddenBox.js +220 -229
  75. package/dist/generis/widget/textBox/textBox.js +169 -178
  76. package/dist/generis/widget/widget.js +246 -255
  77. package/dist/groupedComboBox.js +222 -231
  78. package/dist/groupvalidator.js +2 -2
  79. package/dist/highlighter.js +967 -958
  80. package/dist/image/ImgStateActive/helper.js +7 -5
  81. package/dist/image/ImgStateActive/initHelper.js +49 -43
  82. package/dist/image/ImgStateActive/initMediaEditor.js +24 -20
  83. package/dist/image/ImgStateActive/mediaSizer.js +14 -12
  84. package/dist/image/ImgStateActive.js +72 -70
  85. package/dist/incrementer.js +6 -6
  86. package/dist/inplacer.js +6 -6
  87. package/dist/itemButtonList/css/item-button-list.css +1 -0
  88. package/dist/itemButtonList/css/item-button-list.css.map +1 -1
  89. package/dist/itemButtonList.js +439 -435
  90. package/dist/keyNavigation/navigableDomElement.js +51 -38
  91. package/dist/keyNavigation/navigator.js +85 -70
  92. package/dist/listbox.js +460 -469
  93. package/dist/liststyler.js +8 -8
  94. package/dist/loadingButton/loadingButton.js +209 -218
  95. package/dist/lock.js +476 -485
  96. package/dist/login/login.js +475 -484
  97. package/dist/maths/calculator/basicCalculator.js +235 -244
  98. package/dist/maths/calculator/calculatorComponent.js +3 -3
  99. package/dist/maths/calculator/core/board.js +772 -781
  100. package/dist/maths/calculator/core/expression.js +476 -485
  101. package/dist/maths/calculator/core/labels.js +228 -237
  102. package/dist/maths/calculator/core/tokenizer.js +1 -1
  103. package/dist/maths/calculator/core/tokens.js +163 -170
  104. package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +244 -253
  105. package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +279 -288
  106. package/dist/maths/calculator/scientificCalculator.js +327 -336
  107. package/dist/mediaEditor/mediaEditorComponent.js +238 -245
  108. package/dist/mediaEditor/plugins/mediaAlignment/helper.js +7 -7
  109. package/dist/mediaEditor/plugins/mediaAlignment/mediaAlignmentComponent.js +229 -235
  110. package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +580 -589
  111. package/dist/mediaplayer/players/html5.js +666 -675
  112. package/dist/mediaplayer/players/youtube.js +419 -424
  113. package/dist/mediaplayer/support.js +11 -10
  114. package/dist/mediaplayer/utils/reminder.js +14 -13
  115. package/dist/mediaplayer/utils/timeObserver.js +10 -11
  116. package/dist/mediaplayer/youtubeManager.js +164 -145
  117. package/dist/mediaplayer.js +1565 -1520
  118. package/dist/mediasizer.js +669 -678
  119. package/dist/modal.js +10 -17
  120. package/dist/pageSizeSelector.js +219 -228
  121. package/dist/pagination/providers/pages.js +280 -289
  122. package/dist/pagination/providers/simple.js +192 -201
  123. package/dist/previewer.js +30 -30
  124. package/dist/progressbar.js +4 -4
  125. package/dist/report.js +347 -356
  126. package/dist/resource/filters.js +271 -280
  127. package/dist/resource/list.js +1264 -1273
  128. package/dist/resource/selector.js +865 -874
  129. package/dist/resource/tree.js +1483 -1492
  130. package/dist/resourcemgr/fileBrowser.js +564 -569
  131. package/dist/resourcemgr/filePreview.js +16 -16
  132. package/dist/resourcemgr/fileSelector.js +515 -524
  133. package/dist/resourcemgr/util/updatePermissions.js +2 -2
  134. package/dist/resourcemgr.js +306 -315
  135. package/dist/searchModal/advancedSearch.js +796 -767
  136. package/dist/searchModal.js +114 -91
  137. package/dist/switch/switch.js +298 -307
  138. package/dist/tabs.js +598 -575
  139. package/dist/taskQueue/status.js +312 -321
  140. package/dist/taskQueue/table.js +375 -384
  141. package/dist/taskQueue/taskQueueModel.js +488 -472
  142. package/dist/taskQueueButton/taskable.js +264 -273
  143. package/dist/taskQueueButton/treeButton.js +189 -198
  144. package/dist/themeLoader.js +24 -23
  145. package/dist/themes.js +1 -1
  146. package/dist/toggler.js +3 -3
  147. package/dist/tooltip.js +295 -304
  148. package/dist/transformer.js +2 -2
  149. package/dist/tristateCheckboxGroup.js +311 -320
  150. package/dist/uploader.js +687 -696
  151. package/dist/validator/Report.js +1 -1
  152. package/dist/validator/Validator.js +3 -3
  153. package/dist/validator/validators.js +9 -9
  154. package/dist/validator.js +240 -230
  155. package/dist/waitForMedia.js +1 -1
  156. package/package.json +3 -3
  157. package/src/animable/absorbable/css/absorb.css +1 -0
  158. package/src/animable/absorbable/css/absorb.css.map +1 -1
  159. package/src/autocomplete/css/autocomplete.css +1 -0
  160. package/src/autocomplete/css/autocomplete.css.map +1 -1
  161. package/src/badge/css/badge.css +1 -0
  162. package/src/badge/css/badge.css.map +1 -1
  163. package/src/ckeditor/ckConfigurator.js +4 -0
  164. package/src/itemButtonList/css/item-button-list.css +1 -0
  165. package/src/itemButtonList/css/item-button-list.css.map +1 -1
  166. package/src/.DS_Store +0 -0
  167. package/src/css/basic.css +0 -7826
  168. package/src/css/basic.css.map +0 -1
  169. package/src/css/ckeditor/skins/tao/css/dialog.css +0 -950
  170. package/src/css/ckeditor/skins/tao/css/dialog.css.map +0 -1
  171. package/src/css/ckeditor/skins/tao/css/editor.css +0 -1850
  172. package/src/css/ckeditor/skins/tao/css/editor.css.map +0 -1
  173. package/src/scss/.DS_Store +0 -0
  174. package/src/scss/basic.scss +0 -16
  175. package/src/scss/ckeditor/skins/tao/scss/dialog.scss +0 -763
  176. package/src/scss/ckeditor/skins/tao/scss/editor.scss +0 -111
  177. package/src/scss/ckeditor/skins/tao/scss/inc/_ck-icons.scss +0 -59
  178. package/src/scss/ckeditor/skins/tao/scss/inc/_colorpanel.scss +0 -118
  179. package/src/scss/ckeditor/skins/tao/scss/inc/_elementspath.scss +0 -69
  180. package/src/scss/ckeditor/skins/tao/scss/inc/_mainui.scss +0 -194
  181. package/src/scss/ckeditor/skins/tao/scss/inc/_menu.scss +0 -181
  182. package/src/scss/ckeditor/skins/tao/scss/inc/_panel.scss +0 -200
  183. package/src/scss/ckeditor/skins/tao/scss/inc/_presets.scss +0 -32
  184. package/src/scss/ckeditor/skins/tao/scss/inc/_reset.scss +0 -101
  185. package/src/scss/ckeditor/skins/tao/scss/inc/_richcombo.scss +0 -213
  186. package/src/scss/ckeditor/skins/tao/scss/inc/_tao.scss +0 -59
  187. package/src/scss/ckeditor/skins/tao/scss/inc/_toolbar.scss +0 -301
  188. package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot +0 -0
  189. package/src/scss/font/source-sans-pro/source-sans-pro-italic.eot.b64 +0 -1
  190. package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff +0 -0
  191. package/src/scss/font/source-sans-pro/source-sans-pro-italic.woff.b64 +0 -1
  192. package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot +0 -0
  193. package/src/scss/font/source-sans-pro/source-sans-pro-regular.eot.b64 +0 -1
  194. package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff +0 -0
  195. package/src/scss/font/source-sans-pro/source-sans-pro-regular.woff.b64 +0 -1
  196. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot +0 -0
  197. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.eot.b64 +0 -1
  198. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff +0 -0
  199. package/src/scss/font/source-sans-pro/source-sans-pro-semibold-italic.woff.b64 +0 -1
  200. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot +0 -0
  201. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.eot.b64 +0 -1
  202. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff +0 -0
  203. package/src/scss/font/source-sans-pro/source-sans-pro-semibold.woff.b64 +0 -1
  204. package/src/scss/font/tao/tao.eot +0 -0
  205. package/src/scss/font/tao/tao.svg +0 -235
  206. package/src/scss/font/tao/tao.ttf +0 -0
  207. package/src/scss/font/tao/tao.woff +0 -0
  208. package/src/scss/inc/_base.scss +0 -496
  209. package/src/scss/inc/_bootstrap.scss +0 -6
  210. package/src/scss/inc/_buttons.scss +0 -114
  211. package/src/scss/inc/_colors.scss +0 -88
  212. package/src/scss/inc/_feedback.scss +0 -150
  213. package/src/scss/inc/_flex-grid.scss +0 -15
  214. package/src/scss/inc/_fonts.scss +0 -4
  215. package/src/scss/inc/_forms.scss +0 -827
  216. package/src/scss/inc/_functions.scss +0 -283
  217. package/src/scss/inc/_grid.scss +0 -66
  218. package/src/scss/inc/_jquery.nouislider.scss +0 -254
  219. package/src/scss/inc/_normalize.scss +0 -528
  220. package/src/scss/inc/_report.scss +0 -68
  221. package/src/scss/inc/_secondary-properties.scss +0 -89
  222. package/src/scss/inc/_select2.scss +0 -634
  223. package/src/scss/inc/_toolbars.scss +0 -155
  224. package/src/scss/inc/_tooltip.scss +0 -312
  225. package/src/scss/inc/_variables.scss +0 -21
  226. package/src/scss/inc/base/_highlight.scss +0 -5
  227. package/src/scss/inc/base/_list-style.scss +0 -59
  228. package/src/scss/inc/base/_svg.scss +0 -3
  229. package/src/scss/inc/base/_table.scss +0 -63
  230. package/src/scss/inc/fonts/_source-sans-pro.scss +0 -29
  231. package/src/scss/inc/fonts/_tao-icon-classes.scss +0 -226
  232. package/src/scss/inc/fonts/_tao-icon-def.scss +0 -12
  233. package/src/scss/inc/fonts/_tao-icon-vars.scss +0 -240
@@ -1,641 +1,632 @@
1
1
  define(['jquery', 'lodash', 'ui/autoscroll', 'ui/hider', 'ui/documentViewer/providers/pdfViewer/pdfjs/searchEngine', 'handlebars', 'i18n', 'lib/dompurify/purify'], function ($$1, _, autoscroll, hider, searchEngineFactory, Handlebars, __, DOMPurify) { 'use strict';
2
2
 
3
- $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
- _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
- autoscroll = autoscroll && Object.prototype.hasOwnProperty.call(autoscroll, 'default') ? autoscroll['default'] : autoscroll;
6
- hider = hider && Object.prototype.hasOwnProperty.call(hider, 'default') ? hider['default'] : hider;
7
- searchEngineFactory = searchEngineFactory && Object.prototype.hasOwnProperty.call(searchEngineFactory, 'default') ? searchEngineFactory['default'] : searchEngineFactory;
8
- Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
9
- __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
10
- DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
11
-
3
+ $$1 = $$1 && Object.prototype.hasOwnProperty.call($$1, 'default') ? $$1['default'] : $$1;
4
+ _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
5
+ autoscroll = autoscroll && Object.prototype.hasOwnProperty.call(autoscroll, 'default') ? autoscroll['default'] : autoscroll;
6
+ hider = hider && Object.prototype.hasOwnProperty.call(hider, 'default') ? hider['default'] : hider;
7
+ searchEngineFactory = searchEngineFactory && Object.prototype.hasOwnProperty.call(searchEngineFactory, 'default') ? searchEngineFactory['default'] : searchEngineFactory;
8
+ Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
9
+ __ = __ && Object.prototype.hasOwnProperty.call(__, 'default') ? __['default'] : __;
10
+ DOMPurify = DOMPurify && Object.prototype.hasOwnProperty.call(DOMPurify, 'default') ? DOMPurify['default'] : DOMPurify;
11
+
12
+ function _typeof(obj) {
13
+ "@babel/helpers - typeof";
14
+
15
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
16
+ return typeof obj;
17
+ } : function (obj) {
18
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
19
+ }, _typeof(obj);
20
+ }
21
+
22
+ function Helpers0 (hb) {
23
+ //register a i18n helper
24
+ hb.registerHelper('__', function (key) {
25
+ return __(key);
26
+ });
12
27
  /**
13
- * This program is free software; you can redistribute it and/or
14
- * modify it under the terms of the GNU General Public License
15
- * as published by the Free Software Foundation; under version 2
16
- * of the License (non-upgradable).
17
- *
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program; if not, write to the Free Software
25
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
- *
27
- * Copyright (c) 2013-2019 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
28
- *
28
+ * Register dompurify helper
29
29
  *
30
+ * https://github.com/cure53/DOMPurify
31
+ * with config SAFE_FOR_TEMPLATES: true
32
+ * to make output safe for template systems
30
33
  */
31
- function Helpers0 (hb) {
32
- //register a i18n helper
33
- hb.registerHelper('__', function (key) {
34
- return __(key);
35
- });
36
- /**
37
- * Register dompurify helper
38
- *
39
- * https://github.com/cure53/DOMPurify
40
- * with config SAFE_FOR_TEMPLATES: true
41
- * to make output safe for template systems
42
- */
43
34
 
44
- hb.registerHelper('dompurify', function (context) {
45
- return DOMPurify.sanitize(context);
46
- });
47
- /**
48
- * Register join helper
49
- *
50
- * Example :
51
- * var values = {a:v1, b:v2, c:v3};
52
- * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
53
- * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
54
- */
55
-
56
- hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
57
- var fragments = [];
58
- keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
59
- fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
60
- wrapper = typeof wrapper === 'string' ? wrapper : '"';
35
+ hb.registerHelper('dompurify', function (context) {
36
+ return DOMPurify.sanitize(context);
37
+ });
38
+ /**
39
+ * Register join helper
40
+ *
41
+ * Example :
42
+ * var values = {a:v1, b:v2, c:v3};
43
+ * Using {{{join attributes '=' ' ' '"'}}} will return : a="v1" b="v2" c="v3"
44
+ * Using {{{join values null ' or ' '*'}}} will return : *v1* or *v2* or *v3*
45
+ */
61
46
 
62
- _.forIn(arr, function (value, key) {
63
- var fragment = '';
47
+ hb.registerHelper('join', function (arr, keyValueGlue, fragmentGlue, wrapper) {
48
+ var fragments = [];
49
+ keyValueGlue = typeof keyValueGlue === 'string' ? keyValueGlue : undefined;
50
+ fragmentGlue = typeof fragmentGlue === 'string' ? fragmentGlue : ' ';
51
+ wrapper = typeof wrapper === 'string' ? wrapper : '"';
64
52
 
65
- if (value !== null || value !== undefined) {
66
- if (typeof value === 'boolean') {
67
- value = value ? 'true' : 'false';
68
- } else if (typeof value === 'object') {
69
- value = _.values(value).join(' ');
70
- }
71
- } else {
72
- value = '';
73
- }
53
+ _.forIn(arr, function (value, key) {
54
+ var fragment = '';
74
55
 
75
- if (keyValueGlue !== undefined) {
76
- fragment += key + keyValueGlue;
56
+ if (value !== null || value !== undefined) {
57
+ if (typeof value === 'boolean') {
58
+ value = value ? 'true' : 'false';
59
+ } else if (_typeof(value) === 'object') {
60
+ value = _.values(value).join(' ');
77
61
  }
62
+ } else {
63
+ value = '';
64
+ }
78
65
 
79
- fragment += wrapper + value + wrapper;
80
- fragments.push(fragment);
81
- });
82
-
83
- return fragments.join(fragmentGlue);
84
- }); //register a classic "for loop" helper
85
- //it also adds a local variable "i" as the index in each iteration loop
86
-
87
- hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
88
- var ret = '';
89
- startIndex = parseInt(startIndex);
90
- stopIndex = parseInt(stopIndex);
91
- increment = parseInt(increment);
92
-
93
- for (var i = startIndex; i < stopIndex; i += increment) {
94
- ret += options.fn(_.extend({}, this, {
95
- i: i
96
- }));
66
+ if (keyValueGlue !== undefined) {
67
+ fragment += key + keyValueGlue;
97
68
  }
98
69
 
99
- return ret;
70
+ fragment += wrapper + value + wrapper;
71
+ fragments.push(fragment);
100
72
  });
101
- hb.registerHelper('equal', function (var1, var2, options) {
102
- if (var1 == var2) {
103
- return options.fn(this);
104
- } else {
105
- return options.inverse(this);
106
- }
107
- }); // register a "get property" helper
108
- // it gets the named property from the provided context
109
73
 
110
- hb.registerHelper('property', function (name, context) {
111
- return context[name] || '';
112
- }); // register an 'includes' helper
113
- // it checks if value is in array
74
+ return fragments.join(fragmentGlue);
75
+ }); //register a classic "for loop" helper
76
+ //it also adds a local variable "i" as the index in each iteration loop
114
77
 
115
- hb.registerHelper('includes', function (haystack, needle, options) {
116
- if (_.contains(haystack, needle)) {
117
- return options.fn(this);
118
- }
119
- });
120
- }
78
+ hb.registerHelper('for', function (startIndex, stopIndex, increment, options) {
79
+ var ret = '';
80
+ startIndex = parseInt(startIndex);
81
+ stopIndex = parseInt(stopIndex);
82
+ increment = parseInt(increment);
121
83
 
122
- if (!Helpers0.__initialized) {
123
- Helpers0(Handlebars);
124
- Helpers0.__initialized = true;
125
- }
126
- var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
127
- this.compilerInfo = [4,'>= 1.0.0'];
128
- helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
129
- var buffer = "", stack1, helper, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, self=this;
130
-
131
- function program1(depth0,data) {
132
-
133
-
134
- return "checked ";
84
+ for (var i = startIndex; i < stopIndex; i += increment) {
85
+ ret += options.fn(_.extend({}, this, {
86
+ i: i
87
+ }));
135
88
  }
136
89
 
137
- buffer += "<button class=\"small search\" data-control=\"pdf-search\" title=\""
138
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Search", options) : helperMissing.call(depth0, "__", "Search", options)))
139
- + "\"><span class=\"icon icon-find\"></span></button>\n<div class=\"pdf-find-bar hidden\">\n <label for=\"pdf-search-query\">"
140
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Search", options) : helperMissing.call(depth0, "__", "Search", options)))
141
- + ":</label>\n <input type=\"text\" id=\"pdf-search-query\" data-control=\"pdf-search-query\" placeholder=\""
142
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Type your search", options) : helperMissing.call(depth0, "__", "Type your search", options)))
143
- + "\"/>\n <button class=\"small search\" data-control=\"pdf-search-prev\" title=\""
144
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Previous match", options) : helperMissing.call(depth0, "__", "Previous match", options)))
145
- + "\"><span class=\"icon icon-left\"></span></button>\n <button class=\"small search\" data-control=\"pdf-search-next\" title=\""
146
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Next match", options) : helperMissing.call(depth0, "__", "Next match", options)))
147
- + "\"><span class=\"icon icon-right\"></span></button>\n <input type=\"checkbox\" id=\"highlight-all\" data-control=\"highlight-all\" value=\"1\" ";
148
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.highlightAll), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
149
- if(stack1 || stack1 === 0) { buffer += stack1; }
150
- buffer += "/><label for=\"highlight-all\">"
151
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Highlight all", options) : helperMissing.call(depth0, "__", "Highlight all", options)))
152
- + "</label>\n <input type=\"checkbox\" id=\"case-sensitive-search\" data-control=\"case-sensitive-search\" value=\"1\" ";
153
- stack1 = helpers['if'].call(depth0, (depth0 && depth0.caseSensitive), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
154
- if(stack1 || stack1 === 0) { buffer += stack1; }
155
- buffer += "/><label for=\"case-sensitive-search\">"
156
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Case sensitive", options) : helperMissing.call(depth0, "__", "Case sensitive", options)))
157
- + "</label>\n <span class=\"pdf-search-info\" data-control=\"pdf-search-info\">\n <span class=\"pdf-search-position hidden\" data-control=\"pdf-search-position\">\n <span class=\"pdf-search-index\" data-control=\"pdf-search-index\"></span>/<span class=\"pdf-search-count\" data-control=\"pdf-search-count\"></span>\n </span>\n <span class=\"pdf-search-loop hidden\" data-control=\"pdf-search-loop-begin\">\n "
158
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "End of document reached. Continuing from the beginning.", options) : helperMissing.call(depth0, "__", "End of document reached. Continuing from the beginning.", options)))
159
- + "\n </span>\n <span class=\"pdf-search-loop hidden\" data-control=\"pdf-search-loop-end\">\n "
160
- + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Start of document reached. Continuing from the end.", options) : helperMissing.call(depth0, "__", "Start of document reached. Continuing from the end.", options)))
161
- + "\n </span>\n </span>\n</div>\n";
162
- return buffer;
163
- });
164
- function findBarTpl(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) 2016 (original work) Open Assessment Technologies SA ;
185
- */
186
- /**
187
- * The keypress delay before performing a search
188
- * @type {Number}
189
- */
90
+ return ret;
91
+ });
92
+ hb.registerHelper('equal', function (var1, var2, options) {
93
+ if (var1 == var2) {
94
+ return options.fn(this);
95
+ } else {
96
+ return options.inverse(this);
97
+ }
98
+ }); // register a "get property" helper
99
+ // it gets the named property from the provided context
190
100
 
191
- var searchThrottle = 250;
192
- /**
193
- * Enable/disable an element
194
- * @param {jQuery} $element
195
- * @param {Boolean} enabled
196
- */
101
+ hb.registerHelper('property', function (name, context) {
102
+ return context[name] || '';
103
+ }); // register an 'includes' helper
104
+ // it checks if value is in array
197
105
 
198
- function toggleState($element, enabled) {
199
- if (enabled) {
200
- $element.removeAttr('disabled');
201
- } else {
202
- $element.attr('disabled', true);
106
+ hb.registerHelper('includes', function (haystack, needle, options) {
107
+ if (_.contains(haystack, needle)) {
108
+ return options.fn(this);
203
109
  }
110
+ });
111
+ }
112
+
113
+ if (!Helpers0.__initialized) {
114
+ Helpers0(Handlebars);
115
+ Helpers0.__initialized = true;
116
+ }
117
+ var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
118
+ this.compilerInfo = [4,'>= 1.0.0'];
119
+ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
120
+ var buffer = "", stack1, helper, options, helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, self=this;
121
+
122
+ function program1(depth0,data) {
123
+
124
+
125
+ return "checked ";
126
+ }
127
+
128
+ buffer += "<button class=\"small search\" data-control=\"pdf-search\" title=\""
129
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Search", options) : helperMissing.call(depth0, "__", "Search", options)))
130
+ + "\"><span class=\"icon icon-find\"></span></button>\n<div class=\"pdf-find-bar hidden\">\n <label for=\"pdf-search-query\">"
131
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Search", options) : helperMissing.call(depth0, "__", "Search", options)))
132
+ + ":</label>\n <input type=\"text\" id=\"pdf-search-query\" data-control=\"pdf-search-query\" placeholder=\""
133
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Type your search", options) : helperMissing.call(depth0, "__", "Type your search", options)))
134
+ + "\"/>\n <button class=\"small search\" data-control=\"pdf-search-prev\" title=\""
135
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Previous match", options) : helperMissing.call(depth0, "__", "Previous match", options)))
136
+ + "\"><span class=\"icon icon-left\"></span></button>\n <button class=\"small search\" data-control=\"pdf-search-next\" title=\""
137
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Next match", options) : helperMissing.call(depth0, "__", "Next match", options)))
138
+ + "\"><span class=\"icon icon-right\"></span></button>\n <input type=\"checkbox\" id=\"highlight-all\" data-control=\"highlight-all\" value=\"1\" ";
139
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.highlightAll), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
140
+ if(stack1 || stack1 === 0) { buffer += stack1; }
141
+ buffer += "/><label for=\"highlight-all\">"
142
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Highlight all", options) : helperMissing.call(depth0, "__", "Highlight all", options)))
143
+ + "</label>\n <input type=\"checkbox\" id=\"case-sensitive-search\" data-control=\"case-sensitive-search\" value=\"1\" ";
144
+ stack1 = helpers['if'].call(depth0, (depth0 && depth0.caseSensitive), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
145
+ if(stack1 || stack1 === 0) { buffer += stack1; }
146
+ buffer += "/><label for=\"case-sensitive-search\">"
147
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Case sensitive", options) : helperMissing.call(depth0, "__", "Case sensitive", options)))
148
+ + "</label>\n <span class=\"pdf-search-info\" data-control=\"pdf-search-info\">\n <span class=\"pdf-search-position hidden\" data-control=\"pdf-search-position\">\n <span class=\"pdf-search-index\" data-control=\"pdf-search-index\"></span>/<span class=\"pdf-search-count\" data-control=\"pdf-search-count\"></span>\n </span>\n <span class=\"pdf-search-loop hidden\" data-control=\"pdf-search-loop-begin\">\n "
149
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "End of document reached. Continuing from the beginning.", options) : helperMissing.call(depth0, "__", "End of document reached. Continuing from the beginning.", options)))
150
+ + "\n </span>\n <span class=\"pdf-search-loop hidden\" data-control=\"pdf-search-loop-end\">\n "
151
+ + escapeExpression((helper = helpers.__ || (depth0 && depth0.__),options={hash:{},data:data},helper ? helper.call(depth0, "Start of document reached. Continuing from the end.", options) : helperMissing.call(depth0, "__", "Start of document reached. Continuing from the end.", options)))
152
+ + "\n </span>\n </span>\n</div>\n";
153
+ return buffer;
154
+ });
155
+ function findBarTpl(data, options, asString) {
156
+ var html = Template(data, options);
157
+ return (asString || true) ? html : $(html);
158
+ }
159
+
160
+ /**
161
+ * This program is free software; you can redistribute it and/or
162
+ * modify it under the terms of the GNU General Public License
163
+ * as published by the Free Software Foundation; under version 2
164
+ * of the License (non-upgradable).
165
+ *
166
+ * This program is distributed in the hope that it will be useful,
167
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
168
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
169
+ * GNU General Public License for more details.
170
+ *
171
+ * You should have received a copy of the GNU General Public License
172
+ * along with this program; if not, write to the Free Software
173
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
174
+ *
175
+ * Copyright (c) 2016 (original work) Open Assessment Technologies SA ;
176
+ */
177
+ /**
178
+ * The keypress delay before performing a search
179
+ * @type {Number}
180
+ */
181
+
182
+ var searchThrottle = 250;
183
+ /**
184
+ * Enable/disable an element
185
+ * @param {jQuery} $element
186
+ * @param {Boolean} enabled
187
+ */
188
+
189
+ function toggleState($element, enabled) {
190
+ if (enabled) {
191
+ $element.removeAttr('disabled');
192
+ } else {
193
+ $element.attr('disabled', true);
204
194
  }
195
+ }
196
+ /**
197
+ * Creates a find bar to search and display terms in the PDF document
198
+ * @param {Object} config
199
+ * @param {Object} config.events - The events hub
200
+ * @param {Object} config.areaBroker - The areaBroker that gives access to the UI area
201
+ * @param {Object} config.textManager - The textManager component that gives access to the text content
202
+ * @param {Boolean} [config.caseSensitive] - Use a case sensitive search when the search feature is available
203
+ * @param {Boolean} [config.highlightAll] - Highlight all matches to see all of them at a glance
204
+ */
205
+
206
+
207
+ function pdfjsFindBarFactory(config) {
208
+ var throttledSearchStart = _.throttle(checkQuery, searchThrottle);
209
+
210
+ var events = null;
211
+ var broker = null;
212
+ var searchEngine = null;
213
+ var query = null;
214
+ var pageNum = 0;
215
+ var enabled = true;
216
+ var loopBegin = false;
217
+ var loopEnd = false;
218
+ var navigating = false;
219
+ var controls;
205
220
  /**
206
- * Creates a find bar to search and display terms in the PDF document
207
- * @param {Object} config
208
- * @param {Object} config.events - The events hub
209
- * @param {Object} config.areaBroker - The areaBroker that gives access to the UI area
210
- * @param {Object} config.textManager - The textManager component that gives access to the text content
211
- * @param {Boolean} [config.caseSensitive] - Use a case sensitive search when the search feature is available
212
- * @param {Boolean} [config.highlightAll] - Highlight all matches to see all of them at a glance
221
+ * Search for the provided query, then trigger an update request
213
222
  */
214
223
 
224
+ function doSearch() {
225
+ loopBegin = false;
226
+ loopEnd = false;
215
227
 
216
- function pdfjsFindBarFactory(config) {
217
- var throttledSearchStart = _.throttle(checkQuery, searchThrottle);
218
-
219
- var events = null;
220
- var broker = null;
221
- var searchEngine = null;
222
- var query = null;
223
- var pageNum = 0;
224
- var enabled = true;
225
- var loopBegin = false;
226
- var loopEnd = false;
227
- var navigating = false;
228
- var controls;
229
- /**
230
- * Search for the provided query, then trigger an update request
231
- */
232
-
233
- function doSearch() {
234
- loopBegin = false;
235
- loopEnd = false;
236
-
237
- if (query) {
238
- if (searchEngine) {
228
+ if (query) {
229
+ if (searchEngine) {
230
+ /**
231
+ * Notifies a search is processing
232
+ * @event searching
233
+ * @param {String} query
234
+ */
235
+ events.trigger('searching', query);
236
+ searchEngine.search(query, pageNum).then(function (page) {
239
237
  /**
240
- * Notifies a search is processing
241
- * @event searching
238
+ * Notifies the search has ended
239
+ * @event searchdone
242
240
  * @param {String} query
241
+ * @param {Number} page
243
242
  */
244
- events.trigger('searching', query);
245
- searchEngine.search(query, pageNum).then(function (page) {
246
- /**
247
- * Notifies the search has ended
248
- * @event searchdone
249
- * @param {String} query
250
- * @param {Number} page
251
- */
252
- events.trigger('searchdone', query, page);
253
-
254
- if (page) {
255
- jumpTo(page);
256
- } else {
257
- refresh();
258
- }
259
- }).catch(function (err) {
260
- /**
261
- * Notifies the search error
262
- * @event error
263
- * @param {Object} err
264
- */
265
- events.trigger('error', err);
266
- });
267
- }
268
- } else {
269
- if (searchEngine) {
270
- searchEngine.clearMatches();
271
- }
243
+ events.trigger('searchdone', query, page);
272
244
 
273
- refresh();
245
+ if (page) {
246
+ jumpTo(page);
247
+ } else {
248
+ refresh();
249
+ }
250
+ }).catch(function (err) {
251
+ /**
252
+ * Notifies the search error
253
+ * @event error
254
+ * @param {Object} err
255
+ */
256
+ events.trigger('error', err);
257
+ });
258
+ }
259
+ } else {
260
+ if (searchEngine) {
261
+ searchEngine.clearMatches();
274
262
  }
275
263
 
276
- updateControls();
264
+ refresh();
277
265
  }
278
- /**
279
- * Displays the search matches on the rendered page
280
- * @param {Number} page - The page number of the rendered page
281
- * @returns {Promise}
282
- */
283
266
 
267
+ updateControls();
268
+ }
269
+ /**
270
+ * Displays the search matches on the rendered page
271
+ * @param {Number} page - The page number of the rendered page
272
+ * @returns {Promise}
273
+ */
284
274
 
285
- function updateMatches(page) {
286
- var textManager = searchEngine && searchEngine.getTextManager();
287
-
288
- if (textManager && textManager.getDocument()) {
289
- /**
290
- * Notifies the matches are updating
291
- * @event matchesupdating
292
- * @param {Number} page
293
- */
294
- events.trigger('matchesupdating', page);
295
- return searchEngine.updateMatches(page).then(matchUpdated);
296
- }
297
- }
298
- /**
299
- * Requests a page change
300
- * @param {Number} page
301
- */
302
275
 
276
+ function updateMatches(page) {
277
+ var textManager = searchEngine && searchEngine.getTextManager();
303
278
 
304
- function jumpTo(page) {
279
+ if (textManager && textManager.getDocument()) {
305
280
  /**
306
- * @event setpage
281
+ * Notifies the matches are updating
282
+ * @event matchesupdating
307
283
  * @param {Number} page
308
284
  */
309
- events.trigger('setpage', page);
285
+ events.trigger('matchesupdating', page);
286
+ return searchEngine.updateMatches(page).then(matchUpdated);
310
287
  }
311
- /**
312
- * Requests a page refresh
313
- */
288
+ }
289
+ /**
290
+ * Requests a page change
291
+ * @param {Number} page
292
+ */
314
293
 
315
294
 
316
- function refresh() {
317
- /**
318
- * @event refresh
319
- */
320
- events.trigger('refresh');
321
- }
295
+ function jumpTo(page) {
322
296
  /**
323
- * Finalizes the matches update
297
+ * @event setpage
324
298
  * @param {Number} page
325
299
  */
300
+ events.trigger('setpage', page);
301
+ }
302
+ /**
303
+ * Requests a page refresh
304
+ */
326
305
 
327
306
 
328
- function matchUpdated(page) {
329
- if (navigating) {
330
- navigating = false;
331
- focusOnMatch();
332
- }
307
+ function refresh() {
308
+ /**
309
+ * @event refresh
310
+ */
311
+ events.trigger('refresh');
312
+ }
313
+ /**
314
+ * Finalizes the matches update
315
+ * @param {Number} page
316
+ */
333
317
 
334
- updateControls();
335
- /**
336
- * Notifies the matches have been displayed
337
- * @event matchesupdated
338
- * @param {Number} page
339
- */
340
318
 
341
- events.trigger('matchesupdated', page);
319
+ function matchUpdated(page) {
320
+ if (navigating) {
321
+ navigating = false;
322
+ focusOnMatch();
342
323
  }
324
+
325
+ updateControls();
343
326
  /**
344
- * Select the current match and displays the page that contains it
327
+ * Notifies the matches have been displayed
328
+ * @event matchesupdated
329
+ * @param {Number} page
345
330
  */
346
331
 
332
+ events.trigger('matchesupdated', page);
333
+ }
334
+ /**
335
+ * Select the current match and displays the page that contains it
336
+ */
347
337
 
348
- function jumpToMatch() {
349
- var match;
350
338
 
351
- if (searchEngine) {
352
- match = searchEngine.getCurrentMatch();
339
+ function jumpToMatch() {
340
+ var match;
353
341
 
354
- if (match) {
355
- navigating = true;
342
+ if (searchEngine) {
343
+ match = searchEngine.getCurrentMatch();
356
344
 
357
- if (pageNum !== match.page) {
358
- jumpTo(match.page);
359
- } else {
360
- updateSelection();
361
- }
345
+ if (match) {
346
+ navigating = true;
347
+
348
+ if (pageNum !== match.page) {
349
+ jumpTo(match.page);
350
+ } else {
351
+ updateSelection();
362
352
  }
363
353
  }
364
354
  }
365
- /**
366
- * Moves between matches
367
- * @param {Number} direction
368
- */
369
-
355
+ }
356
+ /**
357
+ * Moves between matches
358
+ * @param {Number} direction
359
+ */
370
360
 
371
- function moveBy(direction) {
372
- loopBegin = false;
373
- loopEnd = false;
374
361
 
375
- if (searchEngine) {
376
- if (direction < 0) {
377
- loopEnd = searchEngine.previousMatch();
378
- } else {
379
- loopBegin = searchEngine.nextMatch();
380
- }
362
+ function moveBy(direction) {
363
+ loopBegin = false;
364
+ loopEnd = false;
381
365
 
382
- jumpToMatch();
366
+ if (searchEngine) {
367
+ if (direction < 0) {
368
+ loopEnd = searchEngine.previousMatch();
369
+ } else {
370
+ loopBegin = searchEngine.nextMatch();
383
371
  }
384
372
 
385
- updateControls();
386
- focusOnInput();
373
+ jumpToMatch();
387
374
  }
388
- /**
389
- * Gets the selected match element
390
- * @returns {jQuery}
391
- */
392
375
 
376
+ updateControls();
377
+ focusOnInput();
378
+ }
379
+ /**
380
+ * Gets the selected match element
381
+ * @returns {jQuery}
382
+ */
393
383
 
394
- function getSelectectMatchElement() {
395
- return broker.getContentArea().find('.highlight.selected');
396
- }
397
- /**
398
- * Gets the current match element
399
- * @returns {jQuery}
400
- */
401
384
 
385
+ function getSelectectMatchElement() {
386
+ return broker.getContentArea().find('.highlight.selected');
387
+ }
388
+ /**
389
+ * Gets the current match element
390
+ * @returns {jQuery}
391
+ */
402
392
 
403
- function getCurrentMatchElement() {
404
- var match = searchEngine.getCurrentMatch();
405
- return broker.getContentArea().find('[data-match="' + match.index + '"]');
406
- }
407
- /**
408
- * Updates the selection to reflect the current match
409
- */
393
+
394
+ function getCurrentMatchElement() {
395
+ var match = searchEngine.getCurrentMatch();
396
+ return broker.getContentArea().find('[data-match="' + match.index + '"]');
397
+ }
398
+ /**
399
+ * Updates the selection to reflect the current match
400
+ */
410
401
 
411
402
 
412
- function updateSelection() {
413
- if (broker && searchEngine) {
414
- getSelectectMatchElement().removeClass('selected');
415
- getCurrentMatchElement().addClass('selected');
416
- matchUpdated(pageNum);
417
- }
403
+ function updateSelection() {
404
+ if (broker && searchEngine) {
405
+ getSelectectMatchElement().removeClass('selected');
406
+ getCurrentMatchElement().addClass('selected');
407
+ matchUpdated(pageNum);
418
408
  }
419
- /**
420
- * Gives the focus to the selected match
421
- */
409
+ }
410
+ /**
411
+ * Gives the focus to the selected match
412
+ */
422
413
 
423
414
 
424
- function focusOnMatch() {
425
- if (broker && searchEngine) {
426
- autoscroll(getSelectectMatchElement(), broker.getContentArea());
427
- }
415
+ function focusOnMatch() {
416
+ if (broker && searchEngine) {
417
+ autoscroll(getSelectectMatchElement(), broker.getContentArea());
428
418
  }
429
- /**
430
- * Gives the focus to the query input
431
- */
419
+ }
420
+ /**
421
+ * Gives the focus to the query input
422
+ */
432
423
 
433
424
 
434
- function focusOnInput() {
435
- controls.$searchQuery.focus();
436
- }
437
- /**
438
- * Reads the caseSensitive option and update the config
439
- */
425
+ function focusOnInput() {
426
+ controls.$searchQuery.focus();
427
+ }
428
+ /**
429
+ * Reads the caseSensitive option and update the config
430
+ */
440
431
 
441
432
 
442
- function readCaseSensitiveOption() {
443
- config.caseSensitive = controls.$caseSensitive.is(':checked');
444
- }
445
- /**
446
- * Reads the highlightAll option and apply the state
447
- */
433
+ function readCaseSensitiveOption() {
434
+ config.caseSensitive = controls.$caseSensitive.is(':checked');
435
+ }
436
+ /**
437
+ * Reads the highlightAll option and apply the state
438
+ */
448
439
 
449
440
 
450
- function applyHighlightAllOption() {
451
- if (broker) {
452
- broker.getContentArea().toggleClass('highlight-all', controls.$highlightAll.is(':checked'));
453
- }
441
+ function applyHighlightAllOption() {
442
+ if (broker) {
443
+ broker.getContentArea().toggleClass('highlight-all', controls.$highlightAll.is(':checked'));
454
444
  }
455
- /**
456
- * Checks if a change has been made in the current query, then performs a new search if needed
457
- */
445
+ }
446
+ /**
447
+ * Checks if a change has been made in the current query, then performs a new search if needed
448
+ */
458
449
 
459
450
 
460
- function checkQuery() {
461
- var typedQuery = controls.$searchQuery.val();
451
+ function checkQuery() {
452
+ var typedQuery = controls.$searchQuery.val();
462
453
 
463
- if (typedQuery !== query) {
464
- query = typedQuery;
465
- navigating = true;
466
- doSearch();
467
- }
454
+ if (typedQuery !== query) {
455
+ query = typedQuery;
456
+ navigating = true;
457
+ doSearch();
468
458
  }
469
- /**
470
- * Fetches the required controls
471
- * @param {jQuery} $container
472
- * @returns {Object}
473
- */
474
-
459
+ }
460
+ /**
461
+ * Fetches the required controls
462
+ * @param {jQuery} $container
463
+ * @returns {Object}
464
+ */
475
465
 
476
- function fetchControls($container) {
477
- return {
478
- $searchBar: $$1('.pdf-find-bar', $container),
479
- $searchButton: $$1('[data-control="pdf-search"]', $container),
480
- $searchQuery: $$1('[data-control="pdf-search-query"]', $container),
481
- $prevMatch: $$1('[data-control="pdf-search-prev"]', $container),
482
- $nextMatch: $$1('[data-control="pdf-search-next"]', $container),
483
- $caseSensitive: $$1('[data-control="case-sensitive-search"]', $container),
484
- $highlightAll: $$1('[data-control="highlight-all"]', $container),
485
- $matchIndex: $$1('[data-control="pdf-search-index"]', $container),
486
- $matchCount: $$1('[data-control="pdf-search-count"]', $container),
487
- $searchPosition: $$1('[data-control="pdf-search-position"]', $container),
488
- $searchLoopBegin: $$1('[data-control="pdf-search-loop-begin"]', $container),
489
- $searchLoopEnd: $$1('[data-control="pdf-search-loop-end"]', $container)
490
- };
491
- }
492
- /**
493
- * Will update the displayed controls
494
- */
495
466
 
467
+ function fetchControls($container) {
468
+ return {
469
+ $searchBar: $$1('.pdf-find-bar', $container),
470
+ $searchButton: $$1('[data-control="pdf-search"]', $container),
471
+ $searchQuery: $$1('[data-control="pdf-search-query"]', $container),
472
+ $prevMatch: $$1('[data-control="pdf-search-prev"]', $container),
473
+ $nextMatch: $$1('[data-control="pdf-search-next"]', $container),
474
+ $caseSensitive: $$1('[data-control="case-sensitive-search"]', $container),
475
+ $highlightAll: $$1('[data-control="highlight-all"]', $container),
476
+ $matchIndex: $$1('[data-control="pdf-search-index"]', $container),
477
+ $matchCount: $$1('[data-control="pdf-search-count"]', $container),
478
+ $searchPosition: $$1('[data-control="pdf-search-position"]', $container),
479
+ $searchLoopBegin: $$1('[data-control="pdf-search-loop-begin"]', $container),
480
+ $searchLoopEnd: $$1('[data-control="pdf-search-loop-end"]', $container)
481
+ };
482
+ }
483
+ /**
484
+ * Will update the displayed controls
485
+ */
496
486
 
497
- function updateControls() {
498
- var matchCount = 0;
499
- var matchIndex = 0;
500
- var match;
501
487
 
502
- if (searchEngine) {
503
- matchCount = searchEngine.getMatchCount();
504
- match = searchEngine.getCurrentMatch();
505
- matchIndex = match && match.overall;
506
- }
488
+ function updateControls() {
489
+ var matchCount = 0;
490
+ var matchIndex = 0;
491
+ var match;
507
492
 
508
- if (!enabled && !hider.isHidden(controls.$searchBar)) {
509
- hider.hide(controls.$searchBar);
510
- }
493
+ if (searchEngine) {
494
+ matchCount = searchEngine.getMatchCount();
495
+ match = searchEngine.getCurrentMatch();
496
+ matchIndex = match && match.overall;
497
+ }
511
498
 
512
- toggleState(controls.$searchButton, enabled);
513
- toggleState(controls.$searchQuery, enabled);
514
- toggleState(controls.$caseSensitive, enabled);
515
- toggleState(controls.$highlightAll, enabled);
516
- toggleState(controls.$prevMatch, enabled && matchCount > 1);
517
- toggleState(controls.$nextMatch, enabled && matchCount > 1);
518
- controls.$matchIndex.text(matchIndex);
519
- controls.$matchCount.text(matchCount);
520
- hider.toggle(controls.$searchPosition, enabled && matchCount > 0);
521
- hider.toggle(controls.$searchLoopBegin, enabled && loopBegin);
522
- hider.toggle(controls.$searchLoopEnd, enabled && loopEnd);
499
+ if (!enabled && !hider.isHidden(controls.$searchBar)) {
500
+ hider.hide(controls.$searchBar);
523
501
  }
524
502
 
525
- config = config || {};
503
+ toggleState(controls.$searchButton, enabled);
504
+ toggleState(controls.$searchQuery, enabled);
505
+ toggleState(controls.$caseSensitive, enabled);
506
+ toggleState(controls.$highlightAll, enabled);
507
+ toggleState(controls.$prevMatch, enabled && matchCount > 1);
508
+ toggleState(controls.$nextMatch, enabled && matchCount > 1);
509
+ controls.$matchIndex.text(matchIndex);
510
+ controls.$matchCount.text(matchCount);
511
+ hider.toggle(controls.$searchPosition, enabled && matchCount > 0);
512
+ hider.toggle(controls.$searchLoopBegin, enabled && loopBegin);
513
+ hider.toggle(controls.$searchLoopEnd, enabled && loopEnd);
514
+ }
526
515
 
527
- if (!_.isPlainObject(config.events)) {
528
- throw new TypeError('You must provide an events hub! [config.events is missing]');
529
- }
516
+ config = config || {};
530
517
 
531
- if (!_.isPlainObject(config.areaBroker)) {
532
- throw new TypeError('You must provide an areaBroker to give access to the UI! [config.areaBroker is missing]');
533
- }
518
+ if (!_.isPlainObject(config.events)) {
519
+ throw new TypeError('You must provide an events hub! [config.events is missing]');
520
+ }
534
521
 
535
- if (!_.isPlainObject(config.textManager)) {
536
- throw new TypeError('You must provide a textManager to give access to the PDF text content! [config.textManager is missing]');
537
- }
522
+ if (!_.isPlainObject(config.areaBroker)) {
523
+ throw new TypeError('You must provide an areaBroker to give access to the UI! [config.areaBroker is missing]');
524
+ }
525
+
526
+ if (!_.isPlainObject(config.textManager)) {
527
+ throw new TypeError('You must provide a textManager to give access to the PDF text content! [config.textManager is missing]');
528
+ }
538
529
 
539
- searchEngine = searchEngineFactory(config);
540
- broker = config.areaBroker;
541
- events = config.events;
542
- broker.getActionsArea().prepend(findBarTpl(config));
543
- controls = fetchControls(broker.getBarArea());
530
+ searchEngine = searchEngineFactory(config);
531
+ broker = config.areaBroker;
532
+ events = config.events;
533
+ broker.getActionsArea().prepend(findBarTpl(config));
534
+ controls = fetchControls(broker.getBarArea());
535
+ readCaseSensitiveOption();
536
+ applyHighlightAllOption();
537
+ controls.$searchButton.on('click', function () {
538
+ hider.toggle(controls.$searchBar);
539
+
540
+ if (!hider.isHidden(controls.$searchBar)) {
541
+ focusOnInput();
542
+ }
543
+ });
544
+ controls.$prevMatch.on('click', function () {
545
+ moveBy(-1);
546
+ });
547
+ controls.$nextMatch.on('click', function () {
548
+ moveBy(1);
549
+ });
550
+ controls.$caseSensitive.on('change', function () {
551
+ navigating = true;
544
552
  readCaseSensitiveOption();
553
+ doSearch();
554
+ focusOnInput();
555
+ });
556
+ controls.$highlightAll.on('change', function () {
545
557
  applyHighlightAllOption();
546
- controls.$searchButton.on('click', function () {
547
- hider.toggle(controls.$searchBar);
558
+ focusOnInput();
559
+ });
560
+ controls.$searchQuery.on('keypress', function (event) {
561
+ switch (event.keyCode) {
562
+ case 27:
563
+ hider.hide(controls.$searchBar);
564
+ break;
548
565
 
549
- if (!hider.isHidden(controls.$searchBar)) {
550
- focusOnInput();
551
- }
552
- });
553
- controls.$prevMatch.on('click', function () {
554
- moveBy(-1);
555
- });
556
- controls.$nextMatch.on('click', function () {
557
- moveBy(1);
558
- });
559
- controls.$caseSensitive.on('change', function () {
560
- navigating = true;
561
- readCaseSensitiveOption();
562
- doSearch();
563
- focusOnInput();
564
- });
565
- controls.$highlightAll.on('change', function () {
566
- applyHighlightAllOption();
567
- focusOnInput();
568
- });
569
- controls.$searchQuery.on('keypress', function (event) {
570
- switch (event.keyCode) {
571
- case 27:
572
- hider.hide(controls.$searchBar);
573
- break;
574
-
575
- default:
576
- throttledSearchStart();
577
- }
578
- });
579
- events.on('enable.findbar', function () {
580
- enabled = true;
581
- updateControls();
582
- }).on('disable.findbar', function () {
583
- enabled = false;
584
- updateControls();
585
- }).on('pagechange.findbar', function (page) {
586
- pageNum = page;
587
- updateControls();
588
- }).on('allrendered.findbar', function (page) {
589
- pageNum = page;
590
- updateMatches(page);
591
- updateControls();
592
- })
566
+ default:
567
+ throttledSearchStart();
568
+ }
569
+ });
570
+ events.on('enable.findbar', function () {
571
+ enabled = true;
572
+ updateControls();
573
+ }).on('disable.findbar', function () {
574
+ enabled = false;
575
+ updateControls();
576
+ }).on('pagechange.findbar', function (page) {
577
+ pageNum = page;
578
+ updateControls();
579
+ }).on('allrendered.findbar', function (page) {
580
+ pageNum = page;
581
+ updateMatches(page);
582
+ updateControls();
583
+ })
584
+ /**
585
+ * Notifies the component is initialized
586
+ * @event init.findbar
587
+ */
588
+ .trigger('init.findbar');
589
+ return {
593
590
  /**
594
- * Notifies the component is initialized
595
- * @event init.findbar
591
+ * Gets the search engine instance
592
+ * @returns {Object}
596
593
  */
597
- .trigger('init.findbar');
598
- return {
599
- /**
600
- * Gets the search engine instance
601
- * @returns {Object}
602
- */
603
- getSearchEngine: function getSearchEngine() {
604
- return searchEngine;
605
- },
594
+ getSearchEngine: function getSearchEngine() {
595
+ return searchEngine;
596
+ },
606
597
 
607
- /**
608
- * Destroys the search engine and frees the resources
609
- */
610
- destroy: function destroy() {
611
- if (searchEngine) {
612
- searchEngine.destroy();
613
- }
598
+ /**
599
+ * Destroys the search engine and frees the resources
600
+ */
601
+ destroy: function destroy() {
602
+ if (searchEngine) {
603
+ searchEngine.destroy();
604
+ }
614
605
 
615
- if (controls.$searchButton) {
616
- controls.$searchButton.remove();
617
- }
606
+ if (controls.$searchButton) {
607
+ controls.$searchButton.remove();
608
+ }
618
609
 
619
- if (controls.$searchBar) {
620
- controls.$searchBar.remove();
621
- }
610
+ if (controls.$searchBar) {
611
+ controls.$searchBar.remove();
612
+ }
622
613
 
623
- controls = {};
624
- config = null;
625
- searchEngine = null;
626
- broker = null;
627
- /**
628
- * Notifies the component is destroying
629
- * @event destroy.findbar
630
- */
614
+ controls = {};
615
+ config = null;
616
+ searchEngine = null;
617
+ broker = null;
618
+ /**
619
+ * Notifies the component is destroying
620
+ * @event destroy.findbar
621
+ */
631
622
 
632
- events.trigger('destroy.findbar');
633
- events.off('.findbar');
634
- events = null;
635
- }
636
- };
637
- }
623
+ events.trigger('destroy.findbar');
624
+ events.off('.findbar');
625
+ events = null;
626
+ }
627
+ };
628
+ }
638
629
 
639
- return pdfjsFindBarFactory;
630
+ return pdfjsFindBarFactory;
640
631
 
641
632
  });