firstLoad added. Todo: multiple modalHelper!

pull/232/head
Nils Kenneweg 11 years ago
parent 30784cf465
commit 6c33da00ad
  1. 17
      app/assets/javascripts/modal.js

@ -12,6 +12,7 @@
var ModalHelper = (function() {
var ModalHelper = function() {
this._firstLoad = true;
var modalHelper = this;
var modalDiv, modalIframe;
@ -33,7 +34,7 @@ var ModalHelper = (function() {
var body = jQuery(document.body);
// whatever globals there are, they need to be added to the
// prototype, so that all ModalHelper instances can share them.
if (ModalHelper.prototype.done !== true) {
if (ModalHelper._done !== true) {
// one time initialization
modalDiv = jQuery('<div/>').css('hidden', true).attr('id', 'modalDiv');
modalIframe = modalHelper.writeIframe(modalDiv);
@ -46,7 +47,7 @@ var ModalHelper = (function() {
// close when body is clicked
body.on("click", ".ui-widget-overlay", jQuery.proxy(modalHelper.close, modalHelper));
ModalHelper.prototype.done = true;
ModalHelper._done = true;
} else {
modalDiv = jQuery('#modalDiv');
modalIframe = jQuery('#modalIframe');
@ -69,10 +70,6 @@ var ModalHelper = (function() {
this.hideLoadingModal();
this.loadingModal = false;
//add closer
modalDiv.parent().prepend('<div id="ui-dialog-closer" />').click(jQuery.proxy(this.close, this));
jQuery('.ui-dialog-titlebar').hide();
modalDiv.data('changed', false);
//tweak body.
@ -184,6 +181,14 @@ var ModalHelper = (function() {
}
});
if (this._firstLoad) {
//add closer
modalDiv.parent().prepend('<div id="ui-dialog-closer" />').click(jQuery.proxy(this.close, this));
jQuery('.ui-dialog-titlebar').hide();
this._firstLoad = false;
}
this.loading();
modalIframe.attr("src", url);

Loading…
Cancel
Save