2017-02-21 10:36:43 +00:00
|
|
|
import {module} from '../module';
|
|
|
|
import Component from '../lib/component';
|
2017-02-21 12:06:45 +00:00
|
|
|
import './style.css';
|
2017-02-21 10:36:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A spinner to inform the user about loading process.
|
|
|
|
*/
|
|
|
|
export default class Spinner extends Component {
|
|
|
|
constructor($element, $scope) {
|
|
|
|
super($element);
|
|
|
|
this._enable = false;
|
|
|
|
this.spinner = $element[0].firstChild;
|
|
|
|
componentHandler.upgradeElement(this.spinner);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Enables/disables the spinner.
|
2017-05-17 19:23:47 +00:00
|
|
|
*
|
|
|
|
* @param {Boolean} value %true to enable, %false to disable
|
2017-02-21 10:36:43 +00:00
|
|
|
*/
|
|
|
|
set enable(value) {
|
|
|
|
if (value)
|
|
|
|
this.start();
|
|
|
|
else
|
|
|
|
this.stop();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Returns the current spinner state.
|
2017-05-17 19:23:47 +00:00
|
|
|
*
|
2017-02-21 10:36:43 +00:00
|
|
|
* @return {Boolean} %true if it's enabled, %false otherwise
|
|
|
|
*/
|
|
|
|
get enable() {
|
|
|
|
return this._enable;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Activates the spinner.
|
|
|
|
*/
|
|
|
|
start() {
|
|
|
|
this.spinner.MaterialSpinner.start();
|
|
|
|
this._enable = true;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Deactivates the spinner.
|
|
|
|
*/
|
|
|
|
stop() {
|
|
|
|
this.spinner.MaterialSpinner.stop();
|
|
|
|
this._enable = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Spinner.$inject = ['$element', '$scope'];
|
|
|
|
|
|
|
|
export const component = {
|
|
|
|
template: require('./index.html'),
|
|
|
|
bindings: {
|
|
|
|
enable: '='
|
|
|
|
},
|
|
|
|
controller: Spinner
|
|
|
|
};
|
|
|
|
module.component('vnSpinner', component);
|