diff options
-rw-r--r-- | index.html | 3 | ||||
-rw-r--r-- | jquery-impromptu.js | 6 |
2 files changed, 7 insertions, 2 deletions
@@ -150,6 +150,9 @@ <dt>focus</dt> <dd>Index of the button to focus or selector to element to focus. <em>Default: 0</em></dd> + + <dt>defaultButton</dt> + <dd>Index of the button to focus. Similar to the focus option, but if focus is a selector this can still style the button as the default. <em>Default: 0</em></dd> <dt>submit</dt> <dd>A function to be called when the prompt is submitted. <em>Default: function(event, value, message, formVals){}</em> Return false or event.preventDefault() to keep the prompt open. Event object also has properties event.state and event.stateName.</dd> diff --git a/jquery-impromptu.js b/jquery-impromptu.js index 2270c31..4f5b59b 100644 --- a/jquery-impromptu.js +++ b/jquery-impromptu.js @@ -233,6 +233,7 @@ promptspeed: 'fast',
show: 'fadeIn',
focus: 0,
+ defaultButton: 0,
useiframe: false,
top: '15%',
position: {
@@ -253,6 +254,7 @@ Ok: true
},
focus: 0,
+ defaultButton: 0,
position: {
container: null,
x: null,
@@ -423,7 +425,7 @@ title = "",
opts = $.prompt.options,
$jqistates = $('.'+ $.prompt.currentPrefix +'states'),
- k,v,i=0;
+ defbtn,k,v,i=0;
stateobj = $.extend({},$.prompt.defaults.state, {name:statename}, stateobj);
@@ -438,7 +440,7 @@ for(k in stateobj.buttons){
v = stateobj.buttons[k],
- defbtn = stateobj.focus === i? ($.prompt.currentPrefix+'defaultbutton '+ opts.classes.defaultButton):'';
+ defbtn = stateobj.focus === i || stateobj.defaultButton === i ? ($.prompt.currentPrefix + 'defaultbutton ' + opts.classes.defaultButton) : '';
if(typeof v == 'object'){
state += '<button class="'+ opts.classes.button +' '+ defbtn;
|