summaryrefslogtreecommitdiffstats
path: root/jquery-impromptu.js
diff options
context:
space:
mode:
authorCalum Brodie <calumbrodie@googlemail.com>2012-03-14 07:32:53 +0000
committerCalum Brodie <calumbrodie@googlemail.com>2012-03-14 07:32:53 +0000
commit2be998f660cfc2040af549a83e678d7bc395e66c (patch)
treed66da33bf17ed074cea14ff61ae21a12fa54c293 /jquery-impromptu.js
parentb7657a91712da82e1f0af6544e61a9765754fd43 (diff)
downloadjQuery-Impromptu-2be998f660cfc2040af549a83e678d7bc395e66c.zip
jQuery-Impromptu-2be998f660cfc2040af549a83e678d7bc395e66c.tar.gz
jQuery-Impromptu-2be998f660cfc2040af549a83e678d7bc395e66c.tar.bz2
Added the ability to pass an array of 'classes' alongside a button to be used to style the button. This is helpful for using improptu within another css framework (like so http://twitter.github.com/bootstrap/components.html) and having everything themed consistently
Diffstat (limited to 'jquery-impromptu.js')
-rw-r--r--jquery-impromptu.js46
1 files changed, 30 insertions, 16 deletions
diff --git a/jquery-impromptu.js b/jquery-impromptu.js
index 788f4f4..33a8936 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;