Bug 16400: Let's hack the fixFloat plugin to fix our needs
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 29 Apr 2016 18:01:10 +0000 (19:01 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 24 Jun 2016 13:34:44 +0000 (13:34 +0000)
On comment bug 11088 comment 2, Owen explained the problem with the
fixFloat toolbar. Since we have a hidden div, the plugin does not manage
to place the toolbar correctly.
In order to make it work, this patch adds some changes to the plugin to
add the ability to define our own offset.
When the div is extended (+, filteraction_on), the offset should be
updated to move the toolbar. Same when the div is folded (-,
filteraction_off)

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.fixFloat.js
koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt

index db0454c..fb9ffcf 100644 (file)
@@ -3,13 +3,16 @@
 */
 (function ($, window) {
     "use strict";
-    $.fn.fixFloat = function (options) {
+    $.fn.fixFloat = function (options={}) {
+        var tbh = $(this);
         var defaults = {
-            enabled: true
+            enabled: true,
+            originalOffset: tbh.position().top
         };
+        var originalOffset = typeof options.originalOffset === 'undefined'
+            ? defaults.originalOffset
+            : options.originalOffset;
         options = $.extend(defaults, options);
-        var tbh = $(this);
-        var originalOffset = tbh.position().top;
 
         if (tbh.css('position') !== 'absolute') {
             var tbhBis = tbh.clone();
index 12c1e83..9786cf3 100644 (file)
@@ -3,10 +3,26 @@
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Patrons &rsaquo; [% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])</title>
 [% INCLUDE 'doc-head-close.inc' %]
+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
 [% INCLUDE 'calendar.inc' %]
 <script type="text/javascript">
 //<![CDATA[
 $(document).ready(function() {
+
+        var original_offset = $("#toolbar").position().top;
+        var additional_height = $("#filters").height();
+        $('#toolbar').fixFloat({ 'originalOffset': original_offset - additional_height });
+        $("#filteraction_on").on("click", function(){
+            $(window).off('scroll');
+            $("#toolbar").css({ top: original_offset });
+            $('#toolbar').fixFloat({ 'originalOffset': original_offset });
+        });
+        $("#filteraction_off").on("click", function(){
+            $(window).off('scroll');
+            $("#toolbar").css({ top: original_offset - additional_height});
+            $('#toolbar').fixFloat({ 'originalOffset': original_offset - additional_height });
+        })
+
        [% IF categorycode %]
                update_category_code( "[% categorycode %]" );
        [% ELSE %]
@@ -163,6 +179,23 @@ $(document).ready(function() {
 [% END %]
 [% END %]
 [% END %]
+<div id="toolbar" class="btn-toolbar">
+[% UNLESS ( check_member ) %]
+    <div class="btn-group">
+        <button class="btn btn-small" id="saverecord" type="submit" name="save" onclick="return check_form_borrowers();"><i class="fa fa-save"></i> Save</button>
+    </div>
+    [% IF opadd %]
+            <a class="cancel" href="/cgi-bin/koha/members/member.pl">Cancel</a>
+            <div class="btn-group">
+                <a class="btn btn-small cancel" id="cancel" href="/cgi-bin/koha/members/member.pl">Cancel</a>
+            </div>
+       [% ELSE %]
+            <div class="btn-group">
+                <a class="btn btn-small cancel" id="cancel" href="/cgi-bin/koha/members/member.pl?borrowernumber=[% borrowernumber %]">Cancel</a>
+            </div>
+        [% END %]
+[% END %]
+</div>
 
 [% IF ( step_1 ) %]
 [%UNLESS notitle && nosurname && nofirstname && nodateofbirth && noinitials && noothernames &&nosex %]
@@ -1015,20 +1048,6 @@ $(document).ready(function() {
   </fieldset>
 [% END %] [% END %]
 
-<fieldset class="rows" id="floating-save">
-[% UNLESS ( check_member ) %]
-    <fieldset class="action">
-        <button type="submit" name="save" onclick="return check_form_borrowers();">
-            <i class="fa fa-save"></i> Save
-        </button>
-      [% IF ( opadd ) %]
-       <a class="cancel" href="/cgi-bin/koha/members/member.pl">Cancel</a>
-          [% ELSE %]
-         <a class="cancel" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">Cancel</a>
-          [% END %]
-    </fieldset>
-[% END %]
-</fieldset>
 </form>
   
 </div>