1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2025-01-18 07:52:21 +01:00

Contacts: Updates to dialog handling.

This commit is contained in:
Thomas Tanghus 2013-04-01 15:12:53 +02:00
parent 724f12b230
commit 10c1a9ad8a
3 changed files with 50 additions and 26 deletions

View File

@ -5,6 +5,7 @@
z-index: 200; z-index: 200;
} }
.oc-dialog-title { .oc-dialog-title {
font-weight: bold;
} }
.oc-dialog-content { .oc-dialog-content {
} }
@ -14,6 +15,5 @@
float: right; float: right;
position: relative; position: relative;
bottom: 0; bottom: 0;
height: 2em;
display: block; display: block;
} }

View File

@ -1331,13 +1331,20 @@ OC.Contacts = OC.Contacts || {
this.$addGroupTmpl = $('#addGroupTemplate'); this.$addGroupTmpl = $('#addGroupTemplate');
} }
var $dlg = this.$addGroupTmpl.octemplate(); var $dlg = this.$addGroupTmpl.octemplate();
$('#add_group_dialog').html($dlg).dialog({ $('#add_group_dialog').html($dlg).ocdialog({
modal: true, modal: true,
closeOnEscape: true, closeOnEscape: true,
title: t('contacts', 'Add group'), title: t('contacts', 'Add group'),
height: 'auto', width: 'auto', height: 'auto', width: 'auto',
buttons: { buttons: [
'Ok':function() { {
text: t('contacts', 'OK'),
click:function() {
console.log(this, $(this).find('input'));
var name = $(this).find('input').val();
if(name.trim() === '') {
return false;
}
self.groups.addGroup( self.groups.addGroup(
{name:$dlg.find('input:text').val()}, {name:$dlg.find('input:text').val()},
function(response) { function(response) {
@ -1349,15 +1356,20 @@ OC.Contacts = OC.Contacts || {
} }
} }
}); });
$(this).dialog('close'); console.log('this?', this);
}, $(this).ocdialog('close');
'Cancel':function() {
$(this).dialog('close');
return false;
} }
}, },
{
text: t('contacts', 'Cancel'),
click:function(dlg) {
$(this).ocdialog('close');
return false;
}
}
],
close: function(event, ui) { close: function(event, ui) {
$(this).dialog('destroy').remove(); $(this).ocdialog('destroy').remove();
$('#add_group_dialog').remove(); $('#add_group_dialog').remove();
}, },
open: function(event, ui) { open: function(event, ui) {

View File

@ -5,8 +5,11 @@
height: 'auto' height: 'auto'
}, },
_create: function() { _create: function() {
console.log('ocdialog._init');
var self = this; var self = this;
console.log('test name', this);
this.$element = $('<div class="oc-dialog" />').insertBefore(this.element); this.$element = $('<div class="oc-dialog" />').insertBefore(this.element);
this.$element.append(this.element.detach()); this.$element.append(this.element.detach());
this.$content = this.element.wrap('<div class="oc-dialog-content" />').parent(); this.$content = this.element.wrap('<div class="oc-dialog-content" />').parent();
@ -14,17 +17,22 @@
this.$element.css('display', 'inline-block'); this.$element.css('display', 'inline-block');
$(window).resize(function() { $(window).resize(function() {
var pos = self.$element.parent().position(); self.parent = self.$element.parent().length > 0 ? self.$element.parent() : $('body');
console.log('parent', self.parent.length);
var pos = self.parent.position();
self.$element.css({ self.$element.css({
position:'absolute', position:'absolute',
left: pos.left + (self.$element.parent().width() - self.$element.outerWidth())/2, left: pos.left + (self.parent.width() - self.$element.outerWidth())/2,
top: pos.top + (self.$element.parent().height() - self.$element.outerHeight())/2 top: pos.top + (self.parent.height() - self.$element.outerHeight())/2
}); });
}); });
this._setOptions(this.options); this._setOptions(this.options);
$(window).trigger('resize'); $(window).trigger('resize');
}, },
_init: function() {
console.log('ocdialog._init');
},
_setOption: function(key, value) { _setOption: function(key, value) {
console.log('_setOption', key, value); console.log('_setOption', key, value);
switch(key) { switch(key) {
@ -47,9 +55,13 @@
} }
var self = this; var self = this;
$.each(value, function(idx, val) { $.each(value, function(idx, val) {
var $button = $('<button>' + val.text+ '</button>'); console.log('button text', val.text);
var $button = $('<button>' + val.text + '</button>');
self.$buttonrow.append($button); self.$buttonrow.append($button);
$button.click(val.click); $button.click(function() {
val.click.apply(self.element[0], arguments);
//val.click(new $.Event(self));
});
}); });
this._setSizes(); this._setSizes();
break; break;
@ -87,7 +99,7 @@
}, },
close: function() { close: function() {
console.log('close 1'); console.log('close 1');
this._trigger('close'); this._trigger('close', this);
this.$element.hide(); this.$element.hide();
}, },
destroy: function() { destroy: function() {