salix/client/core/src/icon-menu/icon-menu.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

import {module} from '../module';
export default class IconMenu {
constructor($element, $http, $timeout) {
this.$element = $element;
this.$http = $http;
this.$timeout = $timeout;
this._showDropDown = false;
}
get showDropDown() {
return this._showDropDown;
}
set showDropDown(value) {
this._showDropDown = value;
}
getItems() {
this.$http.get(this.url).then(
json => {
this.items = json.data;
}
);
}
$onInit() {
if (!this.items && this.url) {
this.getItems();
}
this.$element.bind('mouseover', () => {
this.$timeout(() => {
this.showDropDown = true;
});
});
this.$element.bind('mouseout', () => {
this.$timeout(() => {
this.showDropDown = false;
});
});
}
}
IconMenu.$inject = ['$element', '$http', '$timeout'];
module.component('vnIconMenu', {
template: require('./icon-menu.html'),
bindings: {
url: '@?',
items: '=?',
icon: '@',
selected: '='
},
controller: IconMenu,
controllerAs: 'im'
});