You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metron.apache.org by rm...@apache.org on 2016/05/20 16:21:59 UTC
[05/15] incubator-metron git commit: METRON-173 Update the the Apache
Metron Web Page (iraghumitra via merrimanr) closes
apache/incubator-metron#126
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/7077dbd6/site/js/jquery.classyloader.js
----------------------------------------------------------------------
diff --git a/site/js/jquery.classyloader.js b/site/js/jquery.classyloader.js
new file mode 100644
index 0000000..7526bfa
--- /dev/null
+++ b/site/js/jquery.classyloader.js
@@ -0,0 +1,157 @@
+/*!
+ * jQuery ClassyLoader
+ * www.class.pm
+ *
+ * Written by Marius Stanciu - Sergiu <ma...@class.pm>
+ * Licensed under the MIT license www.class.pm/LICENSE-MIT
+ * Version 1.2.0
+ *
+ */
+
+(function($) {
+ $.fn.ClassyLoader = function(settings) {
+ function radius(e) {
+ return Math.PI / 180 * e;
+ }
+ var defaultSettings = {
+ width: 200,
+ height: 200,
+ animate: true,
+ displayOnLoad: true,
+ percentage: 100,
+ speed: 1,
+ roundedLine: false,
+ showRemaining: true,
+ fontFamily: 'Helvetica',
+ fontSize: '50px',
+ showText: true,
+ diameter: 80,
+ fontColor: 'rgba(25, 25, 25, 0.6)',
+ lineColor: 'rgba(55, 55, 55, 1)',
+ remainingLineColor: 'rgba(55, 55, 55, 0.4)',
+ lineWidth: 5,
+ start: 'left'
+ };
+ settings = $.extend({
+ }, defaultSettings, settings);
+ var r = $(this);
+ this.draw = function(percent) {
+ if (typeof percent !== 'undefined') {
+ settings.percentage = percent;
+ }
+ var ctx = r[0].getContext("2d");
+ var hw = r.width() / 2;
+ var hh = r.height() / 2;
+ var u = 100;
+ var a = 0;
+ var startPos = 0;
+ var f = function(e) {
+ var t = radius(360) / u;
+ return t * e;
+ };
+ ctx.scale(1, 1);
+ ctx.lineWidth = settings.lineWidth;
+ ctx.strokeStyle = settings.lineColour;
+ var l = function(s, u) {
+ s = s || f(a);
+ u = u || f(a + 1);
+ ctx.clearRect(0, 0, r.width(), r.height());
+ if (settings.showRemaining === true) {
+ ctx.beginPath();
+ ctx.strokeStyle = settings.remainingLineColor;
+ ctx.arc(hw, hh, settings.diameter, 0, 360);
+ ctx.stroke();
+ ctx.closePath();
+ }
+ ctx.strokeStyle = settings.lineColor;
+ ctx.beginPath();
+ if (settings.roundedLine === true) {
+ ctx.lineCap = 'round';
+ }
+ else {
+ ctx.lineCap = 'butt';
+ }
+ switch (settings.start) {
+ case 'top':
+ startPos = 1.5 * Math.PI;
+ break;
+ case 'bottom':
+ startPos = 0.5 * Math.PI;
+ break;
+ case 'right':
+ startPos = 1 * Math.PI;
+ break;
+ case 'left':
+ default:
+ startPos = 0;
+ break;
+ }
+ ctx.arc(hw, hh, settings.diameter, startPos, u + startPos);
+ ctx.stroke();
+ ctx.closePath();
+ if (settings.showText === true) {
+ ctx.fillStyle = settings.fontColor;
+ ctx.font = settings.fontSize + " " + settings.fontFamily;
+ ctx.textAlign = "center";
+ ctx.textBaseline = "middle";
+ ctx.fillText(a + 1 + "%", hw, hh);
+ }
+ };
+ setTimeout(function c() {
+ l(f(a), f(a + 1));
+ a += 1;
+ if (a < settings.percentage) {
+ setTimeout(c, settings.speed);
+ }
+ }, settings.speed);
+ };
+ this.setPercent = function(percentage) {
+ settings.percentage = percentage;
+ return this;
+ };
+ this.getPercent = function() {
+ return settings.percentage;
+ };
+ this.show = function() {
+ var ctx = r[0].getContext("2d");
+ var hw = r.width() / 2;
+ var hh = r.height() / 2;
+ ctx.scale(1, 1);
+ ctx.lineWidth = settings.lineWidth;
+ ctx.strokeStyle = settings.lineColour;
+ ctx.clearRect(0, 0, r.width(), r.height());
+ ctx.strokeStyle = settings.lineColor;
+ ctx.beginPath();
+ ctx.arc(hw, hh, settings.diameter, 0, radius(settings.percentage / 100 * 360));
+ ctx.stroke();
+ ctx.closePath();
+ if (settings.showText === true) {
+ ctx.fillStyle = settings.fontColor;
+ ctx.font = settings.fontSize + ' ' + settings.font;
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+ ctx.fillText(settings.percentage + '%', hw, hh);
+ }
+ if (settings.showRemaining === true) {
+ ctx.beginPath();
+ ctx.strokeStyle = settings.remainingLineColor;
+ ctx.arc(hw, hh, settings.diameter, 0, 360);
+ ctx.stroke();
+ ctx.closePath();
+ }
+ };
+ this.__constructor = function() {
+ $(this).attr('width', settings.width);
+ $(this).attr('height', settings.height);
+ if (settings.displayOnLoad === true) {
+ if (settings.animate === true) {
+ this.draw();
+ } else {
+ this.show();
+ }
+ }
+ return this;
+ };
+ return this.__constructor();
+ };
+})(jQuery);
\ No newline at end of file