').html(data);
}
else {
// unsupported data type!
if (console) {
console.log('SimpleModal Error: Unsupported data type: ' + typeof data);
}
return false;
}
this.dialog.data = data.addClass('modalData');
data = null;
// create the modal overlay, container and, if necessary, iframe
this.create();
// display the modal dialog
this.open();
// useful for adding events/manipulating data in the modal dialog
if ($.isFunction(this.opts.onShow)) {
this.opts.onShow.apply(this, [this.dialog]);
}
// don't break the chain =)
return this;
},
/*
* Create and add the modal overlay and container to the page
*/
create: function () {
// create the overlay
this.dialog.overlay = $('
')
.attr('id', this.opts.overlayId)
.addClass('modalOverlay')
.css($.extend(this.opts.overlayCss, {
opacity: this.opts.overlay / 100,
height: '100%',
width: '100%',
position: 'fixed',
left: 0,
top: 0,
zIndex: 3000
}))
.hide()
.appendTo('body');
// create the container
this.dialog.container = $('
')
.attr('id', this.opts.containerId)
.addClass('modalContainer')
.css($.extend(this.opts.containerCss, {
position: 'fixed',
zIndex: 3100
}))
.append(this.opts.close
? '
'
: '')
.hide()
.appendTo('body');
// fix issues with IE and create an iframe
if ($.browser.msie && ($.browser.version < 7)) {
this.fixIE();
}
// hide the data and add it to the container
this.dialog.container.append(this.dialog.data.hide());
},
/*
* Bind events
*/
bindEvents: function () {
var modal = this;
// bind the close event to any element with the closeClass class
$('.' + this.opts.closeClass).click(function (e) {
e.preventDefault();
modal.close();
});
},
/*
* Unbind events
*/
unbindEvents: function () {
// remove the close event
$('.' + this.opts.closeClass).unbind('click');
},
/*
* Fix issues in IE 6
*/
fixIE: function () {
var wHeight = $(document.body).height() + 'px';
var wWidth = $(document.body).width() + 'px';
// position hacks
this.dialog.overlay.css({position: 'absolute', height: wHeight, width: wWidth});
this.dialog.container.css({position: 'absolute'});
// add an iframe to prevent select options from bleeding through
this.dialog.iframe = $('