2014-03-11 14:48:26 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
// Loading options
|
2014-03-19 17:43:04 +00:00
|
|
|
chrome.storage.sync.get(['option_fancybox_images', 'option_fancybox_videos', 'option_fancybox_posts', 'option_ctrl_enter', 'option_fluid_layout', 'option_images_load_original'], function(options) {
|
2014-03-14 12:16:06 +00:00
|
|
|
// Fancybox
|
|
|
|
// Images
|
|
|
|
if (options.option_fancybox_images == true) {
|
2014-03-19 17:43:04 +00:00
|
|
|
// TODO: group images to the galeries
|
2014-03-14 12:16:06 +00:00
|
|
|
$('.postimg:not(.video)').fancybox();
|
|
|
|
}
|
|
|
|
// Videos
|
|
|
|
if (options.option_fancybox_videos == true) {
|
|
|
|
$('.postimg.video').addClass('fancybox-media').fancybox({
|
2014-03-11 14:48:26 +00:00
|
|
|
helpers: {
|
|
|
|
media: {
|
|
|
|
youtube: {
|
|
|
|
params: {
|
|
|
|
autoplay: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-03-14 12:16:06 +00:00
|
|
|
// Posts
|
|
|
|
if (options.option_fancybox_posts == true) {
|
|
|
|
$('.post-id a').attr('data-fancybox-type', 'iframe').fancybox({
|
|
|
|
maxWidth: 780
|
|
|
|
});
|
|
|
|
}
|
2014-03-19 17:43:04 +00:00
|
|
|
// Hotkeys
|
2014-03-11 14:48:26 +00:00
|
|
|
// Send by CTRL+Enter
|
|
|
|
if (options.option_ctrl_enter == true) {
|
|
|
|
$('.reply-form textarea').keydown(function(e) {
|
|
|
|
//e.preventDefault();
|
|
|
|
if (e.ctrlKey && (e.keyCode == 10 || e.keyCode == 13)) {
|
|
|
|
e.preventDefault();
|
|
|
|
$(this).parent('.reply-form').submit();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-03-19 17:43:04 +00:00
|
|
|
// Look and feel
|
|
|
|
// Fluid #main layout
|
|
|
|
if (options.option_fluid_layout == true) {
|
|
|
|
$('#main').css({
|
|
|
|
'width': '95%',
|
|
|
|
'max-width': '95%'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
// Image resizing
|
|
|
|
if (options.option_images_load_original == true) {
|
|
|
|
// Setting new image source
|
|
|
|
$('.postimg:not(.video) img').each(function(){
|
|
|
|
console.log($(this).parent('.postimg').attr('href'));
|
|
|
|
$(this).attr('src', $(this).parent('.postimg').attr('href'));
|
|
|
|
});
|
|
|
|
// Resizing
|
|
|
|
$('.postimg:not(.video), .postimg:not(.video) img').css({
|
|
|
|
'width': 'auto',
|
|
|
|
'height': 'auto',
|
|
|
|
'max-width': '100%',
|
|
|
|
'max-height': '100%'
|
|
|
|
});
|
|
|
|
}
|
2014-03-11 14:48:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Showing page action
|
|
|
|
chrome.extension.sendMessage({type: 'showPageAction'});
|
|
|
|
});
|