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,33 +617,31 @@ 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) {
|
||||
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 <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) {
|
||||
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) {
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue