2018-12-10 18:22:11 +00:00
|
|
|
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
|
|
|
//
|
|
|
|
// This software (Documize Community Edition) is licensed under
|
|
|
|
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
|
|
|
//
|
|
|
|
// You can operate outside the AGPL restrictions by purchasing
|
|
|
|
// Documize Enterprise Edition and obtaining a commercial license
|
|
|
|
// by contacting <sales@documize.com>.
|
|
|
|
//
|
|
|
|
// https://documize.com
|
|
|
|
|
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import Component from '@ember/component';
|
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
tagName: 'button',
|
|
|
|
classNames: [],
|
|
|
|
classNameBindings: ['calcClass'],
|
2018-12-13 13:34:26 +00:00
|
|
|
attributeBindings: ['calcAttrs:data-dismiss', 'submitAttrs:type'],
|
2018-12-10 18:22:11 +00:00
|
|
|
|
|
|
|
label: '',
|
|
|
|
icon: '',
|
|
|
|
color: '',
|
|
|
|
light: false,
|
|
|
|
themed: false,
|
2018-12-11 18:00:08 +00:00
|
|
|
dismiss: false,
|
2018-12-10 18:22:11 +00:00
|
|
|
|
|
|
|
iconClass: '',
|
|
|
|
hasIcon: computed('iconClass', function() {
|
|
|
|
return this.iconClass.trim() != '';
|
|
|
|
}),
|
|
|
|
|
|
|
|
calcClass: computed(function() {
|
|
|
|
// Prepare icon class name
|
2018-12-11 18:00:08 +00:00
|
|
|
this.iconClass = this.icon;
|
2018-12-10 18:22:11 +00:00
|
|
|
|
|
|
|
// Prepare button class name
|
|
|
|
let bc = 'dmz-button';
|
|
|
|
if (this.themed) {
|
|
|
|
bc += '-theme';
|
|
|
|
} else {
|
|
|
|
bc += '-' + this.color;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.light) {
|
|
|
|
bc += '-light';
|
|
|
|
}
|
|
|
|
|
|
|
|
return bc;
|
|
|
|
}),
|
|
|
|
|
2018-12-11 18:00:08 +00:00
|
|
|
calcAttrs: computed(function() {
|
|
|
|
if (this.dismiss) {
|
|
|
|
return 'modal';
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}),
|
|
|
|
|
2018-12-13 13:34:26 +00:00
|
|
|
submitAttrs: computed(function() {
|
|
|
|
return this.submit ? "submit": null;
|
|
|
|
}),
|
|
|
|
|
2018-12-11 18:00:08 +00:00
|
|
|
click(e) {
|
|
|
|
if (is.not.undefined(this.onClick)) {
|
2018-12-18 19:03:34 +00:00
|
|
|
e.preventDefault();
|
2018-12-11 18:00:08 +00:00
|
|
|
this.onClick(e);
|
|
|
|
}
|
2018-12-10 18:22:11 +00:00
|
|
|
}
|
|
|
|
});
|