blatyo
unread,Aug 12, 2008, 12:10:54 PM8/12/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Prototype & script.aculo.us
I have written the following class:
/**
* This class handles displaying notifications on the page.
*/
var NotificationManager = Class.create({
/**
* This method initializes the NotificationManager class.
*
* @return {NotificationManager} A class to handle displaying
notifications
* on page.
* @constructor
*/
initialize: function(){
//Find the page container.
var container = $$('.container_contents')[0];
// Create a div for showing notifications.
var notifications = new Element('div', {
'id': 'notifications'
});
//Create tables for the three levels of errors.
this.addNotificationTable('user_error', notifications);
this.addNotificationTable('system_error', notifications);
this.addNotificationTable('information', notifications);
//Add the notifications div to the top of the page. These will be
used
//whenever any new notifications are sent back from the server.
container.insert({
'top': notifications
});
}, //End initialize
/**
* This method creates a notification table.
*
* @param {String} type
* The type of table to create. (ie. User Error, System
Error, and
* Information)
* @param {div} notifications
* The div to add this table to.
*/
addNotificationTable: function(type, notifications){
//Create elements
var table = new Element('table', {
'class': type + '_message',//gives the table its styling
'border': '0',
'cellpadding': '0',
'cellspacing': '0'
});
var row = new Element('tr');
var imageTD = new Element('td', {
'valign': 'top',
'class': 'field_cell',
'height': '22'
});
var image = new Element('img', {
'src': '/images/newUI/' + type + '.gif',//grabs the
appropriate image
'align': 'bottom',
'border': '0'
});
var messageTD = new Element('td', {
'valign': 'top',
'class': 'field_cell',
'height': '22',
'id': type //gives the td a name we can use later to
update it
});
//Build DOM
imageTD.insert(image);
row.insert(imageTD);
row.insert({
bottom: messageTD
});
table.insert(row);
table.hide();
notifications.insert({
'bottom': table
});
}, //End addNotificationTable
/**
* This method updates the three notification types.
*
* @param {String} userError
* Errors the user can rectify.
* @param {String} systemError
* Errors in the system.
* @param {String} info
* Information the user should know.
*/
update: function(userError, systemError, info){
//If there are user errors, show them.
if (userError) {
$('user_error').update(userError);
$('user_error').up(1).show();
}
else { //Otherwise, hide the table from view.
$('user_error').up(1).hide();
}
//If there are system errors, show them.
if (systemError) {
$('system_error').update(systemError);
$('system_error').up(1).show();
}
else { //Otherwise, hide the table from view.
$('system_error').up(1).hide();
}
//If there is information, show it.
if (info) {
$('information').update(info);
$('information').up(1).show();
}
else { //Otherwise, hide the table from view.
$('information').up(1).hide();
}
//If there were any notifications.
if (userError || systemError || info) {
//Scroll there, so the user will see them.
$('notifications').scrollTo();
}
}//End update
}); //End NotificationManager
This class works perfectly in firefox, but does not work in IE7. I
have verified with firebug lite that everything is being added to the
page correctly. I have verified that calling $('name').up(1).show();
is correctly changing the display property. It seems as if IE7 is just
not refreshing the elements once they have changed.