forked from verdnatura/hedera-web
Fixed duplicated dialog response
This commit is contained in:
parent
54966582b5
commit
8e916d376a
|
@ -1,4 +1,4 @@
|
|||
hedera-web (1.407.13) stable; urgency=low
|
||||
hedera-web (1.407.14) stable; urgency=low
|
||||
|
||||
* Initial Release.
|
||||
|
||||
|
|
103
js/htk/dialog.js
103
js/htk/dialog.js
|
@ -1,10 +1,10 @@
|
|||
|
||||
var Popup = require ('./popup');
|
||||
var Popup = require('./popup');
|
||||
|
||||
/**
|
||||
* Class to show message dialogs with buttons.
|
||||
**/
|
||||
var Dialog = new Class ();
|
||||
var Dialog = new Class();
|
||||
module.exports = Dialog;
|
||||
|
||||
var Button =
|
||||
|
@ -42,13 +42,11 @@ Button.CANCEL_ACCEPT = Button.CANCEL | Button.ACCEPT;
|
|||
Button.ACCEPT_RETRY = Button.ACCEPT | Button.RETRY;
|
||||
Button.YES_NO = Button.YES | Button.NO;
|
||||
|
||||
Dialog.extend
|
||||
({
|
||||
Dialog.extend({
|
||||
Button: Button
|
||||
});
|
||||
|
||||
Dialog.implement
|
||||
({
|
||||
Dialog.implement({
|
||||
Extends: Popup
|
||||
,Tag: 'htk-dialog'
|
||||
,Properties:
|
||||
|
@ -59,12 +57,10 @@ Dialog.implement
|
|||
message:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
{
|
||||
,set: function(x) {
|
||||
this._message = x;
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
,get: function() {
|
||||
return this._message;
|
||||
}
|
||||
}
|
||||
|
@ -74,12 +70,10 @@ Dialog.implement
|
|||
,icon:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
{
|
||||
,set: function(x) {
|
||||
this._icon = x;
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
,get: function() {
|
||||
return this._icon;
|
||||
}
|
||||
}
|
||||
|
@ -89,12 +83,10 @@ Dialog.implement
|
|||
,buttons:
|
||||
{
|
||||
enumType: Button
|
||||
,set: function (x)
|
||||
{
|
||||
,set: function(x) {
|
||||
this._buttons = x;
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
,get: function() {
|
||||
return this._buttons;
|
||||
}
|
||||
}
|
||||
|
@ -104,81 +96,66 @@ Dialog.implement
|
|||
,_icon: 'info'
|
||||
,_buttons: Button.ACCEPT
|
||||
|
||||
,initialize: function (props)
|
||||
{
|
||||
this.parent (props);
|
||||
this.on ('closed', this._onClosed, this);
|
||||
}
|
||||
|
||||
,open: function ()
|
||||
{
|
||||
this.parent ();
|
||||
,open: function() {
|
||||
this.parent();
|
||||
|
||||
// Dialog body
|
||||
|
||||
var root = this.createElement ('div');
|
||||
var root = this.createElement('div');
|
||||
root.className = 'htk-dialog';
|
||||
|
||||
var body = this.createElement ('div');
|
||||
root.appendChild (body);
|
||||
var body = this.createElement('div');
|
||||
root.appendChild(body);
|
||||
|
||||
if (this._icon)
|
||||
{
|
||||
var icon = new Htk.Icon ({
|
||||
if (this._icon) {
|
||||
var icon = new Htk.Icon({
|
||||
doc: this.doc,
|
||||
icon: this._icon
|
||||
});
|
||||
body.appendChild (icon.node);
|
||||
body.appendChild(icon.node);
|
||||
}
|
||||
|
||||
var p = this.createElement ('p');
|
||||
body.appendChild (p);
|
||||
var p = this.createElement('p');
|
||||
body.appendChild(p);
|
||||
|
||||
if (this._message)
|
||||
p.appendChild (this.createTextNode (this._message));
|
||||
p.appendChild(this.createTextNode(this._message));
|
||||
|
||||
var clear = this.createElement ('div');
|
||||
var clear = this.createElement('div');
|
||||
clear.style.clear = 'both';
|
||||
body.appendChild (clear);
|
||||
body.appendChild(clear);
|
||||
|
||||
// Button bar
|
||||
|
||||
var buttonBar = this._buttonBar = this.createElement ('div');
|
||||
var buttonBar = this._buttonBar = this.createElement('div');
|
||||
buttonBar.className = 'button-bar';
|
||||
root.appendChild (buttonBar);
|
||||
root.appendChild(buttonBar);
|
||||
|
||||
var i = labels.length;
|
||||
|
||||
while (i--)
|
||||
if (this._buttons & labels[i].response)
|
||||
this.createButton (_(labels[i].label), labels[i].response);
|
||||
this.createButton(_(labels[i].label), labels[i].response);
|
||||
|
||||
var clear = this.createElement ('div');
|
||||
var clear = this.createElement('div');
|
||||
clear.style.clear = 'both';
|
||||
root.appendChild (clear);
|
||||
root.appendChild(clear);
|
||||
|
||||
this.childNode = root;
|
||||
}
|
||||
|
||||
,hide(response) {
|
||||
if (!this._isOpen) return;
|
||||
this.parent();
|
||||
this.signalEmit('response', response);
|
||||
}
|
||||
|
||||
,createButton: function (label, response)
|
||||
{
|
||||
var button = this.createElement ('button');
|
||||
,createButton: function(label, response) {
|
||||
var button = this.createElement('button');
|
||||
button.className = 'thin';
|
||||
button.appendChild (this.createTextNode (label));
|
||||
button.addEventListener ('click',
|
||||
this._onButtonClick.bind (this, response));
|
||||
this._buttonBar.appendChild (button);
|
||||
}
|
||||
|
||||
,_onButtonClick: function (response)
|
||||
{
|
||||
this.hide ();
|
||||
this.signalEmit ('response', response);
|
||||
}
|
||||
|
||||
,_onClosed: function ()
|
||||
{
|
||||
this.signalEmit ('response', null);
|
||||
button.appendChild(this.createTextNode(label));
|
||||
button.addEventListener('click',
|
||||
this.hide.bind(this, response));
|
||||
this._buttonBar.appendChild(button);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "hedera-web",
|
||||
"version": "1.407.13",
|
||||
"version": "1.407.14",
|
||||
"description": "Verdnatura web page",
|
||||
"license": "GPL-3.0",
|
||||
"repository": {
|
||||
|
|
Loading…
Reference in New Issue