mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-01 14:07:54 +01:00
Cleaned up sb-admin-2.js code
- Removed redundant for-i loops for readability - Renamed some variables to be easier to read. - Removed jquery-easing - Removed sb-admin-2.min.js (not up to date) - Fixed an issue with network/server plugins-overview tab id with no data. - Fixed an issue with player plugins tab id with no data. Affects issues: - Fixed #1409
This commit is contained in:
parent
053e497fb5
commit
fa8e8673b0
@ -170,7 +170,6 @@ public class NetworkPageExporter extends FileExporter {
|
||||
"./css/style.css",
|
||||
"./vendor/jquery/jquery.min.js",
|
||||
"./vendor/bootstrap/js/bootstrap.bundle.min.js",
|
||||
"./vendor/jquery-easing/jquery.easing.min.js",
|
||||
"./vendor/datatables/jquery.dataTables.min.js",
|
||||
"./vendor/datatables/dataTables.bootstrap4.min.js",
|
||||
"./vendor/highcharts/highstock.js",
|
||||
|
@ -143,7 +143,6 @@ public class PlayerPageExporter extends FileExporter {
|
||||
"../css/style.css",
|
||||
"../vendor/jquery/jquery.min.js",
|
||||
"../vendor/bootstrap/js/bootstrap.bundle.min.js",
|
||||
"../vendor/jquery-easing/jquery.easing.min.js",
|
||||
"../vendor/datatables/jquery.dataTables.min.js",
|
||||
"../vendor/datatables/dataTables.bootstrap4.min.js",
|
||||
"../vendor/highcharts/highstock.js",
|
||||
|
@ -132,7 +132,6 @@ public class PlayersPageExporter extends FileExporter {
|
||||
"css/style.css",
|
||||
"vendor/jquery/jquery.min.js",
|
||||
"vendor/bootstrap/js/bootstrap.bundle.min.js",
|
||||
"vendor/jquery-easing/jquery.easing.min.js",
|
||||
"vendor/datatables/jquery.dataTables.min.js",
|
||||
"vendor/datatables/dataTables.bootstrap4.min.js",
|
||||
"vendor/fontawesome-free/css/all.min.css",
|
||||
|
@ -182,7 +182,6 @@ public class ServerPageExporter extends FileExporter {
|
||||
"../css/style.css",
|
||||
"../vendor/jquery/jquery.min.js",
|
||||
"../vendor/bootstrap/js/bootstrap.bundle.min.js",
|
||||
"../vendor/jquery-easing/jquery.easing.min.js",
|
||||
"../vendor/datatables/jquery.dataTables.min.js",
|
||||
"../vendor/datatables/dataTables.bootstrap4.min.js",
|
||||
"../vendor/highcharts/highstock.js",
|
||||
|
@ -85,7 +85,7 @@ public class PlayerPluginTab implements Comparable<PlayerPluginTab> {
|
||||
|
||||
private void generate() {
|
||||
if (playerData.isEmpty()) {
|
||||
nav = NavLink.collapsed(Icon.called("cubes").build(), "plugins-" + serverName, serverName + " (No Data)").toHtml();
|
||||
nav = NavLink.collapsed(Icon.called("cubes").build(), "plugins-" + serverName + " (No Data)", serverName + " (No Data)").toHtml();
|
||||
tab = wrapInWideTab(
|
||||
serverName + " (No Data)",
|
||||
"<div class=\"card\"><div class=\"card-body\"><p>No Extension Data</p></div></div>"
|
||||
|
@ -89,7 +89,7 @@ public class ServerPluginTabs {
|
||||
if (serverData.isEmpty()) {
|
||||
nav = new StringBuilder(NavLink.main(Icon.called("cubes").build(), tabID, "Overview (No Data)").toHtml());
|
||||
tab = wrapInWideColumnTab(
|
||||
tabID, "<div class=\"card\"><div class=\"card-body\"><p>No Extension Data</p></div></div>"
|
||||
"overview", "<div class=\"card\"><div class=\"card-body\"><p>No Extension Data</p></div></div>"
|
||||
);
|
||||
} else {
|
||||
nav = new StringBuilder(NavLink.main(Icon.called("cubes").build(), tabID, "Overview").toHtml());
|
||||
|
@ -241,9 +241,6 @@
|
||||
<script src="vendor/jquery/jquery.min.js"></script>
|
||||
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Core plugin JavaScript-->
|
||||
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
|
||||
|
||||
<!-- Custom scripts for all pages-->
|
||||
<script src="js/sb-admin-2.js"></script>
|
||||
<script src="js/color-selector.js"></script>
|
||||
|
@ -1,147 +1,116 @@
|
||||
function openTab(i) {
|
||||
var x = document.getElementById("content");
|
||||
var navButtons = document.getElementsByClassName("nav-button");
|
||||
var max = navButtons.length;
|
||||
for (var j = 0; j < max; j++) {
|
||||
if (navButtons[j].classList.contains('active')) {
|
||||
navButtons[j].classList.remove('active');
|
||||
}
|
||||
if (j === i) {
|
||||
navButtons[j].classList.add('active');
|
||||
const content = document.getElementById("content");
|
||||
const navButtons = Array.from(document.getElementsByClassName("nav-button"));
|
||||
const tabs = Array.from(document.getElementsByClassName("tab")).filter(tab => tab.id);
|
||||
const tabCount = tabs.length;
|
||||
|
||||
function openTab(openIndex) {
|
||||
for (let navButton of navButtons) {
|
||||
if (navButton.classList.contains('active')) {
|
||||
navButton.classList.remove('active');
|
||||
}
|
||||
}
|
||||
var percent = -100 / navButtons.length;
|
||||
slideIndex = i;
|
||||
if (slideIndex > max) {
|
||||
slideIndex = 0
|
||||
}
|
||||
if (slideIndex < 0) {
|
||||
slideIndex = max
|
||||
}
|
||||
window.scrollTo(0, 0);
|
||||
var value = slideIndex * percent;
|
||||
x.style.transition = "0.5s";
|
||||
x.style.transform = "translate3d(" + value + "%,0px,0)";
|
||||
|
||||
const outOfRange = openIndex < 0 || tabCount < openIndex;
|
||||
const slideIndex = outOfRange ? 0 : openIndex;
|
||||
|
||||
navButtons[slideIndex].classList.add('active');
|
||||
|
||||
window.scrollTo(0, 0); // Scroll to top
|
||||
const tabWidthPercent = -100 / tabCount;
|
||||
const verticalScrollPercent = slideIndex * tabWidthPercent;
|
||||
content.style.transition = "0.5s";
|
||||
content.style.transform = "translate3d(" + verticalScrollPercent + "%,0px,0)";
|
||||
}
|
||||
|
||||
function openPage() {
|
||||
var params = (window.location.hash.substr(5)).split("&");
|
||||
// substr removes tab- from the id
|
||||
const uriHash = (window.location.hash.substr(5)).split("&").filter(part => part);
|
||||
|
||||
if (!params.length) {
|
||||
if (!uriHash.length) {
|
||||
openTab(0);
|
||||
return;
|
||||
}
|
||||
// window.sessionStorage.setItem("server_slide_index", slideIndex);
|
||||
|
||||
var tabID = params[0];
|
||||
var button = $('.nav-button[href="#' + tabID + '"]');
|
||||
const tabId = uriHash[0];
|
||||
const openIndex = tabs.map(tab => tab.id).indexOf(tabId);
|
||||
openTab(openIndex);
|
||||
|
||||
var tabs = document.getElementsByClassName("tab");
|
||||
for (var i = 0; i < tabs.length; i++) {
|
||||
if (tabs[i].id === tabID) openTab(i);
|
||||
if (uriHash.length > 1) {
|
||||
const bootstrapTabId = uriHash[1];
|
||||
$('a[href="#' + bootstrapTabId + '"]').tab('show');
|
||||
}
|
||||
}
|
||||
|
||||
if (params.length <= 1) {
|
||||
// Prepare tabs for display
|
||||
content.style.transform = "translate3d(0px,0px,0)";
|
||||
content.style.width = (tabCount * 100) + "%";
|
||||
content.style.opacity = "1";
|
||||
for (let tab of tabs) {
|
||||
tab.style.width = (100 / tabCount) + "%";
|
||||
}
|
||||
|
||||
window.addEventListener('hashchange', openPage);
|
||||
|
||||
// Persistent Bootstrap tabs
|
||||
$('.nav-tabs a.nav-link').click(event => {
|
||||
const uriHash = (window.location.hash).split("&");
|
||||
if (!uriHash) return;
|
||||
const currentTab = uriHash[0];
|
||||
const originalTargetId = event.target.href.split('#')[1];
|
||||
window.location.hash = currentTab + '&' + originalTargetId;
|
||||
});
|
||||
|
||||
let oldWidth = null;
|
||||
|
||||
function reduceSidebar() {
|
||||
const newWidth = $(window).width();
|
||||
if (oldWidth && oldWidth === newWidth) {
|
||||
return;
|
||||
}
|
||||
|
||||
var graphTabID = params[1];
|
||||
$('a[href="#' + graphTabID + '"]').tab('show');
|
||||
const $sidebar = $('.sidebar');
|
||||
const closeModal = $('.sidebar-close-modal');
|
||||
if ($(window).width() < 1350) {
|
||||
if (!$sidebar.hasClass('hidden')) $sidebar.addClass('hidden');
|
||||
if (!closeModal.hasClass('hidden')) closeModal.addClass('hidden');
|
||||
|
||||
// Close any open menu accordions when window is resized
|
||||
$('.sidebar .collapse').collapse('hide');
|
||||
} else if ($(window).width() > 1400 && $sidebar.hasClass('hidden')) {
|
||||
$sidebar.removeClass('hidden');
|
||||
if (!closeModal.hasClass('hidden')) closeModal.addClass('hidden');
|
||||
}
|
||||
oldWidth = newWidth;
|
||||
}
|
||||
|
||||
(function ($) {
|
||||
"use strict"; // Start of use strict
|
||||
reduceSidebar();
|
||||
$(window).resize(reduceSidebar);
|
||||
|
||||
var x = document.getElementById("content");
|
||||
// Prepare tabs for display
|
||||
var navButtons = document.getElementsByClassName("nav-button");
|
||||
var tabs = document.getElementsByClassName("tab");
|
||||
x.style.transform = "translate3d(0px,0px,0)";
|
||||
x.style.width = "" + navButtons.length * 100 + "%";
|
||||
for (var i = 0; i < navButtons.length; i++) {
|
||||
tabs[i].style.width = "" + 100 / navButtons.length + "%";
|
||||
function toggleSidebar() {
|
||||
$('.sidebar').toggleClass('hidden');
|
||||
$('.sidebar .collapse').collapse('hide');
|
||||
|
||||
const closeModal = $('.sidebar-close-modal');
|
||||
if ($(window).width() < 900) {
|
||||
closeModal.toggleClass('hidden');
|
||||
} else {
|
||||
if (!closeModal.hasClass('hidden')) closeModal.addClass('hidden');
|
||||
}
|
||||
x.style.opacity = "1";
|
||||
}
|
||||
|
||||
window.addEventListener('hashchange', function (e) {
|
||||
openPage();
|
||||
});
|
||||
$('.sidebar-toggler,.sidebar-close-modal').on('click', toggleSidebar);
|
||||
|
||||
// Persistent Bootstrap tabs
|
||||
$('.nav-tabs a.nav-link').click(function (e) {
|
||||
var params = (window.location.hash).split("&");
|
||||
if (!params) return;
|
||||
window.location.hash = params[0] + '&' + e.target.href.split('#')[1];
|
||||
});
|
||||
|
||||
var oldWidth = null;
|
||||
|
||||
function reduceSidebar() {
|
||||
var newWidth = $(window).width();
|
||||
if (oldWidth && oldWidth === newWidth) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $sidebar = $('.sidebar');
|
||||
var closeModal = $('.sidebar-close-modal');
|
||||
if ($(window).width() < 1350) {
|
||||
if (!$sidebar.hasClass('hidden')) $sidebar.addClass('hidden');
|
||||
if (!closeModal.hasClass('hidden')) closeModal.addClass('hidden');
|
||||
|
||||
$('.sidebar .collapse').collapse('hide');
|
||||
} else if ($(window).width() > 1400 && $sidebar.hasClass('hidden')) {
|
||||
$sidebar.removeClass('hidden');
|
||||
if (!closeModal.hasClass('hidden')) closeModal.addClass('hidden');
|
||||
}
|
||||
oldWidth = newWidth;
|
||||
// Scroll to top button appear
|
||||
$(document).on('scroll', () => {
|
||||
const scrollDistance = $(this).scrollTop();
|
||||
if (scrollDistance > 100) {
|
||||
$('.scroll-to-top').fadeIn();
|
||||
} else {
|
||||
$('.scroll-to-top').fadeOut();
|
||||
}
|
||||
});
|
||||
|
||||
reduceSidebar();
|
||||
|
||||
function toggleSidebar() {
|
||||
$('.sidebar').toggleClass('hidden');
|
||||
$('.sidebar .collapse').collapse('hide');
|
||||
|
||||
var closeModal = $('.sidebar-close-modal');
|
||||
if ($(window).width() < 900) {
|
||||
closeModal.toggleClass('hidden');
|
||||
} else {
|
||||
if (!closeModal.hasClass('hidden')) closeModal.addClass('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
$('.sidebar-toggler,.sidebar-close-modal').on('click', toggleSidebar);
|
||||
|
||||
// Close any open menu accordions when window is resized below 924px
|
||||
$(window).resize(reduceSidebar);
|
||||
|
||||
// Prevent the content wrapper from scrolling when the fixed side navigation hovered over
|
||||
$('body.fixed-nav .sidebar').on('mousewheel DOMMouseScroll wheel', function (e) {
|
||||
if ($(window).width() > 924) {
|
||||
var e0 = e.originalEvent,
|
||||
delta = e0.wheelDelta || -e0.detail;
|
||||
this.scrollTop += (delta < 0 ? 1 : -1) * 30;
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// Scroll to top button appear
|
||||
$(document).on('scroll', function () {
|
||||
var scrollDistance = $(this).scrollTop();
|
||||
if (scrollDistance > 100) {
|
||||
$('.scroll-to-top').fadeIn();
|
||||
} else {
|
||||
$('.scroll-to-top').fadeOut();
|
||||
}
|
||||
});
|
||||
|
||||
// Smooth scrolling using jQuery easing
|
||||
$(document).on('click', 'a.scroll-to-top', function (e) {
|
||||
var $anchor = $(this);
|
||||
$('html, body').stop().animate({
|
||||
scrollTop: ($($anchor.attr('href')).offset().top)
|
||||
}, 1000, 'easeInOutExpo');
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
})(jQuery); // End of use strict
|
||||
$('.scroll-to-top').on('click', 'a.scroll-to-top', event => {
|
||||
window.scrollTo(0, 0); // Scroll to top
|
||||
event.preventDefault();
|
||||
});
|
||||
|
@ -1,7 +0,0 @@
|
||||
/*!
|
||||
* Start Bootstrap - SB Admin 2 v4.0.0 (https://startbootstrap.com/template-overviews/sb-admin-2)
|
||||
* Copyright 2013-2019 Start Bootstrap
|
||||
* Licensed under MIT (https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/blob/master/LICENSE)
|
||||
*/
|
||||
|
||||
!function(t){"use strict";t("#sidebarToggle, #sidebarToggleTop").on("click",function(o){t("body").toggleClass("sidebar-toggled"),t(".sidebar").toggleClass("toggled"),t(".sidebar").hasClass("toggled")&&t(".sidebar .collapse").collapse("hide")}),t(window).resize(function(){t(window).width()<768&&t(".sidebar .collapse").collapse("hide")}),t("body.fixed-nav .sidebar").on("mousewheel DOMMouseScroll wheel",function(o){if(768<t(window).width()){var e=o.originalEvent,l=e.wheelDelta||-e.detail;this.scrollTop+=30*(l<0?1:-1),o.preventDefault()}}),t(document).on("scroll",function(){100<t(this).scrollTop()?t(".scroll-to-top").fadeIn():t(".scroll-to-top").fadeOut()}),t(document).on("click","a.scroll-to-top",function(o){var e=t(this);t("html, body").stop().animate({scrollTop:t(e.attr("href")).offset().top},1e3,"easeInOutExpo"),o.preventDefault()})}(jQuery);
|
@ -174,11 +174,7 @@
|
||||
<script src="vendor/jquery/jquery.min.js"></script>
|
||||
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Core plugin JavaScript-->
|
||||
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
|
||||
|
||||
<!-- Custom scripts for all pages-->
|
||||
<script src="js/sb-admin-2.min.js"></script>
|
||||
<script src="js/xmlhttprequests.js"></script>
|
||||
<script src="js/color-selector.js"></script>
|
||||
|
||||
|
@ -783,9 +783,6 @@
|
||||
<script src="./vendor/jquery/jquery.min.js"></script>
|
||||
<script src="./vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Core plugin JavaScript-->
|
||||
<script src="./vendor/jquery-easing/jquery.easing.min.js"></script>
|
||||
|
||||
<!-- Page level plugins -->
|
||||
<script src="./vendor/datatables/jquery.dataTables.min.js"></script>
|
||||
<script src="./vendor/datatables/dataTables.bootstrap4.min.js"></script>
|
||||
|
@ -705,9 +705,6 @@
|
||||
<script src="../vendor/jquery/jquery.min.js"></script>
|
||||
<script src="../vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Core plugin JavaScript-->
|
||||
<script src="../vendor/jquery-easing/jquery.easing.min.js"></script>
|
||||
|
||||
<!-- Page level plugins -->
|
||||
<script src="../vendor/datatables/jquery.dataTables.min.js"></script>
|
||||
<script src="../vendor/datatables/dataTables.bootstrap4.min.js"></script>
|
||||
|
@ -251,9 +251,6 @@
|
||||
<script src="vendor/jquery/jquery.min.js"></script>
|
||||
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Core plugin JavaScript-->
|
||||
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
|
||||
|
||||
<!-- Page level plugins -->
|
||||
<script src="vendor/datatables/jquery.dataTables.min.js"></script>
|
||||
<script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
|
||||
|
@ -178,11 +178,7 @@
|
||||
<script src="vendor/jquery/jquery.min.js"></script>
|
||||
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Core plugin JavaScript-->
|
||||
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
|
||||
|
||||
<!-- Custom scripts for all pages-->
|
||||
<script src="js/sb-admin-2.min.js"></script>
|
||||
<script src="js/xmlhttprequests.js"></script>
|
||||
<script src="js/color-selector.js"></script>
|
||||
|
||||
|
@ -1258,9 +1258,6 @@
|
||||
<script src="../vendor/jquery/jquery.min.js"></script>
|
||||
<script src="../vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<!-- Core plugin JavaScript-->
|
||||
<script src="../vendor/jquery-easing/jquery.easing.min.js"></script>
|
||||
|
||||
<!-- Page level plugins -->
|
||||
<script src="../vendor/datatables/jquery.dataTables.min.js"></script>
|
||||
<script src="../vendor/datatables/dataTables.bootstrap4.min.js"></script>
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Easing Compatibility v1 - http://gsgd.co.uk/sandbox/jquery/easing
|
||||
*
|
||||
* Adds compatibility for applications that use the pre 1.2 easing names
|
||||
*
|
||||
* Copyright (c) 2007 George Smith
|
||||
* Licensed under the MIT License:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
$.extend($.easing,
|
||||
{
|
||||
easeIn: function (x, t, b, c, d) {
|
||||
return $.easing.easeInQuad(x, t, b, c, d);
|
||||
},
|
||||
easeOut: function (x, t, b, c, d) {
|
||||
return $.easing.easeOutQuad(x, t, b, c, d);
|
||||
},
|
||||
easeInOut: function (x, t, b, c, d) {
|
||||
return $.easing.easeInOutQuad(x, t, b, c, d);
|
||||
},
|
||||
expoin: function (x, t, b, c, d) {
|
||||
return $.easing.easeInExpo(x, t, b, c, d);
|
||||
},
|
||||
expoout: function (x, t, b, c, d) {
|
||||
return $.easing.easeOutExpo(x, t, b, c, d);
|
||||
},
|
||||
expoinout: function (x, t, b, c, d) {
|
||||
return $.easing.easeInOutExpo(x, t, b, c, d);
|
||||
},
|
||||
bouncein: function (x, t, b, c, d) {
|
||||
return $.easing.easeInBounce(x, t, b, c, d);
|
||||
},
|
||||
bounceout: function (x, t, b, c, d) {
|
||||
return $.easing.easeOutBounce(x, t, b, c, d);
|
||||
},
|
||||
bounceinout: function (x, t, b, c, d) {
|
||||
return $.easing.easeInOutBounce(x, t, b, c, d);
|
||||
},
|
||||
elasin: function (x, t, b, c, d) {
|
||||
return $.easing.easeInElastic(x, t, b, c, d);
|
||||
},
|
||||
elasout: function (x, t, b, c, d) {
|
||||
return $.easing.easeOutElastic(x, t, b, c, d);
|
||||
},
|
||||
elasinout: function (x, t, b, c, d) {
|
||||
return $.easing.easeInOutElastic(x, t, b, c, d);
|
||||
},
|
||||
backin: function (x, t, b, c, d) {
|
||||
return $.easing.easeInBack(x, t, b, c, d);
|
||||
},
|
||||
backout: function (x, t, b, c, d) {
|
||||
return $.easing.easeOutBack(x, t, b, c, d);
|
||||
},
|
||||
backinout: function (x, t, b, c, d) {
|
||||
return $.easing.easeInOutBack(x, t, b, c, d);
|
||||
}
|
||||
});
|
||||
})(jQuery);
|
@ -1,166 +0,0 @@
|
||||
/*
|
||||
* jQuery Easing v1.4.1 - http://gsgd.co.uk/sandbox/jquery/easing/
|
||||
* Open source under the BSD License.
|
||||
* Copyright © 2008 George McGinley Smith
|
||||
* All rights reserved.
|
||||
* https://raw.github.com/gdsmith/jquery-easing/master/LICENSE
|
||||
*/
|
||||
|
||||
(function (factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(['jquery'], function ($) {
|
||||
return factory($);
|
||||
});
|
||||
} else if (typeof module === "object" && typeof module.exports === "object") {
|
||||
exports = factory(require('jquery'));
|
||||
} else {
|
||||
factory(jQuery);
|
||||
}
|
||||
})(function ($) {
|
||||
|
||||
// Preserve the original jQuery "swing" easing as "jswing"
|
||||
$.easing.jswing = $.easing.swing;
|
||||
|
||||
var pow = Math.pow,
|
||||
sqrt = Math.sqrt,
|
||||
sin = Math.sin,
|
||||
cos = Math.cos,
|
||||
PI = Math.PI,
|
||||
c1 = 1.70158,
|
||||
c2 = c1 * 1.525,
|
||||
c3 = c1 + 1,
|
||||
c4 = (2 * PI) / 3,
|
||||
c5 = (2 * PI) / 4.5;
|
||||
|
||||
// x is the fraction of animation progress, in the range 0..1
|
||||
function bounceOut(x) {
|
||||
var n1 = 7.5625,
|
||||
d1 = 2.75;
|
||||
if (x < 1 / d1) {
|
||||
return n1 * x * x;
|
||||
} else if (x < 2 / d1) {
|
||||
return n1 * (x -= (1.5 / d1)) * x + 0.75;
|
||||
} else if (x < 2.5 / d1) {
|
||||
return n1 * (x -= (2.25 / d1)) * x + 0.9375;
|
||||
} else {
|
||||
return n1 * (x -= (2.625 / d1)) * x + 0.984375;
|
||||
}
|
||||
}
|
||||
|
||||
$.extend($.easing,
|
||||
{
|
||||
def: 'easeOutQuad',
|
||||
swing: function (x) {
|
||||
return $.easing[$.easing.def](x);
|
||||
},
|
||||
easeInQuad: function (x) {
|
||||
return x * x;
|
||||
},
|
||||
easeOutQuad: function (x) {
|
||||
return 1 - (1 - x) * (1 - x);
|
||||
},
|
||||
easeInOutQuad: function (x) {
|
||||
return x < 0.5 ?
|
||||
2 * x * x :
|
||||
1 - pow(-2 * x + 2, 2) / 2;
|
||||
},
|
||||
easeInCubic: function (x) {
|
||||
return x * x * x;
|
||||
},
|
||||
easeOutCubic: function (x) {
|
||||
return 1 - pow(1 - x, 3);
|
||||
},
|
||||
easeInOutCubic: function (x) {
|
||||
return x < 0.5 ?
|
||||
4 * x * x * x :
|
||||
1 - pow(-2 * x + 2, 3) / 2;
|
||||
},
|
||||
easeInQuart: function (x) {
|
||||
return x * x * x * x;
|
||||
},
|
||||
easeOutQuart: function (x) {
|
||||
return 1 - pow(1 - x, 4);
|
||||
},
|
||||
easeInOutQuart: function (x) {
|
||||
return x < 0.5 ?
|
||||
8 * x * x * x * x :
|
||||
1 - pow(-2 * x + 2, 4) / 2;
|
||||
},
|
||||
easeInQuint: function (x) {
|
||||
return x * x * x * x * x;
|
||||
},
|
||||
easeOutQuint: function (x) {
|
||||
return 1 - pow(1 - x, 5);
|
||||
},
|
||||
easeInOutQuint: function (x) {
|
||||
return x < 0.5 ?
|
||||
16 * x * x * x * x * x :
|
||||
1 - pow(-2 * x + 2, 5) / 2;
|
||||
},
|
||||
easeInSine: function (x) {
|
||||
return 1 - cos(x * PI / 2);
|
||||
},
|
||||
easeOutSine: function (x) {
|
||||
return sin(x * PI / 2);
|
||||
},
|
||||
easeInOutSine: function (x) {
|
||||
return -(cos(PI * x) - 1) / 2;
|
||||
},
|
||||
easeInExpo: function (x) {
|
||||
return x === 0 ? 0 : pow(2, 10 * x - 10);
|
||||
},
|
||||
easeOutExpo: function (x) {
|
||||
return x === 1 ? 1 : 1 - pow(2, -10 * x);
|
||||
},
|
||||
easeInOutExpo: function (x) {
|
||||
return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ?
|
||||
pow(2, 20 * x - 10) / 2 :
|
||||
(2 - pow(2, -20 * x + 10)) / 2;
|
||||
},
|
||||
easeInCirc: function (x) {
|
||||
return 1 - sqrt(1 - pow(x, 2));
|
||||
},
|
||||
easeOutCirc: function (x) {
|
||||
return sqrt(1 - pow(x - 1, 2));
|
||||
},
|
||||
easeInOutCirc: function (x) {
|
||||
return x < 0.5 ?
|
||||
(1 - sqrt(1 - pow(2 * x, 2))) / 2 :
|
||||
(sqrt(1 - pow(-2 * x + 2, 2)) + 1) / 2;
|
||||
},
|
||||
easeInElastic: function (x) {
|
||||
return x === 0 ? 0 : x === 1 ? 1 :
|
||||
-pow(2, 10 * x - 10) * sin((x * 10 - 10.75) * c4);
|
||||
},
|
||||
easeOutElastic: function (x) {
|
||||
return x === 0 ? 0 : x === 1 ? 1 :
|
||||
pow(2, -10 * x) * sin((x * 10 - 0.75) * c4) + 1;
|
||||
},
|
||||
easeInOutElastic: function (x) {
|
||||
return x === 0 ? 0 : x === 1 ? 1 : x < 0.5 ?
|
||||
-(pow(2, 20 * x - 10) * sin((20 * x - 11.125) * c5)) / 2 :
|
||||
pow(2, -20 * x + 10) * sin((20 * x - 11.125) * c5) / 2 + 1;
|
||||
},
|
||||
easeInBack: function (x) {
|
||||
return c3 * x * x * x - c1 * x * x;
|
||||
},
|
||||
easeOutBack: function (x) {
|
||||
return 1 + c3 * pow(x - 1, 3) + c1 * pow(x - 1, 2);
|
||||
},
|
||||
easeInOutBack: function (x) {
|
||||
return x < 0.5 ?
|
||||
(pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2)) / 2 :
|
||||
(pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2;
|
||||
},
|
||||
easeInBounce: function (x) {
|
||||
return 1 - bounceOut(1 - x);
|
||||
},
|
||||
easeOutBounce: bounceOut,
|
||||
easeInOutBounce: function (x) {
|
||||
return x < 0.5 ?
|
||||
(1 - bounceOut(1 - 2 * x)) / 2 :
|
||||
(1 + bounceOut(2 * x - 1)) / 2;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
@ -1 +0,0 @@
|
||||
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],function($){return factory($)})}else if(typeof module==="object"&&typeof module.exports==="object"){exports=factory(require("jquery"))}else{factory(jQuery)}})(function($){$.easing.jswing=$.easing.swing;var pow=Math.pow,sqrt=Math.sqrt,sin=Math.sin,cos=Math.cos,PI=Math.PI,c1=1.70158,c2=c1*1.525,c3=c1+1,c4=2*PI/3,c5=2*PI/4.5;function bounceOut(x){var n1=7.5625,d1=2.75;if(x<1/d1){return n1*x*x}else if(x<2/d1){return n1*(x-=1.5/d1)*x+.75}else if(x<2.5/d1){return n1*(x-=2.25/d1)*x+.9375}else{return n1*(x-=2.625/d1)*x+.984375}}$.extend($.easing,{def:"easeOutQuad",swing:function(x){return $.easing[$.easing.def](x)},easeInQuad:function(x){return x*x},easeOutQuad:function(x){return 1-(1-x)*(1-x)},easeInOutQuad:function(x){return x<.5?2*x*x:1-pow(-2*x+2,2)/2},easeInCubic:function(x){return x*x*x},easeOutCubic:function(x){return 1-pow(1-x,3)},easeInOutCubic:function(x){return x<.5?4*x*x*x:1-pow(-2*x+2,3)/2},easeInQuart:function(x){return x*x*x*x},easeOutQuart:function(x){return 1-pow(1-x,4)},easeInOutQuart:function(x){return x<.5?8*x*x*x*x:1-pow(-2*x+2,4)/2},easeInQuint:function(x){return x*x*x*x*x},easeOutQuint:function(x){return 1-pow(1-x,5)},easeInOutQuint:function(x){return x<.5?16*x*x*x*x*x:1-pow(-2*x+2,5)/2},easeInSine:function(x){return 1-cos(x*PI/2)},easeOutSine:function(x){return sin(x*PI/2)},easeInOutSine:function(x){return-(cos(PI*x)-1)/2},easeInExpo:function(x){return x===0?0:pow(2,10*x-10)},easeOutExpo:function(x){return x===1?1:1-pow(2,-10*x)},easeInOutExpo:function(x){return x===0?0:x===1?1:x<.5?pow(2,20*x-10)/2:(2-pow(2,-20*x+10))/2},easeInCirc:function(x){return 1-sqrt(1-pow(x,2))},easeOutCirc:function(x){return sqrt(1-pow(x-1,2))},easeInOutCirc:function(x){return x<.5?(1-sqrt(1-pow(2*x,2)))/2:(sqrt(1-pow(-2*x+2,2))+1)/2},easeInElastic:function(x){return x===0?0:x===1?1:-pow(2,10*x-10)*sin((x*10-10.75)*c4)},easeOutElastic:function(x){return x===0?0:x===1?1:pow(2,-10*x)*sin((x*10-.75)*c4)+1},easeInOutElastic:function(x){return x===0?0:x===1?1:x<.5?-(pow(2,20*x-10)*sin((20*x-11.125)*c5))/2:pow(2,-20*x+10)*sin((20*x-11.125)*c5)/2+1},easeInBack:function(x){return c3*x*x*x-c1*x*x},easeOutBack:function(x){return 1+c3*pow(x-1,3)+c1*pow(x-1,2)},easeInOutBack:function(x){return x<.5?pow(2*x,2)*((c2+1)*2*x-c2)/2:(pow(2*x-2,2)*((c2+1)*(x*2-2)+c2)+2)/2},easeInBounce:function(x){return 1-bounceOut(1-x)},easeOutBounce:bounceOut,easeInOutBounce:function(x){return x<.5?(1-bounceOut(1-2*x))/2:(1+bounceOut(2*x-1))/2}})});
|
Loading…
Reference in New Issue
Block a user