/**
* Inserts twitter button.
*
* The Widget inserts a twitter button into the target element on which the widget is executed on.
*
* ### Examples
* The Widget is executed on a pageelement and is called with passing optional parameters. The Widget adds a Tweet (share) button to the page element which shows the as default displayed string "Look at this amazing page!" after klicking on the button.
*
* JavaScript:
*
*
*
*
*
* The Widget is executed on a pageelement and is called with passing optional parameters. The Widget adds a Follow button to the page element which makes the user follow the Twitteraccount with the passed name "MyFlowerShop".
*
* JavaScript:
*
*
*
*
*
* The Widget is executed on a pageelement and is called with passing optional parameters. The Widget adds a Twitter search widget which shows all Tweets of the last days with the given searchterm in it. The Title and subject are displayed in the frame of the Widget. The Widget will have the given height and width.
*
* JavaScript:
*
*
*
*
*
* The Widget is executed on a pageelement and is called with passing optional parameters. The Widget adds a Twitter profile widget which shows all Tweets of the passed username in the Widget, it will have the given height and width. The shellbackground is the option for the color of the frame around the widget entries, the shellcolor is the one of the the text in the widgetframe. The tweetbackground is the color of the background of the tweet field, the tweetcolor defines the color of the tweetfont and the parameter tweetlink passes the color that in tweets posted links have.
*
* JavaScript:
*
*
*
*
*
*
* @class jQuery.ui.externalcontentUiTwitter
* @extends jQuery.widget
*
* @uses de_epages
* @uses jQuery.ui.widget
* @uses jQuery.uid
* @uses jQuery.tmpl
* @since 6.15.0
*/
/**
* @cfg {String} [url] The URL of the page to share
*/
/**
* @cfg {String} [type] The type of the button or widget to be inserted. Possible values: 'share', 'follow', 'profile', or 'search'
*/
/**
* @cfg {String} [username] The username, for either the user to follow (follow button) or to show the profile of (profile widget)
*/
/**
* @cfg {Boolean} [showScreenName] Defines if the username should be shown in the tweet or not
*/
/**
* @cfg {String} [text] A Default for the Tweet Text
*/
/**
* @cfg {String} [searchterm] The searchterm for the search Widget
*/
/**
* @cfg {String} [title] Title of the search widget
*/
/**
* @cfg {String} [subject] Subtitle of the search widget
*/
/**
* @cfg {String} [shellbackground] color of the frame around the widget entries
*/
/**
* @cfg {String} [shellcolor] color of the text in the widgetframe
*/
/**
* @cfg {String} [tweetbackground] color of the background of the tweet field
*/
/**
* @cfg {String} [tweetcolor] color of the tweets
*/
/**
* @cfg {String} [tweetlinks] color of the links in tweets
*/
/**
* @cfg {Integer} [width] Width of the Search/Profile Widget
*/
/**
* @cfg {Integer} [height] Height of the Search/Profile Widget
*/
/**
* @cfg {integer} [interval] time interval of refreshing in ms
*/
/**
* @cfg {String} [behaviour] amount of tweets to show; possible values: 'all', 'default'
*/
/**
* @cfg {String} [count] specifying the count annotation rendering of the Share Widget values: 'none', 'vertical', 'horizontal'
*/
/**
* @cfg {Boolean} [showcount] defines if the User's followers count is displayed with the Follow Button or not
*/
/**
* See `jQuery.ui.externalcontentUiTwitter` for details.
*
* @param {Object} [options] A map of additional options to pass to the method.
* @param {String} [url] The URL of the page to share
* @param {String} [type] The type of the button or widget to be inserted. Possible values: 'share', 'follow', 'profile', or 'search'
* @param {String} [username] The username, for either the user to follow (follow button) or to show the profile of (profile widget)
* @param {Boolean} [showScreenName] Defines if the username should be shown in the tweet or not
* @param {String} [text] A Default for the Tweet Text
* @param {String} [searchterm] The searchterm for the search Widget
* @param {String} [title] Title of the search widget
* @param {String} [subject] Subtitle of the search widget
* @param {String} [shellbackground] color of the frame around the widget entries
* @param {String} [shellcolor] color of the text in the widgetframe
* @param {String} [tweetbackground] color of the background of the tweet field
* @param {String} [tweetcolor] color of the tweets
* @param {String} [tweetlinks] color of the links in tweets
* @param {Integer} [width] Width of the Search/Profile Widget
* @param {Integer} [height] Height of the Search/Profile Widget
* @param {integer} [interval] time interval of refreshing in ms
* @param {String} [behaviour] amount of tweets to show; possible values: 'all', 'default'
* @param {String} [count] specifying the count annotation rendering of the Share Widget values: 'none', 'vertical', 'horizontal'
* @param {Boolean} [showcount] defines if the User's followers count is displayed with the Follow Button or not
*
* @method externalcontentUiTwitter
* @member jQuery
*
* @since 6.15.0
*/
/*
* @copyright © Copyright 2006-2011, epages GmbH, All Rights Reserved.
*
* @module de_epages.externalcontent.ui.twitter
*/
/*jslint nomen: true*/
/*global define, document, window*/
define('de_epages/externalcontent/ui/twitter', [
'jquery/ui/widget',
'ep',
'de_epages',
'$tmpl!./twitter',
'ep/ajax'
], function ($, ep, de_epages, template) {
'use strict';
// Constants.
var gClassNames = 'SocialWeb';
$.widget('ui.externalcontentUiTwitter', {
options: {
url: ep.config.canonicalUrl || ep.config.webUrl,
type: 'share',
// Expects one of the following string values: 'share', 'follow'.
// 'profile' and 'search' have been removed, since they are both no longer supported by twitter.
username: '',
// The username for 'via', if type 'share'.
text: $(document).attr('title'),
// The default tweet text.
count: 'none',
// String specifying the count annotation type. Possible values: 'none', 'vertical', 'horizontal'.
showcount: false
// Show counter?
},
_create: function () {
var self = this,
o = this.options,
type = o.type,
ending = (type === 'follow') ? o.username : 'share';
// With EPG-28229 we removed the types 'profile' and 'search'
// but it is possible that merchants still have these types in their shop
// so we will only render the supported types
if ((type === 'share') || (type === 'follow')) {
// Get links for the dereferred ChangeAction
ep.ajax({
dataType: 'json',
data: {
'ViewAction': 'JSONDerefer',
'DereferURLs': 'https://twitter.com/' + ending
}
}).done(function (data) {
o.href = data[0];
self._twitterButton();
});
}
},
_twitterButton: function () {
var o = this.options;
// Append button placeholder.
this.renderedTemplate = template(o).appendTo(this.element.addClass(gClassNames));
// Load Twitter Button API.
ep.ajax({
dataType: 'script',
url: '//platform.twitter.com/widgets.js',
cache: true,
}).done(function () {
// Render button.
window.twttr.widgets.load();
});
},
/**
* This method removes the container on which the Google-Plus button has been appended to.
*
* @method destroy
* @member jQuery.ui.externalcontentUiTwitter
*
* @since 6.15.0
*/
destroy: function () {
// Remove all traces of the widget.
this.element.removeClass(gClassNames);
this.renderedTemplate.remove();
this._superApply(arguments);
}
});
return de_epages;
});