[Fusionforge-commits] FusionForge branch master updated. 5c780ba73809cabffead519dc038a2dfab25b2f0

Franck VILLAUME nerville at fusionforge.org
Sun Jan 12 17:18:48 CET 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  5c780ba73809cabffead519dc038a2dfab25b2f0 (commit)
      from  75ff72ead0cc7c6eac5f72077b7e2ea67cd92e12 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5c780ba73809cabffead519dc038a2dfab25b2f0
Author: Franck Villaume <franck.villaume at trivialdev.com>
Date:   Sun Jan 12 17:18:14 2014 +0100

    plugin scmgit: use the jQuery plugin auto height for iframe, no more multiple scrollbars!

diff --git a/src/etc/httpd.conf.d/vhost-main.inc b/src/etc/httpd.conf.d/vhost-main.inc
index cb049bf..be1297c 100644
--- a/src/etc/httpd.conf.d/vhost-main.inc
+++ b/src/etc/httpd.conf.d/vhost-main.inc
@@ -43,6 +43,7 @@ Alias /scripts/jquery-jqplot/ {core/source_path}/vendor/jquery-jqplot/
 Alias /scripts/jquery-teamwork-gantt/ {core/source_path}/vendor/jquery-teamwork-gantt/
 Alias /scripts/yui/ {core/source_path}/vendor/yui/build/
 Alias /scripts/jquery-splitter/ {core/source_path}/vendor/jquery-splitter/
+Alias /scripts/jquery-auto-height/ {core/source_path}/vendor/jquery-auto-height/
 
 # For FusionForge without DNS delegation, uncomment this
 # and remove 30-vhosts-projects.conf
diff --git a/src/plugins/scmgit/common/GitPlugin.class.php b/src/plugins/scmgit/common/GitPlugin.class.php
index 269258e..236805e 100644
--- a/src/plugins/scmgit/common/GitPlugin.class.php
+++ b/src/plugins/scmgit/common/GitPlugin.class.php
@@ -4,7 +4,7 @@
  *
  * Copyright 2009, Roland Mas
  * Copyright 2009, Mehdi Dogguy <mehdi at debian.org>
- * Copyright 2012-2013, Franck Villaume - TrivialDev
+ * Copyright 2012-2014, Franck Villaume - TrivialDev
  * Copyright © 2013
  *	Thorsten Glaser <t.glaser at tarent.de>
  * http://fusionforge.org
@@ -294,6 +294,7 @@ class GitPlugin extends SCMPlugin {
 	}
 
 	function printBrowserPage($params) {
+		global $HTML;
 		$project = $this->checkParams($params);
 		if (!$project) {
 			return;
@@ -303,11 +304,16 @@ class GitPlugin extends SCMPlugin {
 			if ($params['user_id']) {
 				$user = user_get_object($params['user_id']);
 				echo $project->getUnixName().'/users/'.$user->getUnixName();
-				print '<iframe src="'.util_make_url("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/users/'.$user->getUnixName().'.git').'" frameborder="0" width=100% height=700></iframe>';
+				print '<iframe id="scm_iframe" src="'.util_make_url("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/users/'.$user->getUnixName().'.git').'" frameborder="0" width=100% height=700></iframe>';
 			} elseif ($this->browserDisplayable($project)) {
-				print '<iframe src="'.util_make_url("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/'.$project->getUnixName().'.git').'" frameborder="0" width=100% height=700></iframe>';
+				print '<iframe id="scm_iframe" src="'.util_make_url("/plugins/scmgit/cgi-bin/gitweb.cgi?p=".$project->getUnixName().'/'.$project->getUnixName().'.git').'" frameborder="0" width=100% height=700></iframe>';
 			}
 		}
+		html_use_jqueryautoheight();
+		echo $HTML->getJavascripts();
+		echo '<script type="text/javascript">//<![CDATA[
+			jQuery(\'#scm_iframe\').iframeAutoHeight({heightOffset: 50});
+			//]]></script>';
 	}
 
 	function getBrowserLinkBlock($project) {
diff --git a/src/vendor/jquery-auto-height/jquery.iframe-auto-height.plugin.1.9.3.js b/src/vendor/jquery-auto-height/jquery.iframe-auto-height.plugin.1.9.3.js
new file mode 100644
index 0000000..974e0af
--- /dev/null
+++ b/src/vendor/jquery-auto-height/jquery.iframe-auto-height.plugin.1.9.3.js
@@ -0,0 +1,208 @@
+/*jslint white: true, indent: 2, onevar: false, browser: true, undef: true, nomen: false, eqeqeq: true, plusplus: false, bitwise: true, regexp: true, strict: false, newcap: true, immed: true */
+/*global window, console, jQuery, setTimeout */
+
+/*
+  Plugin: iframe autoheight jQuery Plugin
+  Version: 1.9.3
+  Author and Contributors
+  ========================================
+  NATHAN SMITH (http://sonspring.com/)
+  Jesse House (https://github.com/house9)
+  aaron manela (https://github.com/aaronmanela)
+  Hideki Abe (https://github.com/hideki-a)
+  Patrick Clark (https://github.com/hellopat)
+  ChristineP2 (https://github.com/ChristineP2)
+  Mmjavellana (https://github.com/Mmjavellana)
+  yiqing-95 (https://github.com/yiqing-95)
+  jcaspian (https://github.com/jcaspian)
+  adamjgray (https://github.com/adamjgray)
+  Jens Bissinger (https://github.com/dpree)
+
+  File: jquery.iframe-auto-height.plugin.js
+  Remarks: original code from http://sonspring.com/journal/jquery-iframe-sizing
+  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 ($) {
+  $.fn.iframeAutoHeight = function (spec) {
+
+    var undef;
+    if ($.browser === undef) {
+      var message = [];
+      message.push("WARNING: you appear to be using a newer version of jquery which does not support the $.browser variable.");
+      message.push("The jQuery iframe auto height plugin relies heavly on the $.browser features.");
+      message.push("Install jquery-browser: https://raw.github.com/house9/jquery-iframe-auto-height/master/release/jquery.browser.js");
+      alert(message.join("\n"));
+      return $;
+    }
+
+    // set default option values
+    var options = $.extend({
+        heightOffset: 0,
+        minHeight: 0,
+        callback: function (newHeight) {},
+        animate: false,
+        debug: false,
+        diagnostics: false, // used for development only
+        resetToMinHeight: false,
+        triggerFunctions: [],
+        heightCalculationOverrides: []
+      }, spec);
+
+    // logging
+    function debug(message) {
+      if (options.debug && options.debug === true && window.console) {
+        console.log(message);
+      }
+    }
+
+    // not used by production code
+    function showDiagnostics(iframe, calledFrom) {
+      debug("Diagnostics from '" + calledFrom + "'");
+      try {
+        debug("  " + $(iframe, window.top.document).contents().find('body')[0].scrollHeight + " for ...find('body')[0].scrollHeight");
+        debug("  " + $(iframe.contentWindow.document).height() + " for ...contentWindow.document).height()");
+        debug("  " + $(iframe.contentWindow.document.body).height() + " for ...contentWindow.document.body).height()");
+      } catch (ex) {
+        // ie fails when called during for each, ok later on
+        // probably not an issue if called in a document ready block
+        debug("  unable to check in this state");
+      }
+      debug("End diagnostics -> results vary by browser and when diagnostics are requested");
+    }
+
+    // show all option values
+    debug(options);
+
+    // ******************************************************
+    // iterate over the matched elements passed to the plugin ; return will make it chainable
+    return this.each(function () {
+
+      // ******************************************************
+      // http://api.jquery.com/jQuery.browser/
+      var strategyKeys = ['webkit', 'mozilla', 'msie', 'opera'];
+      var strategies = [];
+      strategies['default'] = function (iframe, $iframeBody, options, browser) {
+        // NOTE: this is how the plugin determines the iframe height, override if you need custom
+        return $iframeBody[0].scrollHeight + options.heightOffset;
+      };
+
+      jQuery.each(strategyKeys, function (index, value) {
+        // use the default strategy for all browsers, can be overridden if desired
+        strategies[value] = strategies['default'];
+      });
+
+      // override strategies if registered in options
+      jQuery.each(options.heightCalculationOverrides, function (index, value) {
+        strategies[value.browser] = value.calculation;
+      });
+
+      function findStrategy(browser) {
+        var strategy = null;
+
+        jQuery.each(strategyKeys, function (index, value) {
+          if (browser[value]) {
+            strategy = strategies[value];
+            return false;
+          }
+        });
+
+        if (strategy === null) {
+          strategy = strategies['default'];
+        }
+
+        return strategy;
+      }
+      // ******************************************************
+
+      // for use by webkit only
+      var loadCounter = 0;
+
+      // resizeHeight
+      function resizeHeight(iframe) {
+        if (options.diagnostics) {
+          showDiagnostics(iframe, "resizeHeight");
+        }
+
+        // set the iframe size to minHeight so it'll get smaller on resizes in FF and IE
+        if (options.resetToMinHeight && options.resetToMinHeight === true) {
+          iframe.style.height = options.minHeight + 'px';
+        }
+
+        // get the iframe body height and set inline style to that plus a little
+        var $body = $(iframe, window.top.document).contents().find('body');
+        var strategy = findStrategy($.browser);
+        var newHeight = strategy(iframe, $body, options, $.browser);
+        debug(newHeight);
+
+        if (newHeight < options.minHeight) {
+          debug("new height is less than minHeight");
+          newHeight = options.minHeight + options.heightOffset;
+        }
+
+        debug("New Height: " + newHeight);
+        if (options.animate) {
+          $(iframe).animate({height: newHeight + 'px'}, {duration: 500});
+        } else {
+          iframe.style.height = newHeight + 'px';
+        }
+
+        options.callback.apply($(iframe), [{newFrameHeight: newHeight}]);
+      } // END resizeHeight
+
+      // debug me
+      debug(this);
+      if (options.diagnostics) {
+        showDiagnostics(this, "each iframe");
+      }
+
+      // if trigger functions are registered, invoke them
+      if (options.triggerFunctions.length > 0) {
+        debug(options.triggerFunctions.length + " trigger Functions");
+        for (var i = 0; i < options.triggerFunctions.length; i++) {
+          options.triggerFunctions[i](resizeHeight, this);
+        }
+      }
+
+      // Check if browser is Webkit (Safari/Chrome) or Opera
+      if ($.browser.webkit || $.browser.opera) {
+        debug("browser is webkit or opera");
+
+        // Start timer when loaded.
+        $(this).load(function () {
+          var delay = 0;
+          var iframe = this;
+
+          var delayedResize = function () {
+            resizeHeight(iframe);
+          };
+
+          if (loadCounter === 0) {
+            // delay the first one
+            delay = 500;
+          } else {
+            // Reset iframe height to 0 to force new frame size to fit window properly
+            // this is only an issue when going from large to small iframe, not executed on page load
+            iframe.style.height = options.minHeight + 'px';
+          }
+
+          debug("load delay: " + delay);
+          setTimeout(delayedResize, delay);
+          loadCounter++;
+        });
+
+        // Safari and Opera need a kick-start.
+        var source = $(this).attr('src');
+        $(this).attr('src', '');
+        $(this).attr('src', source);
+      } else {
+        // For other browsers.
+        $(this).load(function () {
+          resizeHeight(this);
+        });
+      } // if browser
+
+    }); // $(this).each(function () {
+  }; // $.fn.iframeAutoHeight = function (options) {
+}(jQuery)); // (function ($) {
\ No newline at end of file
diff --git a/src/www/include/html.php b/src/www/include/html.php
index d3b3115..523d85c 100644
--- a/src/www/include/html.php
+++ b/src/www/include/html.php
@@ -525,6 +525,11 @@ function html_use_jquerysplitter() {
 	use_stylesheet('/scripts/jquery-splitter/css/jquery.splitter.css');
 }
 
+function html_use_jqueryautoheight() {
+	html_use_jquery();
+	use_javascript('/scripts/jquery-auto-height/jquery.iframe-auto-height.plugin.1.9.3.js');
+}
+
 /**
  * html_build_select_box_from_arrays() - Takes two arrays, with the first array being the "id" or value and the other
  * array being the text you want displayed.

-----------------------------------------------------------------------

Summary of changes:
 src/etc/httpd.conf.d/vhost-main.inc                |    1 +
 src/plugins/scmgit/common/GitPlugin.class.php      |   12 +-
 .../jquery.iframe-auto-height.plugin.1.9.3.js      |  208 ++++++++++++++++++++
 src/www/include/html.php                           |    5 +
 4 files changed, 223 insertions(+), 3 deletions(-)
 create mode 100644 src/vendor/jquery-auto-height/jquery.iframe-auto-height.plugin.1.9.3.js


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list