From 1f3064ae3ef1f94deb0d132365be92e44502838e Mon Sep 17 00:00:00 2001 From: skobkin Date: Wed, 19 Mar 2014 10:43:04 -0700 Subject: [PATCH] New features: fluid layout and original images loading. --- chrome_point_plus/js/options.js | 18 ++++++++++++++++-- chrome_point_plus/js/point-plus.js | 29 ++++++++++++++++++++++++++--- chrome_point_plus/manifest.json | 2 +- chrome_point_plus/options.html | 7 +++++++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/chrome_point_plus/js/options.js b/chrome_point_plus/js/options.js index 4fe5d03..4b4f601 100644 --- a/chrome_point_plus/js/options.js +++ b/chrome_point_plus/js/options.js @@ -9,13 +9,19 @@ function save_options() { var checkbox_fancybox_videos = document.getElementById('option-fancybox-videos'); // Posts var checkbox_fancybox_posts = document.getElementById('option-fancybox-posts'); - + // Fluid layout + var checkbox_layout_fluid = document.getElementById('option-layout-fluid'); + // Load original images + var checkbox_images_load_original = document.getElementById('option-images-load-original'); + // Saving parameters chrome.storage.sync.set({ 'option_ctrl_enter': checkbox_ctrl_enter.checked, 'option_fancybox_images': checkbox_fancybox_images.checked, 'option_fancybox_videos': checkbox_fancybox_videos.checked, 'option_fancybox_posts': checkbox_fancybox_posts.checked, + 'option_fluid_layout': checkbox_layout_fluid.checked, + 'option_images_load_original': checkbox_images_load_original.checked }, function() { // Update status to let user know options were saved. var status = document.getElementById('status'); @@ -29,7 +35,7 @@ function save_options() { // Restores select box state to saved value from localStorage. function restore_options() { // Loading options - chrome.storage.sync.get(['option_fancybox_images', 'option_fancybox_videos', 'option_fancybox_posts', 'option_ctrl_enter'], function(options) { + chrome.storage.sync.get(['option_fancybox_images', 'option_fancybox_videos', 'option_fancybox_posts', 'option_ctrl_enter', 'option_images_load_original', 'option_fluid_layout'], function(options) { // CTRL+Enter if (options.option_ctrl_enter == true) { document.getElementById('option-ctrl-enter').checked = true; @@ -47,6 +53,14 @@ function restore_options() { if (options.option_fancybox_posts == true) { document.getElementById('option-fancybox-posts').checked = true; } + // Fluid layout + if (options.option_fluid_layout == true) { + document.getElementById('option-layout-fluid').checked = true; + } + // Load original images + if (options.option_images_load_original == true) { + document.getElementById('option-images-load-original').checked = true; + } }); } document.addEventListener('DOMContentLoaded', restore_options); diff --git a/chrome_point_plus/js/point-plus.js b/chrome_point_plus/js/point-plus.js index 5695f22..b45eeaa 100644 --- a/chrome_point_plus/js/point-plus.js +++ b/chrome_point_plus/js/point-plus.js @@ -1,9 +1,10 @@ $(document).ready(function() { // Loading options - chrome.storage.sync.get(['option_fancybox_images', 'option_fancybox_videos', 'option_fancybox_posts', 'option_ctrl_enter'], function(options) { + 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) { // Fancybox // Images if (options.option_fancybox_images == true) { + // TODO: group images to the galeries $('.postimg:not(.video)').fancybox(); } // Videos @@ -26,7 +27,7 @@ $(document).ready(function() { maxWidth: 780 }); } - + // Hotkeys // Send by CTRL+Enter if (options.option_ctrl_enter == true) { $('.reply-form textarea').keydown(function(e) { @@ -37,7 +38,29 @@ $(document).ready(function() { } }); } - + // 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%' + }); + } }); // Showing page action diff --git a/chrome_point_plus/manifest.json b/chrome_point_plus/manifest.json index 14efe28..a1f4dca 100644 --- a/chrome_point_plus/manifest.json +++ b/chrome_point_plus/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Point+", - "version": "1.1", + "version": "1.2", "author": "Alexey Skobkin", "homepage_url": "https://bitbucket.org/skobkin/chrome_point_plus", "description": "Some new features for point.im", diff --git a/chrome_point_plus/options.html b/chrome_point_plus/options.html index c09feb0..63368d4 100644 --- a/chrome_point_plus/options.html +++ b/chrome_point_plus/options.html @@ -18,6 +18,13 @@

+

Look and feel

+

+ +

+

+