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:
parent
724f12b230
commit
10c1a9ad8a
@ -5,6 +5,7 @@
|
||||
z-index: 200;
|
||||
}
|
||||
.oc-dialog-title {
|
||||
font-weight: bold;
|
||||
}
|
||||
.oc-dialog-content {
|
||||
}
|
||||
@ -14,6 +15,5 @@
|
||||
float: right;
|
||||
position: relative;
|
||||
bottom: 0;
|
||||
height: 2em;
|
||||
display: block;
|
||||
}
|
||||
|
50
js/app.js
50
js/app.js
@ -1331,33 +1331,45 @@ OC.Contacts = OC.Contacts || {
|
||||
this.$addGroupTmpl = $('#addGroupTemplate');
|
||||
}
|
||||
var $dlg = this.$addGroupTmpl.octemplate();
|
||||
$('#add_group_dialog').html($dlg).dialog({
|
||||
$('#add_group_dialog').html($dlg).ocdialog({
|
||||
modal: true,
|
||||
closeOnEscape: true,
|
||||
title: t('contacts', 'Add group'),
|
||||
height: 'auto', width: 'auto',
|
||||
buttons: {
|
||||
'Ok':function() {
|
||||
self.groups.addGroup(
|
||||
{name:$dlg.find('input:text').val()},
|
||||
function(response) {
|
||||
if(typeof cb === 'function') {
|
||||
cb(response);
|
||||
} else {
|
||||
if(response.error) {
|
||||
OC.notify({message: response.message});
|
||||
buttons: [
|
||||
{
|
||||
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(
|
||||
{name:$dlg.find('input:text').val()},
|
||||
function(response) {
|
||||
if(typeof cb === 'function') {
|
||||
cb(response);
|
||||
} else {
|
||||
if(response.error) {
|
||||
OC.notify({message: response.message});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$(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) {
|
||||
$(this).dialog('destroy').remove();
|
||||
$(this).ocdialog('destroy').remove();
|
||||
$('#add_group_dialog').remove();
|
||||
},
|
||||
open: function(event, ui) {
|
||||
|
@ -5,8 +5,11 @@
|
||||
height: 'auto'
|
||||
},
|
||||
_create: function() {
|
||||
console.log('ocdialog._init');
|
||||
var self = this;
|
||||
|
||||
console.log('test name', this);
|
||||
|
||||
this.$element = $('<div class="oc-dialog" />').insertBefore(this.element);
|
||||
this.$element.append(this.element.detach());
|
||||
this.$content = this.element.wrap('<div class="oc-dialog-content" />').parent();
|
||||
@ -14,17 +17,22 @@
|
||||
this.$element.css('display', 'inline-block');
|
||||
|
||||
$(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({
|
||||
position:'absolute',
|
||||
left: pos.left + (self.$element.parent().width() - self.$element.outerWidth())/2,
|
||||
top: pos.top + (self.$element.parent().height() - self.$element.outerHeight())/2
|
||||
left: pos.left + (self.parent.width() - self.$element.outerWidth())/2,
|
||||
top: pos.top + (self.parent.height() - self.$element.outerHeight())/2
|
||||
});
|
||||
});
|
||||
|
||||
this._setOptions(this.options);
|
||||
$(window).trigger('resize');
|
||||
},
|
||||
_init: function() {
|
||||
console.log('ocdialog._init');
|
||||
},
|
||||
_setOption: function(key, value) {
|
||||
console.log('_setOption', key, value);
|
||||
switch(key) {
|
||||
@ -47,9 +55,13 @@
|
||||
}
|
||||
var self = this;
|
||||
$.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);
|
||||
$button.click(val.click);
|
||||
$button.click(function() {
|
||||
val.click.apply(self.element[0], arguments);
|
||||
//val.click(new $.Event(self));
|
||||
});
|
||||
});
|
||||
this._setSizes();
|
||||
break;
|
||||
@ -87,7 +99,7 @@
|
||||
},
|
||||
close: function() {
|
||||
console.log('close 1');
|
||||
this._trigger('close');
|
||||
this._trigger('close', this);
|
||||
this.$element.hide();
|
||||
},
|
||||
destroy: function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user