Initial commit
This commit is contained in:
9789
typo3conf/ext/tgm_socialshareprivacy/Resources/Public/Javascript/jquery-1.10.2.js
vendored
Normal file
9789
typo3conf/ext/tgm_socialshareprivacy/Resources/Public/Javascript/jquery-1.10.2.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* Social Share Privacy Button Class
|
||||
*
|
||||
* @param {number} uid
|
||||
* @param {string} script The script as hex escaped string
|
||||
* @param {string} html The HTML as hex escaped string
|
||||
* @param {number} cObjUid The uid of the content element for multiple usage on a page
|
||||
* @param {number} jsIncludeMethode The desired position for JS -> 0 = Append to Body, 1 = Prepend to Body
|
||||
*/
|
||||
var tgm_socialbutton = function(uid, script, html, cObjUid, jsIncludeMethode) {
|
||||
|
||||
/** Back reference to the class */
|
||||
var self = this;
|
||||
|
||||
/** Basic variables */
|
||||
this.script = script;
|
||||
this.html = html;
|
||||
this.requiredInitialization = true;
|
||||
this.enabled = false;
|
||||
this.button = $('.ssp_bar'+cObjUid+' .ssp_btn_'+ uid);
|
||||
|
||||
/**
|
||||
* Initialze button function
|
||||
* @return {void}
|
||||
*/
|
||||
this.init = function() {
|
||||
$('.ssp_btn_dummy_image', this.button).hide();
|
||||
$('.ssp_btn_src', this.button).html(this.html);
|
||||
|
||||
jsIncludeMethode ? $('body').prepend(this.script) : $('body').append(this.script);
|
||||
|
||||
this.requiredInitialization = false;
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable button function when button already has been initialized
|
||||
* @return {void}
|
||||
*/
|
||||
this.enable = function() {
|
||||
$('.ssp_btn_dummy_image', this.button).hide();
|
||||
$('.ssp_btn_src', this.button).show();
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable button function
|
||||
* @return {void}
|
||||
*/
|
||||
this.disable = function() {
|
||||
$('.ssp_btn_dummy_image', this.button).show();
|
||||
$('.ssp_btn_src', this.button).hide();
|
||||
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the button state depending on it's current state
|
||||
*
|
||||
* @param {boolean} toggleOn To force activate the button
|
||||
* @return {void}
|
||||
*/
|
||||
this.toggleButtonState = function(toggleOn) {
|
||||
$(this.button).toggleClass('inactive active');
|
||||
if (this.requiredInitialization) {
|
||||
this.init();
|
||||
} else if (!this.enabled) {
|
||||
this.enable();
|
||||
} else if (!toggleOn) {
|
||||
this.disable();
|
||||
}
|
||||
}
|
||||
|
||||
/** Set default width of each container to the dummy images size */
|
||||
$('.ssp_btn_container', this.button).css({
|
||||
'width' : $('.ssp_btn_dummy_image', this.button).width() + 'px',
|
||||
'height' : $('.ssp_btn_dummy_image', this.button).height() + 'px'
|
||||
});
|
||||
|
||||
/** Provide tooltip to each button */
|
||||
$('.ssp_btn_dummy_image', this.button).tooltip();
|
||||
|
||||
/** Event-Listener to control button */
|
||||
$('.ssp_btn_control', this.button).click(function() {
|
||||
self.toggleButtonState();
|
||||
});
|
||||
|
||||
/** Activate button if a cookie has been set */
|
||||
if (readCookie('ssp_btn' + uid + '_enable') == 1) {
|
||||
this.toggleButtonState(true);
|
||||
$('.ssp_btn_uid'+uid).attr('checked', 'checked');
|
||||
}
|
||||
}
|
||||
|
||||
/** Event-Listener for the additional buttons control */
|
||||
$(document).ready(function() {
|
||||
if($('.ssp_addButtons_toggle').length) {
|
||||
$('.ssp_addButtons_toggle').tooltip().click(function() {
|
||||
$(this).toggleClass('icon-plus-circled icon-minus-circled');
|
||||
$('.ssp_additional_buttons').fadeToggle();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Create cookie function
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {number} value
|
||||
*/
|
||||
function createCookie(name, value) {
|
||||
|
||||
if (tgm_socialbutton_expires) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (tgm_socialbutton_expires * 24 * 60 * 60 * 1000));
|
||||
var expires = "; expires=" + date.toGMTString();
|
||||
} else {
|
||||
var expires = "";
|
||||
}
|
||||
|
||||
// TODO: Allow setup for the cookie domain also checking for https / http
|
||||
|
||||
if (!tgm_socialbutton_path) {
|
||||
tgm_socialbutton_path = '/'
|
||||
}
|
||||
document.cookie = name + "=" + value + expires + "; path=" + tgm_socialbutton_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read cookie function checking all cookies if the requestd cookie is existing
|
||||
*
|
||||
* @param {string} name
|
||||
*/
|
||||
function readCookie(name) {
|
||||
var cookie_name = name + "=";
|
||||
var cookie_array = document.cookie.split(';');
|
||||
for (var i = 0; i < cookie_array.length; i++) {
|
||||
var cur_cookie = cookie_array[i];
|
||||
while (cur_cookie.charAt(0) == ' ')
|
||||
cur_cookie = cur_cookie.substring(1, cur_cookie.length);
|
||||
if (cur_cookie.indexOf(cookie_name) == 0)
|
||||
return cur_cookie.substring(cookie_name.length, cur_cookie.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete cookie function
|
||||
*
|
||||
* @param {string} name
|
||||
*/
|
||||
function eraseCookie(name) {
|
||||
createCookie(name, -1);
|
||||
}
|
||||
Reference in New Issue
Block a user