Move popup/unblockimages into imp.js.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 10 Feb 2009 04:36:51 +0000 (21:36 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 10 Feb 2009 04:46:03 +0000 (21:46 -0700)
19 files changed:
imp/folders.php
imp/index-dimp.php
imp/js/imp.js
imp/js/popup.js [deleted file]
imp/js/src/imp.js
imp/js/src/popup.js [deleted file]
imp/js/src/unblockImages.js [deleted file]
imp/js/unblockImages.js [deleted file]
imp/lib/IMP.php
imp/lib/Mime/Viewer/html.php
imp/lib/Mime/Viewer/smime.php
imp/mailbox.php
imp/message-dimp.php
imp/message.php
imp/pgp.php
imp/smime.php
imp/templates/javascript_defs.php
imp/templates/pgp/pgp.html
imp/templates/smime/smime.html

index 07af5bd..1edef3f 100644 (file)
@@ -510,7 +510,7 @@ if ($open_compose_window === false) {
     if (!isset($options)) {
         $options = array();
     }
-    Horde::addScriptFile('popup.js', 'imp', true);
+    Horde::addScriptFile('imp.js', 'imp', true);
     IMP::addInlineScript(IMP::popupIMPString('compose.php', array_merge(array('popup' => 1), $options, IMP::getComposeArgs())));
 }
 
index b634bc5..72522cb 100644 (file)
@@ -23,8 +23,7 @@ $scripts = array(
     array('redbox.js', 'horde', true),
     array('mailbox-dimp.js', 'imp', false),
     array('DimpSlider.js', 'imp', true),
-    array('unblockImages.js', 'imp', true),
-    array('popup.js', 'imp', true),
+    array('imp.js', 'imp', true),
     array('dialog.js', 'imp', true)
 );
 
index 2568d7f..5ca3bdf 100644 (file)
@@ -1 +1 @@
-if(!IMP){var IMP={}}IMP.menuFolderSubmit=function(a){var b=$("menuform");if((!this.menufolder_load||a)&&$F(b.down('SELECT[name="mailbox"]'))){this.menufolder_load=true;b.submit()}};document.observe("dom:loaded",function(){$("menuform").observe("change",IMP.menuFolderSubmit.bind(IMP));$("openfoldericon").down().observe("click",IMP.menuFolderSubmit.bind(IMP,true))});
\ No newline at end of file
+var IMP=window.IMP||{};IMP.menuFolderSubmit=function(a){var b=$("menuform");if((!this.menufolder_load||a)&&$F(b.down('SELECT[name="mailbox"]'))){this.menufolder_load=true;b.submit()}};IMP.popup=function(d,e,a,c){var f,g,h=$H(),b=new Date().getTime();a=Math.min(screen.height-75,a||500);e=Math.min(screen.width-75,e||600);f=d.indexOf("?");if(f!=-1){h=$H(d.toQueryParams());d=d.substring(0,f)}if(c){$H(c.toQueryParams()).each(function(i){h.set(i.key,unescape(i.value))})}h.set("uniq",b);g=window.open(d+"?"+h.toQueryString(),b,"toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width="+e+",height="+a+",left=0,top=0");if(!g){alert(IMP.text.popup_block)}else{if(Object.isUndefined(g.name)){g.name=b}if(Object.isUndefined(g.opener)){g.opener=self}g.focus()}};IMP.unblockImages=function(c,b){var a;if(!c){return true}$(c).select("[blocked]").each(function(d){var e=decodeURIComponent(d.readAttribute("blocked"));if(d.hasAttribute("src")){d.writeAttribute("src",e)}else{if(d.hasAttribute("background")){d.writeAttribute("background",e)}else{if(d.style.backgroundImage){d.setStyle({backgroundImage:"url("+e+")"})}}}});b=$(b);if(b){a=b.up();b.remove();if(!a.childElements().size()){a=a.up("TABLE.mimeStatusMessage");if(a){a.remove()}}}return false};document.observe("dom:loaded",function(){var a=$("menuform");if(a){a.observe("change",IMP.menuFolderSubmit.bind(IMP));$("openfoldericon").down().observe("click",IMP.menuFolderSubmit.bind(IMP,true))}});
\ No newline at end of file
diff --git a/imp/js/popup.js b/imp/js/popup.js
deleted file mode 100644 (file)
index 2949d5b..0000000
+++ /dev/null
@@ -1 +0,0 @@
-function popup_imp(d,e,a,c){var f,g,h=$H(),b=new Date().getTime();a=Math.min(screen.height-75,a||500);e=Math.min(screen.width-75,e||600);f=d.indexOf("?");if(f!=-1){h=$H(d.toQueryParams());d=d.substring(0,f)}if(c){$H(c.toQueryParams()).each(function(i){h.set(i.key,unescape(i.value))})}h.set("uniq",b);g=window.open(d+"?"+h.toQueryString(),b,"toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width="+e+",height="+a+",left=0,top=0");if(!g){alert(IMP.text.popup_block)}else{if(Object.isUndefined(g.name)){g.name=b}if(Object.isUndefined(g.opener)){g.opener=self}g.focus()}};
\ No newline at end of file
index 7f2b6d3..660d6df 100644 (file)
@@ -1,13 +1,11 @@
 /**
- * Provides basic IMP javascript.
+ * Provides basic IMP javascript functions.
  *
  * See the enclosed file COPYING for license information (GPL). If you
  * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  */
 
-if (!IMP) {
-    var IMP = {};
-}
+var IMP = window.IMP || {};
 
 IMP.menuFolderSubmit = function(clear)
 {
@@ -20,7 +18,94 @@ IMP.menuFolderSubmit = function(clear)
     }
 };
 
+/**
+ * Open a popup window.
+ *
+ * @param string $url      The URL to open in the popup window.
+ * @param integer $width   The width of the popup window. (Default: 600 px)
+ * @param integer $height  The height of the popup window. (Default: 500 px)
+ * @param string $args     Any additional args to pass to the script.
+ *                         (Default: no args)
+ */
+IMP.popup = function(url, width, height, args)
+{
+    var q, win,
+        params = $H(),
+        name = new Date().getTime();
+
+    height = Math.min(screen.height - 75, height || 500);
+    width = Math.min(screen.width - 75, width || 600);
+
+    q = url.indexOf('?');
+    if (q != -1) {
+        params = $H(url.toQueryParams());
+        url = url.substring(0, q);
+    }
+
+    if (args) {
+        $H(args.toQueryParams()).each(function(a) {
+            params.set(a.key, unescape(a.value));
+        });
+    }
+    params.set('uniq', name);
+
+    win = window.open(url + '?' + params.toQueryString(), name, 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',left=0,top=0');
+    if (!win) {
+        alert(IMP.text.popup_block);
+    } else {
+        if (Object.isUndefined(win.name)) {
+            win.name = name;
+        }
+        if (Object.isUndefined(win.opener)) {
+            win.opener = self;
+        }
+        win.focus();
+    }
+};
+
+/**
+ * Use DOM manipulation to un-block images that had been redirected.
+ */
+IMP.unblockImages = function(p, message)
+{
+    var tmp;
+
+    if (!p) {
+        return true;
+    }
+
+    $(p).select('[blocked]').each(function(elt) {
+        var src = decodeURIComponent(elt.readAttribute('blocked'));
+        if (elt.hasAttribute('src')) {
+            elt.writeAttribute('src', src);
+        } else if (elt.hasAttribute('background')) {
+            elt.writeAttribute('background', src);
+        } else if (elt.style.backgroundImage) {
+            elt.setStyle({ backgroundImage: 'url(' + src + ')' });
+        }
+    });
+
+    message = $(message);
+    if (message) {
+        tmp = message.up();
+        message.remove();
+        if (!tmp.childElements().size()) {
+            tmp = tmp.up('TABLE.mimeStatusMessage');
+            if (tmp) {
+                tmp.remove();
+            }
+        }
+    }
+
+    // On success return false to stop event propagation.
+    return false;
+};
+
 document.observe('dom:loaded', function() {
-    $('menuform').observe('change', IMP.menuFolderSubmit.bind(IMP));
-    $('openfoldericon').down().observe('click', IMP.menuFolderSubmit.bind(IMP, true));
+    // If menu is present, attach event handlers to folder switcher.
+    var tmp = $('menuform');
+    if (tmp) {
+        tmp.observe('change', IMP.menuFolderSubmit.bind(IMP));
+        $('openfoldericon').down().observe('click', IMP.menuFolderSubmit.bind(IMP, true));
+    }
 });
diff --git a/imp/js/src/popup.js b/imp/js/src/popup.js
deleted file mode 100644 (file)
index f6c37d2..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * IMP Popup JavaScript.
- *
- * Provides the javascript to open popup windows.
- * This file should be included via Horde::addScriptFile().
- * Requires prototypejs 1.6.0.2+
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- */
-
-/**
- * Open a popup window.
- *
- * @param string $url      The URL to open in the popup window.
- * @param integer $width   The width of the popup window. (Default: 600 px)
- * @param integer $height  The height of the popup window. (Default: 500 px)
- * @param string $args     Any additional args to pass to the script.
- *                         (Default: no args)
- */
-function popup_imp(url, width, height, args)
-{
-    var q, win,
-        params = $H(),
-        name = new Date().getTime();
-
-    height = Math.min(screen.height - 75, height || 500);
-    width = Math.min(screen.width - 75, width || 600);
-
-    q = url.indexOf('?');
-    if (q != -1) {
-        params = $H(url.toQueryParams());
-        url = url.substring(0, q);
-    }
-
-    if (args) {
-        $H(args.toQueryParams()).each(function(a) {
-            params.set(a.key, unescape(a.value));
-        });
-    }
-    params.set('uniq', name);
-
-    win = window.open(url + '?' + params.toQueryString(), name, 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',left=0,top=0');
-    if (!win) {
-        alert(IMP.text.popup_block);
-    } else {
-        if (Object.isUndefined(win.name)) {
-            win.name = name;
-        }
-        if (Object.isUndefined(win.opener)) {
-            win.opener = self;
-        }
-        win.focus();
-    }
-}
diff --git a/imp/js/src/unblockImages.js b/imp/js/src/unblockImages.js
deleted file mode 100644 (file)
index b04fecd..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Use DOM manipulation to un-block images that had been redirected.
- */
-
-var IMP = window.IMP || {};
-
-IMP.unblockImages = function(parent, message)
-{
-    var tmp;
-
-    if (!parent) {
-        return true;
-    }
-
-    $(parent).select('[blocked]').each(function(elt) {
-        var src = decodeURIComponent(elt.readAttribute('blocked'));
-        if (elt.hasAttribute('src')) {
-            elt.writeAttribute('src', src);
-        } else if (elt.hasAttribute('background')) {
-            elt.writeAttribute('background', src);
-        } else if (elt.style.backgroundImage) {
-            elt.setStyle({ backgroundImage: 'url(' + src + ')' });
-        }
-    });
-
-    message = $(message);
-    if (message) {
-        tmp = message.up();
-        message.remove();
-        if (!tmp.childElements().size()) {
-            tmp = tmp.up('TABLE.mimeStatusMessage');
-            if (tmp) {
-                tmp.remove();
-            }
-        }
-    }
-
-    // On success return false to stop event propagation.
-    return false;
-};
diff --git a/imp/js/unblockImages.js b/imp/js/unblockImages.js
deleted file mode 100644 (file)
index a2ef8a5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-var IMP=window.IMP||{};IMP.unblockImages=function(b,c){var a;if(!b){return true}$(b).select("[blocked]").each(function(d){var e=decodeURIComponent(d.readAttribute("blocked"));if(d.hasAttribute("src")){d.writeAttribute("src",e)}else{if(d.hasAttribute("background")){d.writeAttribute("background",e)}else{if(d.style.backgroundImage){d.setStyle({backgroundImage:"url("+e+")"})}}}});c=$(c);if(c){a=c.up();c.remove();if(!a.childElements().size()){a=a.up("TABLE.mimeStatusMessage");if(a){a.remove()}}}return false};
\ No newline at end of file
index e638295..4094b71 100644 (file)
@@ -419,7 +419,7 @@ class IMP
             $GLOBALS['prefs']->getValue('compose_popup') &&
             $GLOBALS['browser']->hasFeature('javascript')) {
             Horde::addScriptFile('prototype.js', 'horde', true);
-            Horde::addScriptFile('popup.js', 'imp', true);
+            Horde::addScriptFile('imp.js', 'imp', true);
             if (isset($args['to'])) {
                 $args['to'] = addcslashes($args['to'], '\\"');
             }
@@ -1339,7 +1339,7 @@ class IMP
     }
 
     /**
-     * Output the javascript needed to call the popup_imp JS function.
+     * Output the javascript needed to call the IMP popup JS function.
      *
      * @param string $url      The IMP page to load.
      * @param array $params    An array of paramters to pass to the URL.
@@ -1351,7 +1351,7 @@ class IMP
     static public function popupIMPString($url, $params = array(),
                                           $width = 700, $height = 650)
     {
-        return "popup_imp('" . Horde::applicationUrl($url) . "'," . $width . "," . $height . ",'" . $GLOBALS['browser']->escapeJSCode(str_replace('+', '%20', substr(Util::addParameter('', $params, null, false), 1))) . "');";
+        return "IMP.popup('" . Horde::applicationUrl($url) . "'," . $width . "," . $height . ",'" . $GLOBALS['browser']->escapeJSCode(str_replace('+', '%20', substr(Util::addParameter('', $params, null, false), 1))) . "');";
     }
 
     /**
index d0f2278..bf01cd2 100644 (file)
@@ -219,7 +219,7 @@ class IMP_Horde_Mime_Viewer_html extends Horde_Mime_Viewer_html
 
             if (!$view_img && !$addr_check) {
                 $data .= Util::bufferOutput(array('Horde', 'addScriptFile'), 'prototype.js', 'horde', true) .
-                    Util::bufferOutput(array('Horde', 'addScriptFile'), 'unblockImages.js', 'imp', true);
+                    Util::bufferOutput(array('Horde', 'addScriptFile'), 'imp.js', 'imp', true);
 
                 $cleanhtml['status'][] = array(
                     'icon' => Horde::img('mime/image.png'),
index a20c859..df9f7a7 100644 (file)
@@ -72,7 +72,7 @@ class IMP_Horde_Mime_Viewer_smime extends Horde_Mime_Viewer_Driver
             /* We need to insert JavaScript code now if S/MIME support is
              * active. */
             Horde::addScriptFile('prototype.js', 'horde', true);
-            Horde::addScriptFile('popup.js', 'imp', true);
+            Horde::addScriptFile('imp.js', 'imp', true);
         }
 
         switch ($this->_mimepart->getType()) {
index 3ed7868..f15d372 100644 (file)
@@ -413,7 +413,7 @@ if ($open_compose_window === false) {
     if (!isset($options)) {
         $options = array();
     }
-    Horde::addScriptFile('popup.js', 'imp', true);
+    Horde::addScriptFile('imp.js', 'imp', true);
     $notification->push(IMP::popupIMPString('compose.php', array_merge(array('popup' => 1), $options, IMP::getComposeArgs())), 'javascript');
 }
 
index f027625..111ecd1 100644 (file)
@@ -71,8 +71,7 @@ $scripts = array(
     array('ContextSensitive.js', 'imp', true),
     array('fullmessage-dimp.js', 'imp', true),
     array('compose-dimp.js', 'imp', true),
-    array('unblockImages.js', 'imp', true),
-    array('popup.js', 'imp', true)
+    array('imp.js', 'imp', true)
 );
 
 DIMP::header($show_msg_result['subject'], $scripts);
index e61d17d..5981762 100644 (file)
@@ -725,7 +725,7 @@ $m_template->set('msgtext', $msgtext);
 
 /* Output message page now. */
 Horde::addScriptFile('prototype.js', 'horde', true);
-Horde::addScriptFile('popup.js', 'imp', true);
+Horde::addScriptFile('imp.js', 'imp', true);
 Horde::addScriptFile('message.js', 'imp', true);
 require IMP_TEMPLATES . '/common-header.inc';
 if (IMP::$printMode) {
index ce20f9e..3076ea5 100644 (file)
@@ -288,7 +288,7 @@ $t = new IMP_Template();
 $t->setOption('gettext', true);
 if ($prefs->getValue('use_pgp')) {
     Horde::addScriptFile('prototype.js', 'horde', true);
-    Horde::addScriptFile('popup.js', 'imp', true);
+    Horde::addScriptFile('imp.js', 'imp', true);
     $t->set('pgpactive', true);
     $t->set('overview-help', Help::link('imp', 'pgp-overview'));
     $t->set('attach_pubkey_notlocked', !$prefs->isLocked('pgp_attach_pubkey'));
index 26f1ec2..07ca108 100644 (file)
@@ -232,7 +232,7 @@ $t = new IMP_Template();
 $t->setOption('gettext', true);
 $t->set('use_smime_help', Help::link('imp', 'smime-overview'));
 if (!is_a($openssl_check, 'PEAR_Error') && $prefs->getValue('use_smime')) {
-    Horde::addScriptFile('popup.js', 'imp', true);
+    Horde::addScriptFile('imp.js', 'imp', true);
     $t->set('smimeactive', true);
     $t->set('manage_pubkey-help', Help::link('imp', 'smime-manage-pubkey'));
 
index d0cf3df..a9d67e8 100644 (file)
@@ -59,7 +59,7 @@ $code = array(
         /* Strings used in search.js */
         'search_select' => _("Please select at least one folder to search."),
 
-        /* Strings used in popup.js */
+        /* Strings used in imp.js */
         'popup_block' => _("A popup window could not be opened. Perhaps you have set your browser to block popup windows?"),
 
         /* Strings used in login.js */
index d0cd060..acef4c2 100644 (file)
@@ -52,7 +52,7 @@
 <if:no_source>
  <br /><em><gettext>Key import is not available. You have no address book defined to add your contacts.</gettext></em><br />
 <else:no_source>
- <br /><input type="submit" name="save" class="button" onclick="popup_imp('<tag:public_import_url />',750,275); return false;" value="<gettext>Import Public Key</gettext>" />
+ <br /><input type="submit" name="save" class="button" onclick="IMP.popup('<tag:public_import_url />',750,275); return false;" value="<gettext>Import Public Key</gettext>" />
  <tag:import_pubkey-help />
 </else:no_source></if:no_source></else:no_file_upload></if:no_file_upload>
 </div>
  <p>
   <input type="submit" name="save" class="button" onclick="if (confirm('<tag:keygen />')) { document.prefs.actionID.value='generate_key';return true; } else { return false; }" value="<gettext>Create Keys</gettext>" />
 <if:no_file_upload><else:no_file_upload>
-  <input type="submit" name="save" class="button" onclick="popup_imp('<tag:personal_import_url />',750,275);return false;" value="<gettext>Import Keypair</gettext>" />
+  <input type="submit" name="save" class="button" onclick="IMP.popup('<tag:personal_import_url />',750,275);return false;" value="<gettext>Import Keypair</gettext>" />
 </else:no_file_upload></if:no_file_upload>
   <tag:personalkey-create-actions-help />
 </p>
index 4b0317d..9cc83d6 100644 (file)
@@ -44,7 +44,7 @@
 <if:no_source>
  <em><gettext>Key import is not available. You have no address book defined to add your contacts.</gettext></em>
 <else:no_source>
- <p><input type="submit" name="save" class="button" onclick="popup_imp('<tag:public_import_url />',750,275); return false;" value="<gettext>Import Public Key</gettext>" />
+ <p><input type="submit" name="save" class="button" onclick="IMP.popup('<tag:public_import_url />',750,275); return false;" value="<gettext>Import Public Key</gettext>" />
  <tag:import_pubkey-help /></p>
 </else:no_source></if:no_source></else:no_file_upload></if:no_file_upload>
 </div>
@@ -78,7 +78,7 @@
 <if:no_file_upload>
  <em style="color:red"><gettext>Certificate import is not available. File upload is not enabled on this server.</gettext></em>
 <else:no_file_upload>
- <p><input type="submit" name="save" class="button" onclick="popup_imp('<tag:personal_import_url />',750,275);return false;" value="<gettext>Import Keypair</gettext>" /> <tag:import-cert-help /></p>
+ <p><input type="submit" name="save" class="button" onclick="IMP.popup('<tag:personal_import_url />',750,275);return false;" value="<gettext>Import Keypair</gettext>" /> <tag:import-cert-help /></p>
 </else:no_file_upload></if:no_file_upload>
 </else:has_key></if:has_key></else:secure_check></if:secure_check>
 <else:smimeactive>