]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fixed dialogs styling, reversed buttons
authorVincent Petry <pvince81@owncloud.com>
Thu, 3 Jul 2014 12:38:40 +0000 (14:38 +0200)
committerVincent Petry <pvince81@owncloud.com>
Mon, 7 Jul 2014 13:56:42 +0000 (15:56 +0200)
Default dialog button is now on the right, other one on the left.

core/css/jquery.ocdialog.css
core/js/jquery.ocdialog.js
core/js/oc-dialogs.js

index a1221137bc447da3394c3140d763f3ea35574dd7..93930bf435f9f46dac04a970b7988ce837ff146c 100644 (file)
        margin-top: 10px;
        width: 100%;
 }
+/* align primary button to right, other buttons to left */
+.oc-dialog-buttonrow.twobuttons button:nth-child(1) {
+       float: left;
+}
+.oc-dialog-buttonrow.twobuttons button:nth-child(2) {
+       float: right;
+}
+
+.oc-dialog-buttonrow.onebutton button {
+       float: right;
+}
 
 .oc-dialog-close {
        position:absolute;
index af32591ce5246682a9a394282a2ce939f65b8ab5..e48e3e8df6ab8cafbb88b8afb4225cba68dba093 100644 (file)
                                                var $buttonrow = $('<div class="oc-dialog-buttonrow" />');
                                                this.$buttonrow = $buttonrow.appendTo(this.$dialog);
                                        }
+                                       if (value.length === 1) {
+                                               this.$buttonrow.addClass('onebutton');
+                                       } else if (value.length === 2) {
+                                               this.$buttonrow.addClass('twobuttons');
+                                       } else if (value.length === 3) {
+                                               this.$buttonrow.addClass('threebuttons');
+                                       }
                                        $.each(value, function(idx, val) {
                                                var $button = $('<button>').text(val.text);
                                                if (val.classes) {
index a76f9170dc8b345a5d02b71a091a1f492bb0b668..9920cc58e236eb3e4005cbc479f14cd40b5e5406 100644 (file)
@@ -19,7 +19,7 @@
  *
  */
 
-/* global OC, t, alert, $ */
+/* global alert */
 
 /**
  * this class to ease the usage of jquery dialogs
@@ -66,7 +66,7 @@ var OCdialogs = {
        * @param modal make the dialog modal
        */
        confirm:function(text, title, callback, modal) {
-               this.message(
+               return this.message(
                        text,
                        title,
                        'notice',
@@ -86,7 +86,7 @@ var OCdialogs = {
         * @param password whether the input should be a password input
         */
        prompt: function (text, title, callback, modal, name, password) {
-               $.when(this._getMessageTemplate()).then(function ($tmpl) {
+               return $.when(this._getMessageTemplate()).then(function ($tmpl) {
                        var dialogName = 'oc-dialog-' + OCdialogs.dialogsCounter + '-content';
                        var dialogId = '#' + dialogName;
                        var $dlg = $tmpl.octemplate({
@@ -104,8 +104,15 @@ var OCdialogs = {
                                modal = false;
                        }
                        $('body').append($dlg);
-                       var buttonlist = [
-                               {
+                       var buttonlist = [{
+                                       text : t('core', 'No'),
+                                       click: function () {
+                                               if (callback !== undefined) {
+                                                       callback(false, input.val());
+                                               }
+                                               $(dialogId).ocdialog('close');
+                                       }
+                               }, {
                                        text         : t('core', 'Yes'),
                                        click        : function () {
                                                if (callback !== undefined) {
@@ -114,15 +121,6 @@ var OCdialogs = {
                                                $(dialogId).ocdialog('close');
                                        },
                                        defaultButton: true
-                               },
-                               {
-                                       text : t('core', 'No'),
-                                       click: function () {
-                                               if (callback !== undefined) {
-                                                       callback(false, input.val());
-                                               }
-                                               $(dialogId).ocdialog('close');
-                                       }
                                }
                        ];
 
@@ -237,7 +235,7 @@ var OCdialogs = {
         * You better use a wrapper instead ...
        */
        message:function(content, title, dialogType, buttons, callback, modal) {
-               $.when(this._getMessageTemplate()).then(function($tmpl) {
+               return $.when(this._getMessageTemplate()).then(function($tmpl) {
                        var dialogName = 'oc-dialog-' + OCdialogs.dialogsCounter + '-content';
                        var dialogId = '#' + dialogName;
                        var $dlg = $tmpl.octemplate({
@@ -254,23 +252,23 @@ var OCdialogs = {
                        switch (buttons) {
                        case OCdialogs.YES_NO_BUTTONS:
                                buttonlist = [{
-                                       text: t('core', 'Yes'),
+                                       text: t('core', 'No'),
                                        click: function(){
                                                if (callback !== undefined) {
-                                                       callback(true);
+                                                       callback(false);
                                                }
                                                $(dialogId).ocdialog('close');
-                                       },
-                                       defaultButton: true
+                                       }
                                },
                                {
-                                       text: t('core', 'No'),
+                                       text: t('core', 'Yes'),
                                        click: function(){
                                                if (callback !== undefined) {
-                                                       callback(false);
+                                                       callback(true);
                                                }
                                                $(dialogId).ocdialog('close');
-                                       }
+                                       },
+                                       defaultButton: true
                                }];
                                break;
                        case OCdialogs.OK_BUTTON: