Bug 16400: Let's hack the fixFloat plugin to fix our needs

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>
(cherry picked from commit c1f101e86c)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
This commit is contained in:
Jonathan Druart 2016-04-29 19:01:10 +01:00 committed by Frédéric Demians
parent 2628fdd8c4
commit 7012121d08
2 changed files with 42 additions and 20 deletions

View File

@ -3,13 +3,16 @@
*/
(function ($, window) {
"use strict";
$.fn.fixFloat = function (options) {
var defaults = {
enabled: true
};
options = $.extend(defaults, options);
$.fn.fixFloat = function (options={}) {
var tbh = $(this);
var originalOffset = tbh.position().top;
var defaults = {
enabled: true,
originalOffset: tbh.position().top
};
var originalOffset = typeof options.originalOffset === 'undefined'
? defaults.originalOffset
: options.originalOffset;
options = $.extend(defaults, options);
if (tbh.css('position') !== 'absolute') {
var tbhBis = tbh.clone();

View 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>