Prettified all files.
This commit is contained in:
+41
-32
@@ -1439,11 +1439,11 @@
|
||||
</header>
|
||||
<article>
|
||||
<pre id="source-code" class="prettyprint source linenums"><code>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({
|
||||
@@ -1468,10 +1468,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.
|
||||
@@ -1483,20 +1482,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
|
||||
|
||||
@@ -1514,15 +1516,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
|
||||
@@ -1560,21 +1561,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()
|
||||
|
||||
@@ -1584,33 +1587,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() {
|
||||
@@ -1622,11 +1631,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() {
|
||||
@@ -1652,7 +1661,7 @@ export default class Modal extends PIXI.Container {
|
||||
|
||||
<footer class="content-size">
|
||||
<div class="footer">
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.2</a> on Wed Jul 10 2019 11:54:25 GMT+0200 (Mitteleuropäische Sommerzeit)
|
||||
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> on Thu Jul 18 2019 12:16:18 GMT+0200 (Mitteleuropäische Sommerzeit)
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user