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;
|
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;
|
||||||
}
|
}
|
||||||
|
50
js/app.js
50
js/app.js
@ -1331,33 +1331,45 @@ 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() {
|
{
|
||||||
self.groups.addGroup(
|
text: t('contacts', 'OK'),
|
||||||
{name:$dlg.find('input:text').val()},
|
click:function() {
|
||||||
function(response) {
|
console.log(this, $(this).find('input'));
|
||||||
if(typeof cb === 'function') {
|
var name = $(this).find('input').val();
|
||||||
cb(response);
|
if(name.trim() === '') {
|
||||||
} else {
|
return false;
|
||||||
if(response.error) {
|
}
|
||||||
OC.notify({message: response.message});
|
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});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
console.log('this?', this);
|
||||||
$(this).dialog('close');
|
$(this).ocdialog('close');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
'Cancel':function() {
|
{
|
||||||
$(this).dialog('close');
|
text: t('contacts', 'Cancel'),
|
||||||
return false;
|
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) {
|
||||||
|
@ -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() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user