diff options
author | Trent Richardson <trentdrichardson@gmail.com> | 2012-03-15 07:44:58 -0700 |
---|---|---|
committer | Trent Richardson <trentdrichardson@gmail.com> | 2012-03-15 07:44:58 -0700 |
commit | 9ddc850cb329e3d783e201d13a6135502c2712b2 (patch) | |
tree | ba67c949628b87e17986937b725a98932214b7ab | |
parent | b7657a91712da82e1f0af6544e61a9765754fd43 (diff) | |
parent | 6c66dbb448fc0f95eb3a6182458bddd8380014bd (diff) | |
download | jQuery-Impromptu-9ddc850cb329e3d783e201d13a6135502c2712b2.zip jQuery-Impromptu-9ddc850cb329e3d783e201d13a6135502c2712b2.tar.gz jQuery-Impromptu-9ddc850cb329e3d783e201d13a6135502c2712b2.tar.bz2 |
Merge pull request #3 from calumbrodie/master
Can pass classes to buttons to assist with styling
-rw-r--r-- | jquery-impromptu.js | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/jquery-impromptu.js b/jquery-impromptu.js index 788f4f4..5d79aa7 100644 --- a/jquery-impromptu.js +++ b/jquery-impromptu.js @@ -59,22 +59,36 @@ var states = "";
$.each(message,function(statename,stateobj){
- stateobj = $.extend({},$.prompt.defaults.state,stateobj);
- message[statename] = stateobj;
-
- var arrow = "";
- if(stateobj.position.arrow !== null)
- arrow = '<div class="'+ $.prompt.options.prefix + 'arrow '+ $.prompt.options.prefix + 'arrow'+ stateobj.position.arrow +'"></div>';
-
- states += '<div id="'+ $.prompt.options.prefix +'_state_'+ statename +'" class="'+ $.prompt.options.prefix + '_state" style="display:none;">'+ arrow +'<div class="'+ $.prompt.options.prefix +'message">' + stateobj.html +'</div><div class="'+ $.prompt.options.prefix +'buttons">';
-
- $.each(stateobj.buttons, function(k, v){
- if(typeof v == 'object')
- states += '<button name="' + $.prompt.options.prefix + '_' + statename + '_button' + v.title.replace(/[^a-z0-9]+/gi,'') + '" id="' + $.prompt.options.prefix + '_' + statename + '_button' + v.title.replace(/[^a-z0-9]+/gi,'') + '" value="' + v.value + '">' + v.title + '</button>';
- else states += '<button name="' + $.prompt.options.prefix + '_' + statename + '_button' + k + '" id="' + $.prompt.options.prefix + '_' + statename + '_button' + k + '" value="' + v + '">' + k + '</button>';
- });
- states += '</div></div>';
- });
+ stateobj = $.extend({},$.prompt.defaults.state,stateobj);
+ message[statename] = stateobj;
+
+ var arrow = "";
+ if(stateobj.position.arrow !== null)
+ arrow = '<div class="'+ $.prompt.options.prefix + 'arrow '+ $.prompt.options.prefix + 'arrow'+ stateobj.position.arrow +'"></div>';
+
+ states += '<div id="'+ $.prompt.options.prefix +'_state_'+ statename +'" class="'+ $.prompt.options.prefix + '_state" style="display:none;">'+ arrow +'<div class="'+ $.prompt.options.prefix +'message">' + stateobj.html +'</div><div class="'+ $.prompt.options.prefix +'buttons">';
+
+ $.each(stateobj.buttons, function(k, v){
+ if(typeof v == 'object'){
+
+ states += '<button ';
+ if(typeof v.classes !== "undefined"){
+ states += 'class="'
+ $.each(v.classes, function(k, v){
+ states += ' ' + v
+ })
+ states += '" ';
+ }
+
+ states += ' name="' + $.prompt.options.prefix + '_' + statename + '_button' + v.title.replace(/[^a-z0-9]+/gi,'') + '" id="' + $.prompt.options.prefix + '_' + statename + '_button' + v.title.replace(/[^a-z0-9]+/gi,'') + '" value="' + v.value + '">' + v.title + '</button>';
+
+ } else {
+ states += '<button name="' + $.prompt.options.prefix + '_' + statename + '_button' + k + '" id="' + $.prompt.options.prefix + '_' + statename + '_button' + k + '" value="' + v + '">' + k + '</button>';
+
+ }
+ });
+ states += '</div></div>';
+ });
//insert the states...
$.prompt.states = message;
|