]> git.parisson.com Git - telemeta.git/commitdiff
auto size admin iframe
authorGuillaume Pellerin <yomguy@parisson.com>
Thu, 11 Dec 2014 01:07:00 +0000 (02:07 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Thu, 11 Dec 2014 01:07:00 +0000 (02:07 +0100)
example/sandbox/settings.py
telemeta/static/telemeta/js/jquery.browser.js [new file with mode: 0644]
telemeta/static/telemeta/js/jquery.iframe-auto-height.plugin.1.9.5.min.js [new file with mode: 0644]
telemeta/templates/telemeta/admin.html
telemeta/templates/telemeta/admin_general.html

index 5817fcfdca1295597f3540d5672df5cca33f451e..6a9d79e062b52622e9b5b81ca05a0cba68b9e91e 100644 (file)
@@ -190,3 +190,7 @@ PAGINATION_SETTINGS = {
     'PAGE_RANGE_DISPLAYED': 10,
     'MARGIN_PAGES_DISPLAYED': 2,
 }
+
+SUIT_CONFIG = {
+    'ADMIN_NAME': 'Telemeta Admin'
+}
diff --git a/telemeta/static/telemeta/js/jquery.browser.js b/telemeta/static/telemeta/js/jquery.browser.js
new file mode 100644 (file)
index 0000000..c1acb86
--- /dev/null
@@ -0,0 +1,39 @@
+(function( jQuery ) {
+       var matched,
+               userAgent = navigator.userAgent || "";
+
+       // Use of jQuery.browser is frowned upon.
+       // More details: http://api.jquery.com/jQuery.browser
+       // jQuery.uaMatch maintained for back-compat
+       jQuery.uaMatch = function( ua ) {
+               ua = ua.toLowerCase();
+
+               var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
+                       /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
+                       /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) ||
+                       /(msie) ([\w.]+)/.exec( ua ) ||
+                       ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) ||
+                       [];
+
+               return {
+                       browser: match[ 1 ] || "",
+                       version: match[ 2 ] || "0"
+               };
+       };
+
+       matched = jQuery.uaMatch( userAgent );
+
+       jQuery.browser = {};
+
+       if ( matched.browser ) {
+               jQuery.browser[ matched.browser ] = true;
+               jQuery.browser.version = matched.version;
+       }
+
+       // Deprecated, use jQuery.browser.webkit instead
+       // Maintained for back-compat only
+       if ( jQuery.browser.webkit ) {
+               jQuery.browser.safari = true;
+       }
+
+}( jQuery ));
\ No newline at end of file
diff --git a/telemeta/static/telemeta/js/jquery.iframe-auto-height.plugin.1.9.5.min.js b/telemeta/static/telemeta/js/jquery.iframe-auto-height.plugin.1.9.5.min.js
new file mode 100644 (file)
index 0000000..871fc87
--- /dev/null
@@ -0,0 +1,7 @@
+/*
+  Plugin: iframe autoheight jQuery Plugin
+  Version: 1.9.5
+  Description: when the page loads set the height of an iframe based on the height of its contents
+  see README: http://github.com/house9/jquery-iframe-auto-height 
+*/
+!function(e){e.fn.iframeAutoHeight=function(t){function i(e){h.debug&&h.debug===!0&&window.console&&console.log(e)}function n(t,n){i("Diagnostics from '"+n+"'");try{i("  "+e(t,window.top.document).contents().find("body")[0].scrollHeight+" for ...find('body')[0].scrollHeight"),i("  "+e(t.contentWindow.document).height()+" for ...contentWindow.document).height()"),i("  "+e(t.contentWindow.document.body).height()+" for ...contentWindow.document.body).height()")}catch(r){i("  unable to check in this state")}i("End diagnostics -> results vary by browser and when diagnostics are requested")}var r;if(e.browser===r){var o=[];return o.push("WARNING: you appear to be using a newer version of jquery which does not support the $.browser variable."),o.push("The jQuery iframe auto height plugin relies heavly on the $.browser features."),o.push("Install jquery-browser: https://raw.github.com/house9/jquery-iframe-auto-height/master/release/jquery.browser.js"),alert(o.join("\n")),e}var h=e.extend({heightOffset:0,minHeight:0,maxHeight:0,callback:function(){},animate:!1,debug:!1,diagnostics:!1,resetToMinHeight:!1,triggerFunctions:[],heightCalculationOverrides:[]},t);return i(h),this.each(function(){function t(e){var t=null;return jQuery.each(o,function(i,n){return e[n]?(t=s[n],!1):void 0}),null===t&&(t=s["default"]),t}function r(r){h.diagnostics&&n(r,"resizeHeight"),h.resetToMinHeight&&h.resetToMinHeight===!0&&(r.style.height=h.minHeight+"px");var o=e(r,window.top.document).contents().find("body"),s=t(e.browser),a=s(r,o,h,e.browser);i(a),a<h.minHeight&&(i("new height is less than minHeight"),a=h.minHeight),h.maxHeight>0&&a>h.maxHeight&&(i("new height is greater than maxHeight"),a=h.maxHeight),a+=h.heightOffset,i("New Height: "+a),h.animate?e(r).animate({height:a+"px"},{duration:500}):r.style.height=a+"px",h.callback.apply(e(r),[{newFrameHeight:a}])}var o=["webkit","mozilla","msie","opera"],s={};s["default"]=function(e,t,i){return t[0].scrollHeight+i.heightOffset},jQuery.each(o,function(e,t){s[t]=s["default"]}),jQuery.each(h.heightCalculationOverrides,function(e,t){s[t.browser]=t.calculation});var a=0,c=this.contentDocument||this.contentWindow.document;if(i(this),h.diagnostics&&n(this,"each iframe"),h.triggerFunctions.length>0){i(h.triggerFunctions.length+" trigger Functions");for(var u=0;u<h.triggerFunctions.length;u++)h.triggerFunctions[u](r,this)}if(e.browser.webkit||e.browser.opera||e.browser.chrome){i("browser is webkit or opera"),e(this).load(function(){var e=0,t=this,n=function(){r(t)};0===a?e=500:t.style.height=h.minHeight+"px",i("load delay: "+e),setTimeout(n,e),a++});var g=e(this).attr("src");e(this).attr("src",""),e(this).attr("src",g)}else"complete"===c.readyState?r(this):e(this).load(function(){r(this)})})}}(jQuery);; 
\ No newline at end of file
index d9b1dd1b57c9fd413f9d1cc4a145395e08f50518..d71c90bb20e503066177e2e3dac8b8e13c655f84 100644 (file)
@@ -12,7 +12,7 @@
 {% endblock %}
 
  <li>{% trans "General" %}</a></li>
+
 {% block content %}
 
 <div class="tabcontents">
index c83baffe2aad94a3f917e49ea926016d713db5c5..f225bb404b4cef1888725e5f3da419c86781efe7 100644 (file)
@@ -1,10 +1,24 @@
 {% extends "telemeta/admin.html" %}
 {% load i18n %}
 
+{% block extra_javascript %}
+{{ block.super }}
+<script src="{{ STATIC_URL }}telemeta/js/jquery.iframe-auto-height.plugin.1.9.5.min.js" type="text/javascript"
+></script>
+<script src="{{ STATIC_URL }}telemeta/js/jquery.browser.js" type="text/javascript"></script>
+{% endblock %}
+
 {% block title %}
 <h1><img src="{{ STATIC_URL }}telemeta/images/admin_red.png" style="vertical-align:middle" /> {% trans "Administration" %} > {% trans "General" %}</h1>
 {% endblock %}
 
 {% block tabcontents %}
- <iframe align="middle" frameborder="0" width="100%" height="600px"  src="{% url "telemeta-home" %}admin/django/" />
+ <iframe align="middle" frameborder="0" width="100%" src="{% url "telemeta-home" %}admin/django/"></iframe>
+
+ <script type='text/javascript'>
+        $('iframe').iframeAutoHeight();
+ </script>
+
 {% endblock %}
+
+