changeset 1837:7bfcad341121

display svg objects with IE8
author Roger Haase <crosseyedpenguin@yahoo.com>
date Tue, 09 Oct 2012 13:50:06 -0700
parents 7f938234a924
children 581f3c92618e
files MoinMoin/converter/html_out.py MoinMoin/templates/base.html MoinMoin/templates/common.js MoinMoin/templates/forms.html MoinMoin/templates/index.html
diffstat 5 files changed, 33 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/html_out.py	Sun Oct 07 13:41:18 2012 -0700
+++ b/MoinMoin/converter/html_out.py	Tue Oct 09 13:50:06 2012 -0700
@@ -85,6 +85,7 @@
     visit_style = Attribute('style')
     visit_title = Attribute('title')
     visit_id = Attribute('id')
+    visit_type = Attribute('type') # IE8 needs <object... type="image/svg+xml" ...> to display svg images
 
     def __init__(self, element):
         self.element = element
@@ -349,6 +350,7 @@
             return "object"
 
     def visit_moinpage_object(self, elem):
+        # TODO: maybe IE8 would display transcluded external pages if we could do <object... type="text/html" ...>
         href = elem.get(xlink.href, None)
         attrib = {}
         mimetype = Type(_type=elem.get(moin_page.type_, 'application/x-nonexistent'))
--- a/MoinMoin/templates/base.html	Sun Oct 07 13:41:18 2012 -0700
+++ b/MoinMoin/templates/base.html	Tue Oct 09 13:50:06 2012 -0700
@@ -45,20 +45,7 @@
     {%- endif %}
     {% endblock %}
 
-    {% block head_scripts %}
-    <script src="{{ url_for('serve.files', name='jquery', filename='jquery.min.js') }}"></script>
-    <script src="{{ url_for('serve.files', name='svgweb', filename='svg.js') }}"></script>
-    <script src="{{ url_for('frontend.template', filename='common.js') }}"></script>
-    {{ scripts }}
-    <!--[if lt IE 9]>
-        {# TODO: use a local copy later #}
-        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
-    <![endif]-->
-    <!--[if lt IE 8]>
-        {# required to save user settings with IE7 and earlier #}
-        <script src="{{ url_for('serve.files', name='json_js', filename='json2.js') }}"></script>
-    <![endif]-->
-    {% endblock %}
+
 {% endblock %}
 </head>
 <body{% if body_onload %} onload="{{ body_onload }}"{% endif %} lang="{{ theme_supp.ui_lang }}" dir="{{ theme_supp.ui_dir }}">
@@ -72,5 +59,22 @@
 {% endblock %}
 </div>
 
+{% block body_scripts %} {# js before </body> reduces IE8 js errors related to svgweb #}
+    <!--[if IE 8]>
+        <script src="{{ url_for('serve.files', name='svgweb', filename='svg.js') }}"></script>
+    <![endif]-->
+    <script src="{{ url_for('serve.files', name='jquery', filename='jquery.min.js') }}"></script>
+    <script src="{{ url_for('frontend.template', filename='common.js') }}"></script>
+    {{ scripts }}
+    <!--[if lt IE 9]>
+        {# TODO: use a local copy later #}
+        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
+    <![endif]-->
+    <!--[if lt IE 8]>
+        {# required to save user settings with IE7 and earlier #}
+        <script src="{{ url_for('serve.files', name='json_js', filename='json2.js') }}"></script>
+    <![endif]-->
+{% endblock %}
+
 </body>
 </html>
--- a/MoinMoin/templates/common.js	Sun Oct 07 13:41:18 2012 -0700
+++ b/MoinMoin/templates/common.js	Tue Oct 09 13:50:06 2012 -0700
@@ -155,11 +155,11 @@
             if ($(elem).parent()[0].tagName === 'A') {
                 elem = $(elem).parent()[0];
             }
-            // wrap element, add UL and LR overlay siblings, and replace old elem with wrapped elem
-            $(wrapper).append($(elem).clone(true));
+            // insert wrapper after elem, append (move) elem, append overlays
+            $(elem).after(wrapper);
+            $(wrapper).append(elem);
             $(wrapper).append(overlayUL);
             $(wrapper).append(overlayLR);
-            $(elem).replaceWith(wrapper);
         }
     });
     // if an element was wrapped above, then make the Transclusions buttons visible
--- a/MoinMoin/templates/forms.html	Sun Oct 07 13:41:18 2012 -0700
+++ b/MoinMoin/templates/forms.html	Tue Oct 09 13:50:06 2012 -0700
@@ -207,7 +207,7 @@
   </dd>
 {% endmacro %}
 
-{% macro render_file_uploader(submit_url) %}
+{% macro render_file_uploader(submit_url) %} {# pages that use this macro must also use file_uploader_scripts macro below #}
     <div id="file_upload">
         <div class="upload-form">
         <form action="{{ submit_url }}" method="POST" enctype="multipart/form-data" class="upload_file">
@@ -230,6 +230,8 @@
             </tr>
         </table>
     </div>
+{% endmacro %}
+{% macro file_uploader_scripts() %}
     <link rel="stylesheet" href="{{ url_for('serve.files', name='jquery_file_upload', filename='jquery.fileupload-ui.css') }}">
     <script src="{{ url_for('serve.files', name='jquery_file_upload', filename='jquery.fileupload.js') }}"></script>
     <script src="{{ url_for('serve.files', name='jquery_file_upload', filename='jquery.fileupload-ui.js') }}"></script>
--- a/MoinMoin/templates/index.html	Sun Oct 07 13:41:18 2012 -0700
+++ b/MoinMoin/templates/index.html	Tue Oct 09 13:50:06 2012 -0700
@@ -7,11 +7,6 @@
     {% set title = _("Global Index") %}
 {% endif %}
 
-{% block head_scripts %}
-{{ super() }}
-    <script src="{{ url_for('frontend.template', filename='index_action.js') }}"></script>
-{% endblock %}
-
 {% block action_bars_inner %}
     <ul>
         {% if index %}
@@ -215,6 +210,12 @@
     {{ forms.render_file_uploader(submit_url) }}
     </div>
     <span class="moin-drag">{{ _("(Drag and drop multiple files to this white area to upload them.)") }}</span>
-    <script src="{{ url_for('static', filename='js/jfu.js') }}"></script>
     <div id="lightbox">&nbsp;</div>
 {% endblock %}
+
+{% block body_scripts %}
+{{ super() }}
+    <script src="{{ url_for('frontend.template', filename='index_action.js') }}"></script>
+    <script src="{{ url_for('static', filename='js/jfu.js') }}"></script>
+    {{ forms.file_uploader_scripts() }}
+{% endblock %}