From e843f81f3cfa94852a61665881aafcf798ee1436 Mon Sep 17 00:00:00 2001 From: 8chan Date: Sat, 20 Dec 2014 07:02:00 -0800 Subject: [PATCH] Customize embed sizes --- js/youtube.js | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/js/youtube.js b/js/youtube.js index c4ef77fb..b40bbb66 100644 --- a/js/youtube.js +++ b/js/youtube.js @@ -23,11 +23,39 @@ */ -onready(function(){ +$(document).ready(function(){ + if (window.Options && Options.get_tab('general')) { + Options.extend_tab("general", "" + _('YouTube size') + ": x"); + + if (typeof localStorage.youtube_size === 'undefined') { + localStorage.youtube_size = '{"width":360,"height":270}'; + var our_yt = JSON.parse(localStorage.youtube_size); + } else { + var our_yt = JSON.parse(localStorage.youtube_size); + $('#youtube-height').val(our_yt.height); + $('#youtube-width').val(our_yt.width); + } + + + $('#youtube-width, #youtube-height').on('change', function() { + if ($(this).attr('id') === 'youtube-height') { + our_yt.height = $(this).val(); + } else { + our_yt.width = $(this).val(); + } + + localStorage.youtube_size = JSON.stringify(our_yt); + }); + } + var do_embed_yt = function(tag) { + if (typeof our_yt === "undefined") { + our_yt = {"width":360,"height":270}; + } + $('div.video-container a', tag).click(function() { $(this.parentNode).html('