Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 6b1b070c

Přidáno uživatelem Pavel Fidranský před více než 6 roky(ů)

reworked StatusBar to ES6 class

Zobrazit rozdíly:

sources/src/main/webapp/js/components/statusBar.js
1 1
/**
2 2
 * Class representing the sidebar status bar. It displays number of components loaded in the diagram.
3
 * @constructor
4 3
 */
5
function StatusBar() {
6
	var rootElement;
7
	var componentCounterElement;
8

  
9
	/**
10
	 * Sets a new count of components loaded in the diagram.
11
	 * @param {integer} componentCount New count of components.
12
	 */
13
	this.setComponentCount = function(componentCount) {
14
		componentCounterElement.innerHTML = '';
15
		componentCounterElement.appendChild(DOM.createTextElement('loaded components: ' + componentCount));
16
	};
17

  
4
class StatusBar {
18 5
	/**
19 6
	 * Creates a new DOM element representing the status bar in memory.
20
	 * @returns {Element} HTML DOM element.
7
	 * @public
8
	 * @returns {HTMLElement} HTML DOM element.
21 9
	 */
22
	this.render = function() {
23
		rootElement = DOM.createHtmlElement('nav', {
24
			'class': 'status-bar',
25
		});
26

  
27
		componentCounterElement = DOM.createHtmlElement('span', {
28
			'class': 'component-counter',
10
	render() {
11
		this._componentCounterElement = DOM.h('span', {
12
			class: 'component-counter',
29 13
		});
30
		rootElement.appendChild(componentCounterElement);
31 14

  
32
		minimapToggleElement = DOM.createHtmlElement('span', {
33
			'class': 'link',
34
		});
35
		minimapToggleElement.appendChild(DOM.createTextElement('toggle minimap'));
36
		minimapToggleElement.addEventListener('click', toggleMinimap.bind(this));
37
		rootElement.appendChild(minimapToggleElement);
15
		this._rootElement = DOM.h('nav', {
16
			class: 'status-bar',
17
		}, [
18
			this._componentCounterElement,
19
			DOM.h('span', {
20
				class: 'link',
21
				innerText: 'toggle minimap',
22
				onClick: this._toggleMinimap.bind(this),
23
			}),
24
		]);
25

  
26
		return this._rootElement;
27
	}
38 28

  
39
		return rootElement;
40
	};
29
	/**
30
	 * Sets a new count of components loaded in the diagram.
31
	 * @public
32
	 * @param {integer} count New count of components.
33
	 */
34
	set componentCount(count) {
35
		this._componentCounterElement.innerText = 'loaded components: ' + count;
36
	}
41 37

  
42 38
	/**
43 39
	 * Resets the information displayed in the status bar.
40
	 * @public
44 41
	 */
45
	this.reset = function() {
46
		componentCounterElement.innerHTML = '';
42
	reset() {
43
		this._componentCounterElement.innerText = '';
47 44
	};
48 45

  
49
	function toggleMinimap(e) {
46
	/**
47
	 * @private
48
	 */
49
	_toggleMinimap(e) {
50 50
		e.preventDefault();
51 51

  
52 52
		document.getElementById('minimapComponent').classList.toggle('hidden');
sources/src/main/webapp/js/services/graphLoader.js
183 183
		app.viewportComponent.center();
184 184

  
185 185
		// update status bar
186
		app.sidebarComponent.statusBarComponent.setComponentCount(data.vertices.length);
186
		app.sidebarComponent.statusBarComponent.componentCount = data.vertices.length;
187 187

  
188 188
		if (Utils.isDefined(highlightedEdge)) {
189 189
            highlightedEdge.setHighlighted(true);

Také k dispozici: Unified diff