2009-11-21 03:36:26 +01:00
|
|
|
(function($) {
|
|
|
|
$.widget("ssui.titlebar", {
|
2011-02-24 05:12:19 +01:00
|
|
|
_create: function() {
|
2009-11-21 03:36:26 +01:00
|
|
|
this.originalTitle = this.element.attr('title');
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
var options = this.options;
|
|
|
|
|
|
|
|
var title = options.title || this.originalTitle || ' ';
|
|
|
|
var titleId = $.ui.dialog.getTitleId(this.element);
|
2011-02-24 05:12:19 +01:00
|
|
|
|
2009-11-21 03:36:26 +01:00
|
|
|
this.element.parent().addClass('ui-dialog');
|
|
|
|
|
|
|
|
var uiDialogTitlebar = this.element.
|
|
|
|
addClass(
|
|
|
|
'ui-dialog-titlebar ' +
|
|
|
|
'ui-widget-header ' +
|
|
|
|
'ui-corner-all ' +
|
|
|
|
'ui-helper-clearfix'
|
|
|
|
);
|
2011-02-24 05:12:19 +01:00
|
|
|
|
|
|
|
// By default, the
|
2009-11-21 03:36:26 +01:00
|
|
|
|
|
|
|
if(options.closeButton) {
|
|
|
|
var uiDialogTitlebarClose = $('<a href="#"/>')
|
|
|
|
.addClass(
|
|
|
|
'ui-dialog-titlebar-close ' +
|
|
|
|
'ui-corner-all'
|
|
|
|
)
|
|
|
|
.attr('role', 'button')
|
|
|
|
.hover(
|
|
|
|
function() {
|
|
|
|
uiDialogTitlebarClose.addClass('ui-state-hover');
|
|
|
|
},
|
|
|
|
function() {
|
|
|
|
uiDialogTitlebarClose.removeClass('ui-state-hover');
|
|
|
|
}
|
|
|
|
)
|
|
|
|
.focus(function() {
|
|
|
|
uiDialogTitlebarClose.addClass('ui-state-focus');
|
|
|
|
})
|
|
|
|
.blur(function() {
|
|
|
|
uiDialogTitlebarClose.removeClass('ui-state-focus');
|
|
|
|
})
|
|
|
|
.mousedown(function(ev) {
|
|
|
|
ev.stopPropagation();
|
|
|
|
})
|
|
|
|
.appendTo(uiDialogTitlebar);
|
2011-02-24 05:12:19 +01:00
|
|
|
|
2009-11-21 03:36:26 +01:00
|
|
|
var uiDialogTitlebarCloseText = (this.uiDialogTitlebarCloseText = $('<span/>'))
|
|
|
|
.addClass(
|
|
|
|
'ui-icon ' +
|
|
|
|
'ui-icon-closethick'
|
|
|
|
)
|
|
|
|
.text(options.closeText)
|
|
|
|
.appendTo(uiDialogTitlebarClose);
|
|
|
|
}
|
2011-02-24 05:12:19 +01:00
|
|
|
|
2009-11-21 03:36:26 +01:00
|
|
|
var uiDialogTitle = $('<span/>')
|
|
|
|
.addClass('ui-dialog-title')
|
|
|
|
.attr('id', titleId)
|
|
|
|
.html(title)
|
|
|
|
.prependTo(uiDialogTitlebar);
|
2011-02-24 05:12:19 +01:00
|
|
|
|
2009-11-21 03:36:26 +01:00
|
|
|
uiDialogTitlebar.find("*").add(uiDialogTitlebar).disableSelection();
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
this.element
|
|
|
|
.unbind('.dialog')
|
|
|
|
.removeData('dialog')
|
|
|
|
.removeClass('ui-dialog-content ui-widget-content')
|
|
|
|
.hide().appendTo('body');
|
|
|
|
|
|
|
|
(this.originalTitle && this.element.attr('title', this.originalTitle));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$.extend($.ssui.titlebar, {
|
|
|
|
version: "0.0.1",
|
2011-02-24 05:12:19 +01:00
|
|
|
options: {
|
2009-11-21 03:36:26 +01:00
|
|
|
title: '',
|
|
|
|
closeButton: false,
|
|
|
|
closeText: 'close'
|
|
|
|
},
|
|
|
|
|
|
|
|
uuid: 0,
|
|
|
|
|
|
|
|
getTitleId: function($el) {
|
|
|
|
return 'ui-dialog-title-' + ($el.attr('id') || ++this.uuid);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}(jQuery));
|