Skip to content

Commit

Permalink
more jshint save syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
moxx committed Oct 29, 2016
1 parent ca30fbb commit c5d7aaf
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 36 deletions.
91 changes: 91 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
// JSHint Default Configuration File (as on JSHint website)
// See http://jshint.com/docs/ for more details

"maxerr" : 50, // {int} Maximum error before stopping

// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : false, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
"immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
"latedef" : false, // true: Require variables/functions to be defined before being used
"newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
"noempty" : true, // true: Prohibit use of empty blocks
"nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters.
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
"plusplus" : false, // true: Prohibit use of `++` and `--`
"quotmark" : false, // Quotation mark consistency:
// false : do nothing (default)
// true : ensure whatever is used is consistent
// "single" : require single quotes
// "double" : require double quotes
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
"unused" : true, // Unused variables:
// true : all variables, last function parameter
// "vars" : all variables only
// "strict" : all variables, all function parameters
"strict" : true, // true: Requires all functions run in ES5 Strict Mode
"maxparams" : false, // {int} Max number of formal params allowed per function
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
"maxstatements" : false, // {int} Max number statements per function
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
"maxlen" : false, // {int} Max number of characters per line
"varstmt" : false, // true: Disallow any var statements. Only `let` and `const` are allowed.

// Relaxing
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"boss" : false, // true: Tolerate assignments where comparisons would be expected
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // true: Tolerate use of `== null`
"esversion" : 5, // {int} Specify the ECMAScript version to which the code must adhere.
"moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
// (ex: `for each`, multiple try/catch, function expression…)
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
"funcscope" : false, // true: Tolerate defining variables inside control statements
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
"iterator" : false, // true: Tolerate using the `__iterator__` property
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
"laxcomma" : false, // true: Tolerate comma-first style coding
"loopfunc" : false, // true: Tolerate functions being defined in loops
"multistr" : false, // true: Tolerate multi-line strings
"noyield" : false, // true: Tolerate generator functions with no yield statement in them.
"notypeof" : false, // true: Tolerate invalid typeof operator values
"proto" : false, // true: Tolerate using the `__proto__` property
"scripturl" : false, // true: Tolerate script-targeted URLs
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
"validthis" : false, // true: Tolerate using this in a non-constructor function

// Environments
"browser" : true, // Web Browser (window, document, etc)
"browserify" : false, // Browserify (node.js code in the browser)
"couch" : false, // CouchDB
"devel" : true, // Development/debugging (alert, confirm, etc)
"dojo" : false, // Dojo Toolkit
"jasmine" : false, // Jasmine
"jquery" : false, // jQuery
"mocha" : true, // Mocha
"mootools" : false, // MooTools
"node" : false, // Node.js
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
"phantom" : false, // PhantomJS
"prototypejs" : false, // Prototype and Scriptaculous
"qunit" : false, // QUnit
"rhino" : true, // Rhino
"shelljs" : false, // ShellJS
"typed" : false, // Globals for typed array constructions
"worker" : false, // Web Workers
"wsh" : false, // Windows Scripting Host
"yui" : false, // Yahoo User Interface

// Custom Globals
"globals" : {} // additional predefined global variables
}
74 changes: 38 additions & 36 deletions src/scripts/chartist-plugin-fill-donut.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* author-url: https://github.com/moxx/chartist-plugin-fill-donut
*
*/
(function(window, document, Chartist) {
(function (document, Chartist) {
'use strict';

var defaultOptions = {
Expand All @@ -17,26 +17,27 @@
};

Chartist.plugins = Chartist.plugins || {};
Chartist.plugins.fillDonut = function(options) {
Chartist.plugins.fillDonut = function (options) {
options = Chartist.extend({}, defaultOptions, options);
return function fillDonut(chart){
if(chart instanceof Chartist.Pie) {
return function fillDonut(chart) {
if (chart instanceof Chartist.Pie) {
var $chart = chart.container;
$chart.style.position = 'relative';
var $svg;

function drawDonut(data){
if(data.type == 'slice'){
if(data.index == 0)
function drawDonut(data) { // jshint ignore:line
if (data.type === 'slice') {
if (data.index === 0) {
$svg = $chart.querySelector('svg');
}

var $clone = data.group._node.cloneNode(true);
options.fillClass.split(" ").forEach(function(className) {
var $clone = data.group._node.cloneNode(true); // jshint ignore:line
options.fillClass.split(" ").forEach(function (className) {
$clone.setAttribute('class', $clone.getAttribute('class') + ' ' + className);
});

[].forEach.call($clone.querySelectorAll('path'), function(el){
[].forEach.call(el.querySelectorAll('animate'), function(node) {
[].forEach.call($clone.querySelectorAll('path'), function (el) {
[].forEach.call(el.querySelectorAll('animate'), function (node) {
node.parentNode.removeChild(node);
});

Expand All @@ -48,25 +49,26 @@
}
}

chart.on('draw', function(data) {
chart.on('draw', function (data) {
drawDonut(data);
});

chart.on('created', function(data){
chart.on('created', function (data) {
var itemIndex = 0;

if(chart.options.fillDonutOptions){
if (chart.options.fillDonutOptions) {
options = Chartist.extend({}, options, chart.options.fillDonutOptions);
drawDonut(data);
}

[].forEach.call(options.items, function(thisItem){
[].forEach.call(options.items, function (thisItem) {
var $wrapper = document.createElement(options.label.html);
options.label.class.split(" ").forEach(function(className) {
if ($wrapper.classList)
$wrapper.classList.add(className);
else
$wrapper.className += ' ' + className;
options.label.class.split(" ").forEach(function (className) {
if ($wrapper.classList) {
$wrapper.classList.add(className);
} else {
$wrapper.className += ' ' + className;
}
});
var item = Chartist.extend({}, {
class: '',
Expand All @@ -77,18 +79,19 @@
offsetX: 0 //left, right in px
}, thisItem);

var content = item.content;

if(item.id.length > 0)
if (item.id.length > 0) {
$wrapper.setAttribute('id', item.id);
if(item.class.length > 0)
}
if (item.class.length > 0) {
$wrapper.setAttribute('class', item.class);
}

[].forEach.call($chart.querySelectorAll('*[data-fill-index$="fdid-'+itemIndex+'"]'), function(node){
[].forEach.call($chart.querySelectorAll('*[data-fill-index$="fdid-' + itemIndex + '"]'), function (node) {
node.parentNode.removeChild(node);
});
$wrapper.setAttribute('data-fill-index','fdid-'+itemIndex);
itemIndex++;
$wrapper.setAttribute('data-fill-index', 'fdid-' + itemIndex);
itemIndex += 1;

$wrapper.insertAdjacentHTML('beforeend', item.content);
$wrapper.style.position = 'absolute';
Expand All @@ -102,31 +105,30 @@
var style = {
bottom: {
bottom: 0 + item.offsetY + "px",
left: (cWidth - wWidth) + item.offsetX + "px",
left: (cWidth - wWidth) + item.offsetX + "px"
},
top: {
top: 0 + item.offsetY + "px",
left: (cWidth - wWidth) + item.offsetX + "px",
top: 0 + item.offsetY + "px",
left: (cWidth - wWidth) + item.offsetX + "px"
},
left: {
top: (cHeight - wHeight) + item.offsetY + "px",
left: 0 + item.offsetX + "px",
left: 0 + item.offsetX + "px"
},
right: {
top: (cHeight - wHeight) + item.offsetY + "px",
right: 0 + item.offsetX + "px",
right: 0 + item.offsetX + "px"
},
center: {
top: (cHeight - wHeight) + item.offsetY + "px",
left: (cWidth - wWidth) + item.offsetX + "px",
left: (cWidth - wWidth) + item.offsetX + "px"
}
};

Object.assign($wrapper.style, style[item.position]);
});
});
}
}
}

}(window, document, Chartist));
};
};
}(document, Chartist)); // jshint ignore:line

0 comments on commit c5d7aaf

Please sign in to comment.