Issues (149)

js/ui/siteapp.screenlayer.js (9 issues)

1
/**
2
 * [Siteapp] - multi-purpose frontend application
3
 * 
4
 * Siteapp UI screen-layer object
5
 *     
6
 * @package     [Siteapp]
7
 * @subpackage  [Siteapp] UI
8
 * @author      Björn Bartels <[email protected]>
9
 * @link        https://gitlab.bjoernbartels.earth/groups/themes
10
 * @license     http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
11
 * @copyright   copyright (c) 2016 Björn Bartels <[email protected]>
12
 * 
13
 * @namespace   Siteapp
14
 * @module      Siteapp.Ui.Screenlayer
15
 */
16 View Code Duplication
import Module        from '../module/siteapp.module';
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
17
18
const Siteapp_Screenlayer_DEFAULTS = {
0 ignored issues
show
The constant Siteapp_Screenlayer_DEFAULTS seems to be never used. Consider removing it.
Loading history...
19
	
20
	/* UI modes: 'flow', 'window', false */
21
	type : 'default',
22
	
23
	/* UI modes: 'flow', 'window', false */
24
	adapter : 'default',
25
	
26
	/* UI modes: 'flow', 'window', false */
27
	configurable : true,
28
	
29
	/* UI modes: 'flow', 'window', false */
30
	removable : true,
31
	
32
	/* screen layer adapters */
33
	adapters: {
34
		'default' : {}
35
	},
36
	
37
};
38
39
40
const Screenlayer = class Screenlayer extends Module {
0 ignored issues
show
The variable Module seems to be never declared. If this is a global, consider adding a /** global: Module */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
41
42
43
	get panelAdapter ( ) {
44
		if (this.options.adapter != '') {
45
			return this.application.Ui.getAdapterByName(this.options.adapter);
46
		}
47
		return null;
48
	}
49
50
	setAdapter ( adaptername ) {
51
		if (this.application.Ui.Paneladapters.isRegistered(adaptername)) {
52
			this.options.adapter = adaptername;
53
			this.$element.data('adapter', adaptername);
54
			this.$element.attr('data-adapter', adaptername);
55
		}
56
	}
57
	
58
	/**
59
	 * Minimizes screen layer.
60
	 */
61
	minimize () {
62
		this.$element.addClass('screenlayer-minimized');
63
		this.hide();
64
	}
65
	
66
	/**
67
	 * Restores minimized screen layer.
68
	 */
69
	restore () {
70
		this.$element.removeClass('screenlayer-minimized');
71
		this.show();
72
	}
73
74
	/**
75
	 * Sets screen layer active class and status flag.
76
	 */
77
	setActive () {
78
		this._active = true;
79
		this.$element.addClass('screenlayer-active');
80
	}
81
	
82
	/**
83
	 * Removes screen layer active class and status flag.
84
	 */
85
	setInactive () {
86
		this._active = false;
87
		this.$element.removeClass('screenlayer-active');
88
	}
89
	
90
	/**
91
	 * Focuses the screen layer, z-index to front, set active.
92
	 */
93
	focus () {
94
		this.manager.focusLayer(this);
95
	}
96
	
97
	/**
98
	 * Gets current 'active' status flag.
99
	 */
100
	get isActive () {
101
		return this._active === true;
102
	}
103
	
104
    /**
105
     * Create a new instance of the screen layer.
106
     * @class
107
     * @name Screenlayer
108
     * @extends Module
109
     * @param {jQuery} element - jQuery object to apply the module to.
110
     * @param {Object} options - Overrides to the default module settings.
0 ignored issues
show
Documentation Bug introduced by
The parameter options does not exist. Did you maybe mean option instead?
Loading history...
111
     */
112
	constructor (element, option) {
113
		super(element, option);
114
    	
115
		if (Siteapp.sys.functionName(this) == 'Screenlayer') {
0 ignored issues
show
The variable Siteapp seems to be never declared. If this is a global, consider adding a /** global: Siteapp */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
116
			//console.//log('initializing default screenlayer module...');
117
		}
118
	}
119
	
120
    /**
121
     * Setup a new instance of a Screenlayer.
122
     *  
123
     * @class
124
     * @name  Screenlayer
125
     * @param {jQuery} element - jQuery object to make into a screenlayer.
126
     *        Object should be of the screenlayer panel, rather than its anchor.
127
     * @param {Object} options - Overrides to the default plugin settings.
128
     */
129
	_setup(element, options) {
130
		
131
    	this.$element = element;
132
        this.options = $.extend({}, Siteapp_Screenlayer_DEFAULTS, /*this.$element.data(),*/ this.options, options);
0 ignored issues
show
The variable Siteapp_Screenlayer_DEFAULTS seems to be never declared. If this is a global, consider adding a /** global: Siteapp_Screenlayer_DEFAULTS */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
133
134
        var layerName = Siteapp.sys.functionName(this);
0 ignored issues
show
The variable Siteapp seems to be never declared. If this is a global, consider adding a /** global: Siteapp */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
135
        this.className = 'earthTheme.Ui.'+layerName; // ie9 back compat
136
        
137
        this._init();
138
139
        
140
    }
141
				
142
	/**
143
     * Initializes the screen layer by setting/checking options and attributes, 
144
     * adding helper variables...
145
     * Connects to UI manager
146
     * 
147
     * @function
148
     * @private
149
     */
150
    _init() {
151
    	
152
    	this.events = new Siteapp.sys.EventManager(this);
0 ignored issues
show
The variable Siteapp seems to be never declared. If this is a global, consider adding a /** global: Siteapp */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
153
	    this._events();
154
    	
155
    	this._initPanelAdapter();
156
157
		// usually: earthTheme.Ui.initialize(this) ,but in this case lets call the alias
158
    	// because, we are 'connecting' a '(screen)layer' to a '(UI)manager'
159
        var layerName = Siteapp.sys.functionName(this);
160
        this.manager.connectLayer(this, layerName);
161
	    
162
    }
163
	
164
	/**
165
     * Initializes the plugin by setting/checking options and attributes, adding helper variables, and saving the anchor.
166
     * @function
167
     * @private
168
     */
169
    _initPanelAdapter() {
170
    }
171
172
    /**
173
     * Adds event listeners to the element utilizing the triggers utility library.
174
     * @function
175
     * @private
176
     */
177
    _events() {
178
    	this._addKeyHandler();
179
    	this._addClickHandler();
180
    }
181
    
182
    _addClickHandler () {
183
    }
184
    
185
    /**
186
     * Adds keyboard event handlers for items within the tabs.
187
     * @private
188
     */
189
    _addKeyHandler() {
190
         // Keyboard.addKeyHandlers...
191
    }
192
    
193
    /**
194
     * Removes keyboard event handlers.
195
     * @private
196
     */
197
    _removeKeyHandler() {
198
        // Keyboard.unregister...
199
    }
200
    
201
    /**
202
     * Destroys the screenlayer.
203
     * @function
204
     */
205
    _destroy() {
206
    	this._removeKeyHandler();
207
    	
208
        this.$element.find('*').off('.'+_this.application.NS);
0 ignored issues
show
The variable _this seems to be never declared. If this is a global, consider adding a /** global: _this */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
209
        this.$element.off('.'+_this.application.NS);
210
        
211
        this.$element.remove();
212
    }
213
	
214
}
215
216
export default Screenlayer;