@componyx/ui 0.0.0-stage → 1.0.4
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/AppSkin/AppSkin.css +1268 -0
- package/AppSkin/AppSkin.js +2748 -0
- package/AppSkin/Themes/Default.css +241 -0
- package/Base/Base.js +3407 -0
- package/Base/ComponentIcons.css +66 -0
- package/Base/Font/ComponentIcons.woff +0 -0
- package/Base/Font/UI.woff +0 -0
- package/Base/Library.js +8432 -0
- package/Base/NavigationManager.js +462 -0
- package/Base/ResponsiveTemplates.js +371 -0
- package/Base/Sanitizer.js +288 -0
- package/Base/Themes/Default.css +255 -0
- package/Base/UI.css +618 -0
- package/Base/UIResourcePath.js +6 -0
- package/Bindary/Bindary.js +2011 -0
- package/Bindary/Modules/Connection.js +216 -0
- package/Bindary/Modules/Core.js +854 -0
- package/Bindary/Modules/DataUpdater.js +351 -0
- package/Bindary/Modules/ExpressionEngine.js +347 -0
- package/Bindary/Modules/ProxyManager.js +482 -0
- package/Bindary/Modules/Renderer.js +605 -0
- package/Bindary/Modules/Router.js +291 -0
- package/Bindary/Modules/Scroller.js +89 -0
- package/Bindary/Modules/Template.js +1273 -0
- package/BookmarkSpy/BookmarkSpy.js +430 -0
- package/Box/Box.css +36 -0
- package/Box/Box.js +1685 -0
- package/Button/Button.css +470 -0
- package/Button/Button.js +1398 -0
- package/Button/Themes/Default.css +200 -0
- package/Carousel/Carousel.css +273 -0
- package/Carousel/Carousel.js +607 -0
- package/ColorButton/ColorButton.css +39 -0
- package/ColorButton/ColorButton.js +336 -0
- package/ColorPicker/ColorPicker.css +359 -0
- package/ColorPicker/ColorPicker.js +972 -0
- package/ComboBox/ComboBox.css +357 -0
- package/ComboBox/ComboBox.js +2342 -0
- package/ComboBox/Themes/Default.css +23 -0
- package/DataPager/DataPager.css +72 -0
- package/DataPager/DataPager.js +674 -0
- package/DatePicker/DatePicker.css +227 -0
- package/DatePicker/DatePicker.js +1531 -0
- package/DatePicker/Themes/Default.css +26 -0
- package/Dialog/Dialog.css +106 -0
- package/Dialog/Dialog.js +572 -0
- package/Dialog/Themes/Default.css +10 -0
- package/Editor/Data/Emoji.json +8285 -0
- package/Editor/Data/Special.json +1042 -0
- package/Editor/Editor.css +1562 -0
- package/Editor/Editor.js +4058 -0
- package/Editor/Font/Editor.woff +0 -0
- package/Editor/Modules/ComponentFactory.js +565 -0
- package/Editor/Modules/ContentManager.js +748 -0
- package/Editor/Modules/DialogManager.js +1234 -0
- package/Editor/Modules/EventManager.js +458 -0
- package/Editor/Modules/Format.js +950 -0
- package/Editor/Modules/History.js +191 -0
- package/Editor/Modules/LayoutState.js +379 -0
- package/Editor/Modules/ListManager.js +296 -0
- package/Editor/Modules/MenuManager.js +388 -0
- package/Editor/Modules/NodeManager.js +681 -0
- package/Editor/Modules/ParagraphButtons.js +122 -0
- package/Editor/Modules/Resizer.js +176 -0
- package/Editor/Modules/SelectionRange.js +564 -0
- package/Editor/Modules/SourceViewBuilder.js +212 -0
- package/Editor/Modules/SymbolPicker.js +208 -0
- package/Editor/Modules/Table.js +2327 -0
- package/Editor/Modules/TableDialog.js +757 -0
- package/Editor/Modules/Toolbar.js +375 -0
- package/Editor/Modules/TooltipMenu.js +125 -0
- package/Editor/Modules/Utility.js +131 -0
- package/Editor/Themes/Default.css +204 -0
- package/FileUpload/FileUpload.css +156 -0
- package/FileUpload/FileUpload.js +898 -0
- package/FileUpload/Themes/Default.css +17 -0
- package/Form/Form.css +1934 -0
- package/Form/Form.js +4943 -0
- package/Form/Modules/ActionManager.js +368 -0
- package/Form/Modules/BuildPanelManager.js +319 -0
- package/Form/Modules/ComponentFactory.js +468 -0
- package/Form/Modules/ComponentPanel.js +265 -0
- package/Form/Modules/ConfigPanelManager.js +685 -0
- package/Form/Modules/DataBinder.js +602 -0
- package/Form/Modules/DataObserver.js +717 -0
- package/Form/Modules/Draggable.js +756 -0
- package/Form/Modules/OptionsPanel.js +342 -0
- package/Form/Modules/Renderer.js +1889 -0
- package/Form/Modules/RuleEngine.js +585 -0
- package/Form/Modules/RulesPanel.js +1158 -0
- package/Form/Modules/Types.js +1709 -0
- package/Form/Modules/ValidationManager.js +194 -0
- package/Form/Themes/Default.css +216 -0
- package/FormField/FormField.css +468 -0
- package/FormField/FormField.js +576 -0
- package/FormField/Themes/Default.css +99 -0
- package/Grid/Grid.css +544 -0
- package/Grid/Grid.js +3761 -0
- package/Grid/Themes/Default.css +43 -0
- package/LICENSE +126 -0
- package/MaskedTextBox/MaskedTextBox.css +28 -0
- package/MaskedTextBox/MaskedTextBox.js +642 -0
- package/MaskedTextBox/Themes/Default.css +6 -0
- package/Menu/Menu.css +328 -0
- package/Menu/Menu.js +2386 -0
- package/Menu/Themes/Default.css +24 -0
- package/NumericBox/NumericBox.css +120 -0
- package/NumericBox/NumericBox.js +984 -0
- package/PanelBar/PanelBar.css +123 -0
- package/PanelBar/PanelBar.js +505 -0
- package/PanelBar/Themes/Default.css +51 -0
- package/PieChart/PieChart.css +95 -0
- package/PieChart/PieChart.js +820 -0
- package/PieChart/Themes/Default.css +9 -0
- package/README.md +178 -3
- package/Slider/Slider.css +348 -0
- package/Slider/Slider.js +1306 -0
- package/Slider/Themes/Default.css +44 -0
- package/TabStrip/TabStrip.css +52 -0
- package/TabStrip/TabStrip.js +362 -0
- package/TabStrip/Themes/Default.css +35 -0
- package/TimePicker/Themes/Default.css +30 -0
- package/TimePicker/TimePicker.css +253 -0
- package/TimePicker/TimePicker.js +1485 -0
- package/TooltipManager/Themes/Default.css +21 -0
- package/TooltipManager/TooltipManager.css +227 -0
- package/TooltipManager/TooltipManager.js +791 -0
- package/Validator/Validator.css +54 -0
- package/Validator/Validator.js +2508 -0
- package/componyx.html-data.json +619 -0
- package/index.js +27 -0
- package/package.json +43 -4
- package/types/AppSkin.d.ts +842 -0
- package/types/Base.d.ts +1034 -0
- package/types/Bindary.d.ts +1196 -0
- package/types/BookmarkSpy.d.ts +112 -0
- package/types/Box.d.ts +374 -0
- package/types/Button.d.ts +455 -0
- package/types/Carousel.d.ts +136 -0
- package/types/ColorButton.d.ts +120 -0
- package/types/ColorPicker.d.ts +225 -0
- package/types/ComboBox.d.ts +507 -0
- package/types/DataPager.d.ts +152 -0
- package/types/DatePicker.d.ts +354 -0
- package/types/Dialog.d.ts +160 -0
- package/types/Editor.d.ts +1289 -0
- package/types/FileUpload.d.ts +206 -0
- package/types/Form.d.ts +3078 -0
- package/types/FormField.d.ts +204 -0
- package/types/Grid.d.ts +911 -0
- package/types/Library.d.ts +1899 -0
- package/types/MaskedTextBox.d.ts +91 -0
- package/types/Menu.d.ts +577 -0
- package/types/NumericBox.d.ts +310 -0
- package/types/PanelBar.d.ts +223 -0
- package/types/PieChart.d.ts +224 -0
- package/types/ResponsiveTemplates.d.ts +108 -0
- package/types/Slider.d.ts +227 -0
- package/types/TabStrip.d.ts +185 -0
- package/types/TimePicker.d.ts +265 -0
- package/types/TooltipManager.d.ts +178 -0
- package/types/UI.d.ts +29 -0
- package/types/Validator.d.ts +653 -0
- package/types/index.d.ts +59 -0
- package/ui.css +11783 -0
- package/ui.js +79477 -0
- package/ui.min.css +138 -0
- package/ui.min.js +264 -0
- package/ui.min.js.map +1 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
|
|
2
|
+
import '../Base/Base.js';
|
|
3
|
+
import '../Base/Library.js';
|
|
4
|
+
|
|
5
|
+
(function (window)
|
|
6
|
+
{
|
|
7
|
+
/**
|
|
8
|
+
* BookmarkSpy class.
|
|
9
|
+
* @class
|
|
10
|
+
* @memberof componyx.UI
|
|
11
|
+
* @augments componyx.UI.base.Component
|
|
12
|
+
* @mixes componyx.UI.base.methods
|
|
13
|
+
* @param {String} id The id of the component.
|
|
14
|
+
* @param {Object|HTMLElement} properties The properties used to initialize the component or the container element.
|
|
15
|
+
* @returns {Object} An instance of the component.
|
|
16
|
+
*/
|
|
17
|
+
componyx.UI.BookmarkSpy = function BookmarkSpy(id, properties)
|
|
18
|
+
{
|
|
19
|
+
// define private properties
|
|
20
|
+
let _instance = this,
|
|
21
|
+
_raf = window.requestAnimationFrame, _caf = window.cancelAnimationFrame, _reqId,
|
|
22
|
+
_scroller, _anchorContainer, _firstAnchor, _lastAnchor, _selected, _lastScroll,
|
|
23
|
+
_initPath, _anchors = new Map(), _bookmarks = [];
|
|
24
|
+
|
|
25
|
+
// define public properties
|
|
26
|
+
/**
|
|
27
|
+
* Gets or sets the css class to apply to the active menu-item anchor.
|
|
28
|
+
* @property {String} cssClass=selected
|
|
29
|
+
*/
|
|
30
|
+
this.cssClass = 'selected';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets or sets the css class to apply to the parent anchor(s) of the active menu-item anchor.
|
|
34
|
+
* @property {String} [cssClassParent]
|
|
35
|
+
*/
|
|
36
|
+
this.cssClassParent = '';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Gets or sets a value indicating to spy on horizontal instead of vertical scrolling.
|
|
40
|
+
* @property {Boolean} [horizontal=false]
|
|
41
|
+
*/
|
|
42
|
+
this.horizontal = false;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Gets or sets a value indicating if the URL anchor must be rewritten to the active bookmark.
|
|
46
|
+
* @property {Boolean} [updateURL=true]
|
|
47
|
+
*/
|
|
48
|
+
this.updateURL = true;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets or sets a value indicating if the click event of the selected anchor is executed.
|
|
52
|
+
* @property {Boolean} [fireAnchorClick=false]
|
|
53
|
+
*/
|
|
54
|
+
this.fireAnchorClick = false;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Gets or sets the scrollable container element or element id.
|
|
58
|
+
* @property {HTMLElement|String} [scroller=document]
|
|
59
|
+
*/
|
|
60
|
+
this.scroller = null;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Gets or sets the anchor container element or element id.
|
|
64
|
+
* @property {HTMLElement|String} [anchorContainer=document]
|
|
65
|
+
*/
|
|
66
|
+
this.anchorContainer = null;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Gets or sets the offset in pixels.
|
|
70
|
+
* @property {Number} [offset=0]
|
|
71
|
+
*/
|
|
72
|
+
this.offset = 0;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Gets or sets the bookmark tags (space delimited) to spy on.
|
|
76
|
+
* @property {String} [tags]
|
|
77
|
+
*/
|
|
78
|
+
this.tags = '';
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Gets or sets the menu component which holds the bookmark links.
|
|
82
|
+
* @property {String} [menuId]
|
|
83
|
+
*/
|
|
84
|
+
this.menuId = null;
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @class
|
|
89
|
+
* @augments componyx.UI.base.Events
|
|
90
|
+
* @memberof componyx.UI.BookmarkSpy
|
|
91
|
+
* @property {componyx.UI.base.Event} onPreInit - Event which fires before init but after resources load.
|
|
92
|
+
* @property {componyx.UI.base.Event} onPostInit - Event which fires after init.
|
|
93
|
+
* @property {componyx.UI.base.Event} onChange - Event which fires when the active bookmark changes. @see {@link componyx.UI.BookmarkSpy.ChangeEventArgs}
|
|
94
|
+
* @see {@link componyx.UI.base.Events}
|
|
95
|
+
*/
|
|
96
|
+
function BookmarkSpyEvents(events)
|
|
97
|
+
{
|
|
98
|
+
Object.assign(this, events);
|
|
99
|
+
this.onPreInit = $base.static.createEvent('onPreInit');
|
|
100
|
+
this.onPostInit = $base.static.createEvent('onPostInit');
|
|
101
|
+
this.onChange = $base.static.createEvent('onChange');
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* BookmarkSpy events
|
|
105
|
+
* @type {componyx.UI.BookmarkSpy.BookmarkSpyEvents}
|
|
106
|
+
*/
|
|
107
|
+
this.events = new BookmarkSpyEvents(this.events);
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* BookmarkSpy change event arguments.
|
|
111
|
+
* @typedef {Object} ChangeEventArgs
|
|
112
|
+
* @memberof componyx.UI.BookmarkSpy
|
|
113
|
+
* @property {HTMLAnchorElement} selected - The anchor of the active bookmark.
|
|
114
|
+
* @property {HTMLAnchorElement|null} [deselected] - The anchor of the previously active bookmark, empty on the first change.
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
if (!properties)
|
|
118
|
+
properties = {};
|
|
119
|
+
else if ($lib.isElement(properties))
|
|
120
|
+
properties = { containerElement: properties };
|
|
121
|
+
|
|
122
|
+
if (properties.cssClass == undefined)
|
|
123
|
+
properties.cssClass = this.cssClass;
|
|
124
|
+
|
|
125
|
+
// inherit base instance members
|
|
126
|
+
$base.Component.apply(this, [id, properties]);
|
|
127
|
+
|
|
128
|
+
// the BookmarkSpy does not render html output, so nothing to hide
|
|
129
|
+
this.hide = null;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Initializes the BookmarkSpy component if this has not yet been done.
|
|
133
|
+
*/
|
|
134
|
+
this.show = function ()
|
|
135
|
+
{
|
|
136
|
+
if (_instance.renderState == $base.static.RenderState.NONE)
|
|
137
|
+
this.render();
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Initializes the BookmarkSpy component.
|
|
142
|
+
*/
|
|
143
|
+
this.init = function ()
|
|
144
|
+
{
|
|
145
|
+
const element = _instance.element;
|
|
146
|
+
|
|
147
|
+
_instance.destroy(true, false); // keep events, keep the placeholder in the DOM
|
|
148
|
+
_instance.element = element;
|
|
149
|
+
_instance.hasTheme = false;
|
|
150
|
+
$UI.store[_instance.id] = _instance;
|
|
151
|
+
|
|
152
|
+
if (element) // a BookmarkSpy created by another component does not have an element
|
|
153
|
+
{
|
|
154
|
+
$UI.elementStore.set(element, _instance); // destroy() removed it
|
|
155
|
+
$base.methods.setupMutationObserver.call(_instance);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
_instance.renderState = $base.static.RenderState.RENDERED; // we need to set this state otherwise main UI postRender event might be blocked
|
|
159
|
+
_instance.events.onPreInit.fire(_instance);
|
|
160
|
+
|
|
161
|
+
if ($UI.busy)
|
|
162
|
+
{
|
|
163
|
+
if (!$UI.onPostRender.has(init))
|
|
164
|
+
$UI.onPostRender.once(init);
|
|
165
|
+
}
|
|
166
|
+
else
|
|
167
|
+
init();
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Initializes the BookmarkSpy component. Both init and render are the same for this component.
|
|
172
|
+
* @function
|
|
173
|
+
*/
|
|
174
|
+
this.render = this.init;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Destroys the component.
|
|
178
|
+
* @see {@link componyx.UI.base.methods#destroy}
|
|
179
|
+
*/
|
|
180
|
+
this.destroy = function (...args)
|
|
181
|
+
{
|
|
182
|
+
dispose();
|
|
183
|
+
$base.methods.destroy.call(this, ...args);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
function init()
|
|
187
|
+
{
|
|
188
|
+
_initPath = window.location.pathname;
|
|
189
|
+
_scroller = getElement(_instance.scroller) || $lib.scrollableRoot();
|
|
190
|
+
_anchorContainer = getElement(_instance.anchorContainer) || document;
|
|
191
|
+
|
|
192
|
+
let bookmarks = $lib(null, _scroller, _instance.tags),
|
|
193
|
+
anchors = $lib(null, _anchorContainer, 'a');
|
|
194
|
+
|
|
195
|
+
$lib.each(bookmarks, function (el)
|
|
196
|
+
{
|
|
197
|
+
let a = getAnchor(el.id, anchors);
|
|
198
|
+
|
|
199
|
+
if (a)
|
|
200
|
+
{
|
|
201
|
+
_bookmarks.push(el);
|
|
202
|
+
_anchors.set(el.id, a);
|
|
203
|
+
_lastAnchor = a;
|
|
204
|
+
|
|
205
|
+
if (!_firstAnchor)
|
|
206
|
+
_firstAnchor = a;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
_bookmarks.reverse();
|
|
211
|
+
update();
|
|
212
|
+
_instance.events.onPostInit.fire(_instance);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function getElement(el)
|
|
216
|
+
{
|
|
217
|
+
if (el && typeof el == 'string' && $lib('#' + el))
|
|
218
|
+
return $lib('#' + el);
|
|
219
|
+
|
|
220
|
+
return el;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function getAnchor(id, anchors)
|
|
224
|
+
{
|
|
225
|
+
if ($lib.isEmpty(id))
|
|
226
|
+
return;
|
|
227
|
+
|
|
228
|
+
let item;
|
|
229
|
+
|
|
230
|
+
$lib.each(anchors, function (a)
|
|
231
|
+
{
|
|
232
|
+
let index = a.href.lastIndexOf('#');
|
|
233
|
+
|
|
234
|
+
if (index > -1)
|
|
235
|
+
{
|
|
236
|
+
let hash = a.href.substr(index + 1);
|
|
237
|
+
|
|
238
|
+
if (hash === id)
|
|
239
|
+
{
|
|
240
|
+
item = a;
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
return item;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function update()
|
|
250
|
+
{
|
|
251
|
+
if (!_anchors.size || window.location.pathname !== _initPath) // no anchors or route has changed
|
|
252
|
+
return;
|
|
253
|
+
|
|
254
|
+
let scroll = (_instance.horizontal) ? _scroller.scrollLeft : _scroller.scrollTop;
|
|
255
|
+
|
|
256
|
+
if ($lib.isEmpty(_lastScroll) || Math.abs(_lastScroll - scroll) >= 1)
|
|
257
|
+
{
|
|
258
|
+
_lastScroll = scroll;
|
|
259
|
+
spy();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
_reqId = _raf(update);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function spy()
|
|
266
|
+
{
|
|
267
|
+
if (_lastScroll == 0)
|
|
268
|
+
selectFirst();
|
|
269
|
+
else if (isScrollEnd())
|
|
270
|
+
selectLast();
|
|
271
|
+
else
|
|
272
|
+
{
|
|
273
|
+
$lib.each(_bookmarks, function (bookmark)
|
|
274
|
+
{
|
|
275
|
+
let scrollerPos = (_scroller !== $lib.scrollableRoot()) ? $lib.getPos(_scroller, null, true) : { top: 0, left: 0 },
|
|
276
|
+
pos = $lib.getPos(bookmark, null, true),
|
|
277
|
+
p = (_instance.horizontal) ? pos.left - (scrollerPos.left + _scroller.clientLeft) : pos.top - (scrollerPos.top + _scroller.clientTop); // include possible scroll-container border difference
|
|
278
|
+
|
|
279
|
+
if (p <= _instance.offset)
|
|
280
|
+
{
|
|
281
|
+
selectItem(_anchors.get(bookmark.id));
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function isScrollEnd()
|
|
289
|
+
{
|
|
290
|
+
let size = (_instance.horizontal) ? _scroller.clientWidth : _scroller.clientHeight,
|
|
291
|
+
scrollSize = (_instance.horizontal) ? _scroller.scrollWidth : _scroller.scrollHeight,
|
|
292
|
+
maxScroll = scrollSize - size;
|
|
293
|
+
|
|
294
|
+
return (Math.abs(_lastScroll - maxScroll) < 1);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
function selectFirst()
|
|
299
|
+
{
|
|
300
|
+
selectItem(_firstAnchor);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function selectLast()
|
|
304
|
+
{
|
|
305
|
+
selectItem(_lastAnchor);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function selectItem(anchor)
|
|
309
|
+
{
|
|
310
|
+
if (anchor === _selected)
|
|
311
|
+
return;
|
|
312
|
+
|
|
313
|
+
let selected = _selected,
|
|
314
|
+
hash = anchor.href.split('#'),
|
|
315
|
+
l = hash.length - 1;
|
|
316
|
+
|
|
317
|
+
_selected = anchor;
|
|
318
|
+
|
|
319
|
+
if (selected)
|
|
320
|
+
deselectItem(selected);
|
|
321
|
+
|
|
322
|
+
if (_instance.cssClass)
|
|
323
|
+
$lib.addClass(anchor, _instance.cssClass);
|
|
324
|
+
|
|
325
|
+
if (_instance.cssClassParent)
|
|
326
|
+
selectParent(anchor);
|
|
327
|
+
|
|
328
|
+
if (_instance.fireAnchorClick)
|
|
329
|
+
anchor.click();
|
|
330
|
+
|
|
331
|
+
anchor.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
332
|
+
|
|
333
|
+
let args = { selected: _selected, deselected: selected };
|
|
334
|
+
|
|
335
|
+
updateMenu(args);
|
|
336
|
+
|
|
337
|
+
if (_instance.updateURL)
|
|
338
|
+
{
|
|
339
|
+
let loc;
|
|
340
|
+
|
|
341
|
+
if ($lib.isEmpty(window.location.hash))
|
|
342
|
+
loc = window.location.href + '#' + hash[l];
|
|
343
|
+
else
|
|
344
|
+
loc = window.location.href.replace(/(.+)(#.+)$/, '$1#' + hash[l]); // replace last hash
|
|
345
|
+
|
|
346
|
+
window.history.replaceState(null, '', loc);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
_instance.events.onChange.fire(_instance, args);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
function updateMenu(args)
|
|
354
|
+
{
|
|
355
|
+
if (!_instance.menuId)
|
|
356
|
+
return;
|
|
357
|
+
|
|
358
|
+
let menu = $UI.store[_instance.menuId];
|
|
359
|
+
|
|
360
|
+
if (args.deselected)
|
|
361
|
+
menu.deselectItem($UI.elementStore.get(args.deselected).id.replace(menu.id + '_', ''));
|
|
362
|
+
|
|
363
|
+
menu.selectItem($UI.elementStore.get(args.selected).id.replace(menu.id + '_', ''));
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
function selectParent(anchor, deselect)
|
|
367
|
+
{
|
|
368
|
+
$lib(function (el)
|
|
369
|
+
{
|
|
370
|
+
let parent = getParentAnchor(el.previousElementSibling);
|
|
371
|
+
|
|
372
|
+
if (parent)
|
|
373
|
+
{
|
|
374
|
+
if (deselect)
|
|
375
|
+
$lib.removeClass(parent, _instance.cssClassParent);
|
|
376
|
+
else
|
|
377
|
+
$lib.addClass(parent, _instance.cssClassParent);
|
|
378
|
+
|
|
379
|
+
selectParent(parent);
|
|
380
|
+
}
|
|
381
|
+
}, anchor, '', false, true);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
function getParentAnchor(el)
|
|
385
|
+
{
|
|
386
|
+
if (!el)
|
|
387
|
+
return null;
|
|
388
|
+
|
|
389
|
+
if (el.nodeName.toLowerCase() === 'a')
|
|
390
|
+
return el;
|
|
391
|
+
|
|
392
|
+
let anchors = $lib(null, el, 'a');
|
|
393
|
+
|
|
394
|
+
if (anchors.length)
|
|
395
|
+
return anchors[anchors.length - 1];
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function deselectItem(anchor)
|
|
399
|
+
{
|
|
400
|
+
$lib.removeClass(anchor, _instance.cssClass);
|
|
401
|
+
|
|
402
|
+
if (_instance.cssClassParent)
|
|
403
|
+
selectParent(anchor, true);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function dispose()
|
|
407
|
+
{
|
|
408
|
+
_caf(_reqId);
|
|
409
|
+
_reqId = null;
|
|
410
|
+
|
|
411
|
+
if (_selected)
|
|
412
|
+
deselectItem(_selected);
|
|
413
|
+
|
|
414
|
+
_bookmarks = [];
|
|
415
|
+
_anchors = new Map();
|
|
416
|
+
_firstAnchor = _lastAnchor = _lastScroll = _selected = null;
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* @see {@link componyx.UI.base.methods}
|
|
422
|
+
*/
|
|
423
|
+
componyx.UI.BookmarkSpy.prototype = Object.create($base.methods);
|
|
424
|
+
componyx.UI.BookmarkSpy.prototype.constructor = componyx.UI.BookmarkSpy;
|
|
425
|
+
|
|
426
|
+
})(window);
|
|
427
|
+
|
|
428
|
+
const BookmarkSpy = componyx.UI.BookmarkSpy;
|
|
429
|
+
|
|
430
|
+
export { BookmarkSpy };
|
package/Box/Box.css
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*! Componyx.UI | (c) E.H. Daanen / Componyx | BUSL-1.1 | componyx.com/license */
|
|
2
|
+
.box.theme
|
|
3
|
+
{
|
|
4
|
+
position: relative;
|
|
5
|
+
display: inline-block;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.box.theme > div.layout
|
|
9
|
+
{
|
|
10
|
+
position: absolute;
|
|
11
|
+
left: 0px;
|
|
12
|
+
right: 0px;
|
|
13
|
+
top: 0px;
|
|
14
|
+
bottom: 0px;
|
|
15
|
+
border-style: solid;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.box.theme > div.layout > div.main
|
|
19
|
+
{
|
|
20
|
+
position: absolute;
|
|
21
|
+
left: 0px;
|
|
22
|
+
right: 0px;
|
|
23
|
+
top: 0px;
|
|
24
|
+
bottom: 0px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.box.theme > div.modal
|
|
28
|
+
{
|
|
29
|
+
opacity: 0.3;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.box.theme > .content
|
|
33
|
+
{
|
|
34
|
+
position: relative;
|
|
35
|
+
padding: 8px;
|
|
36
|
+
}
|