@qtoggle/qui 1.16.1 → 1.16.3
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/js/pages/page.js
CHANGED
|
@@ -9,6 +9,7 @@ import * as Navigation from '$qui/navigation.js'
|
|
|
9
9
|
import * as Theme from '$qui/theme.js'
|
|
10
10
|
import {asap} from '$qui/utils/misc.js'
|
|
11
11
|
import ViewMixin from '$qui/views/view.js'
|
|
12
|
+
import * as Sections from '$qui/sections/sections.js'
|
|
12
13
|
import * as Window from '$qui/window.js'
|
|
13
14
|
|
|
14
15
|
import {getPagesContainer} from './pages.js'
|
|
@@ -182,7 +183,7 @@ const PageMixin = Mixin((superclass = Object, rootclass) => {
|
|
|
182
183
|
/**
|
|
183
184
|
* Override this to implement how the page is loaded.
|
|
184
185
|
*
|
|
185
|
-
*
|
|
186
|
+
* Does nothing by default, returning a resolved promise.
|
|
186
187
|
*
|
|
187
188
|
* @returns {Promise}
|
|
188
189
|
*/
|
|
@@ -727,6 +728,14 @@ const PageMixin = Mixin((superclass = Object, rootclass) => {
|
|
|
727
728
|
this.onSectionHide()
|
|
728
729
|
}
|
|
729
730
|
|
|
731
|
+
/**
|
|
732
|
+
* Returns the section to which the page currently belongs (may be `null`).
|
|
733
|
+
* @returns {?qui.sections.Section}
|
|
734
|
+
*/
|
|
735
|
+
getSection() {
|
|
736
|
+
return Sections.all().find(s => s.getPagesContext() === this.getContext()) || null
|
|
737
|
+
}
|
|
738
|
+
|
|
730
739
|
/**
|
|
731
740
|
* Override this method to enable the options bar for this page.
|
|
732
741
|
* @returns {?jQuery|qui.views.ViewMixin}
|
package/js/pages/pages.js
CHANGED
|
@@ -48,7 +48,7 @@ export function getCurrentContext() {
|
|
|
48
48
|
/**
|
|
49
49
|
* Replace the current pages context.
|
|
50
50
|
* @alias qui.pages.setCurrentContext
|
|
51
|
-
* @param {?qui.pages.PagesContext} context new context, or `null` to replace with a brand
|
|
51
|
+
* @param {?qui.pages.PagesContext} context new context, or `null` to replace with a brand-new context
|
|
52
52
|
*/
|
|
53
53
|
export function setCurrentContext(context) {
|
|
54
54
|
let pagesToDetach = currentContext.getPages()
|
package/js/sections/section.js
CHANGED
|
@@ -3,6 +3,7 @@ import $ from '$qui/lib/jquery.module.js'
|
|
|
3
3
|
import Logger from '$qui/lib/logger.module.js'
|
|
4
4
|
|
|
5
5
|
import {NotImplementedError} from '$qui/base/errors.js'
|
|
6
|
+
import {AssertionError} from '$qui/base/errors.js'
|
|
6
7
|
import {mix} from '$qui/base/mixwith.js'
|
|
7
8
|
import SingletonMixin from '$qui/base/singleton.js'
|
|
8
9
|
import StockIcon from '$qui/icons/stock-icon.js'
|
|
@@ -358,18 +359,24 @@ class Section extends mix().with(SingletonMixin) {
|
|
|
358
359
|
* @returns {?qui.pages.PageMixin}
|
|
359
360
|
*/
|
|
360
361
|
getCurrentPage() {
|
|
361
|
-
|
|
362
|
+
let context = this.getPagesContext()
|
|
363
|
+
return context ? context.getCurrentPage() : null
|
|
362
364
|
}
|
|
363
365
|
|
|
364
366
|
/**
|
|
365
367
|
* Return the pages context of this section.
|
|
366
|
-
* @returns {qui.pages.PagesContext}
|
|
368
|
+
* @returns {?qui.pages.PagesContext}
|
|
367
369
|
*/
|
|
368
370
|
getPagesContext() {
|
|
369
371
|
/* A hidden section has its pages context stored in _savedPagesContext. A visible (current) section owns the
|
|
370
372
|
* current pages context. */
|
|
371
373
|
|
|
372
|
-
|
|
374
|
+
if (this.isCurrent()) {
|
|
375
|
+
return getCurrentContext()
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
return this._savedPagesContext
|
|
379
|
+
}
|
|
373
380
|
}
|
|
374
381
|
|
|
375
382
|
|
|
@@ -525,6 +532,10 @@ class Section extends mix().with(SingletonMixin) {
|
|
|
525
532
|
}
|
|
526
533
|
|
|
527
534
|
let context = this.getPagesContext()
|
|
535
|
+
if (!context) {
|
|
536
|
+
throw new AssertionError('Attempt to push page to uninitialized section')
|
|
537
|
+
}
|
|
538
|
+
|
|
528
539
|
if (!context.isCurrent()) {
|
|
529
540
|
historyEntry = false
|
|
530
541
|
}
|
|
@@ -192,7 +192,9 @@ $.widget('qui.choicebuttons', $.qui.basewidget, {
|
|
|
192
192
|
|
|
193
193
|
_setActive: function (button) {
|
|
194
194
|
this._getButtons().removeClass(this.options.onClass)
|
|
195
|
-
button
|
|
195
|
+
if (button) {
|
|
196
|
+
button.addClass(this.options.onClass)
|
|
197
|
+
}
|
|
196
198
|
},
|
|
197
199
|
|
|
198
200
|
_installClickHandlers: function () {
|
|
@@ -226,6 +228,7 @@ $.widget('qui.choicebuttons', $.qui.basewidget, {
|
|
|
226
228
|
},
|
|
227
229
|
|
|
228
230
|
setValue: function (value) {
|
|
231
|
+
this._setActive(null)
|
|
229
232
|
let widget = this
|
|
230
233
|
this._getButtons().each(function () {
|
|
231
234
|
if ($(this).data('value') === value) {
|
package/package.json
CHANGED