Skip to content
Snippets Groups Projects
Commit 71fe5d67 authored by Vincent Petry's avatar Vincent Petry
Browse files

Fixed dialogs styling, reversed buttons

Default dialog button is now on the right, other one on the left.
parent 268af903
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,17 @@ ...@@ -31,6 +31,17 @@
margin-top: 10px; margin-top: 10px;
width: 100%; 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 { .oc-dialog-close {
position:absolute; position:absolute;
......
...@@ -111,6 +111,13 @@ ...@@ -111,6 +111,13 @@
var $buttonrow = $('<div class="oc-dialog-buttonrow" />'); var $buttonrow = $('<div class="oc-dialog-buttonrow" />');
this.$buttonrow = $buttonrow.appendTo(this.$dialog); 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) { $.each(value, function(idx, val) {
var $button = $('<button>').text(val.text); var $button = $('<button>').text(val.text);
if (val.classes) { if (val.classes) {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* *
*/ */
/* global OC, t, alert, $ */ /* global alert */
/** /**
* this class to ease the usage of jquery dialogs * this class to ease the usage of jquery dialogs
...@@ -66,7 +66,7 @@ var OCdialogs = { ...@@ -66,7 +66,7 @@ var OCdialogs = {
* @param modal make the dialog modal * @param modal make the dialog modal
*/ */
confirm:function(text, title, callback, modal) { confirm:function(text, title, callback, modal) {
this.message( return this.message(
text, text,
title, title,
'notice', 'notice',
...@@ -86,7 +86,7 @@ var OCdialogs = { ...@@ -86,7 +86,7 @@ var OCdialogs = {
* @param password whether the input should be a password input * @param password whether the input should be a password input
*/ */
prompt: function (text, title, callback, modal, name, password) { 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 dialogName = 'oc-dialog-' + OCdialogs.dialogsCounter + '-content';
var dialogId = '#' + dialogName; var dialogId = '#' + dialogName;
var $dlg = $tmpl.octemplate({ var $dlg = $tmpl.octemplate({
...@@ -104,25 +104,23 @@ var OCdialogs = { ...@@ -104,25 +104,23 @@ var OCdialogs = {
modal = false; modal = false;
} }
$('body').append($dlg); $('body').append($dlg);
var buttonlist = [ var buttonlist = [{
{ text : t('core', 'No'),
text : t('core', 'Yes'),
click: function () { click: function () {
if (callback !== undefined) { if (callback !== undefined) {
callback(true, input.val()); callback(false, input.val());
} }
$(dialogId).ocdialog('close'); $(dialogId).ocdialog('close');
}, }
defaultButton: true }, {
}, text : t('core', 'Yes'),
{
text : t('core', 'No'),
click : function () { click : function () {
if (callback !== undefined) { if (callback !== undefined) {
callback(false, input.val()); callback(true, input.val());
} }
$(dialogId).ocdialog('close'); $(dialogId).ocdialog('close');
} },
defaultButton: true
} }
]; ];
...@@ -237,7 +235,7 @@ var OCdialogs = { ...@@ -237,7 +235,7 @@ var OCdialogs = {
* You better use a wrapper instead ... * You better use a wrapper instead ...
*/ */
message:function(content, title, dialogType, buttons, callback, modal) { 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 dialogName = 'oc-dialog-' + OCdialogs.dialogsCounter + '-content';
var dialogId = '#' + dialogName; var dialogId = '#' + dialogName;
var $dlg = $tmpl.octemplate({ var $dlg = $tmpl.octemplate({
...@@ -254,23 +252,23 @@ var OCdialogs = { ...@@ -254,23 +252,23 @@ var OCdialogs = {
switch (buttons) { switch (buttons) {
case OCdialogs.YES_NO_BUTTONS: case OCdialogs.YES_NO_BUTTONS:
buttonlist = [{ buttonlist = [{
text: t('core', 'Yes'), text: t('core', 'No'),
click: function(){ click: function(){
if (callback !== undefined) { if (callback !== undefined) {
callback(true); callback(false);
} }
$(dialogId).ocdialog('close'); $(dialogId).ocdialog('close');
}, }
defaultButton: true
}, },
{ {
text: t('core', 'No'), text: t('core', 'Yes'),
click: function(){ click: function(){
if (callback !== undefined) { if (callback !== undefined) {
callback(false); callback(true);
} }
$(dialogId).ocdialog('close'); $(dialogId).ocdialog('close');
} },
defaultButton: true
}]; }];
break; break;
case OCdialogs.OK_BUTTON: case OCdialogs.OK_BUTTON:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment