/* * * Copyright (c) 2014-2018 Daniele Lenares (https://github.com/dnlnrs) * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. * * Version 1.1.3 * */ (function ($) { 'use strict'; /** * Animate the input object * * @param $obj * @param type * @param animation */ function do_animation($obj, type, animation) { if (type === 'show') { switch (animation) { case 'fade': $obj.fadeIn(); break; case 'slide': $obj.slideDown(); break; default: $obj.fadeIn(); } } else { switch (animation) { case 'fade': $obj.fadeOut(); break; case 'slide': $obj.slideUp(); break; default: $obj.fadeOut(); } } } /** * Bind click event * * @param $obj * @param speed */ function click_event($obj, speed) { var not_clicked = true; $obj.on('click', function () { if (not_clicked === true) { not_clicked = false; $('html, body').animate({scrollTop: 0}, speed, function () { not_clicked = true; }); } }); } $.goup = function (user_params) { /* Default Params */ var params = $.extend({ location: 'right', locationOffset: 20, bottomOffset: 10, containerSize: 40, containerRadius: 10, containerClass: 'goup-container', arrowClass: 'goup-arrow', alwaysVisible: false, trigger: 500, entryAnimation: 'fade', goupSpeed: 'slow', hideUnderWidth: 500, containerColor: '#42B983', arrowColor: '#fff', title: '', titleAsText: false, titleAsTextClass: 'goup-text', zIndex: 1 }, user_params); /* */ /* Parameters check */ if (params.location !== 'right' && params.location !== 'left') { params.location = 'right'; } if (params.locationOffset < 0) { params.locationOffset = 0; } if (params.bottomOffset < 0) { params.bottomOffset = 0; } if (params.containerSize < 20) { params.containerSize = 20; } if (params.containerRadius < 0) { params.containerRadius = 0; } if (params.trigger < 0) { params.trigger = 0; } if (params.hideUnderWidth < 0) { params.hideUnderWidth = 0; } var checkColor = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i; if (!checkColor.test(params.containerColor)) { params.containerColor = '#000'; } if (!checkColor.test(params.arrowColor)) { params.arrowColor = '#fff'; } if (params.title === '') { params.titleAsText = false; } if (isNaN(params.zIndex)) { params.zIndex = 1; } /* */ /* Create required elements */ var $body = $('body'); var $window = $(window); var $container = $('