Remove global IMP print links and replace with part printing
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 21 Jan 2010 21:57:14 +0000 (14:57 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 3 Feb 2010 20:07:40 +0000 (13:07 -0700)
Resolves Ticket #8708.

17 files changed:
framework/Core/lib/Horde.php
horde/js/popup.js
imp/config/conf.xml
imp/js/DimpCore.js
imp/js/imp.js
imp/js/message.js
imp/lib/Contents.php
imp/lib/Views/ShowMessage.php
imp/message-dimp.php
imp/message.php
imp/templates/chunks/message.php
imp/templates/index/index-dimp.inc
imp/templates/message/navbar_actions.html
imp/themes/screen-dimp.css
imp/themes/screen.css
imp/themes/silver/screen-dimp.css
imp/themes/silver/screen.css

index 851c1cf..cab34ce 100644 (file)
@@ -2247,9 +2247,12 @@ HTML;
      *            DEFAULT: 650 px
      * 'menu' - (boolean) Show the browser menu in the popup window?
      *          DEFAULT: false
+     * 'onload' - (string) A JS function to call after the popup window is
+     *            fully loaded.
+     *            DEFAULT: None
      * 'params' - (array) Additional parameters to pass to the URL.
      *            DEFAULT: None
-     * 'urlencode' - (boolean) URL encode the json string
+     * 'urlencode' - (boolean) URL encode the json string?
      *               DEFAULT: No
      * 'width' - (integer) The width of the popup window.
      *           DEFAULT: 700 px
@@ -2278,14 +2281,17 @@ HTML;
         if (!empty($options['height'])) {
             $params->height = $options['height'];
         }
-        if (!empty($options['width'])) {
-            $params->width = $options['width'];
+        if (!empty($options['menu'])) {
+            $params->menu = 1;
+        }
+        if (!empty($options['onload'])) {
+            $params->onload = $options['onload'];
         }
         if (!empty($options['params'])) {
             $params->params = http_build_query(array_map('rawurlencode', $options['params']));
         }
-        if (!empty($options['menu'])) {
-            $params->menu = 1;
+        if (!empty($options['width'])) {
+            $params->width = $options['width'];
         }
 
         return 'Horde.popup(' . self::escapeJson($params, array('urlencode' => !empty($options['urlencode']))) . ');';
index 02890a9..4cbde20 100644 (file)
@@ -15,6 +15,7 @@ window.Horde = window.Horde || {};
  * @param object $opts   The following params:
  * 'height' - The height of the popup window. (Default: 650 px)
  * 'menu' - Show the browser menu in the popup? (Default: no)
+ * 'onload' - A function to call when the window is loaded. (Default: none)
  * 'params' - Any additional params to pass to the script. (Default: no args)
  * 'width' - The width of the popup window. (Default: 700 px)
  * 'url' - The URL to open in the popup window.
@@ -47,9 +48,14 @@ Horde.popup = function(opts)
     params.set('uniq', name);
 
     win = window.open(url + '?' + params.toQueryString(), name, 'menubar=' + menu + ',toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',left=0,top=0');
+
     if (!win) {
         alert(Horde.popup_block_text);
     } else {
+        if (opts.onload) {
+            opts.onload = eval(opts.onload);
+            win.onload = opts.onload.curry(win);
+        }
         if (Object.isUndefined(win.name)) {
             win.name = name;
         }
index 904d193..17d1a3d 100644 (file)
     <case name="false" desc="No" />
    </configswitch>
   </configsection>
-
-  <configsection name="print">
-   <configheader>Print Options</configheader>
-   <configboolean name="add_printedby" desc="Should we add a &quot;Printed
-   By&quot; header to the top of all printed messages?">false</configboolean>
-  </configsection>
  </configtab>
 
  <configtab name="compose" desc="Compose">
index 60c933b..3fca233 100644 (file)
@@ -398,10 +398,6 @@ var DimpCore = {
             id = elt.readAttribute('id');
 
             switch (id) {
-            case 'msg_print':
-                window.print();
-                break;
-
             case 'largeaddrspan_active':
                 tmp = elt.down();
                 if (!tmp.next().visible() ||
index 7ab3b41..5c968d1 100644 (file)
@@ -110,6 +110,12 @@ document.observe('dom:loaded', function() {
          }
     };
 
+    IMP.printWindow = function(win)
+    {
+        win.print();
+        win.close();
+    };
+
     // If menu is present, attach event handlers to folder switcher.
     var tmp = $('openfoldericon');
     if (tmp) {
index ac433ab..2872a45 100644 (file)
@@ -169,8 +169,6 @@ var ImpMessage = {
                     this.submit('spam_report');
                 } else if (elt.hasClassName('notspamAction')) {
                     this.submit('notspam_report');
-                } else if (elt.hasClassName('printAction')) {
-                    window.print();
                 }
             } else if (elt.hasClassName('unblockImageLink')) {
                 IMP.unblockImages(e);
index abf2854..b8b21bc 100644 (file)
@@ -24,7 +24,8 @@ class IMP_Contents
     const SUMMARY_DOWNLOAD_NOJS = 128;
     const SUMMARY_DOWNLOAD_ZIP = 256;
     const SUMMARY_IMAGE_SAVE = 512;
-    const SUMMARY_STRIP_LINK = 1024;
+    const SUMMARY_PRINT = 1024;
+    const SUMMARY_STRIP_LINK = 2048;
 
     /* Rendering mask entries. */
     const RENDER_FULL = 1;
@@ -601,6 +602,9 @@ class IMP_Contents
      * IMP_Contents::SUMMARY_IMAGE_SAVE
      *   Output: parts = 'img_save'
      *
+     * IMP_Contents::SUMMARY_PRINT
+     *   Output: parts = 'print'
+     *
      * IMP_Contents::SUMMARY_STRIP_LINK
      *   Output: parts = 'strip'
      * </pre>
@@ -696,6 +700,11 @@ class IMP_Contents
             $part['img_save'] = Horde::link('#', _("Save Image in Gallery"), 'saveImgAtc', null, Horde::popupJs(Horde::applicationUrl('saveimage.php'), array('params' => array('uid' => ($this->_uid . IMP::IDX_SEP . $this->_mailbox), 'id' => $id), 'height' => 200, 'width' => 450)) . 'return false;') . '</a>';
         }
 
+        /* Add print link? */
+        if ($mask && self::SUMMARY_PRINT) {
+            $part['print'] = $this->linkViewJS($mime_part, 'view_attach', '', array('css' => 'printAtc', 'onload' => 'IMP.printWindow', 'jstext' => _("Print"), 'params' => $param_array));
+        }
+
         /* Strip Attachment? Allow stripping of base parts other than the
          * base multipart and the base text (body) part. */
         if (($mask & self::SUMMARY_STRIP_LINK) &&
@@ -795,6 +804,8 @@ class IMP_Contents
      * <pre>
      * 'css' - (string) The CSS class to use.
      * 'jstext' - (string) The javascript link text.
+     * 'onload' - (string) A JS function to run when popup window is
+     *            fully loaded.
      * 'params' - (array) A list of any additional parameters that need to be
      *            passed to view.php. (key = name)
      * 'widget' - (boolean) If true use Horde::widget() to generate,
@@ -814,7 +825,7 @@ class IMP_Contents
             $options['jstext'] = sprintf(_("View %s"), $mime_part->getDescription(true));
         }
 
-        $url = Horde::popupJs(Horde::applicationUrl('view.php'), array('menu' => true, 'params' => $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array()), 'urlencode' => true)) . 'return false;';
+        $url = Horde::popupJs(Horde::applicationUrl('view.php'), array('menu' => true, 'onload' => empty($options['onload']) ? '' : $options['onload'], 'params' => $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array()), 'urlencode' => true)) . 'return false;';
 
         return empty($options['widget'])
             ? Horde::link('#', $options['jstext'], empty($options['css']) ? null : $options['css'], null, $url) . $text . '</a>'
index 1c0d4b1..88f09ca 100644 (file)
@@ -251,9 +251,10 @@ class IMP_Views_ShowMessage
             IMP_Contents::SUMMARY_ICON |
             IMP_Contents::SUMMARY_DESCRIP_LINK |
             IMP_Contents::SUMMARY_DOWNLOAD |
-            IMP_Contents::SUMMARY_DOWNLOAD_ZIP;
+            IMP_Contents::SUMMARY_DOWNLOAD_ZIP |
+            IMP_Contents::SUMMARY_PRINT;
 
-        $part_info = $part_info_display = array('icon', 'description', 'size', 'download', 'download_zip');
+        $part_info = $part_info_display = array('icon', 'description', 'size', 'download', 'download_zip', 'print');
 
         /* Do MDN processing now. */
         if ($imp_ui->MDNCheck($mailbox, $uid, $mime_headers)) {
index c4964ec..131f34a 100644 (file)
@@ -41,7 +41,8 @@ if (isset($show_msg_result['error'])) {
 
 $scripts = array(
     array('ContextSensitive.js', 'horde'),
-    array('fullmessage-dimp.js', 'imp')
+    array('fullmessage-dimp.js', 'imp'),
+    array('imp.js', 'imp')
 );
 
 $js_onload = $js_out = array();
index 55c36fe..a801bce 100644 (file)
@@ -528,8 +528,6 @@ if (!$disable_compose &&
 $imp_params = IMP::getIMPMboxParameters($imp_mbox['mailbox'], $uid, $mailbox_name);
 $a_template->set('save_as', Horde::widget(Horde::downloadUrl($subject, array_merge(array('actionID' => 'save_message'), $imp_params)), _("Save as"), 'widget', '', '', _("Sa_ve as"), 2));
 
-$a_template->set('print', Horde::widget('#', _("Print"), 'widget printAction', '', '', _("_Print"), true));
-
 if ($conf['spam']['reporting'] &&
     ($conf['spam']['spamfolder'] ||
      ($mailbox_name != IMP::folderPref($prefs->getValue('spam_folder'), true)))) {
@@ -576,7 +574,7 @@ foreach ($all_list_headers as $head => $val) {
 
 /* Determine the fields that will appear in the MIME info entries. */
 $part_info = $part_info_display = array('icon', 'description', 'size');
-$part_info_action = array('download', 'download_zip', 'img_save', 'strip');
+$part_info_action = array('download', 'download_zip', 'img_save', 'strip', 'print');
 
 $show_parts = Horde_Util::getFormData('show_parts', $prefs->getValue('parts_display'));
 $strip_atc = $prefs->getValue('strip_attachments');
@@ -588,7 +586,8 @@ $contents_mask = IMP_Contents::SUMMARY_BYTES |
     IMP_Contents::SUMMARY_DESCRIP_LINK |
     IMP_Contents::SUMMARY_DOWNLOAD |
     IMP_Contents::SUMMARY_DOWNLOAD_ZIP |
-    IMP_Contents::SUMMARY_IMAGE_SAVE;
+    IMP_Contents::SUMMARY_IMAGE_SAVE |
+    IMP_Contents::SUMMARY_PRINT;
 if (!$readonly && $strip_atc) {
     $contents_mask |= IMP_Contents::SUMMARY_STRIP_LINK;
 }
@@ -647,15 +646,6 @@ if (!empty($inlineout['atc_parts'])) {
     );
 }
 
-if (!empty($conf['print']['add_printedby'])) {
-    $hdrs[] = array(
-        'class' => 'printedby',
-        'name' => _("Printed By"),
-        'val' => $user_identity->getFullname() ? $user_identity->getFullname() : Horde_Auth::getAuth(),
-        'i' => (++$i % 2)
-    );
-}
-
 $m_template->set('headers', $hdrs);
 $m_template->set('msgtext', $mdntext . $inlineout['msgtext']);
 
index ee543f3..b0a4a8e 100644 (file)
    <div class="msgHeaders">
     <div id="msgHeaders">
      <div class="dimpOptions">
-      <div>
-       <span id="msg_print">
-        <span class="iconImg"></span>
-        <a><?php echo _("Print") ?></a>
-       </span>
-      </div>
 <?php if (!empty($conf['user']['allow_view_source'])): ?>
       <div>
        <span id="msg_view_source">
index 9da8d6b..bd2aceb 100644 (file)
@@ -236,12 +236,6 @@ function _simpleButton($id, $text, $image, $nodisplay = false)
            <a><?php echo _("Open in new window") ?></a>
           </span>
          </div>
-         <div>
-          <span id="msg_print">
-           <span class="iconImg"></span>
-           <a><?php echo _("Print") ?></a>
-          </span>
-         </div>
 <?php if (!empty($conf['user']['allow_view_source'])): ?>
          <div>
           <span id="msg_view_source">
index f31fe7e..1ee06f2 100644 (file)
@@ -32,7 +32,6 @@
     <if:view_source><li><tag:view_source /></li></if:view_source>
     <if:resume><li><tag:resume /></li></if:resume>
     <li><tag:save_as /></li>
-    <li><tag:print /></li>
 <if:readonly><else:readonly>
     <if:spam><li><tag:spam /></li></if:spam>
     <if:notspam><li><tag:notspam /></li></if:notspam>
index 1e06624..f73452e 100644 (file)
@@ -1021,9 +1021,6 @@ div.msgSubject span.treeImg {
     margin-left: 4px;
     margin-right: 0;
 }
-#msg_print span.iconImg {
-    background-image: url("graphics/print.png");
-}
 #quota span.iconImg {
     background-image: url("graphics/quotauncover.gif");
     width: 0;
@@ -1063,34 +1060,3 @@ span.readonlyImg {
 #Growler div.imp-forward, div.imp-redirect, span.imp-forward, span.imp-redirect {
     background-image: url("graphics/mail_forwarded.png");
 }
-
-
-/* Print CSS rules. */
-@media print {
-    #dimpmain {
-        position: relative;
-        left: 0 !important;
-        margin-left: 0;
-        top: 0;
-    }
-
-    #previewPane {
-        overflow: visible !important;
-    }
-
-    #msgSplitPane {
-        border: 0;
-    }
-
-    #msgHeaders, .dispaddrlist {
-        display: block !important;
-    }
-
-    #sidebar, #dimpmain_folder_top, #msgSplitPane .msglist, div.sbdiv, .splitBarVertSidebar, .splitBarHoriz, #toggleHeaders, #Growler, #GrowlerLog, #writemsg, .dimpActions, .dimpOptions {
-        display: none !important;
-    }
-
-    a.address {
-        padding: 0 !important;
-    }
-}
index ebd6268..f8913e2 100644 (file)
     margin-left: 3px;
 }
 
-/* Message view styling. */
-#msgheaders tr.printedby {
-    display: none;
-}
-
 /* Newmail alerts. */
 #newmail {
     padding: 1em;
@@ -597,7 +592,7 @@ div.mimeStatusMessage, div.mimePartInfo {
     border-color: #ffd0af;
 }
 
-.downloadAtc, .downloadZipAtc, .saveImgAtc, .closeImg, .deleteImg, .foldersImg, .searchuiImg, .reloadImg {
+.downloadAtc, .downloadZipAtc, .saveImgAtc, .printAtc, .closeImg, .deleteImg, .foldersImg, .searchuiImg, .reloadImg {
     display: -moz-inline-stack;
     display: inline-block;
     height: 16px;
@@ -616,6 +611,9 @@ div.mimeStatusMessage, div.mimePartInfo {
 .downloadZipAtc {
     background-image: url("graphics/mime/compressed.png");
 }
+.printAtc {
+    background-image: url("graphics/print.png");
+}
 .saveImgAtc {
     background-image: url("graphics/gallery.png");
 }
@@ -637,29 +635,3 @@ div.mimeStatusMessage, div.mimePartInfo {
 #itipconflicts tr.itipnearcollision {
     background-color: #ee0;
 }
-
-
-/* Print CSS rules. */
-@media print {
-    body {
-        background: #fff;
-    }
-
-    a, a:visited {
-        color: #000;
-    }
-
-    #msgheaders tr.printedby {
-        display: table-row !important;
-    }
-
-    .label {
-        min-width: 60px;
-        text-align: right;
-        font-weight: bold;
-    }
-
-    #msgHeadersColl, .context, .address img, .mimeStatusMessage, .largeaddrlist, #msgAtc, table.msgActionTable, #messages h1.header, table.navbaractions, td.msgheader img, tr.msgheaderParts, .downloadAtc, .downloadZipAtc {
-        display: none !important;
-    }
-}
index e4789fb..a27e755 100644 (file)
@@ -160,9 +160,6 @@ span.dimpactionDrafts {
 #msg_newwin span.iconImg, #msg_newwin_options span.iconImg {
     background-image: url("graphics/newwin.png");
 }
-#msg_print span.iconImg {
-    background-image: url("graphics/print.png");
-}
 
 #qsearch_icon {
     background-image: url("graphics/search.png");
index 7d43430..77064ac 100644 (file)
@@ -88,3 +88,7 @@ span.trashImg {
 .reloadImg {
     background-image: url("graphics/reload.png");
 }
+
+.printAtc {
+    background-image: url("graphics/print.png");
+}