Browse Source

fix some warnings & update package

master
Vitaliy Filippov 7 years ago
parent
commit
ce89acecb1
  1. 4
      Gruntfile.js
  2. 4
      dist/social-likes.min.js
  3. 4
      dist/social-likes_birman.css
  4. 4
      dist/social-likes_classic.css
  5. 4
      dist/social-likes_flat.css
  6. 2
      package.json
  7. 6
      src/.jscs.json
  8. 10
      src/.jshintrc
  9. 58
      src/social-likes.js
  10. 2
      src/styles/flat/font/social-likes.styl

4
Gruntfile.js

@ -8,8 +8,8 @@ module.exports = function(grunt) {
grunt.initConfig({
pkg: require('./package.json'),
banner: '/*! Social Likes v<%= pkg.version %> by Artem Sapegin - ' +
'http://sapegin.github.com/social-likes - Licensed MIT */\n',
banner: '/*! Social Likes v<%= pkg.version %> by Artem Sapegin / Vitaliy Filippov no-jquery - ' +
'http://github.com/vitalif/social-likes - Licensed MIT */\n',
jshint: {
options: {
jshintrc: 'src/.jshintrc'

4
dist/social-likes.min.js

File diff suppressed because one or more lines are too long

4
dist/social-likes_birman.css

File diff suppressed because one or more lines are too long

4
dist/social-likes_classic.css

File diff suppressed because one or more lines are too long

4
dist/social-likes_flat.css

File diff suppressed because one or more lines are too long

2
package.json

@ -41,7 +41,7 @@
"grunt-contrib-uglify": "~0.6.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-csso": "~0.6.3",
"grunt-jscs-checker": "~0.7.1",
"grunt-jscs": "~0.8.1",
"grunt-modernizr": "~1.0.1",
"grunt-replace": "~0.11.0",
"grunt-sweet": "~0.2.2",

6
src/.jscs.json

@ -1,12 +1,8 @@
{
"requireCurlyBraces": ["for", "while", "do"],
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return"],
"requireParenthesesAroundIIFE": true,
"requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true },
"disallowSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true },
"disallowMultipleVarDecl": true,
"disallowSpacesInsideObjectBrackets": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"disallowSpaceAfterObjectKeys": true,
"requireCommaBeforeLineBreak": true,
@ -26,7 +22,7 @@
"requireKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"maximumLineLength": 140,
"safeContextKeyword": "that",
"safeContextKeyword": "self",
"requireDotNotation": true,
"validateJSDoc": {
"checkParamNames": true,

10
src/.jshintrc

@ -2,13 +2,17 @@
"browser": true,
"white": false,
"smarttabs": true,
"eqeqeq": true,
"eqeqeq": false,
"immed": true,
"latedef": true,
"newcap": true,
"undef": true,
"jquery": true,
"jquery": false,
"globals": {
"Modernizr": true
"http_build_query": true,
"addListener": true,
"removeListener": true,
"onDomReady": true,
"GET": true
}
}

58
src/social-likes.js

@ -5,10 +5,11 @@
* Sharing buttons for Russian and worldwide social networks.
* jQuery removed, only requires simple utilities: GET, onDomReady, http_build_query, addListener, removeListener
*
* @author Artem Sapegin
* @copyright 2014 Artem Sapegin (sapegin.me)
* @author Artem Sapegin, Vitaliy Filippov
* @copyright 2014 Artem Sapegin (sapegin.me), 2016 Vitaliy Filippov
* @license MIT
*/
/*jshint -W030 */
(function() {
'use strict';
@ -21,19 +22,18 @@
function hasClass(e, cls, remove)
{
var p = -1;
var p = -1, r = false;
while ((p = e.className.indexOf(cls, p+1)) != -1)
{
if ((!p || /\s/.exec(e.className.charAt(p-1))) &&
(p == e.className.length-cls.length || /\s/.exec(e.className.charAt(p+cls.length))))
{
r = true;
if (remove)
e.className = e.className.substr(0, p-1)+e.className.substr(p+cls.length);
else
return true;
}
}
return false;
return r;
}
function getScript(url, onsuccess, onerror)
{
@ -110,7 +110,7 @@
var index = options._.length;
options._.push(deferred);
getScript(makeUrl(jsonUrl, {index: index}), null, function() { deferred.reject() });
getScript(makeUrl(jsonUrl, {index: index}), null, function() { deferred.reject(); });
},
popupUrl: 'https://vk.com/share.php?url={url}&title={title}',
popupWidth: 655,
@ -130,7 +130,7 @@
var index = options._.length;
options._.push(deferred);
getScript(makeUrl(jsonUrl, {index: index}), null, function() { deferred.reject() });
getScript(makeUrl(jsonUrl, {index: index}), null, function() { deferred.reject(); });
},
popupUrl: 'https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&service=odnoklassniki&st.shareUrl={url}',
popupWidth: 580,
@ -166,14 +166,14 @@
if (!counters.promises[service]) counters.promises[service] = {};
var servicePromises = counters.promises[service];
if (!extraOptions.forceUpdate && servicePromises[url]) {
if (!extraOptions.forceUpdate && servicePromises[url])
return servicePromises[url];
}
else {
else
{
var options = {};
for (var i in services[service])
options[i] = services[service][i];
for (var i in extraOptions)
for (i in extraOptions)
options[i] = extraOptions[i];
var deferred = { resolve: function(v) {}, reject: function() {} };
var jsonUrl = options.counterUrl && makeUrl(options.counterUrl, {url: url});
@ -192,7 +192,7 @@
try
{
if (typeof options.convertNumber == 'function')
number = options.convertNumber(data);
number = options.convertNumber(number);
deferred.resolve(number);
}
catch (e)
@ -226,9 +226,9 @@
var c = {}, o = dataToOptions(element);
for (var i in window.socialLikes.defaults)
c[i] = window.socialLikes.defaults[i];
for (var i in options)
for (i in options)
c[i] = options[i];
for (var i in o)
for (i in o)
c[i] = o[i];
instance = new SocialLikes(element, c);
element['__'+prefix] = instance;
@ -281,18 +281,18 @@
if (this.options.counters)
{
this.timer = setTimeout(function() { self.appear() }, this.options.wait);
this.timeout = setTimeout(function() { self.ready() }, this.options.timeout);
this.timer = setTimeout(function() { self.appear(); }, this.options.wait);
this.timeout = setTimeout(function() { self.ready(); }, this.options.timeout);
}
else
this.appear();
},
initUserButtons: function() {
if (!this.userButtonInited && window.socialLikesButtons) {
for (var i in socialLikesButtons) {
for (var i in window.socialLikesButtons) {
services[i] = services[i] || {};
for (var j in socialLikesButtons[i])
services[i][j] = socialLikesButtons[i][j];
for (var j in window.socialLikesButtons[i])
services[i][j] = window.socialLikesButtons[i][j];
}
}
this.userButtonInited = true;
@ -322,7 +322,7 @@
addListener(widget, 'click', function() {
var activeClass = prefix+'__widget_active';
if (!hasClass(widget, activeClass)) {
if (!hasClass(widget, activeClass, true)) {
widget.className += ' '+activeClass;
container.style.left = ((widget.offsetWidth-container.offsetWidth)/2)+'px';
container.style.top = -container.offsetHeight+'px';
@ -332,7 +332,6 @@
});
}
else {
widget.className = widget.className.substr(0, i);
hasClass(container, openClass, true);
}
return false;
@ -415,7 +414,7 @@
this.detectParams();
this.initHtml();
var self = this;
setTimeout(function() { self.initCounter() }, 0);
setTimeout(function() { self.initCounter(); }, 0);
},
update: function(options) {
@ -495,7 +494,7 @@
this.widget = widget = link;
}
else {
addListener(widget, 'click', function() { self.click() });
addListener(widget, 'click', function() { self.click(); });
}
widget.className = widget.className.replace(' '+this.service, '') + ' '+this.getElementClassNames('widget');
@ -522,7 +521,7 @@
};
var self = this;
var r = counters.fetch(this.service, this.options.url, extraOptions);
r.reject = r.resolve = function(n) { self.updateCounter(n) };
r.reject = r.resolve = function(n) { self.updateCounter(n); };
}
}
},
@ -541,9 +540,10 @@
number = parseInt(number, 10) || 0;
var counterElem = document.createElement('span');
if (!number && !this.options.zeroes) {
if (!number && !this.options.zeroes)
counterElem.className = this.getElementClassNames('counter') + ' ' + prefix + '__counter_empty';
} else {
else
{
counterElem.innerHTML = number;
counterElem.className = this.getElementClassNames('counter');
}
@ -578,7 +578,7 @@
for (var i in this.options.data)
params[i] = this.options.data[i];
var s = '';
for (var i in params)
for (i in params)
s += '&'+encodeURIComponent(i)+'='+encodeURIComponent(params[i]);
if (!s)
return url;
@ -705,6 +705,6 @@
onDomReady(function() {
var es = document.querySelectorAll('.' + prefix);
for (var i = 0; i < es.length; i++)
socialLikes(es[i]);
window.socialLikes(es[i]);
});
})();

2
src/styles/flat/font/social-likes.styl

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save