@oat-sa/tao-core-ui 1.67.0 → 2.0.0

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 (239) hide show
  1. package/README.md +17 -16
  2. package/dist/animable/absorbable/css/absorb.css +25 -29
  3. package/dist/animable/absorbable/css/absorb.css.map +1 -1
  4. package/dist/animable/pulsable/css/pulse.css +20 -23
  5. package/dist/animable/pulsable/css/pulse.css.map +1 -1
  6. package/dist/autocomplete/css/autocomplete.css +20 -21
  7. package/dist/autocomplete/css/autocomplete.css.map +1 -1
  8. package/dist/badge/css/badge.css +67 -79
  9. package/dist/badge/css/badge.css.map +1 -1
  10. package/dist/breadcrumbs/css/breadcrumbs.css +54 -61
  11. package/dist/breadcrumbs/css/breadcrumbs.css.map +1 -1
  12. package/dist/bulkActionPopup/css/bulkActionPopup.css +27 -42
  13. package/dist/bulkActionPopup/css/bulkActionPopup.css.map +1 -1
  14. package/dist/calculator/css/calculator.css +91 -112
  15. package/dist/calculator/css/calculator.css.map +1 -1
  16. package/dist/class/css/selector.css +83 -97
  17. package/dist/class/css/selector.css.map +1 -1
  18. package/dist/component/css/components.css +351 -406
  19. package/dist/component/css/components.css.map +1 -1
  20. package/dist/component/css/windowComponent.css +19 -28
  21. package/dist/component/css/windowComponent.css.map +1 -1
  22. package/dist/contextualPopup/css/contextualPopup.css +42 -55
  23. package/dist/contextualPopup/css/contextualPopup.css.map +1 -1
  24. package/dist/dashboard/css/dashboard.css +43 -57
  25. package/dist/dashboard/css/dashboard.css.map +1 -1
  26. package/dist/datalist/css/datalist.css +63 -88
  27. package/dist/datalist/css/datalist.css.map +1 -1
  28. package/dist/datatable/css/datatable.css +84 -113
  29. package/dist/datatable/css/datatable.css.map +1 -1
  30. package/dist/dateRange/css/dateRange.css +1 -2
  31. package/dist/dateRange/css/dateRange.css.map +1 -1
  32. package/dist/datetime/css/picker.css +71 -103
  33. package/dist/datetime/css/picker.css.map +1 -1
  34. package/dist/destination/css/selector.css +17 -24
  35. package/dist/destination/css/selector.css.map +1 -1
  36. package/dist/documentViewer/css/documentViewer.css +137 -162
  37. package/dist/documentViewer/css/documentViewer.css.map +1 -1
  38. package/dist/dropdown/css/dropdown.css +55 -72
  39. package/dist/dropdown/css/dropdown.css.map +1 -1
  40. package/dist/dynamicComponent/css/dynamicComponent.css +78 -91
  41. package/dist/dynamicComponent/css/dynamicComponent.css.map +1 -1
  42. package/dist/form/css/dropdownForm.css +36 -45
  43. package/dist/form/css/dropdownForm.css.map +1 -1
  44. package/dist/form/css/form.css +12 -16
  45. package/dist/form/css/form.css.map +1 -1
  46. package/dist/form/validator/css/validator.css +5 -7
  47. package/dist/form/validator/css/validator.css.map +1 -1
  48. package/dist/form/widget/css/widget.css +26 -34
  49. package/dist/form/widget/css/widget.css.map +1 -1
  50. package/dist/generis/form/css/form.css +14 -18
  51. package/dist/generis/form/css/form.css.map +1 -1
  52. package/dist/generis/validator/css/validator.css +5 -7
  53. package/dist/generis/validator/css/validator.css.map +1 -1
  54. package/dist/generis/widget/css/widget.css +29 -38
  55. package/dist/generis/widget/css/widget.css.map +1 -1
  56. package/dist/itemButtonList/css/item-button-list.css +135 -172
  57. package/dist/itemButtonList/css/item-button-list.css.map +1 -1
  58. package/dist/listbox/css/listbox.css +64 -84
  59. package/dist/listbox/css/listbox.css.map +1 -1
  60. package/dist/loadingButton/css/button.css +20 -29
  61. package/dist/loadingButton/css/button.css.map +1 -1
  62. package/dist/maths/calculator/basicCalculator.js +4 -4
  63. package/dist/maths/calculator/calculatorComponent.js +22 -25
  64. package/dist/maths/calculator/core/board.js +12327 -720
  65. package/dist/maths/calculator/core/labels.js +7918 -138
  66. package/dist/maths/calculator/core/plugin.js +4 -5
  67. package/dist/maths/calculator/css/calculator.css +224 -270
  68. package/dist/maths/calculator/css/calculator.css.map +1 -1
  69. package/dist/maths/calculator/defaultCalculator.js +10 -6
  70. package/dist/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +23 -25
  71. package/dist/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +7973 -194
  72. package/dist/maths/calculator/scientificCalculator.js +7 -12
  73. package/dist/mediaplayer/css/player.css +281 -370
  74. package/dist/mediaplayer/css/player.css.map +1 -1
  75. package/dist/pagination/css/pagination.css +38 -49
  76. package/dist/pagination/css/pagination.css.map +1 -1
  77. package/dist/propertySelector/css/propertySelector.css +34 -44
  78. package/dist/propertySelector/css/propertySelector.css.map +1 -1
  79. package/dist/resource/css/selector.css +400 -490
  80. package/dist/resource/css/selector.css.map +1 -1
  81. package/dist/resourcemgr/css/resourcemgr.css +192 -237
  82. package/dist/resourcemgr/css/resourcemgr.css.map +1 -1
  83. package/dist/searchModal/css/advancedSearch.css +92 -121
  84. package/dist/searchModal/css/advancedSearch.css.map +1 -1
  85. package/dist/searchModal/css/searchModal.css +261 -333
  86. package/dist/searchModal/css/searchModal.css.map +1 -1
  87. package/dist/switch/css/switch.css +36 -47
  88. package/dist/switch/css/switch.css.map +1 -1
  89. package/dist/tabs/css/tabs.css +32 -40
  90. package/dist/tabs/css/tabs.css.map +1 -1
  91. package/dist/taskQueue/css/taskQueue.css +17 -27
  92. package/dist/taskQueue/css/taskQueue.css.map +1 -1
  93. package/dist/taskQueueButton/css/taskable.css +1 -2
  94. package/dist/taskQueueButton/css/taskable.css.map +1 -1
  95. package/dist/taskQueueButton/css/treeButton.css +20 -26
  96. package/dist/taskQueueButton/css/treeButton.css.map +1 -1
  97. package/dist/tristateCheckboxGroup/css/tristateCheckboxGroup.css +3 -5
  98. package/dist/tristateCheckboxGroup/css/tristateCheckboxGroup.css.map +1 -1
  99. package/dist/waitingDialog/css/waitingDialog.css +18 -23
  100. package/dist/waitingDialog/css/waitingDialog.css.map +1 -1
  101. package/package.json +20 -24
  102. package/scss/inc/_base.scss +9 -8
  103. package/scss/inc/_flex-grid.scss +1 -1
  104. package/scss/inc/_forms.scss +5 -5
  105. package/scss/inc/_functions.scss +8 -8
  106. package/scss/inc/fonts/_tao-icon-classes.scss +230 -230
  107. package/src/animable/absorbable/css/absorb.css +25 -29
  108. package/src/animable/absorbable/css/absorb.css.map +1 -1
  109. package/src/animable/pulsable/css/pulse.css +20 -23
  110. package/src/animable/pulsable/css/pulse.css.map +1 -1
  111. package/src/autocomplete/css/autocomplete.css +20 -21
  112. package/src/autocomplete/css/autocomplete.css.map +1 -1
  113. package/src/badge/css/badge.css +67 -79
  114. package/src/badge/css/badge.css.map +1 -1
  115. package/src/breadcrumbs/css/breadcrumbs.css +54 -61
  116. package/src/breadcrumbs/css/breadcrumbs.css.map +1 -1
  117. package/src/bulkActionPopup/css/bulkActionPopup.css +27 -42
  118. package/src/bulkActionPopup/css/bulkActionPopup.css.map +1 -1
  119. package/src/calculator/css/calculator.css +91 -112
  120. package/src/calculator/css/calculator.css.map +1 -1
  121. package/src/calculator/scss/calculator.scss +1 -1
  122. package/src/class/css/selector.css +83 -97
  123. package/src/class/css/selector.css.map +1 -1
  124. package/src/component/css/components.css +351 -406
  125. package/src/component/css/components.css.map +1 -1
  126. package/src/component/css/windowComponent.css +19 -28
  127. package/src/component/css/windowComponent.css.map +1 -1
  128. package/src/contextualPopup/css/contextualPopup.css +42 -55
  129. package/src/contextualPopup/css/contextualPopup.css.map +1 -1
  130. package/src/css/basic.css +4000 -4374
  131. package/src/css/basic.css.map +1 -1
  132. package/src/dashboard/css/dashboard.css +43 -57
  133. package/src/dashboard/css/dashboard.css.map +1 -1
  134. package/src/datalist/css/datalist.css +63 -88
  135. package/src/datalist/css/datalist.css.map +1 -1
  136. package/src/datatable/css/datatable.css +84 -113
  137. package/src/datatable/css/datatable.css.map +1 -1
  138. package/src/dateRange/css/dateRange.css +1 -2
  139. package/src/dateRange/css/dateRange.css.map +1 -1
  140. package/src/datetime/css/picker.css +71 -103
  141. package/src/datetime/css/picker.css.map +1 -1
  142. package/src/destination/css/selector.css +17 -24
  143. package/src/destination/css/selector.css.map +1 -1
  144. package/src/documentViewer/css/documentViewer.css +137 -162
  145. package/src/documentViewer/css/documentViewer.css.map +1 -1
  146. package/src/dropdown/css/dropdown.css +55 -72
  147. package/src/dropdown/css/dropdown.css.map +1 -1
  148. package/src/dynamicComponent/css/dynamicComponent.css +78 -91
  149. package/src/dynamicComponent/css/dynamicComponent.css.map +1 -1
  150. package/src/form/css/dropdownForm.css +36 -45
  151. package/src/form/css/dropdownForm.css.map +1 -1
  152. package/src/form/css/form.css +12 -16
  153. package/src/form/css/form.css.map +1 -1
  154. package/src/form/validator/css/validator.css +5 -7
  155. package/src/form/validator/css/validator.css.map +1 -1
  156. package/src/form/widget/css/widget.css +26 -34
  157. package/src/form/widget/css/widget.css.map +1 -1
  158. package/src/generis/form/css/form.css +14 -18
  159. package/src/generis/form/css/form.css.map +1 -1
  160. package/src/generis/validator/css/validator.css +5 -7
  161. package/src/generis/validator/css/validator.css.map +1 -1
  162. package/src/generis/widget/css/widget.css +29 -38
  163. package/src/generis/widget/css/widget.css.map +1 -1
  164. package/src/itemButtonList/css/item-button-list.css +135 -172
  165. package/src/itemButtonList/css/item-button-list.css.map +1 -1
  166. package/src/listbox/css/listbox.css +64 -84
  167. package/src/listbox/css/listbox.css.map +1 -1
  168. package/src/listbox/scss/listbox.scss +8 -8
  169. package/src/loadingButton/css/button.css +20 -29
  170. package/src/loadingButton/css/button.css.map +1 -1
  171. package/src/maths/calculator/basicCalculator.js +1 -4
  172. package/src/maths/calculator/calculatorComponent.js +49 -60
  173. package/src/maths/calculator/core/board.js +372 -493
  174. package/src/maths/calculator/core/labels.js +46 -48
  175. package/src/maths/calculator/core/plugin.js +3 -5
  176. package/src/maths/calculator/core/tpl/terms.tpl +7 -1
  177. package/src/maths/calculator/css/calculator.css +224 -270
  178. package/src/maths/calculator/css/calculator.css.map +1 -1
  179. package/src/maths/calculator/defaultCalculator.js +7 -9
  180. package/src/maths/calculator/plugins/keyboard/templateKeyboard/defaultTemplate.tpl +3 -3
  181. package/src/maths/calculator/plugins/keyboard/templateKeyboard/templateKeyboard.js +17 -20
  182. package/src/maths/calculator/plugins/screen/simpleScreen/simpleScreen.js +102 -108
  183. package/src/maths/calculator/scientificCalculator.js +2 -10
  184. package/src/maths/calculator/scss/calculator.scss +20 -7
  185. package/src/maths/calculator/tpl/basicKeyboard.tpl +3 -3
  186. package/src/maths/calculator/tpl/scientificKeyboard.tpl +4 -4
  187. package/src/mediaplayer/css/player.css +281 -370
  188. package/src/mediaplayer/css/player.css.map +1 -1
  189. package/src/pagination/css/pagination.css +38 -49
  190. package/src/pagination/css/pagination.css.map +1 -1
  191. package/src/propertySelector/css/propertySelector.css +34 -44
  192. package/src/propertySelector/css/propertySelector.css.map +1 -1
  193. package/src/resource/css/selector.css +400 -490
  194. package/src/resource/css/selector.css.map +1 -1
  195. package/src/resourcemgr/css/resourcemgr.css +192 -237
  196. package/src/resourcemgr/css/resourcemgr.css.map +1 -1
  197. package/src/searchModal/css/advancedSearch.css +92 -121
  198. package/src/searchModal/css/advancedSearch.css.map +1 -1
  199. package/src/searchModal/css/searchModal.css +261 -333
  200. package/src/searchModal/css/searchModal.css.map +1 -1
  201. package/src/searchModal/scss/searchModal.scss +1 -1
  202. package/src/switch/css/switch.css +36 -47
  203. package/src/switch/css/switch.css.map +1 -1
  204. package/src/tabs/css/tabs.css +32 -40
  205. package/src/tabs/css/tabs.css.map +1 -1
  206. package/src/taskQueue/css/taskQueue.css +17 -27
  207. package/src/taskQueue/css/taskQueue.css.map +1 -1
  208. package/src/taskQueueButton/css/taskable.css +1 -2
  209. package/src/taskQueueButton/css/taskable.css.map +1 -1
  210. package/src/taskQueueButton/css/treeButton.css +20 -26
  211. package/src/taskQueueButton/css/treeButton.css.map +1 -1
  212. package/src/tristateCheckboxGroup/css/tristateCheckboxGroup.css +3 -5
  213. package/src/tristateCheckboxGroup/css/tristateCheckboxGroup.css.map +1 -1
  214. package/src/waitingDialog/css/waitingDialog.css +18 -23
  215. package/src/waitingDialog/css/waitingDialog.css.map +1 -1
  216. package/dist/maths/calculator/core/areaBroker.js +0 -43
  217. package/dist/maths/calculator/core/expression.js +0 -463
  218. package/dist/maths/calculator/core/terms.js +0 -456
  219. package/dist/maths/calculator/core/tokenizer.js +0 -229
  220. package/dist/maths/calculator/core/tokens.js +0 -167
  221. package/dist/maths/calculator/plugins/core/degrad.js +0 -71
  222. package/dist/maths/calculator/plugins/core/history.js +0 -149
  223. package/dist/maths/calculator/plugins/core/remind.js +0 -76
  224. package/dist/maths/calculator/plugins/core/stepNavigation.js +0 -148
  225. package/dist/maths/calculator/plugins/modifiers/pow10.js +0 -136
  226. package/dist/maths/calculator/plugins/modifiers/sign.js +0 -314
  227. package/dist/maths/calculator/pluginsLoader.js +0 -47
  228. package/src/maths/calculator/core/areaBroker.js +0 -38
  229. package/src/maths/calculator/core/expression.js +0 -430
  230. package/src/maths/calculator/core/terms.js +0 -459
  231. package/src/maths/calculator/core/tokenizer.js +0 -245
  232. package/src/maths/calculator/core/tokens.js +0 -178
  233. package/src/maths/calculator/plugins/core/degrad.js +0 -90
  234. package/src/maths/calculator/plugins/core/history.js +0 -166
  235. package/src/maths/calculator/plugins/core/remind.js +0 -96
  236. package/src/maths/calculator/plugins/core/stepNavigation.js +0 -175
  237. package/src/maths/calculator/plugins/modifiers/pow10.js +0 -143
  238. package/src/maths/calculator/plugins/modifiers/sign.js +0 -339
  239. package/src/maths/calculator/pluginsLoader.js +0 -46
@@ -1,178 +0,0 @@
1
- /**
2
- * This program is free software; you can redistribute it and/or
3
- * modify it under the terms of the GNU General Public License
4
- * as published by the Free Software Foundation; under version 2
5
- * of the License (non-upgradable).
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
- *
16
- * Copyright (c) 2019 Open Assessment Technologies SA ;
17
- */
18
- /**
19
- * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com>
20
- */
21
- import registeredTerms from 'ui/maths/calculator/core/terms';
22
-
23
- /**
24
- * List of helpers that apply on tokens
25
- * @type {Object}
26
- */
27
- var tokensHelper = {
28
- /**
29
- * Identifies the type of a given token
30
- * @param {String|Object} token
31
- * @returns {String|null}
32
- */
33
- getType: function getType(token) {
34
- var type, term;
35
- if ('string' !== typeof token) {
36
- type = (token && token.type) || null;
37
- term = registeredTerms[type];
38
- return (term && term.type) || type;
39
- }
40
- return token;
41
- },
42
-
43
- /**
44
- * Checks if the type is related to a digit value
45
- * @param {String|Object} type
46
- * @returns {Boolean}
47
- */
48
- isDigit: function isDigit(type) {
49
- return tokensHelper.getType(type) === 'digit';
50
- },
51
-
52
- /**
53
- * Checks if the type is related to an operator
54
- * @param {String|Object} type
55
- * @returns {Boolean}
56
- */
57
- isOperator: function isOperator(type) {
58
- return tokensHelper.getType(type) === 'operator';
59
- },
60
-
61
- /**
62
- * Checks if the type is related to an operand
63
- * @param {String|Object} type
64
- * @returns {Boolean}
65
- */
66
- isOperand: function isOperand(type) {
67
- type = tokensHelper.getType(type);
68
- return type !== 'operator' && type !== 'aggregator' && type !== 'separator';
69
- },
70
-
71
- /**
72
- * Checks if the type is related to an operand
73
- * @param {String|Object} type
74
- * @returns {Boolean}
75
- */
76
- isValue: function isValue(type) {
77
- type = tokensHelper.getType(type);
78
- return type === 'digit' || type === 'constant' || type === 'variable' || type === 'term' || type === 'error';
79
- },
80
-
81
- /**
82
- * Checks if the type is related to an aggregator
83
- * @param {String|Object} type
84
- * @returns {Boolean}
85
- */
86
- isAggregator: function isAggregator(type) {
87
- return tokensHelper.getType(type) === 'aggregator';
88
- },
89
-
90
- /**
91
- * Checks if the type is related to an error
92
- * @param {String|Object} type
93
- * @returns {Boolean}
94
- */
95
- isError: function isError(type) {
96
- return tokensHelper.getType(type) === 'error';
97
- },
98
-
99
- /**
100
- * Checks if the type is related to a constant
101
- * @param {String|Object} type
102
- * @returns {Boolean}
103
- */
104
- isConstant: function isConstant(type) {
105
- return tokensHelper.getType(type) === 'constant';
106
- },
107
-
108
- /**
109
- * Checks if the type is related to a variable
110
- * @param {String|Object} type
111
- * @returns {Boolean}
112
- */
113
- isVariable: function isVariable(type) {
114
- type = tokensHelper.getType(type);
115
- return type === 'variable' || type === 'term';
116
- },
117
-
118
- /**
119
- * Checks if the type is related to a function
120
- * @param {String|Object} type
121
- * @returns {Boolean}
122
- */
123
- isFunction: function isFunction(type) {
124
- return tokensHelper.getType(type) === 'function';
125
- },
126
-
127
- /**
128
- * Checks if the type is related to an identifier
129
- * @param {String|Object} type
130
- * @returns {Boolean}
131
- */
132
- isIdentifier: function isIdentifier(type) {
133
- type = tokensHelper.getType(type);
134
- return type === 'constant' || type === 'variable' || type === 'term' || type === 'function' || type === 'error';
135
- },
136
-
137
- /**
138
- * Checks if the type is related to a separator
139
- * @param {String|Object} type
140
- * @returns {Boolean}
141
- */
142
- isSeparator: function isSeparator(type) {
143
- type = tokensHelper.getType(type);
144
- return type === 'operator' || type === 'aggregator' || type === 'separator';
145
- },
146
-
147
- /**
148
- * Checks if the type is related to a modifier
149
- * @param {String|Object} type
150
- * @returns {Boolean}
151
- */
152
- isModifier: function isModifier(type) {
153
- type = tokensHelper.getType(type);
154
- return type === 'operator' || type === 'function';
155
- },
156
-
157
- /**
158
- * Ensures an expression is a string. If a token or a descriptor is provided, extract the value.
159
- * @param {String|Number|Object} expression
160
- * @returns {String}
161
- */
162
- stringValue: function stringValue(expression) {
163
- var type = typeof expression;
164
- if (type !== 'string') {
165
- if (expression && 'undefined' !== typeof expression.value) {
166
- expression = expression.value;
167
- } else if (expression && 'undefined' !== typeof expression.result) {
168
- expression = expression.result;
169
- } else if (type === 'object' || type === 'undefined' || expression === null) {
170
- expression = '';
171
- }
172
- expression = String(expression);
173
- }
174
- return expression;
175
- }
176
- };
177
-
178
- export default tokensHelper;
@@ -1,90 +0,0 @@
1
- /**
2
- * This program is free software; you can redistribute it and/or
3
- * modify it under the terms of the GNU General Public License
4
- * as published by the Free Software Foundation; under version 2
5
- * of the License (non-upgradable).
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
- *
16
- * Copyright (c) 2018 Open Assessment Technologies SA ;
17
- */
18
- /**
19
- * Plugin that switch mode between degree and radian in the calculator
20
- * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com>
21
- */
22
- import __ from 'i18n';
23
- import nsHelper from 'util/namespace';
24
- import pluginFactory from 'ui/maths/calculator/core/plugin';
25
-
26
- var pluginName = 'degrad';
27
-
28
- export default pluginFactory({
29
- name: pluginName,
30
-
31
- /**
32
- * Called when the plugin is installing in its host.
33
- */
34
- install: function install() {
35
- var calculator = this.getCalculator();
36
-
37
- calculator
38
- .setCommand('degree', __('Degree'), __('Set the trigonometric function to work in degrees'))
39
- .setCommand('radian', __('Radian'), __('Set the trigonometric function to work in radians'));
40
- },
41
-
42
- /**
43
- * Called when the plugin should be initialized.
44
- */
45
- init: function init() {
46
- var calculator = this.getCalculator();
47
-
48
- function getMathsConfig() {
49
- var config = calculator.getConfig();
50
- if (!config.maths) {
51
- config.maths = {};
52
- }
53
- return config.maths;
54
- }
55
-
56
- function setupMathsEvaluator() {
57
- var config = calculator.getConfig();
58
- var degree = config.maths && config.maths.degree;
59
- calculator
60
- .setState('degree', degree)
61
- .setState('radian', !degree)
62
- .setupMathsEvaluator();
63
- }
64
-
65
- setupMathsEvaluator();
66
-
67
- calculator
68
- .on(nsHelper.namespaceAll('command-degree', pluginName), function() {
69
- getMathsConfig().degree = true;
70
- setupMathsEvaluator();
71
- })
72
- .on(nsHelper.namespaceAll('command-radian', pluginName), function() {
73
- getMathsConfig().degree = false;
74
- setupMathsEvaluator();
75
- });
76
- },
77
-
78
- /**
79
- * Called when the plugin is destroyed. Mostly when the host is destroyed itself.
80
- */
81
- destroy: function destroy() {
82
- var calculator = this.getCalculator();
83
- calculator
84
- .deleteCommand('degree')
85
- .deleteCommand('radian')
86
- .setState('degree', false)
87
- .setState('radian', false)
88
- .off('.' + pluginName);
89
- }
90
- });
@@ -1,166 +0,0 @@
1
- /**
2
- * This program is free software; you can redistribute it and/or
3
- * modify it under the terms of the GNU General Public License
4
- * as published by the Free Software Foundation; under version 2
5
- * of the License (non-upgradable).
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
- *
16
- * Copyright (c) 2018 Open Assessment Technologies SA ;
17
- */
18
- /**
19
- * Plugin that manages an history of evaluated expressions in the calculator
20
- * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com>
21
- */
22
- import _ from 'lodash';
23
- import __ from 'i18n';
24
- import nsHelper from 'util/namespace';
25
- import pluginFactory from 'ui/maths/calculator/core/plugin';
26
-
27
- var pluginName = 'history';
28
-
29
- /**
30
- * Defines an entry in the history
31
- * @typedef {Object} historyEntry
32
- * @property {String} expression - The expression that has been extracted when the entry was created
33
- * @property {Object} variables - The list of variables that has been extracted when the entry was created
34
- * @property {String} [current] - The current edited expression if the entry is modified
35
- */
36
-
37
- export default pluginFactory({
38
- name: pluginName,
39
-
40
- /**
41
- * Called when the plugin is installing in its host.
42
- */
43
- install: function install() {
44
- var calculator = this.getCalculator();
45
-
46
- calculator
47
- .setCommand('historyClear', __('Clear History'), __('Clear history'))
48
- .setCommand('historyGet', __('Get History'), __('Get the history list'))
49
- .setCommand('historyUp', __('Previous'), __('Remind the previous expression in the history'))
50
- .setCommand('historyDown', __('Next'), __('Remind the next expression in the history'));
51
- },
52
-
53
- /**
54
- * Called when the plugin should be initialized.
55
- */
56
- init: function init() {
57
- var calculator = this.getCalculator();
58
- var history, cursor, current;
59
-
60
- /**
61
- * Creates an entry from the current state
62
- * @returns {historyEntry}
63
- */
64
- function getCurrentState() {
65
- return {
66
- expression: calculator.getExpression(),
67
- variables: calculator.getVariables(),
68
- current: null
69
- };
70
- }
71
-
72
- /**
73
- * Clears the entire history
74
- */
75
- function reset() {
76
- current = getCurrentState();
77
- history = [];
78
- cursor = 0;
79
- }
80
-
81
- /**
82
- * Retrieves a memory entry in the history
83
- * @param {Number} position
84
- * @returns {Object|null}
85
- */
86
- function getMemoryAt(position) {
87
- if (position >= 0 && position < history.length) {
88
- return history[position];
89
- } else if (position === history.length) {
90
- return current;
91
- }
92
- return null;
93
- }
94
-
95
- /**
96
- * Reminds an expression from the history
97
- * @param {Number} position
98
- */
99
- function remind(position) {
100
- var memory = getMemoryAt(position);
101
-
102
- // keep the current expression in the memory, in case the user goes back to it
103
- if (cursor === history.length && position !== cursor) {
104
- current = getCurrentState();
105
- } else {
106
- history[cursor].current = calculator.getExpression();
107
- }
108
-
109
- // restore an expression from the history at the wanted position
110
- if (memory) {
111
- cursor = position;
112
- if (memory.variables) {
113
- calculator.setVariables(memory.variables);
114
- }
115
- calculator.replace(memory.current || memory.expression);
116
- memory.current = null;
117
- }
118
- }
119
-
120
- /**
121
- * Adds a memory entry in the history from the current expression
122
- */
123
- function push() {
124
- var last = getMemoryAt(history.length - 1);
125
- var memory = getMemoryAt(cursor);
126
- if (!last || calculator.getExpression() !== last.expression) {
127
- history.push(getCurrentState());
128
- }
129
- if (memory) {
130
- memory.current = null;
131
- }
132
- cursor = history.length;
133
- }
134
-
135
- reset();
136
- calculator
137
- .on(nsHelper.namespaceAll('evaluate', pluginName), push)
138
- .on(nsHelper.namespaceAll('command-historyClear command-clearAll destroy', pluginName), reset)
139
- .on(nsHelper.namespaceAll('command-historyUp', pluginName), function() {
140
- remind(cursor - 1);
141
- })
142
- .on(nsHelper.namespaceAll('command-historyDown', pluginName), function() {
143
- remind(cursor + 1);
144
- })
145
- .on(nsHelper.namespaceAll('command-historyGet', pluginName), function() {
146
- /**
147
- * @event history
148
- * @param {Array} history - The current history list
149
- */
150
- calculator.trigger('history', _.map(history, 'expression'));
151
- });
152
- },
153
-
154
- /**
155
- * Called when the plugin is destroyed. Mostly when the host is destroyed itself.
156
- */
157
- destroy: function destroy() {
158
- var calculator = this.getCalculator();
159
- calculator
160
- .deleteCommand('historyClear')
161
- .deleteCommand('historyUp')
162
- .deleteCommand('historyDown')
163
- .deleteCommand('historyGet')
164
- .off('.' + pluginName);
165
- }
166
- });
@@ -1,96 +0,0 @@
1
- /**
2
- * This program is free software; you can redistribute it and/or
3
- * modify it under the terms of the GNU General Public License
4
- * as published by the Free Software Foundation; under version 2
5
- * of the License (non-upgradable).
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
- *
16
- * Copyright (c) 2018 Open Assessment Technologies SA ;
17
- */
18
- /**
19
- * Plugin that manages a simple value reminder in the calculator
20
- * @author Jean-Sébastien Conan <jean-sebastien@taotesting.com>
21
- */
22
-
23
- import __ from 'i18n';
24
- import nsHelper from 'util/namespace';
25
- import pluginFactory from 'ui/maths/calculator/core/plugin';
26
-
27
- var pluginName = 'remind';
28
- var varRemindName = 'mem';
29
- var varLastName = 'last';
30
-
31
- export default pluginFactory({
32
- name: pluginName,
33
-
34
- /**
35
- * Called when the plugin is installing in its host.
36
- */
37
- install: function install() {
38
- var calculator = this.getCalculator();
39
-
40
- calculator
41
- .setCommand('remind', __('Remind'), __('Remind the recorded value'))
42
- .setCommand('remindLast', __('Remind Last'), __('Remind the last value'))
43
- .setCommand('remindStore', __('Store'), __('Store the value a variable'))
44
- .setCommand('remindClear', __('Clear'), __('Clear the stored variables'));
45
- },
46
-
47
- /**
48
- * Called when the plugin should be initialized.
49
- */
50
- init: function init() {
51
- var calculator = this.getCalculator();
52
-
53
- calculator
54
- .on(nsHelper.namespaceAll('evaluate', pluginName), function(result) {
55
- calculator.setVariable(varLastName, result);
56
- })
57
- .on(nsHelper.namespaceAll('command-remind', pluginName), function() {
58
- if (calculator.hasVariable(varRemindName)) {
59
- calculator.useVariable(varRemindName);
60
- }
61
- })
62
- .on(nsHelper.namespaceAll('command-remindLast', pluginName), function() {
63
- if (calculator.hasVariable(varLastName)) {
64
- calculator.useVariable(varLastName);
65
- }
66
- })
67
- .on(nsHelper.namespaceAll('command-remindStore', pluginName), function() {
68
- if (calculator.hasVariable(varLastName)) {
69
- calculator.setVariable(varRemindName, calculator.getVariable(varLastName));
70
- }
71
- })
72
- .on(nsHelper.namespaceAll('command-remindClear command-clearAll destroy', pluginName), function() {
73
- if (calculator.hasVariable(varRemindName)) {
74
- calculator.deleteVariable(varRemindName);
75
- }
76
- })
77
- .on(nsHelper.namespaceAll('destroy', pluginName), function() {
78
- if (calculator.hasVariable(varLastName)) {
79
- calculator.deleteVariable(varLastName);
80
- }
81
- });
82
- },
83
-
84
- /**
85
- * Called when the plugin is destroyed. Mostly when the host is destroyed itself.
86
- */
87
- destroy: function destroy() {
88
- var calculator = this.getCalculator();
89
- calculator
90
- .deleteCommand('remind')
91
- .deleteCommand('remindLast')
92
- .deleteCommand('remindStore')
93
- .deleteCommand('remindClear')
94
- .off('.' + pluginName);
95
- }
96
- });