Views.Dialog = Views.Base.extend({ classType: "Views.Dialog", tagName: "div", nowLoadingImage: "./skins/default/images/nowLoading.gif", nowLoadingLabel: "", nowLoadingPosition: { my: "center center", at: "center center" }, listenEvents: function() { //See Views.Base listenDefaultEvents() this.on("oninitialize", this.onInitialize); this.on("onrender", this.onRender); this.on("onmouseenter", this.stopCloseTimeout); this.on("onfocus", this.stopCloseTimeout); }, hide: function(callback) { //this.$el.animate({height:'0px'}, 100, callback); var that = this; this.$el.dialog("widget").hide(100, function() { if (callback) { callback(); } that.trigger("onhide"); }); this.options.isShowed = false; }, show: function(callback) { //this.$el.animate({height:'0px'}, 100, callback); var that = this; this.$el.dialog("widget").show(100, function() { if (callback) { callback(); } that.trigger("onshow"); }); this.options.isShowed = true; }, onInitialize: function() { this.options.preventFromCascadingEdViewsCreation = true; }, checkOptions: function() { this.options.minclosetimeout = 5000; if (!(this.options.fixedposition == false)) { this.options.fixedposition = true; } if (!this.options.disableClose) { this.options.disableClose = false; } if (!this.options.modal) { this.options.modal = false; } if (!this.options.closeOnEscape) { this.options.closeOnEscape = true; } if (this.options.modal == true) { this.options.closeOnEscape = false; } if (!this.options.draggable) { this.options.draggable = false; } if (!this.options.resizable) { this.options.resizable = false; } if (!this.options.draggable) { this.options.draggable = false; } if (!this.options.maximizable) { this.options.maximizable = true; } if (!this.options.minimizable) { this.options.minimizable = true; } if (!this.options.size) { this.options.size = {}; } if (!this.options.size.width) { this.options.size.width = 780; } if (!this.options.size.height) { this.options.size.height = 800; } if (!this.options.position) { this.options.position = {}; } if (this.options.position == "STACK") { this.options.position = {my: "right top", at: "right top", of: window}; } if (!this.options.buttons) { this.options.buttons = [ { text: edApplication().labels.OK, click: function() { $( this ).dialog( "close" ); } } ]; } if (!this.options.closetimeout) { this.options.closetimeout = -1; } else { if (this.options.closetimeout < this.options.minclosetimeout) { this.options.closetimeout = this.options.minclosetimeout; } } }, onAsyncLoading: function(data) { this.model.set("value", data); this.removeNowLoading(); var existingEl = $("#" + this.id); if (existingEl.length > 0) { existingEl.html(data); existingEl.dialog( "option", "title", this.options.title ); this.trigger("onrefreshcontent"); } else { this.render(); } }, refreshContent: function() { this.initialize(); }, onRender: function () { this.checkOptions(); var that = this; if (!this.options.dialogCreated) { this.$el.first().dialog({ autoOpen: false, width: this.options.width, height: this.options.height, position: this.options.position, draggable: this.options.draggable, resizable: this.options.resizable, modal: this.options.modal, appendTo: this.options.appendTo, closeOnEscape: this.options.closeOnEscape, beforeClose: this.beforeClose, resizeStart: function (event, ui){ if (that.options.fixedposition) { that.$el.dialog("widget").css("position", "fixed"); } }, dragStart: function (event, ui){ if (that.options.fixedposition) { that.$el.dialog("widget").css("position", "fixed"); } }, close: function (event, ui) { if (that.options.destroyOnClose) { that.$el.dialog("destroy"); that.destroy(); } that.trigger("ondialogclose"); }, open: function (event, ui) { that.$el.dialog("widget").css("z-index", "99999"); that.trigger("ondialogopen"); }, buttons:this.options.buttons }); this.options.dialogCreated = true; } return this; }, /*refresh: function() { this.$el.html(""); this.displayNowLoading(); },*/ hideCloseButton: function() { $(".ui-dialog-titlebar-close", this.$el.dialog("widget")).hide(); this.$el.dialog("option", "closeOnEscape", false); }, showCloseButton: function() { $(".ui-dialog-titlebar-close", this.$el.dialog("widget")).show(); if (this.options.closeOnEscape) { this.$el.dialog("option", "closeOnEscape", true); } }, open: function() { var that = this; if (this.options.disableClose) { this.hideCloseButton(); } if (this.options.linkTo) { this.$el.dialog("open").dialog("widget").css("visibility", "hidden"); this.options.linkTo.effect("transfer", { to: that.$el.dialog("widget"), className: "ui-effects-transfer" }, 300, function() { that.$el.dialog("widget").css("visibility", "visible"); that.setFixedPosition(); }); } else { this.$el.dialog("open"); this.setFixedPosition(); } if (this.options.closetimeout > -1) { var that = this; this.options.closeTimer = setTimeout(function() {that.close();},this.options.closetimeout); } /*if (this.options.draggable) { this.$el.dialog("open"); draggable: this.options.draggable, }*/ }, setFixedPosition: function() { var that = this; if (this.options.fixedposition) { var newPos = that.$el.dialog("widget").position(); newPos.top = newPos.top - $(window).scrollTop(); newPos.left = newPos.left - $(window).scrollLeft(); if (newPos.top > 0 && newPos.left > 0) { that.$el.dialog("widget").css("top", newPos.top + "px"); that.$el.dialog("widget").css("left", newPos.left + "px"); } that.$el.dialog("widget").css("position", "fixed"); } }, beforeClose: function(event, ui) { var viewId = $(event.target)[0].id; var view = edManager.getViewByID(viewId); if (view.options.linkTo) { view.$el.dialog("widget").effect("transfer", { to: view.options.linkTo, className: "ui-effects-transfer" }, 300, function() { //view.$el.dialog("widget").css("position", "absolute"); //view.$el.dialog("close"); }); } }, close: function() { this.$el.dialog("close"); }, stopCloseTimeout: function() { if (this.options.closeTimer) { clearTimeout(this.options.closeTimer); } } }); Views.DialogList = Views.BaseList.extend({ classType: "Views.DialogList" });