Try to fix arrow bug with firefox
This commit is contained in:
parent
4b4d700f5e
commit
b8e5a9a79f
@ -3,20 +3,20 @@
|
|||||||
* Copyright (c) 2014 Daniele Lenares (https://github.com/Ryuk87)
|
* Copyright (c) 2014 Daniele Lenares (https://github.com/Ryuk87)
|
||||||
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||||
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||||
*
|
*
|
||||||
* Version 1.0.0
|
* Version 1.0.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
(function ( $ ) {
|
(function ( $ ) {
|
||||||
|
|
||||||
$.goup = function(user_params) {
|
$.goup = function(user_params) {
|
||||||
|
|
||||||
/* Default Params */
|
/* Default Params */
|
||||||
var params = $.extend({
|
var params = $.extend({
|
||||||
location : 'right',
|
location : 'right',
|
||||||
locationOffset : 20,
|
locationOffset : 20,
|
||||||
bottomOffset : 10,
|
bottomOffset : 10,
|
||||||
containerSize : 40,
|
containerSize : 44,
|
||||||
containerRadius : 10,
|
containerRadius : 10,
|
||||||
containerClass : 'goup-container',
|
containerClass : 'goup-container',
|
||||||
arrowClass : 'goup-arrow',
|
arrowClass : 'goup-arrow',
|
||||||
@ -32,26 +32,26 @@
|
|||||||
titleAsTextClass : 'goup-text'
|
titleAsTextClass : 'goup-text'
|
||||||
}, user_params);
|
}, user_params);
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
|
|
||||||
$('body').append('<div style="display:none" class="'+params.containerClass+'"></div>');
|
$('body').append('<div style="display:none" class="'+params.containerClass+'"></div>');
|
||||||
var container = $('.'+params.containerClass);
|
var container = $('.'+params.containerClass);
|
||||||
$(container).html('<div class="'+params.arrowClass+'"></div>');
|
$(container).html('<div class="'+params.arrowClass+'"></div>');
|
||||||
var arrow = $('.'+params.arrowClass);
|
var arrow = $('.'+params.arrowClass);
|
||||||
|
|
||||||
/* Parameters check */
|
/* Parameters check */
|
||||||
if (params.location != 'right' && params.location != 'left') {
|
if (params.location != 'right' && params.location != 'left') {
|
||||||
params.location = 'right';
|
params.location = 'right';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.locationOffset < 0) {
|
if (params.locationOffset < 0) {
|
||||||
params.locationOffset = 0;
|
params.locationOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.bottomOffset < 0) {
|
if (params.bottomOffset < 0) {
|
||||||
params.bottomOffset = 0;
|
params.bottomOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.containerSize < 20) {
|
if (params.containerSize < 20) {
|
||||||
params.containerSize = 20;
|
params.containerSize = 20;
|
||||||
}
|
}
|
||||||
@ -59,15 +59,15 @@
|
|||||||
if (params.containerRadius < 0) {
|
if (params.containerRadius < 0) {
|
||||||
params.containerRadius = 0;
|
params.containerRadius = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.trigger < 0) {
|
if (params.trigger < 0) {
|
||||||
params.trigger = 0;
|
params.trigger = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.hideUnderWidth < 0) {
|
if (params.hideUnderWidth < 0) {
|
||||||
params.hideUnderWidth = 0;
|
params.hideUnderWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var checkColor = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i;
|
var checkColor = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i;
|
||||||
if (!checkColor.test(params.containerColor)) {
|
if (!checkColor.test(params.containerColor)) {
|
||||||
params.containerColor = '#000';
|
params.containerColor = '#000';
|
||||||
@ -75,12 +75,12 @@
|
|||||||
if (!checkColor.test(params.arrowColor)) {
|
if (!checkColor.test(params.arrowColor)) {
|
||||||
params.arrowColor = '#fff';
|
params.arrowColor = '#fff';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.title === '') {
|
if (params.title === '') {
|
||||||
params.titleAsText = false;
|
params.titleAsText = false;
|
||||||
}
|
}
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
/* Container Style */
|
/* Container Style */
|
||||||
var containerStyle = {};
|
var containerStyle = {};
|
||||||
containerStyle = {
|
containerStyle = {
|
||||||
@ -93,7 +93,7 @@
|
|||||||
containerStyle['bottom'] = params.bottomOffset;
|
containerStyle['bottom'] = params.bottomOffset;
|
||||||
containerStyle[params.location] = params.locationOffset;
|
containerStyle[params.location] = params.locationOffset;
|
||||||
containerStyle['border-radius'] = params.containerRadius;
|
containerStyle['border-radius'] = params.containerRadius;
|
||||||
|
|
||||||
$(container).css(containerStyle);
|
$(container).css(containerStyle);
|
||||||
if (!params.titleAsText) {
|
if (!params.titleAsText) {
|
||||||
$(container).attr('title', params.title);
|
$(container).attr('title', params.title);
|
||||||
@ -109,9 +109,9 @@
|
|||||||
var containerNewBottom = $(textContainer).height() + 10;
|
var containerNewBottom = $(textContainer).height() + 10;
|
||||||
$(container).css('bottom', '+='+containerNewBottom+'px');
|
$(container).css('bottom', '+='+containerNewBottom+'px');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Arrow Style */
|
/* Arrow Style */
|
||||||
var arrowStyle = {};
|
var arrowStyle = {};
|
||||||
var borderSize = 0.25 * params.containerSize;
|
var borderSize = 0.25 * params.containerSize;
|
||||||
arrowStyle = {
|
arrowStyle = {
|
||||||
@ -121,13 +121,13 @@
|
|||||||
'padding-top' : Math.ceil(0.325 * params.containerSize),
|
'padding-top' : Math.ceil(0.325 * params.containerSize),
|
||||||
'border-style' : 'solid',
|
'border-style' : 'solid',
|
||||||
'border-width' : '0 '+borderSize+'px '+borderSize+'px '+borderSize+'px',
|
'border-width' : '0 '+borderSize+'px '+borderSize+'px '+borderSize+'px',
|
||||||
'border-color' : 'transparent transparent '+params.arrowColor+' transparent'
|
'border-color' : 'transparent transparent '+params.arrowColor+' transparent'
|
||||||
};
|
};
|
||||||
$(arrow).css(arrowStyle);
|
$(arrow).css(arrowStyle);
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* params.trigger Hide under a certain width */
|
/* params.trigger Hide under a certain width */
|
||||||
var isHidden = false;
|
var isHidden = false;
|
||||||
$(window).resize(function(){
|
$(window).resize(function(){
|
||||||
@ -148,8 +148,8 @@
|
|||||||
if (textContainer)
|
if (textContainer)
|
||||||
$(textContainer).hide();
|
$(textContainer).hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* params.trigger show event */
|
/* params.trigger show event */
|
||||||
if (!params.alwaysVisible) {
|
if (!params.alwaysVisible) {
|
||||||
$(window).scroll(function(){
|
$(window).scroll(function(){
|
||||||
@ -158,7 +158,7 @@
|
|||||||
if (textContainer)
|
if (textContainer)
|
||||||
do_animation($(textContainer), 'show', params.entryAnimation);
|
do_animation($(textContainer), 'show', params.entryAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($(window).scrollTop() < params.trigger && !isHidden) {
|
if ($(window).scrollTop() < params.trigger && !isHidden) {
|
||||||
do_animation($(container), 'hide', params.entryAnimation);
|
do_animation($(container), 'hide', params.entryAnimation);
|
||||||
if (textContainer)
|
if (textContainer)
|
||||||
@ -176,7 +176,7 @@
|
|||||||
if (textContainer)
|
if (textContainer)
|
||||||
do_animation($(textContainer), 'show', params.entryAnimation);
|
do_animation($(textContainer), 'show', params.entryAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Click event */
|
/* Click event */
|
||||||
var notClicked = true;
|
var notClicked = true;
|
||||||
$(container).add(textContainer).on('click', function(){
|
$(container).add(textContainer).on('click', function(){
|
||||||
@ -186,11 +186,11 @@
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Private function for the animation */
|
/* Private function for the animation */
|
||||||
function do_animation(obj, type, animation) {
|
function do_animation(obj, type, animation) {
|
||||||
if (type == 'show') {
|
if (type == 'show') {
|
||||||
@ -198,11 +198,11 @@
|
|||||||
case 'fade':
|
case 'fade':
|
||||||
obj.fadeIn();
|
obj.fadeIn();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'slide':
|
case 'slide':
|
||||||
obj.slideDown();
|
obj.slideDown();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
obj.fadeIn();
|
obj.fadeIn();
|
||||||
}
|
}
|
||||||
@ -211,15 +211,15 @@
|
|||||||
case 'fade':
|
case 'fade':
|
||||||
obj.fadeOut();
|
obj.fadeOut();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'slide':
|
case 'slide':
|
||||||
obj.slideUp();
|
obj.slideUp();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
obj.fadeOut();
|
obj.fadeOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}( jQuery ));
|
}( jQuery ));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user