luci2: implement LuCI2.cbi.ButtonValue widget
[project/luci2/ui.git] / luci2 / htdocs / luci2 / luci2.js
index bbfb6d3..fc3c3fc 100644 (file)
@@ -1320,7 +1320,7 @@ function LuCI2()
 
                        for (var i = 0, color = '#';
                                 i < 3;
-                                color += ('00' + ((hash >> i++ * 8) & 0xFF).tozoneing(16)).slice(-2));
+                                color += ('00' + ((hash >> i++ * 8) & 0xFF).tostring(16)).slice(-2));
 
                        return color;
                },
@@ -3216,6 +3216,7 @@ function LuCI2()
 
                        var state = _luci2.ui._loading || (_luci2.ui._loading = {
                                modal: $('<div />')
+                                       .css('z-index', 2000)
                                        .addClass('modal fade')
                                        .append($('<div />')
                                                .addClass('modal-dialog')
@@ -3268,13 +3269,13 @@ function LuCI2()
                        {
                                state.dialog.modal('hide');
 
-                               return;
+                               return state.dialog;
                        }
 
                        var cnt = state.dialog.children().children().children('div.modal-body');
                        var ftr = state.dialog.children().children().children('div.modal-footer');
 
-                       ftr.empty();
+                       ftr.empty().show();
 
                        if (options.style == 'confirm')
                        {
@@ -3295,10 +3296,21 @@ function LuCI2()
                                        .attr('disabled', true));
                        }
 
+                       if (options.wide)
+                       {
+                               state.dialog.addClass('wide');
+                       }
+                       else
+                       {
+                               state.dialog.removeClass('wide');
+                       }
+
                        state.dialog.find('h4:first').text(title);
                        state.dialog.modal('show');
 
                        cnt.empty().append(content);
+
+                       return state.dialog;
                },
 
                upload: function(title, content, options)
@@ -5903,6 +5915,21 @@ function LuCI2()
                }
        });
 
+       this.cbi.ButtonValue = this.cbi.AbstractValue.extend({
+               widget: function(sid)
+               {
+                       this.options.optional = true;
+
+                       var btn = $('<button />')
+                               .addClass('btn btn-default')
+                               .attr('id', this.id(sid))
+                               .attr('type', 'button')
+                               .text(this.label('text'));
+
+                       return this.validator(sid, btn);
+               }
+       });
+
        this.cbi.NetworkList = this.cbi.AbstractValue.extend({
                load: function(sid)
                {