add icon to application error dialog

This commit is contained in:
rlx 2011-08-17 11:39:33 +00:00
parent fcdfb03bea
commit 31149d7ecc
5 changed files with 82 additions and 29 deletions

View file

@ -240,8 +240,8 @@ Dialog
} }
.OxDialog > .OxTitlebar > .OxTitle { .OxDialog > .OxTitlebar > .OxTitle {
margin-top: 3px; margin-top: 4px;
font-size: 13px; font-size: 11px;
font-weight: bold; font-weight: bold;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;

View file

@ -152,8 +152,8 @@ Ox.Request = function(options) {
}) })
], ],
content: $iframe, content: $iframe,
width: 800, width: 768,
height: 400 height: 384
}) })
.open(), .open(),
iframe = $iframe[0].contentDocument || $iframe[0].contentWindow.document; iframe = $iframe[0].contentDocument || $iframe[0].contentWindow.document;
@ -214,10 +214,20 @@ Ox.Request = function(options) {
} }
}) })
], ],
content: 'Sorry, we have encountered an application error while handling your request. To help us find out what went wrong, you may want to report this error to an administrator. Otherwise, please try again later.', content: Ox.Element()
.append(
$('<img>')
.attr({src: Ox.UI.PATH + 'png/icon128.png'})
.css({position: 'absolute', left: '16px', top: '16px', width: '64px', height: '64px'})
)
.append(
Ox.Element()
.css({position: 'absolute', left: '96px', top: '16px', width: '256px'})
.html('Sorry, we have encountered an application error while handling your request. To help us find out what went wrong, you may want to report this error to an administrator. Otherwise, please try again later.')
),
height: 192,
keys: {enter: 'close', escape: 'close'}, keys: {enter: 'close', escape: 'close'},
width: 400, width: 368
height: 200
}) })
.open(); .open();
// fixme: change this to Send / Don't Send // fixme: change this to Send / Don't Send

View file

@ -992,7 +992,7 @@ Ox.List = function(options, self) {
if (self.options.centered) { if (self.options.centered) {
that.animate({ that.animate({
scrollLeft: (self.listMargin / 2 + (pos + 0.5) * itemWidth - that.width() / 2) + 'px' scrollLeft: (self.listMargin / 2 + (pos + 0.5) * itemWidth - that.width() / 2) + 'px'
}, 0); }, 250);
} else { } else {
positions[0] = pos * itemWidth + self.listMargin / 2; positions[0] = pos * itemWidth + self.listMargin / 2;
positions[1] = positions[0] + itemWidth + self.itemMargin / 2; positions[1] = positions[0] + itemWidth + self.itemMargin / 2;

View file

@ -31,6 +31,7 @@ Ox.Dialog = function(options, self) {
fixedRatio: false, fixedRatio: false,
focus: true, focus: true,
height: 200, height: 200,
keys: {},
maxHeight: Infinity, maxHeight: Infinity,
maximizeButton: false, maximizeButton: false,
maxWidth: Infinity, maxWidth: Infinity,
@ -41,6 +42,14 @@ Ox.Dialog = function(options, self) {
}) })
.options(options || {}) .options(options || {})
.addClass('OxDialog') .addClass('OxDialog')
.bindEvent({
key_enter: function() {
keypress('enter');
},
key_escape: function() {
keypress('escape');
}
})
.hide() .hide()
.appendTo(Ox.UI.$body); .appendTo(Ox.UI.$body);
@ -128,24 +137,7 @@ Ox.Dialog = function(options, self) {
self.$buttonsRight = $('<div>') self.$buttonsRight = $('<div>')
.addClass('OxButtonsRight') .addClass('OxButtonsRight')
.appendTo(self.$buttonsbar.$element); .appendTo(self.$buttonsbar.$element);
var buttonsLeft, setButtons();
buttonsRight,
index = Ox.map(self.options.buttons, function(v, i) {
return Ox.isEmpty(v) ? i : null;
})[0];
if (index) {
buttonsLeft = Ox.sub(self.options.buttons, 0, index);
buttonsRight = Ox.sub(self.options.buttons, index + 1);
} else {
buttonsLeft = [];
buttonsRight = self.options.buttons;
}
buttonsLeft.forEach(function($button) {
$button.addClass('OxLeft').appendTo(self.$buttonsLeft);
});
buttonsRight.forEach(function($button) {
$button.addClass('OxRight').appendTo(self.$buttonsRight);
});
} }
if (!self.options.fixedCenter) { if (!self.options.fixedCenter) {
@ -263,6 +255,22 @@ Ox.Dialog = function(options, self) {
that.unwrap(); that.unwrap();
} }
function getButtonById(id) {
var ret = null;
Ox.forEach(self.options.buttons, function(button) {
if (button.options && button.options('id') == id) {
ret = button;
return false;
}
});
return ret;
}
function keypress(key) {
var id = self.options.keys[key];
id && getButtonById(id).$element.trigger('click');
}
function maximize() { function maximize() {
var offset = that.offset(); var offset = that.offset();
decenter(); decenter();
@ -501,13 +509,36 @@ Ox.Dialog = function(options, self) {
that.unwrap(); that.unwrap();
} }
function setButtons() {
var buttonsLeft,
buttonsRight,
index = Ox.map(self.options.buttons, function(v, i) {
return Ox.isEmpty(v) ? i : null;
})[0];
if (index) {
buttonsLeft = Ox.sub(self.options.buttons, 0, index);
buttonsRight = Ox.sub(self.options.buttons, index + 1);
} else {
buttonsLeft = [];
buttonsRight = self.options.buttons;
}
self.$buttonsLeft.empty();
buttonsLeft.forEach(function($button) {
$button.addClass('OxLeft').appendTo(self.$buttonsLeft);
});
self.$buttonsRight.empty();
buttonsRight.forEach(function($button) {
$button.addClass('OxRight').appendTo(self.$buttonsRight);
});
}
function setContent() { function setContent() {
var animate = !!self.$content var animate = !!self.$content
isImage = !self.options.content.ox && self.options.content.is('img'); isImage = !self.options.content.ox && self.options.content.is('img');
if (animate) { if (animate) {
self.$content.animate({ self.$content.animate({
opacity: 0 opacity: 0
}, 100, function() { }, 250, function() {
$(this).remove() // fixme: removeElement? $(this).remove() // fixme: removeElement?
}); });
self.options.content.css({ self.options.content.css({
@ -532,7 +563,7 @@ Ox.Dialog = function(options, self) {
); );
animate && self.options.content.animate({ animate && self.options.content.animate({
opacity: 1 opacity: 1
}, 100); }, 250);
} }
function setCSS(css, animate) { function setCSS(css, animate) {
@ -591,7 +622,9 @@ Ox.Dialog = function(options, self) {
} }
self.setOption = function(key, value) { self.setOption = function(key, value) {
if (key == 'content') { if (key == 'buttons') {
setButtons();
} else if (key == 'content') {
setContent(); setContent();
} else if (key == 'height') { } else if (key == 'height') {
setMinAndMax(); setMinAndMax();
@ -631,6 +664,16 @@ Ox.Dialog = function(options, self) {
return that; return that;
}; };
that.disableButton = function(id) {
getButtonById(id).options({disabled: true});
return that;
};
that.enableButton = function(id) {
getButtonById(id).options({disabled: false});
return that;
};
that.open = function() { that.open = function() {
self.initialHeight = self.options.height; self.initialHeight = self.options.height;
self.initialWidth = self.options.width; self.initialWidth = self.options.width;

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB