[Koha-patches] [PATCH] Fix for Bug 7135: Save button options

Owen Leonard oleonard at myacpl.org
Thu Nov 3 19:58:11 CET 2011


This patch adds a jQuery plugin which will cause
an element to remain "fixed" at the top of the
screen if it would otherwise scroll up out of
view.

I submit this patch for TESTING ONLY because
the plugin was not posted with explicit licensing.
I'm waiting to hear back from the author.
---
 koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css  |    5 ++
 .../prog/en/lib/jquery/plugins/jquery.fixFloat.js  |   67 ++++++++++++++++++++
 .../prog/en/modules/cataloguing/addbiblio.tt       |    2 +
 3 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.fixFloat.js

diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css b/koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css
index 3cf2e88..d2489b3 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/addbiblio.css
@@ -144,4 +144,9 @@ a.tagnum {
 
 .yui-gf .yui-u {
 	width: 79.2%;
+}
+/* Class to be added to toolbar when it starts being fixed at the top of the screen*/
+.floating {
+	-webkit-box-shadow: 0px 3px 2px 0px rgba(0, 0, 0, .5);
+	box-shadow: 0px 3px 2px 0px rgba(0, 0, 0, .5);
 }
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.fixFloat.js b/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.fixFloat.js
new file mode 100644
index 0000000..9fb63e0
--- /dev/null
+++ b/koha-tmpl/intranet-tmpl/prog/en/lib/jquery/plugins/jquery.fixFloat.js
@@ -0,0 +1,67 @@
+/* Source: http://www.webspeaks.in/2011/07/new-gmail-like-floating-toolbar-jquery.html
+   Revision: http://jsfiddle.net/pasmalin/AyjeZ/
+*/
+(function($){
+  $.fn.fixFloat = function(options){
+
+    var defaults = {
+      enabled: true
+    };
+    var options = $.extend(defaults, options);
+
+    var offsetTop;    /**Distance of the element from the top of window**/
+    var s;        /**Scrolled distance from the top of window through which we have moved**/
+    var fixMe = true;
+    var repositionMe = true;
+
+    var tbh = $(this);
+    var originalOffset = tbh.position().top;  /**Get the actual distance of the element from the top mychange:change to position better work**/
+
+    if (tbh.css('position')!='absolute') {
+      var tbhBis = $("<div></div>");
+      tbhBis.css({"display":tbh.css("display"),"visibility":"hidden"});
+      tbhBis.width(tbh.outerWidth(true));
+      tbhBis.height(tbh.outerHeight(true));
+      tbh.after(tbhBis);
+      tbh.width(tbh.width());
+      tbh.css({'position':'absolute'});
+    }
+      tbh.css({'z-index':1000});
+
+    if(options.enabled){
+      $(window).scroll(function(){
+        var offsetTop = tbh.offset().top;  /**Get the current distance of the element from the top **/
+        var s = parseInt($(window).scrollTop(), 10);  /**Get the from the top of wondow through which we have scrolled**/
+        var fixMe = true;
+        if(s > offsetTop){
+          fixMe = true;
+        }else{
+          fixMe = false;
+        }
+
+        if(s < originalOffset){
+          repositionMe = true;
+        }else{
+          repositionMe = false;
+        }
+
+        if(fixMe){
+          var cssObj = {
+            'position' : 'fixed',
+            'top' : '0px'
+          }
+          tbh.css(cssObj);
+          tbh.addClass("floating");
+        }
+        if(repositionMe){
+          var cssObj = {
+            'position' : 'absolute',
+            'top' : originalOffset
+          }
+          tbh.css(cssObj);
+          tbh.removeClass("floating");
+        }
+      });
+    }
+  };
+})(jQuery);
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
index 65feefb..62f5d87 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt
@@ -2,6 +2,7 @@
 <title>Koha &rsaquo; Cataloging &rsaquo; [% IF ( biblionumber ) %]Editing [% title |html %] (Record Number [% biblionumber %])[% ELSE %]Add MARC Record[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <script type="text/javascript" src="[% themelang %]/lib/yui/plugins/bubbling-min.js"></script>
+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
 <script type="text/javascript">
 //<![CDATA[
 
@@ -709,6 +710,7 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
 	// prepare DOM for YUI Toolbar
 
 	 $(document).ready(function() {
+        $('#toolbar').fixFloat();
 		$("#z3950searchc").empty();
         $("#savebutton").empty();
 	    yuiToolbar();
-- 
1.7.3



More information about the Koha-patches mailing list