From be893548b9e5d363e5de67e6148fbc50bb244098 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 9 Feb 2009 21:26:40 -0700 Subject: [PATCH] Update message JS/CSS code --- imp/js/message.js | 2 +- imp/js/src/message.js | 247 +++++++++++++++++------------ imp/message.php | 8 +- imp/templates/message/message.html | 12 +- imp/templates/message/navbar_navigate.html | 10 +- imp/themes/screen.css | 19 ++- 6 files changed, 170 insertions(+), 128 deletions(-) diff --git a/imp/js/message.js b/imp/js/message.js index def77167b..d275b25d6 100644 --- a/imp/js/message.js +++ b/imp/js/message.js @@ -1 +1 @@ -function arrowHandler(a){if(a.altKey||a.shiftKey||a.ctrlKey){return}switch(a.keyCode||a.charCode){case Event.KEY_LEFT:if($("prev")){document.location.href=$("prev").href}break;case Event.KEY_RIGHT:if($("next")){document.location.href=$("next").href}break}}function message_submit(a){if(a=="spam_report"){if(!window.confirm(IMP.text.spam_report)){return}}else{if(a=="notspam_report"){if(!window.confirm(IMP.text.notspam_report)){return}}}$("actionID").setValue(a);$("messages").submit()}function flagMessage(b){var a=$("flag1"),c=$("flag2");if((b==1&&$F(a))||(b==2&&$F(c))){$("flag").setValue((b==1)?$F(a):$F(c));message_submit("flag_message")}}function transfer(d,b){var a=$("targetMbox");a.setValue((b==1)?$F("target1"):$F("target2"));if($F(a)=="*new*"){var c=window.prompt(IMP.text.newfolder,"");if(c!=null&&c!=""){$("newMbox").setValue(1);a.setValue(c);message_submit(d)}}else{if(!$F(a)){window.alert(IMP.text.target_mbox)}else{message_submit(d)}}}function updateFolders(a){var b=(a==1)?2:1;$("target"+b).selectedIndex=$("target"+a).selectedIndex}function messageActionsHover(){var a=new Element("IFRAME",{scrolling:"no",frameborder:0}).hide();a.setStyle({position:"absolute"});a.setAttribute("src","javascript:false;");$$("UL.msgactions LI").each(function(b){var c,e=b.down("UL"),d;if(!e){return}c=a.cloneNode(false);b.insert(c);c.clonePosition(e);d=b.getStyle("zIndex");if(d==""){b.setStyle({zIndex:2});c.setStyle({zIndex:1})}else{c.setStyle({zIndex:parseInt(d)-1})}b.observe("mouseout",function(){this.removeClassName("hover");b.down("iframe").hide()});b.observe("mouseover",function(){this.addClassName("hover");b.down("iframe").show()})})}document.observe("dom:loaded",function(){document.observe("keydown",arrowHandler);if(Prototype.Browser.IE){messageActionsHover()}}); \ No newline at end of file +var ImpMessage={_arrowHandler:function(a){if(a.altKey||a.shiftKey||a.ctrlKey){return}switch(a.keyCode||a.charCode){case Event.KEY_LEFT:if($("prev")){document.location.href=$("prev").href}break;case Event.KEY_RIGHT:if($("next")){document.location.href=$("next").href}break}},submit:function(a){switch(a){case"spam_report":if(!window.confirm(IMP.text.spam_report)){return}break;case"notspam_report":if(!window.confirm(IMP.text.notspam_report)){return}break}$("actionID").setValue(a);$("messages").submit()},flagMessage:function(b){var a=$("flag1"),c=$("flag2");if((b==1&&$F(a))||(b==2&&$F(c))){$("flag").setValue((b==1)?$F(a):$F(c));this.submit("flag_message")}},transfer:function(d,b){var c,a=$("targetMbox");a.setValue((b==1)?$F("target1"):$F("target2"));if($F(a)=="*new*"){c=window.prompt(IMP.text.newfolder,"");if(c!=null&&c!=""){$("newMbox").setValue(1);a.setValue(c);this.submit(d)}}else{if(!$F(a)){window.alert(IMP.text.target_mbox)}else{this.submit(d)}}},updateFolders:function(a){var b=(a==1)?2:1;$("target"+b).selectedIndex=$("target"+a).selectedIndex},_messageActionsHover:function(){var a=new Element("IFRAME",{scrolling:"no",frameborder:0}).setStyle({position:"absolute"}).hide();a.writeAttribute("src","javascript:false;");$$("UL.msgactions LI").each(function(b){var c,e=b.down("UL"),d;if(!e){return}c=a.cloneNode(false);b.insert(c);c.clonePosition(e);d=b.getStyle("zIndex");if(d==""){b.setStyle({zIndex:2});c.setStyle({zIndex:1})}else{c.setStyle({zIndex:parseInt(d)-1})}b.observe("mouseout",function(){this.removeClassName("hover");b.down("iframe").hide()});b.observe("mouseover",function(){this.addClassName("hover");b.down("iframe").show()})})},onDomLoad:function(){if(!this.printmode){document.observe("keydown",this._arrowHandler.bindAsEventListener(this));document.observe("change",this._changeHandler.bindAsEventListener(this));if(Prototype.Browser.IE){this._messageActionsHover()}}},onLoad:function(){if(this.printmode){Event.observe(window,"afterprint",function(){window.close()});try{window.print()}catch(a){}}},_changeHandler:function(a){var b=a.element().readAttribute("id");if(b.startsWith("flag")){this.flagMessage(b.substring(4))}else{if(b.startsWith("target")){this.updateFolders(b.substring(6))}}}};document.observe("dom:loaded",ImpMessage.onDomLoad.bind(ImpMessage));Event.observe(window,"load",ImpMessage.onLoad.bind(ImpMessage)); \ No newline at end of file diff --git a/imp/js/src/message.js b/imp/js/src/message.js index 83269462b..2dbe9f0d6 100644 --- a/imp/js/src/message.js +++ b/imp/js/src/message.js @@ -1,126 +1,165 @@ /** - * 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)); diff --git a/imp/message.php b/imp/message.php index bdd2718f2..e61d17d14 100644 --- a/imp/message.php +++ b/imp/message.php @@ -728,7 +728,9 @@ Horde::addScriptFile('prototype.js', 'horde', true); Horde::addScriptFile('popup.js', 'imp', true); Horde::addScriptFile('message.js', 'imp', true); require IMP_TEMPLATES . '/common-header.inc'; -if (!IMP::$printMode) { +if (IMP::$printMode) { + IMP::addInlineScript('ImpMessage.printmode = true'); +} else { if (!empty($conf['maillog']['use_maillog'])) { IMP_Maillog::displayLog($envelope['message-id']); } @@ -757,8 +759,4 @@ if (!IMP::$printMode) { echo $n_template->fetch(IMP_TEMPLATES . '/message/navbar_navigate.html'); } -if ($browser->hasFeature('javascript') && IMP::$printMode) { - require $registry->get('templates', 'horde') . '/javascript/print.js'; -} - require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/imp/templates/message/message.html b/imp/templates/message/message.html index b2b641fad..2ed4b0a53 100644 --- a/imp/templates/message/message.html +++ b/imp/templates/message/message.html @@ -1,12 +1,12 @@
- +
- - - - + + + + -
: 
: 
+
diff --git a/imp/templates/message/navbar_navigate.html b/imp/templates/message/navbar_navigate.html index ede1cadcf..a1f7cfda6 100644 --- a/imp/templates/message/navbar_navigate.html +++ b/imp/templates/message/navbar_navigate.html @@ -1,10 +1,10 @@ - +
- +
- @@ -18,7 +18,7 @@ -
+
  • @@ -26,7 +26,7 @@
-
@@ -41,7 +41,7 @@
diff --git a/imp/themes/screen.css b/imp/themes/screen.css index efc8cfc2b..9b6944a03 100644 --- a/imp/themes/screen.css +++ b/imp/themes/screen.css @@ -121,6 +121,14 @@ ul.msgactions, ul.msgactions ul { border-top: 1px solid #999; } +table.msgActionTable, #fmanager table { + width: 100%; + border-collapse: collapse; +} +div.msgActions, #fmanager div.folderActions { + padding-left: 15px; +} + #msgheaders { clear: left; } @@ -145,16 +153,9 @@ form#search div { #fmanager div, #fmanager div input { vertical-align: middle; } -#fmanager table { - width: 100%; - border-collapse: collapse; -} #fmanager div.folderChoose { padding-left: 5px; } -#fmanager div.folderActions { - padding-left: 15px; -} /* Style for div that fixes KHTML browsers. */ .ohide { @@ -273,6 +274,10 @@ tr.deleted:hover, tr.deleted-over { background: #f00; } +table.msgheaders, td.msgheader { + width: 100%; +} + /* Pad the addressbook icon in header compose links. */ .msgheader img { vertical-align: middle; -- 2.11.0