'
);
}
};
/* format total numbers like 1.2k or 5M
================================================== */
Plugin.prototype.shorterTotal = function (num) {
if (num >= 1e6){
num = (num / 1e6).toFixed(2) + "M"
} else if (num >= 1e3){
num = (num / 1e3).toFixed(1) + "k"
}
return num;
};
/* Methode for open popup
================================================== */
Plugin.prototype.openPopup = function (site) {
popup[site](this.options); //open
if(this.options.enableTracking === true){ //tracking!
var tracking = {
googlePlus: {site: 'Google', action: '+1'},
facebook: {site: 'facebook', action: 'like'},
twitter: {site: 'twitter', action: 'tweet'},
digg: {site: 'digg', action: 'add'},
delicious: {site: 'delicious', action: 'add'},
stumbleupon: {site: 'stumbleupon', action: 'add'},
linkedin: {site: 'linkedin', action: 'share'},
pinterest: {site: 'pinterest', action: 'pin'}
};
//_gaq.push(['_trackSocial', tracking[site].site, tracking[site].action]);
}
};
/* Methode for add +1 to a counter
================================================== */
Plugin.prototype.simulateClick = function () {
var html = $(this.element).html();
$(this.element).html(html.replace(this.options.total, this.options.total+1));
};
/* Methode for add +1 to a counter
================================================== */
Plugin.prototype.update = function (url, text) {
if(url !== ''){
this.options.url = url;
}
if(text !== ''){
this.options.text = text;
}
};
/* A really lightweight plugin wrapper around the constructor, preventing against multiple instantiations
================================================== */
$.fn[pluginName] = function ( options ) {
var args = arguments;
if (options === undefined || typeof options === 'object') {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName, new Plugin( this, options ));
}
});
} else if (typeof options === 'string' && options[0] !== '_' && options !== 'init') {
return this.each(function () {
var instance = $.data(this, 'plugin_' + pluginName);
if (instance instanceof Plugin && typeof instance[options] === 'function') {
instance[options].apply( instance, Array.prototype.slice.call( args, 1 ) );
}
});
}
};
})(jQuery, window, document);