diff --git a/css/jquery.ocdialog.css b/css/jquery.ocdialog.css index 4433cbc7..acd3cadc 100644 --- a/css/jquery.ocdialog.css +++ b/css/jquery.ocdialog.css @@ -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; } diff --git a/js/app.js b/js/app.js index d5952c24..1e43768d 100644 --- a/js/app.js +++ b/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) { diff --git a/js/jquery.ocdialog.js b/js/jquery.ocdialog.js index b8f32d1c..5bbd3dab 100644 --- a/js/jquery.ocdialog.js +++ b/js/jquery.ocdialog.js @@ -5,8 +5,11 @@ height: 'auto' }, _create: function() { + console.log('ocdialog._init'); var self = this; + console.log('test name', this); + this.$element = $('
').insertBefore(this.element); this.$element.append(this.element.detach()); this.$content = this.element.wrap('
').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 = $(''); + console.log('button text', val.text); + var $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() {