update URL controller
This commit is contained in:
parent
6c231c5cd5
commit
bb59e0a3b4
3 changed files with 72 additions and 68 deletions
|
@ -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')*/;
|
||||
}
|
||||
},
|
||||
/*@
|
||||
|
|
|
@ -617,56 +617,52 @@ Ox.URL = function(options) {
|
|||
push <f> Pushes a new URL
|
||||
(state, title, url, callback) -> <o> URL controller
|
||||
state <o> State for the new URL
|
||||
If state is null, it will be derived from url
|
||||
title <s> Title for the new URL
|
||||
url <s|o> 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 <s|o> New URL
|
||||
If url is null, it will be derived from state
|
||||
callback <f> callback function
|
||||
state <o> New state
|
||||
@*/
|
||||
that.push = function(state, title, url, callback) {
|
||||
if (Ox.isString(url)) {
|
||||
if (state) {
|
||||
pushState(state, title, url);
|
||||
} else {
|
||||
if (!state) {
|
||||
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;
|
||||
if (url != self.previousURL) {
|
||||
history.pushState(Ox.extend(state, {title: title}), '', url);
|
||||
document.title = title;
|
||||
callback && callback(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*@
|
||||
replace <f> Replaces the URL with a new URL
|
||||
(state, title, url, callback) -> <o> URL controller
|
||||
state <o> State for the new URL
|
||||
If state is null, it will be derived from url
|
||||
title <s> Title for the new URL
|
||||
url <s|o> New URL, or state object to construct it from
|
||||
url <s|o> New URL
|
||||
If url is null, it will be derived from state
|
||||
callback <f> callback function
|
||||
state <o> New state
|
||||
@*/
|
||||
that.replace = function(state, title, url, callback) {
|
||||
if (Ox.isString(url)) {
|
||||
if (state) {
|
||||
replaceState(state, title, url);
|
||||
} else {
|
||||
if (!state) {
|
||||
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) {
|
||||
|
|
|
@ -38,6 +38,7 @@ Ox.Dialog = function(options, self) {
|
|||
maxWidth: Infinity,
|
||||
minHeight: 64,
|
||||
minWidth: 128,
|
||||
removeOnClose: false,
|
||||
title: '',
|
||||
width: 400
|
||||
})
|
||||
|
@ -647,6 +648,8 @@ Ox.Dialog = function(options, self) {
|
|||
};
|
||||
|
||||
that.close = function(callback) {
|
||||
if (self.isOpen) {
|
||||
self.isOpen = false;
|
||||
that.animate({
|
||||
opacity: 0
|
||||
}, 250, function() {
|
||||
|
@ -663,6 +666,8 @@ Ox.Dialog = function(options, self) {
|
|||
that.loseFocus();
|
||||
}
|
||||
that.triggerEvent('close');
|
||||
self.options.removeOnClose && that.remove();
|
||||
}
|
||||
return that;
|
||||
};
|
||||
|
||||
|
@ -689,6 +694,8 @@ Ox.Dialog = function(options, self) {
|
|||
};
|
||||
|
||||
that.open = function() {
|
||||
if (!self.isOpen) {
|
||||
self.isOpen = true;
|
||||
self.initialHeight = self.options.height;
|
||||
self.initialWidth = self.options.width;
|
||||
setMinAndMax();
|
||||
|
@ -718,6 +725,7 @@ Ox.Dialog = function(options, self) {
|
|||
}
|
||||
});
|
||||
that.triggerEvent('open');
|
||||
}
|
||||
return that;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue