Skip to content

Commit

Permalink
added button properties, hide and disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
craftpip committed May 21, 2017
1 parent 7594d5f commit 74e756d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
16 changes: 12 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,8 @@ <h4 id="defining-buttons">
text: 'Hey there!',
btnClass: 'btn-blue',
keys: ['enter', 'a'],
hide: false, // initially not hidden
disabled: false, // initially not disabled
action: function(){
// button action.
}
Expand Down Expand Up @@ -1455,7 +1457,7 @@ <h4 id="button_keys">Button keys</h4>
'Press &lt;span style="font-size: 20px;"&gt;Y&lt;/span&gt; to proceed.',
buttons: {
yes: {
btnClass: 'hide', // hide is a bootstrap class to hide elements
hide: true, // hide the button using CSS
keys: ['y'],
action: function () {
$.alert('Critical action &lt;strong&gt;was performed&lt;/strong&gt;.');
Expand Down Expand Up @@ -1506,7 +1508,7 @@ <h4 id="button_keys">Button keys</h4>
'Press <span style="font-size: 20px;">Y</span> to proceed.',
buttons: {
yes: {
btnClass: 'hide', // hide is a bootstrap class to hide elements
hide: true,
keys: ['y'],
action: function () {
$.alert('Critical action <strong>was performed</strong>.');
Expand Down Expand Up @@ -1549,8 +1551,11 @@ <h4 id="button-functions">Button functions</h4>
}
},
reset: function () {
this.buttons.buttonB.show();
this.buttons.buttonA.enable();
this.buttons.buttonB.setText('button b');
this.buttons.buttonB.setText('button B!!');
// this.buttons.buttonA.hide();
// this.buttons.buttonA.show();
return false;
}
}
Expand Down Expand Up @@ -1670,8 +1675,11 @@ <h4 id="button-functions">Button functions</h4>
}
},
reset: function () {
this.buttons.buttonB.show();
this.buttons.buttonA.enable();
this.buttons.buttonB.setText('button a');
this.buttons.buttonB.setText('button B!!');
// this.buttons.buttonA.hide();
// this.buttons.buttonA.show();
return false;
}
}
Expand Down
22 changes: 14 additions & 8 deletions js/jquery-confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,14 +627,20 @@ var jconfirm, Jconfirm;
that.buttons[key].keys[i] = a.toLowerCase();
});

var button_element = $('<button type="button" class="btn ' + that.buttons[key].btnClass + '">' + that.buttons[key].text + '</button>').click(function (e) {
e.preventDefault();
var res = that.buttons[key].action.apply(that);
that.onAction(key);
that._stopCountDown();
if (typeof res === 'undefined' || res)
that.close();
});
var button_element = $('<button type="button" class="btn"></button>')
.html(that.buttons[key].text)
.addClass(that.buttons[key].btnClass)
.prop('disabled', !!button.disabled)
.css('display', (!!button.hide) ? 'none' : '')
.click(function (e) {
e.preventDefault();
var res = that.buttons[key].action.apply(that);
that.onAction(key);
that._stopCountDown();
if (typeof res === 'undefined' || res)
that.close();
});

that.buttons[key].el = button_element;
that.buttons[key].setText = function (text) {
button_element.html(text);
Expand Down

0 comments on commit 74e756d

Please sign in to comment.