Koha/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.fixFloat.js
Owen Leonard 84c3587d03 Bug 12116 - Move fixFloat jQuery plugin outside of language-specific directory
This patch moves the fixFloat jQuery plugin to
intranet-tmpl/prog/lib/jquery/plugins so that it will not be duplicated
for each set of translated templates.

This patch also includes a change to staff-global.css to override some
style the floating toolbar inherited when we added Bootstrap widgets.

To test, apply the patch and confirm that the toolbar "sticks" to the
top of the screen when scrolling down on the following pages:

- System preferences
- Authorities editor (Authorities -> New authority)
- Cataloging editor (Cataloging -> New record)
- List contents view (Lists -> View a list's contents)

Followed test plan. Patch behaves as expected.
Signed-off-by: Marc Veron <veron@veron.ch>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
2014-04-25 15:21:11 +00:00

68 lines
No EOL
2 KiB
JavaScript

/* 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'});
}
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',
'z-index' : '1000'
}
tbh.css(cssObj);
tbh.addClass("floating");
}
if(repositionMe){
var cssObj = {
'position' : 'absolute',
'top' : originalOffset,
'z-index' : '1'
}
tbh.css(cssObj);
tbh.removeClass("floating");
}
});
}
};
})(jQuery);