Skip to content

Commit

Permalink
Merge pull request fabien-d#98 from quasipickle/master
Browse files Browse the repository at this point in the history
Same changes as previous PR
  • Loading branch information
fabien-d committed Jan 15, 2013
2 parents 6615290 + ac0cd44 commit 73c24c7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
5 changes: 5 additions & 0 deletions Contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ Credit where credit is due
**Stuart Keith**
* GitHub: [stuartkeith](http://github.com/stuartkeith)

***

**Dylan Anderson**
* GitHub: [quasipickle](http://github.com/quasipickle)

## Documentation Contributors

**Kristoffer Berdal**
Expand Down
13 changes: 11 additions & 2 deletions lib/alertify.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
isopen = false,
keys = { ENTER: 13, ESC: 27, SPACE: 32 },
queue = [],
$, btnCancel, btnOK, btnReset, elCallee, elCover, elDialog, elLog, form, input, getTransitionEvent;
$, btnCancel, btnOK, btnReset, btnFocus, elCallee, elCover, elDialog, elLog, form, input, getTransitionEvent;

/**
* Markup pieces
Expand Down Expand Up @@ -98,6 +98,12 @@
*/
buttonReverse : false,

/**
* Which button should be focused by default
* @type {String} 'ok' (default), 'cancel', or 'none'
*/
buttonFocus : 'ok',

/**
* Set the transition event on load
* @type {[type]}
Expand Down Expand Up @@ -227,6 +233,8 @@

html += "<div class=\"alertify-dialog\">";

if (_alertify.buttonFocus === "none") html += "<a href=\"#\" id=\"alertify-noneFocus\" class=\"alertify-hidden\"></a>";

if (type === "prompt") html += "<form id=\"alertify-form\">";

html += "<article class=\"alertify-inner\">";
Expand Down Expand Up @@ -514,7 +522,7 @@
input.focus();
input.select();
}
else btnOK.focus();
else btnFocus.focus();
},

/**
Expand Down Expand Up @@ -546,6 +554,7 @@
btnReset = $("alertify-resetFocus");
btnOK = $("alertify-ok") || undefined;
btnCancel = $("alertify-cancel") || undefined;
btnFocus = (_alertify.buttonFocus === "cancel") ? btnCancel : ((_alertify.buttonFocus === "none") ? $('alertify-noneFocus') : btnOK),
input = $("alertify-text") || undefined;
form = $("alertify-form") || undefined;
// add placeholder value to the input field
Expand Down
2 changes: 1 addition & 1 deletion lib/alertify.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions src/alertify.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
isopen = false,
keys = { ENTER: 13, ESC: 27, SPACE: 32 },
queue = [],
$, btnCancel, btnOK, btnReset, elCallee, elCover, elDialog, elLog, form, input, getTransitionEvent;
$, btnCancel, btnOK, btnReset, btnFocus, elCallee, elCover, elDialog, elLog, form, input, getTransitionEvent;

/**
* Markup pieces
Expand All @@ -21,7 +21,7 @@
dialogs = {
buttons : {
holder : "<nav class=\"alertify-buttons\">{{buttons}}</nav>",
submit : "<button type=\"submit\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\" />{{ok}}</button>",
submit : "<button type=\"submit\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\">{{ok}}</button>",
ok : "<a href=\"#\" class=\"alertify-button alertify-button-ok\" id=\"alertify-ok\">{{ok}}</a>",
cancel : "<a href=\"#\" class=\"alertify-button alertify-button-cancel\" id=\"alertify-cancel\">{{cancel}}</a>"
},
Expand Down Expand Up @@ -86,6 +86,12 @@
*/
buttonReverse : false,

/**
* Which button should be focused by default
* @type {String} "ok" (default), "cancel", or "none"
*/
buttonFocus : "ok",

/**
* Set the transition event on load
* @type {[type]}
Expand Down Expand Up @@ -215,6 +221,8 @@

html += "<div class=\"alertify-dialog\">";

if (_alertify.buttonFocus === "none") html += "<a href=\"#\" id=\"alertify-noneFocus\" class=\"alertify-hidden\"></a>";

if (type === "prompt") html += "<form id=\"alertify-form\">";

html += "<article class=\"alertify-inner\">";
Expand Down Expand Up @@ -502,7 +510,7 @@
input.focus();
input.select();
}
else btnOK.focus();
else btnFocus.focus();
},

/**
Expand Down Expand Up @@ -534,6 +542,7 @@
btnReset = $("alertify-resetFocus");
btnOK = $("alertify-ok") || undefined;
btnCancel = $("alertify-cancel") || undefined;
btnFocus = (_alertify.buttonFocus === "cancel") ? btnCancel : ((_alertify.buttonFocus === "none") ? $("alertify-noneFocus") : btnOK),
input = $("alertify-text") || undefined;
form = $("alertify-form") || undefined;
// add placeholder value to the input field
Expand Down

0 comments on commit 73c24c7

Please sign in to comment.