From 6be9710a346d45c2b11c57d386f7728b7a22016d Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 7 Jul 2013 19:07:44 +0200 Subject: [PATCH] Implement close button --- jsde.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/jsde.js b/jsde.js index 3d86c7e..98f7add 100755 --- a/jsde.js +++ b/jsde.js @@ -64,16 +64,29 @@ function JsdeWindow(options) $(this._inner).data("jsde-window", this) $(this._title).data("jsde-window", this) + $(this._outer).find(".window-close a").click(this._HandleClose); + this.BringToForeground(); } JsdeWindow.prototype.BringToForeground = function() { + this.z = next_z_index; $(this._outer).css({"z-index": next_z_index}) next_z_index++; return this; } +JsdeWindow.prototype.Close = function(forced) +{ + if(typeof forced === "undefined") + { + forced = false; + } + + $(this._outer).remove(); +} + JsdeWindow.prototype.GetContents = function() { return $(this._inner).html(); @@ -143,6 +156,12 @@ JsdeWindow.prototype._HandleMouseDown = function(event) event.stopPropagation(); } +JsdeWindow.prototype._HandleClose = function(event) +{ + affected_window = $(this).closest(".window-title").data("jsde-window"); + affected_window.Close(); +} + function _HandleMouseUp(event) { if(currently_dragging === true)