diff --git a/source/Ox.UI/js/Core/Ox.Focus.js b/source/Ox.UI/js/Core/Ox.Focus.js index 65910ec8..b1e18e00 100644 --- a/source/Ox.UI/js/Core/Ox.Focus.js +++ b/source/Ox.UI/js/Core/Ox.Focus.js @@ -27,7 +27,7 @@ Ox.Focus = (function() { //$elements[id].removeClass('OxFocus'); $('.OxFocus').removeClass('OxFocus'); // fixme: the above is better, and should work stack.length && Ox.UI.elements[stack[stack.length - 1]] - .addClass('OxFocus').triggerEvent('focus'); + .addClass('OxFocus')/*.triggerEvent('focus')*/; Ox.Log('Core', 'blur', id, stack); } }, @@ -43,7 +43,7 @@ Ox.Focus = (function() { $('.OxFocus').removeClass('OxFocus'); // fixme: see above Ox.Log('Core', 'focus', id, stack); Ox.UI.elements[id] - .addClass('OxFocus').triggerEvent('focus'); + .addClass('OxFocus')/*.triggerEvent('focus')*/; } }, /*@ diff --git a/source/Ox.UI/js/Core/Ox.URL.js b/source/Ox.UI/js/Core/Ox.URL.js index 59f798b5..00d643f2 100644 --- a/source/Ox.UI/js/Core/Ox.URL.js +++ b/source/Ox.UI/js/Core/Ox.URL.js @@ -617,33 +617,31 @@ Ox.URL = function(options) { push Pushes a new URL (state, title, url, callback) -> URL controller state State for the new URL + If state is null, it will be derived from url title Title for the new URL - url New URL, or state object to construct it from - This state object can be different from the first one - (for example: save full state, create URL from reduced state) + url New URL + If url is null, it will be derived from state callback callback function state New state @*/ that.push = function(state, title, url, callback) { - if (Ox.isString(url)) { - if (state) { + if (!state) { + parseURL(url, function(state) { pushState(state, title, url); - } else { - parseURL(url, function(state) { - pushState(state, title, url); - }); - } + }); } else { - url = constructURL(url); + url = url || constructURL(state); pushState(state, title, url); } function pushState(state, title, url) { self.previousURL = document.location.pathname + document.location.search + document.location.hash; - history.pushState(Ox.extend(state, {title: title}), '', url); - document.title = title; - callback && callback(state); + if (url != self.previousURL) { + history.pushState(Ox.extend(state, {title: title}), '', url); + document.title = title; + callback && callback(state); + } } } @@ -651,22 +649,20 @@ Ox.URL = function(options) { replace Replaces the URL with a new URL (state, title, url, callback) -> URL controller state State for the new URL + If state is null, it will be derived from url title Title for the new URL - url New URL, or state object to construct it from + url New URL + If url is null, it will be derived from state callback callback function state New state @*/ that.replace = function(state, title, url, callback) { - if (Ox.isString(url)) { - if (state) { + if (!state) { + parseURL(url, function(state) { replaceState(state, title, url); - } else { - parseURL(url, function(state) { - replaceState(state, title, url); - }); - } + }); } else { - url = constructURL(url); + url = url || constructURL(state); replaceState(state, title, url); } function replaceState(state, title, url) { diff --git a/source/Ox.UI/js/Window/Ox.Dialog.js b/source/Ox.UI/js/Window/Ox.Dialog.js index 8903f4ff..13208566 100644 --- a/source/Ox.UI/js/Window/Ox.Dialog.js +++ b/source/Ox.UI/js/Window/Ox.Dialog.js @@ -38,6 +38,7 @@ Ox.Dialog = function(options, self) { maxWidth: Infinity, minHeight: 64, minWidth: 128, + removeOnClose: false, title: '', width: 400 }) @@ -647,22 +648,26 @@ Ox.Dialog = function(options, self) { }; that.close = function(callback) { - that.animate({ - opacity: 0 - }, 250, function() { - // that.remove(); - that.hide(); - callback && callback(); - }); - if (self.maximized) { - self.$maximizeButton.toggleTitle(); - self.maximized = false; + if (self.isOpen) { + self.isOpen = false; + that.animate({ + opacity: 0 + }, 250, function() { + // that.remove(); + that.hide(); + callback && callback(); + }); + if (self.maximized) { + self.$maximizeButton.toggleTitle(); + self.maximized = false; + } + if (self.options.focus) { + self.$layer.hide(); + that.loseFocus(); + } + that.triggerEvent('close'); + self.options.removeOnClose && that.remove(); } - if (self.options.focus) { - self.$layer.hide(); - that.loseFocus(); - } - that.triggerEvent('close'); return that; }; @@ -689,35 +694,38 @@ Ox.Dialog = function(options, self) { }; that.open = function() { - self.initialHeight = self.options.height; - self.initialWidth = self.options.width; - setMinAndMax(); - center(); - reset(); - that.css({ - opacity: 0 - }).show().animate({ - opacity: 1 - }, 250); - if (self.options.focus) { - self.$layer.show(); - that.gainFocus(); - } - Ox.UI.$window.bind({ - resize: function() { - var offset = that.offset(); - setMinAndMax(); - if (self.centered) { - center(); - } else { - that.css({ - left: Math.min(offset.left, self.maxLeft) + 'px', - top: Math.min(offset.top, self.maxTop) + 'px' - }); - } + if (!self.isOpen) { + self.isOpen = true; + self.initialHeight = self.options.height; + self.initialWidth = self.options.width; + setMinAndMax(); + center(); + reset(); + that.css({ + opacity: 0 + }).show().animate({ + opacity: 1 + }, 250); + if (self.options.focus) { + self.$layer.show(); + that.gainFocus(); } - }); - that.triggerEvent('open'); + Ox.UI.$window.bind({ + resize: function() { + var offset = that.offset(); + setMinAndMax(); + if (self.centered) { + center(); + } else { + that.css({ + left: Math.min(offset.left, self.maxLeft) + 'px', + top: Math.min(offset.top, self.maxTop) + 'px' + }); + } + } + }); + that.triggerEvent('open'); + } return that; };