/**
- * Provides the javascript for the message.php script
+ * Provides the javascript for the message.php script (standard view).
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
*/
-function arrowHandler(e)
-{
- if (e.altKey || e.shiftKey || e.ctrlKey) {
- return;
- }
+var ImpMessage = {
+ // The following variables are defined in message.php:
+ // printmode
- switch (e.keyCode || e.charCode) {
- case Event.KEY_LEFT:
- if ($('prev')) {
- document.location.href = $('prev').href;
+ _arrowHandler: function(e)
+ {
+ if (e.altKey || e.shiftKey || e.ctrlKey) {
+ return;
}
- break;
- case Event.KEY_RIGHT:
- if ($('next')) {
- document.location.href = $('next').href;
- }
- break;
- }
-}
+ switch (e.keyCode || e.charCode) {
+ case Event.KEY_LEFT:
+ if ($('prev')) {
+ document.location.href = $('prev').href;
+ }
+ break;
-function message_submit(actID)
-{
- if (actID == 'spam_report') {
- if (!window.confirm(IMP.text.spam_report)) {
- return;
- }
- } else if (actID == 'notspam_report') {
- if (!window.confirm(IMP.text.notspam_report)) {
- return;
- }
- }
- $('actionID').setValue(actID);
- $('messages').submit();
-}
-
-function flagMessage(form)
-{
- var f1 = $('flag1'), f2 = $('flag2');
- if ((form == 1 && $F(f1)) ||
- (form == 2 && $F(f2))) {
- $('flag').setValue((form == 1) ? $F(f1) : $F(f2));
- message_submit('flag_message');
- }
-}
-
-function transfer(actID, form)
-{
- var tmbox = $('targetMbox');
- tmbox.setValue((form == 1) ? $F('target1') : $F('target2'));
-
- // Check for a mailbox actually being selected.
- if ($F(tmbox) == '*new*') {
- var newFolder = window.prompt(IMP.text.newfolder, '');
- if (newFolder != null && newFolder != '') {
- $('newMbox').setValue(1);
- tmbox.setValue(newFolder);
- message_submit(actID);
+ case Event.KEY_RIGHT:
+ if ($('next')) {
+ document.location.href = $('next').href;
+ }
+ break;
}
- } else {
- if (!$F(tmbox)) {
- window.alert(IMP.text.target_mbox);
- } else {
- message_submit(actID);
+ },
+
+ submit: function(actID)
+ {
+ switch (actID) {
+ case 'spam_report':
+ if (!window.confirm(IMP.text.spam_report)) {
+ return;
+ }
+ break;
+
+ case 'notspam_report':
+ if (!window.confirm(IMP.text.notspam_report)) {
+ return;
+ }
+ break;
}
- }
-}
-
-function updateFolders(form)
-{
- var f = (form == 1) ? 2 : 1;
- $('target' + f).selectedIndex = $('target' + form).selectedIndex;
-}
-
-/* Function needed for IE compatibilty with drop-down menus. */
-function messageActionsHover()
-{
- var iefix = new Element('IFRAME', { scrolling: 'no', frameborder: 0 }).hide();
- iefix.setStyle({ position: 'absolute' });
- // This can not appear in the new Element() call - Bug #5887
- iefix.setAttribute('src', 'javascript:false;');
-
- $$('UL.msgactions LI').each(function(li) {
- var fixcopy, ul = li.down('UL'), zindex;
- if (!ul) {
- return;
+
+ $('actionID').setValue(actID);
+ $('messages').submit();
+ },
+
+ flagMessage: function(form)
+ {
+ var f1 = $('flag1'), f2 = $('flag2');
+ if ((form == 1 && $F(f1)) ||
+ (form == 2 && $F(f2))) {
+ $('flag').setValue((form == 1) ? $F(f1) : $F(f2));
+ this.submit('flag_message');
}
+ },
- fixcopy = iefix.cloneNode(false);
- li.insert(fixcopy);
- fixcopy.clonePosition(ul);
+ transfer: function(actID, form)
+ {
+ var newFolder, tmbox = $('targetMbox');
+ tmbox.setValue((form == 1) ? $F('target1') : $F('target2'));
- zindex = li.getStyle('zIndex');
- if (zindex == '') {
- li.setStyle({ zIndex: 2 });
- fixcopy.setStyle({ zIndex: 1 });
+ // Check for a mailbox actually being selected.
+ if ($F(tmbox) == '*new*') {
+ newFolder = window.prompt(IMP.text.newfolder, '');
+ if (newFolder != null && newFolder != '') {
+ $('newMbox').setValue(1);
+ tmbox.setValue(newFolder);
+ this.submit(actID);
+ }
} else {
- fixcopy.setStyle({ zIndex: parseInt(zindex) - 1 });
+ if (!$F(tmbox)) {
+ window.alert(IMP.text.target_mbox);
+ } else {
+ this.submit(actID);
+ }
}
+ },
- li.observe('mouseout', function() {
- this.removeClassName('hover');
- li.down('iframe').hide();
- });
- li.observe('mouseover', function() {
- this.addClassName('hover');
- li.down('iframe').show();
+ updateFolders: function(form)
+ {
+ var f = (form == 1) ? 2 : 1;
+ $('target' + f).selectedIndex = $('target' + form).selectedIndex;
+ },
+
+ /* Function needed for IE compatibilty with drop-down menus. */
+ _messageActionsHover: function()
+ {
+ var iefix = new Element('IFRAME', { scrolling: 'no', frameborder: 0 }).setStyle({ position: 'absolute' }).hide();
+
+ // This can not appear in the new Element() call - Bug #5887
+ iefix.writeAttribute('src', 'javascript:false;');
+
+ $$('UL.msgactions LI').each(function(li) {
+ var fixcopy, ul = li.down('UL'), zindex;
+ if (!ul) {
+ return;
+ }
+
+ fixcopy = iefix.cloneNode(false);
+ li.insert(fixcopy);
+ fixcopy.clonePosition(ul);
+
+ zindex = li.getStyle('zIndex');
+ if (zindex == '') {
+ li.setStyle({ zIndex: 2 });
+ fixcopy.setStyle({ zIndex: 1 });
+ } else {
+ fixcopy.setStyle({ zIndex: parseInt(zindex) - 1 });
+ }
+
+ li.observe('mouseout', function() {
+ this.removeClassName('hover');
+ li.down('iframe').hide();
+ });
+ li.observe('mouseover', function() {
+ this.addClassName('hover');
+ li.down('iframe').show();
+ });
});
- });
-}
+ },
-document.observe('dom:loaded', function() {
- // Set up left and right arrows to go to the previous/next page.
- document.observe('keydown', arrowHandler);
+ onDomLoad: function()
+ {
+ if (!this.printmode) {
+ // Set up left and right arrows to go to the previous/next page.
+ document.observe('keydown', this._arrowHandler.bindAsEventListener(this));
+ document.observe('change', this._changeHandler.bindAsEventListener(this));
- if (Prototype.Browser.IE) {
- messageActionsHover();
+ if (Prototype.Browser.IE) {
+ this._messageActionsHover();
+ }
+ }
+ },
+
+ onLoad: function()
+ {
+ if (this.printmode) {
+ Event.observe(window, 'afterprint', function() { window.close(); });
+ try {
+ window.print();
+ } catch (e) {}
+ }
+ },
+
+ _changeHandler: function(e)
+ {
+ var id = e.element().readAttribute('id');
+
+ if (id.startsWith('flag')) {
+ this.flagMessage(id.substring(4));
+ } else if (id.startsWith('target')) {
+ this.updateFolders(id.substring(6));
+ }
}
-});
+
+};
+
+document.observe('dom:loaded', ImpMessage.onDomLoad.bind(ImpMessage));
+Event.observe(window, 'load', ImpMessage.onLoad.bind(ImpMessage));