/usr/share/tdiary/js/socialbutton.js is in tdiary-contrib 5.0.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | /**
* socialbutton.js -
*
* Copyright (C) 2011 by MATSUOKA Kohei <kmachu@gmail.com>
* You can distribute it under GPL.
*/
/**
* SYNOPSIS
*
* you can set options at socialbutton.rb
*
* $tDiary.plugin.socialbutton.enables =
* ['twitter', 'hatena', 'facebook_like', 'evernote'];
*
* $tDiary.plugin.socialbutton.options = {
* twitter: { via: 'machu' }
* };
*
*/
$(function() {
// load config from tDiary plugin (socialbutton.rb)
var config = $tDiary.plugin.socialbutton;
// set options for jQuery.socialbutton
var callbacks = {
twitter: function(url, title) {
var link = url;
var pos = 0;
if ((pos = url.indexOf('#')) > 0) {
link = url.substr(0, pos)
}
return {
url: link,
text: title,
button: 'horizontal',
lang: $('html').attr('lang').substr(0,2)
};
},
hatena: function(url, title) {
return {
url: url,
title: title,
button: 'simple-balloon'
};
},
facebook_like: function(url, title) {
return {
url: url,
button: 'button_count',
locale: $('html').attr('lang').replace('-', '_')
};
},
evernote: function(url, title) {
return {
url: url,
title: title,
button: 'article-clipper-jp'
};
},
google_plusone: function(url, title) {
return {
href: url,
size: 'medium',
lang: $('html').attr('lang')
};
},
pinterest: function(url, title) {
return {
url: url,
media: $('p img:first', $('div.section h3 a[name=' + url.substr(-3) + ']').parent().parent()).attr('src'),
description: title,
button: 'horizontal',
};
},
};
function socialbutton(target) {
$('.socialbuttons').css('height', '1em')
var bottom = $(window).height() + $(window).scrollTop();
$($tDiary.blogkit ? '.day' : '.day .section')
.filter(function() {
return bottom > $(this).offset().top;
})
.filter(function() {
return $(this).find('.socialbutton').length == 0
})
.each(function() {
var anchor = $(this).find('h3 a');
if ($tDiary.blogkit) {
var link = $(this).children('h2').find('a:first').get(0);
var url = link ? link.href : document.URL;
var title = $(this).children('h2').find('.title').text();
} else if (anchor.length == 0) {
// The section may not have an anchor on etdiary style.
// https://github.com/tdiary/tdiary-contrib/issues/59
var url = ($(this).parents('.day').find('h2 a:first').get(0)||'').href;
var title = $(this).parents('.day').find('h2 .title').text();
} else {
var url = anchor.get(0).href;
var title = anchor.attr('title');
}
if (url && title) {
// console.debug('loading socialbutton: ' + title);
var socialbuttons = $(this).find('.socialbuttons');
append_button(url, title, socialbuttons);
}
});
}
function append_button(url, title, socialbuttons) {
$.each(config.enables, function(i, service) {
var options = callbacks[service](url, title.replace(/"/g, '"'));
$.extend(options, config.options[service]);
$('<div class="socialbutton"></div>')
.css("float", "left")
.css("margin-right", "0.5em")
.appendTo(socialbuttons)
.socialbutton(service, options);
});
}
$(window).on('scroll', function(event) {
socialbutton(document);
});
socialbutton(document);
});
|