diff --git a/src/social-likes.js b/src/social-likes.js
index 229f21a..0ca89b5 100644
--- a/src/social-likes.js
+++ b/src/social-likes.js
@@ -1,574 +1,574 @@
-/**
- * Social Likes
- * http://sapegin.github.com/social-likes
- *
- * Sharing buttons for Russian and worldwide social networks.
- *
- * @version 2.0.0 alpha
- * @requires jQuery 1.7
- * @author Artem Sapegin
- * @copyright 2012 Artem Sapegin (sapegin.me)
- * @license MIT
- */
-
-/*global define:false, socialLikesButtons:false */
-
-(function (factory) { // Try to register as an anonymous AMD module
- if (typeof define === 'function' && define.amd) {
- define(['jquery'], factory);
- } else {
- factory(jQuery);
- }
-}(function ($) { 'use strict';
-
-var prefix = 'social-likes__',
- fadeSpeed = 'fast';
-
-
-/**
- * Buttons
- */
-var services = {
- facebook: {
- counterUrl: 'http://graph.facebook.com/?ids={url}&callback=?',
- convertNumber: function(data) {
- for (var url in data) if (data.hasOwnProperty(url)) {
- return data[url].shares;
- }
- },
- popupUrl: 'http://www.facebook.com/sharer/sharer.php?u={url}',
- pupupWidth: 600,
- popupHeight: 500
- },
- twitter: {
- counterUrl: 'http://urls.api.twitter.com/1/urls/count.json?url={url}&callback=?',
- convertNumber: function(data) {
- return data.count;
- },
- popupUrl: 'http://twitter.com/intent/tweet?url={url}&text={title}',
- pupupWidth: 600,
- popupHeight: 450,
- additionalParams: ['via', 'related']
- },
- mailru: {
- counterUrl: 'http://connect.mail.ru/share_count?url_list={url}&callback=1&func=?',
- convertNumber: function(data) {
- for (var url in data) if (data.hasOwnProperty(url)) {
- return data[url].shares;
- }
- },
- popupUrl: 'http://connect.mail.ru/share?share_url={url}',
- pupupWidth: 550,
- popupHeight: 360
- },
- vkontakte: {
- counterUrl: 'http://vkontakte.ru/share.php?act=count&url={url}&index={index}',
- counter: function(jsonUrl, deferred) {
- var options = services.vkontakte;
- if (!options._) {
- options._ = [];
- window.VK = {Share: {count: function(idx, number) {
- options._[idx].resolve(number);
- }}};
- }
-
- var index = options._.length;
- options._.push(deferred);
- $.ajax({
- url: makeUrl(jsonUrl, {index: index}),
- dataType: 'jsonp'
- });
- },
- popupUrl: 'http://vk.com/share.php?url={url}&title={title}',
- pupupWidth: 550,
- popupHeight: 330
- },
- odnoklassniki: {
- counterUrl: 'http://www.odnoklassniki.ru/dk?st.cmd=extLike&ref={url}&uid={index}',
- counter: function(jsonUrl, deferred) {
- var options = services.odnoklassniki;
- if (!options._) {
- options._ = [];
- window.ODKL = {updateCount: function(idx, number) {
- options._[idx].resolve(number);
- }};
- }
-
- var index = options._.length;
- options._.push(deferred);
- $.ajax({
- url: makeUrl(jsonUrl, {index: index}),
- dataType: 'jsonp'
- });
- },
- popupUrl: 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st._surl={url}',
- pupupWidth: 550,
- popupHeight: 360
- },
- plusone: {
- popupUrl: 'https://plus.google.com/share?url={url}',
- pupupWidth: 700,
- popupHeight: 500
- },
- code: {
- click: function(e) {
- var balloon = this._codeBalloon;
- if (balloon) {
- if (balloon.is(':visible')) {
- balloon.fadeOut(fadeSpeed);
- return;
- }
- }
- else {
- balloon = $(template(
- '
' +
- '
' +
- '{prompt}
' +
- '
' +
- '
',
- {
- prompt: (this.widget.data('prompt') || 'Copy code to clipboard:'),
- html: this.options.pageHtml
- }
- ));
- this.widget.append(balloon);
- this._codeBalloon = balloon;
- }
- balloon.fadeIn(fadeSpeed);
- balloon.find('textarea').select();
-
- if (balloon.is(':visible')) {
- balloon.removeClass(prefix + 'balloon_right');
- if (balloon.offset().left < 0) {
- balloon.addClass(prefix + 'balloon_right');
- }
-
- closeOnClick(balloon);
- }
- }
- },
- livejournal: {
- click: function(e) {
- var form = this._livejournalForm;
- if (!form) {
- var html = this.options.pageHtml
- .replace(/&/g, '&')
- .replace(/"/g, '"');
- form = $(template(
- '',
- {
- title: this.options.pageTitle,
- html: html
- }
- ));
- this.widget.append(form);
- this._livejournalForm = form;
- }
- form.submit();
- }
- }
-};
-
-
-/**
- * Counters manager
- */
-var counters = {
- promises: {},
- fetch: function(service, url) {
- if (!counters.promises[service]) counters.promises[service] = {};
- var servicePromises = counters.promises[service];
-
- if (servicePromises[url]) {
- return servicePromises[url];
- }
- else {
- var options = services[service],
- deferred = $.Deferred(),
- jsonUrl = options.counterUrl && makeUrl(options.counterUrl, {url: url});
-
- if ($.isFunction(options.counter)) {
- options.counter(jsonUrl, deferred);
- }
- else if (options.counterUrl) {
- $.getJSON(jsonUrl)
- .done(function(data) {
- try {
- var number = data;
- if ($.isFunction(options.convertNumber)) {
- number = options.convertNumber(data);
- }
- deferred.resolve(number);
- }
- catch (e) {
- deferred.reject(e);
- }
- });
- }
-
- servicePromises[url] = deferred.promise();
- return servicePromises[url];
- }
- }
-};
-
-
-/**
- * jQuery plugin
- */
-$.fn.socialLikes = function() {
- return this.each(function() {
- new SocialLikes($(this));
- });
-};
-
-
-function SocialLikes(container) {
- this.container = container;
- this.init();
-}
-
-SocialLikes.prototype = {
- optionsMap: {
- pageUrl: {
- attr: 'url',
- default: function() { return window.location.href.replace(window.location.hash, ''); }
- },
- pageTitle: {
- attr: 'title',
- default: function() { return document.title; }
- },
- pageHtml: {
- attr: 'html',
- default: function() { return '' + this.options.pageTitle + ''; }
- },
- pageCounters: {
- attr: 'counters',
- default: 'yes',
- convert: function(value) { return value === 'yes'; }
- }
- },
- init: function() {
- this.readOptions();
- this.single = this.container.hasClass('social-likes_single');
-
- this.initUserButtons();
-
- if (this.single)
- this.container.on('counter.social-likes', $.proxy(this.updateCounter, this));
-
- var options = this.options;
- this.container.find('li').each(function() {
- new Button($(this), options);
- });
-
- if (this.single)
- this.makeSingleButton();
- },
- readOptions: function() {
- this.options = {};
- for (var key in this.optionsMap) {
- var option = this.optionsMap[key];
- this.options[key] = this.container.data(option.attr) ||
- ($.isFunction(option.default) ? $.proxy(option.default, this)() : option.default);
- if ($.isFunction(option.convert))
- this.options[key] = option.convert(this.options[key]);
- }
- },
- initUserButtons: function() {
- if (!this.userButtonInited && window.socialLikesButtons) {
- $.extend(services, socialLikesButtons);
- }
- this.userButtonInited = true;
- },
- makeSingleButton: function() {
- var container = this.container;
- container.addClass('social-likes_vertical');
- container.wrap($('