Prettified all files.
This commit is contained in:
+40
-31
@@ -1,9 +1,9 @@
|
||||
import Theme from './theme.js'
|
||||
import {InteractivePopup} from './popup.js'
|
||||
import { InteractivePopup } from './popup.js'
|
||||
|
||||
/**
|
||||
* Class that represents a PixiJS Modal.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* // Create the button and the modal when clicked
|
||||
* const button = new Button({
|
||||
@@ -28,10 +28,9 @@ import {InteractivePopup} from './popup.js'
|
||||
* @see {@link https://www.iwm-tuebingen.de/iwmbrowser/lib/pixi/modal.html|DocTest}
|
||||
*/
|
||||
export default class Modal extends PIXI.Container {
|
||||
|
||||
/**
|
||||
* Creates an instance of a Modal.
|
||||
*
|
||||
*
|
||||
* @constructor
|
||||
* @param {object} [opts] - An options object to specify to style and behaviour of the modal.
|
||||
* @param {number} [opts.id=auto generated] - The id of the modal.
|
||||
@@ -43,20 +42,23 @@ export default class Modal extends PIXI.Container {
|
||||
* @param {boolean} [opts.visible=true] - Is the modal initially visible (property visible)?
|
||||
*/
|
||||
constructor(opts = {}) {
|
||||
|
||||
super()
|
||||
|
||||
|
||||
const theme = Theme.fromString(opts.theme)
|
||||
this.theme = theme
|
||||
|
||||
this.opts = Object.assign({}, {
|
||||
id: PIXI.utils.uid(),
|
||||
app: window.app,
|
||||
backgroundFill: theme.background,
|
||||
backgroundFillAlpha: .6,
|
||||
closeOnBackground: true,
|
||||
visible: true
|
||||
}, opts)
|
||||
this.opts = Object.assign(
|
||||
{},
|
||||
{
|
||||
id: PIXI.utils.uid(),
|
||||
app: window.app,
|
||||
backgroundFill: theme.background,
|
||||
backgroundFillAlpha: 0.6,
|
||||
closeOnBackground: true,
|
||||
visible: true
|
||||
},
|
||||
opts
|
||||
)
|
||||
|
||||
this.id = this.opts.id
|
||||
|
||||
@@ -74,15 +76,14 @@ export default class Modal extends PIXI.Container {
|
||||
//-----------------
|
||||
this.layout()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates children and instantiates everything.
|
||||
*
|
||||
*
|
||||
* @private
|
||||
* @return {Modal} A reference to the modal for chaining.
|
||||
*/
|
||||
setup() {
|
||||
|
||||
// interaction
|
||||
//-----------------
|
||||
this.interactive = true
|
||||
@@ -120,21 +121,23 @@ export default class Modal extends PIXI.Container {
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should be called to refresh the layout of the modal. Can be used after resizing.
|
||||
*
|
||||
*
|
||||
* @return {Modal} A reference to the modal for chaining.
|
||||
*/
|
||||
layout() {
|
||||
|
||||
const width = this.opts.app.size.width
|
||||
const height = this.opts.app.size.height
|
||||
|
||||
// background
|
||||
//-----------------
|
||||
this.background.clear()
|
||||
this.background.beginFill(this.opts.backgroundFill, this.opts.backgroundFillAlpha)
|
||||
this.background.beginFill(
|
||||
this.opts.backgroundFill,
|
||||
this.opts.backgroundFillAlpha
|
||||
)
|
||||
this.background.drawRect(0, 0, width, height)
|
||||
this.background.endFill()
|
||||
|
||||
@@ -144,33 +147,39 @@ export default class Modal extends PIXI.Container {
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shows the modal (sets his alpha values to 1).
|
||||
*
|
||||
*
|
||||
* @return {Modal} A reference to the modal for chaining.
|
||||
*/
|
||||
show() {
|
||||
TweenLite.to(this, this.theme.fast, {alpha: 1, onStart: () => this.visible = true})
|
||||
TweenLite.to(this, this.theme.fast, {
|
||||
alpha: 1,
|
||||
onStart: () => (this.visible = true)
|
||||
})
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hides the modal (sets his alpha values to 0).
|
||||
*
|
||||
*
|
||||
* @return {Modal} A reference to the modal for chaining.
|
||||
*/
|
||||
hide() {
|
||||
TweenLite.to(this, this.theme.fast, {alpha: 0, onComplete: () => this.visible = false})
|
||||
TweenLite.to(this, this.theme.fast, {
|
||||
alpha: 0,
|
||||
onComplete: () => (this.visible = false)
|
||||
})
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets or gets the header. The getter always returns a PIXI.Text object. The setter can receive
|
||||
* a string or a PIXI.Text object.
|
||||
*
|
||||
*
|
||||
* @member {string|PIXI.Text}
|
||||
*/
|
||||
get header() {
|
||||
@@ -182,11 +191,11 @@ export default class Modal extends PIXI.Container {
|
||||
this.popup.destroy()
|
||||
this.setup().layout()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets or gets the content. The getter always returns an PIXI.DisplayObject. The setter can receive
|
||||
* a string or a PIXI.DisplayObject.
|
||||
*
|
||||
*
|
||||
* @member {string|PIXI.DisplayObject}
|
||||
*/
|
||||
get content() {
|
||||
|
||||
Reference in New Issue
Block a user