Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get rid of those ugly share buttons

  • Loading branch information...
commit b373c2fc7a7aff416aeb64020edc30594a107da3 1 parent 1505f1b
@andey authored
View
BIN  app/assets/images/social-icons-sprite.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  app/assets/images/social-icons.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
4 app/assets/javascripts/application.js
@@ -14,5 +14,5 @@
//= require jquery_ujs
//= require bootstrap-3.0.2.min
//= require jquery.sticky-1.0.0.js
-//= require_tree ./layout
-//= require_tree ./ops
+//= require jquery.share-1.0.js
+//= require_tree ./include
View
0  ...vascripts/layout/advertisements.js.coffee → ...ascripts/include/advertisements.js.coffee
File renamed without changes
View
0  app/assets/javascripts/ops/show.js.coffee → ...ts/javascripts/include/ops_show.js.coffee
File renamed without changes
View
12 app/assets/javascripts/include/social.js.coffee
@@ -0,0 +1,12 @@
+jQuery ->
+ $("#share").share
+ networks: [
+ 'facebook',
+ 'twitter',
+ 'googleplus'
+ 'linkedin',
+ 'stumbleupon',
+ 'digg',
+ 'email'
+ ]
+ theme: "square"
View
0  ...s/javascripts/layout/timestamps.js.coffee → .../javascripts/include/timestamps.js.coffee
File renamed without changes
View
1  app/assets/stylesheets/application.css
@@ -16,4 +16,5 @@
*= require ops
*= require tags
*= require fonts.css
+ *= require jquery.share-1.0
*/
View
9 app/views/amas/_share.html.erb
@@ -1,9 +0,0 @@
-<a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-hashtags="ama">Tweet</a>
-<div class="g-plus" data-action="share" data-annotation="none"></div>
-<script type="text/javascript" src="//platform.linkedin.com/in.js"></script>
-<script type="IN/Share"></script>
-<div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>
-
-<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
-<script type="text/javascript">(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script>
-<script type="text/javascript">(function() {var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);})();</script>
View
2  app/views/amas/show.html.slim
@@ -35,7 +35,7 @@
= @ama.date
= link_to "source", reddit_ama_path(@ama.permalink), :class => "pull-right", :rel => :nofollow
- = render 'share'
+ #share
.row.tabs
ul.nav.nav-tabs
View
137 vendor/assets/javascripts/jquery.share-1.0.js
@@ -0,0 +1,137 @@
+/**
+ * jQuery.share - social media sharing plugin
+ * ---
+ * @author Carol Skelly (http://in1.com)
+ * @version 1.0
+ * @license MIT license (http://opensource.org/licenses/mit-license.php)
+ * ---
+ */
+
+;(function ( $, window, undefined ) {
+
+ var document = window.document;
+
+ $.fn.share = function(method) {
+
+ var methods = {
+
+ init : function(options) {
+ this.share.settings = $.extend({}, this.share.defaults, options);
+ var settings = this.share.settings,
+ networks = this.share.settings.networks,
+ theme = this.share.settings.theme,
+ orientation = this.share.settings.orientation,
+ affix = this.share.settings.affix,
+ margin = this.share.settings.margin,
+ pageTitle = this.share.settings.title||$(document).attr('title'),
+ pageUrl = this.share.settings.urlToShare||$(location).attr('href'),
+ pageDesc = "";
+
+ $.each($(document).find('meta[name="description"]'),function(idx,item){
+ pageDesc = $(item).attr("content");
+ });
+
+ // each instance of this plugin
+ return this.each(function() {
+ var $element = $(this),
+ id=$element.attr("id"),
+ u=encodeURIComponent(pageUrl),
+ t=encodeURIComponent(pageTitle),
+ d=pageDesc.substring(0,250),
+ href;
+
+ // append HTML for each network button
+ for (var item in networks) {
+ item = networks[item];
+ href = helpers.networkDefs[item].url;
+ href = href.replace('|u|',u).replace('|t|',t).replace('|d|',d)
+ .replace('|140|',t.substring(0,130));
+ $("<a href='"+href+"' title='Share this page on "+item+
+ "' class='pop share-"+theme+" share-"+theme+"-"+item+"'></a>")
+ .appendTo($element);
+ }
+
+ // customize css
+ $("#"+id+".share-"+theme).css('margin',margin);
+
+ if (orientation != "horizontal"){
+ $("#"+id+" a.share-"+theme).css('display','block');
+ }
+ else {
+ $("#"+id+" a.share-"+theme).css('display','inline-block');
+ }
+
+ if (typeof affix != "undefined"){
+ $element.addClass('share-affix');
+ if (affix.indexOf('right')!=-1){
+ $element.css('left','auto');
+ $element.css('right','0px');
+ if (affix.indexOf('center')!=-1){
+ $element.css('top','40%');
+ }
+ }
+ else if (affix.indexOf('left center')!=-1){
+ $element.css('top','40%');
+ }
+
+ if (affix.indexOf('bottom')!=-1){
+ $element.css('bottom','0px');
+ $element.css('top','auto');
+ if (affix.indexOf('center')!=-1){
+ $element.css('left','40%');
+ }
+ }
+ }
+
+ // bind click
+ $('.pop').click(function(){
+ window.open($(this).attr('href'),'t','toolbar=0,resizable=1,status=0,width=640,height=528');
+ return false;
+ });
+
+
+ });// end plugin instance
+
+ }
+ }
+
+ var helpers = {
+ networkDefs: {
+ facebook:{url:'http://www.facebook.com/share.php?u=|u|'},
+ //http://twitter.com/home?status=jQuery%20Share%20Social%20Media%20Plugin%20-%20Share%20to%20multiple%20social%20networks%20from%20a%20single%20form%20http://plugins.in1.com/share/demo
+ twitter:{url:'https://twitter.com/share?url=|u|&text=|140|'},
+ linkedin:{url:'http://www.linkedin.com/shareArticle?mini=true&url=|u|&title=|t|&summary=|d|&source=in1.com'},
+ in1:{url:'http://www.in1.com/cast?u=|u|',w:'490',h:'529'},
+ tumblr:{url:'http://www.tumblr.com/share?v=3&u=|u|'},
+ digg:{url:'http://digg.com/submit?url=|u|&title=|t|'},
+ googleplus:{url:'https://plusone.google.com/_/+1/confirm?hl=en&url=|u|'},
+ reddit:{url:'http://reddit.com/submit?url=|u|'},
+ pinterest:{url:'http://pinterest.com/pin/create/button/?url=|u|&media=&description=|d|'},
+ posterous:{url:'http://posterous.com/share?linkto=|u|&title=|t|'},
+ stumbleupon:{url:'http://www.stumbleupon.com/submit?url=|u|&title=|t|'},
+ email:{url:'mailto:?subject=|t|'}
+ }
+ }
+
+ if (methods[method]) {
+ return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
+ } else if (typeof method === 'object' || !method) {
+ return methods.init.apply(this, arguments);
+ } else {
+ $.error( 'Method "' + method + '" does not exist in social plugin');
+ }
+
+ }
+
+ $.fn.share.defaults = {
+ networks: ['facebook','twitter','linkedin'],
+ theme: 'icon', // use round icons sprite
+ autoShow: true,
+ margin: '3px',
+ orientation: 'horizontal',
+ useIn1: false
+ }
+
+ $.fn.share.settings = {}
+
+})(jQuery, window);
View
217 vendor/assets/stylesheets/jquery.share-1.0.css
@@ -0,0 +1,217 @@
+.share {
+
+}
+
+.share-affix {
+ position: fixed;
+ top:50px;
+ left:0px;
+}
+
+.share-icon {
+ background-repeat: no-repeat;
+ background-image:url('/assets/social-icons.png');
+ height:40px;
+ width:40px;
+ display: inline-block;
+ text-indent: -99999px;
+ margin:2px;
+ opacity: .9;
+ filter:Alpha(Opacity=90);
+}
+
+.share-icon:hover {
+ opacity: 1;
+ filter:Alpha(Opacity=100);
+}
+
+.share-icon-digg {
+ background-position: -526px 0;
+}
+.share-icon-email {
+ background-position: -614px 0;
+}
+.share-icon-flickr {
+ background-position: -261px 0;
+}
+.share-icon-foursquare {
+ background-position: 0 0;
+}
+.share-icon-rss {
+ background-position: -305px 0;
+}
+.share-icon-facebook {
+ background-position: -131px 0;
+}
+.share-icon-twitter {
+ background-position: -174px 0;
+}
+.share-icon-tumblr {
+ background-position: -87px 0;
+}
+.share-icon-linkedin {
+ background-position: -438px 0;
+}
+.share-icon-vimeo {
+ background-position: -393px 0;
+}
+.share-icon-instagram {
+ background-position: -44px 0;
+}
+.share-icon-pinterest {
+ background-position: -349px 0;
+}
+.share-icon-googleplus {
+ background-position: -218px 0;
+}
+.share-icon-in1 {
+ background-position: -482px 0;
+}
+.share-icon-stumbleupon {
+ background-position: -570px 0;
+}
+
+/**a.behance, a.delicious, a.deviantart, a.digg, a.dribbble, a.facebook, a.flickr, a.forrst, a.foursquare, a.googleplus, a.in1, a.instagram, a.lastfm, a.linkedin, a.pinterest, a.rss, a.skype, a.tumblr, a.twitter, a.vimeo, a.youtube {*/
+.share-square {
+ -moz-transition: all 0.2s linear 0s;
+ background: url("/assets/social-icons.png") no-repeat scroll left top transparent;
+ display: inline-block;
+ height: 32px;
+ line-height: 0;
+ margin: 2px;
+ width: 32px;
+}
+.share-square-behance {
+ background-position: -544px -44px;
+}
+.share-square-behance:hover {
+ background-position: -544px -77px;
+}
+.share-square-delicious {
+ background-position: -512px -44px;
+}
+.share-square-delicious:hover {
+ background-position: -512px -77px;
+}
+.share-square-deviantart {
+ background-position: -480px -44px;
+}
+.share-square-deviantart:hover {
+ background-position: -480px -77px;
+}
+.share-square-digg {
+ background-position: -448px -44px;
+}
+.share-square-digg:hover {
+ background-position: -448px -77px;
+}
+.share-square-dribbble {
+ background-position: -416px -44px;
+}
+.share-square-dribbble:hover {
+ background-position: -416px -77px;
+}
+.share-square-email {
+ background-position: -674px -44px;
+}
+.share-square-email:hover {
+ background-position: -674px -77px;
+}
+.share-square-facebook {
+ background-position: -384px -44px;
+}
+.share-square-facebook:hover {
+ background-position: -384px -77px;
+}
+.share-square-flickr {
+ background-position: -352px -44px;
+}
+.share-square-flickr:hover {
+ background-position: -352px -77px;
+}
+.share-square-forrst {
+ background-position: -320px -44px;
+}
+.share-square-forrst:hover {
+ background-position: -320px -77px;
+}
+.share-square-googleplus {
+ background-position: -288px -44px;
+}
+.share-square-googleplus:hover {
+ background-position: -288px -77px;
+}
+.share-square-in1 {
+ background-position: -576px -44px;
+}
+.share-square-in1:hover {
+ background-position: -576px -77px;
+}
+.share-square-instagram {
+ background-position: -608px -44px;
+}
+.share-square-instagram:hover {
+ background-position: -608px -77px;
+}
+.share-square-lastfm {
+ background-position: -256px -44px;
+}
+.share-square-lastfm:hover {
+ background-position: -256px -77px;
+}
+.share-square-linkedin {
+ background-position: -224px -44px;
+}
+.share-square-linkedin:hover {
+ background-position: -224px -77px;
+}
+.share-square-pinterest {
+ background-position: -192px -44px;
+}
+.share-square-pinterest:hover {
+ background-position: -192px -77px;
+}
+.share-square-rss {
+ background-position: -160px -44px;
+}
+.share-square-rss:hover {
+ background-position: -160px -77px;
+}
+.share-square-skype {
+ background-position: -128px -44px;
+}
+.share-square-skype:hover {
+ background-position: -128px -77px;
+}
+.share-square-stumbleupon {
+ background-position: -640px -44px;
+}
+.share-square-stumbleupon:hover {
+ background-position: -640px -77px;
+}
+.share-square-tumblr {
+ background-position: -96px -44px;
+}
+.share-square-tumblr:hover {
+ background-position: -96px -77px;
+}
+.share-square-twitter {
+ background-position: -64px -44px;
+}
+.share-square-twitter:hover {
+ background-position: -64px -77px;
+}
+.share-square-vimeo {
+ background-position: -32px -44px;
+}
+.share-square-vimeo:hover {
+ background-position: -32px -77px;
+}
+.share-square-youtube {
+ background-position: 0 -44px;
+}
+.share-square-youtube:hover {
+ background-position: 0 -77px;
+}
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.