From 2e79d8d539ebc1830553a49a8080d0356c9d9531 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 15 Apr 2014 13:11:00 -0400
Subject: [PATCH] Move more IE<9 specific code to legacy_browser

---
 program/js/common.js                      |   14 --------------
 plugins/legacy_browser/js/iehacks.js      |   20 ++++++++++++++++++++
 plugins/legacy_browser/legacy_browser.php |   19 +++++--------------
 3 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/plugins/legacy_browser/js/iehacks.js b/plugins/legacy_browser/js/iehacks.js
new file mode 100644
index 0000000..129ad60
--- /dev/null
+++ b/plugins/legacy_browser/js/iehacks.js
@@ -0,0 +1,20 @@
+
+// Make getElementById() case-sensitive on IE7
+document._getElementById = document.getElementById;
+document.getElementById = function(id) {
+  var i = 0, obj = document._getElementById(id);
+
+  if (obj && obj.id != id)
+    while ((obj = document.all[i]) && obj.id != id)
+      i++;
+
+  return obj;
+}
+
+// fix missing :last-child selectors
+$(document).ready(function() {
+  if (rcmail && rcmail.env.skin != 'classic')
+    $('ul.treelist ul').each(function(i, ul) {
+      $('li:last-child', ul).css('border-bottom', 0);
+  });
+});
diff --git a/plugins/legacy_browser/legacy_browser.php b/plugins/legacy_browser/legacy_browser.php
index c910d76..bdf831e 100644
--- a/plugins/legacy_browser/legacy_browser.php
+++ b/plugins/legacy_browser/legacy_browser.php
@@ -23,10 +23,12 @@
     function send_page($args)
     {
         // replace jQuery 2.x with 1.x
-        $ts = filemtime($this->home . '/js/jquery.min.js');
+        $ts1 = filemtime($this->home . '/js/jquery.min.js');
+        $ts2 = filemtime($this->home . '/js/iehacks.js');
         $args['content'] = preg_replace(
-            '|"program/js/jquery\.min\.js\?s=[0-9]+"|',
-            '"plugins/legacy_browser/js/jquery.min.js?s=' . $ts . '"',
+            '|<script src="program/js/jquery\.min\.js\?s=[0-9]+" type="text/javascript"></script>|',
+            '<script src="plugins/legacy_browser/js/jquery.min.js?s=' . $ts1 . '" type="text/javascript"></script>'."\n"
+            .'<script src="plugins/legacy_browser/js/iehacks.js?s=' . $ts2 . '" type="text/javascript"></script>',
             $args['content'], 1);
 
         return $args;
@@ -53,17 +55,6 @@
                     '<link rel="stylesheet" type="text/css" href="plugins/legacy_browser/larry/iehacks.css" />'
                 );
             }
-
-            // fix missing :last-child selectors
-            $rcube->output->add_footer(implode("\n", array(
-                '<script type="text/javascript">',
-                '$(document).ready(function() {',
-                '    $(\'ul.treelist ul\').each(function(i,ul) {',
-                '        $(\'li:last-child\', ul).css(\'border-bottom\', 0);',
-                '    });',
-                '});',
-                '</script>'
-            )));
         }
     }
 
diff --git a/program/js/common.js b/program/js/common.js
index ed9488b..3f82b6d 100644
--- a/program/js/common.js
+++ b/program/js/common.js
@@ -596,20 +596,6 @@
   };
 }
 
-// Make getElementById() case-sensitive on IE
-if (bw.ie) {
-  document._getElementById = document.getElementById;
-  document.getElementById = function(id) {
-    var i = 0, obj = document._getElementById(id);
-
-    if (obj && obj.id != id)
-      while ((obj = document.all[i]) && obj.id != id)
-        i++;
-
-    return obj;
-  }
-}
-
 // jQuery plugin to emulate HTML5 placeholder attributes on input elements
 jQuery.fn.placeholder = function(text) {
   return this.each(function() {

--
Gitblit v1.9.1