diff --git a/js/oekaki.js b/js/oekaki.js index c2ce92d3..fc4eb4b2 100644 --- a/js/oekaki.js +++ b/js/oekaki.js @@ -9,12 +9,12 @@ var oekaki_form = '\ \


\ \ -

\ +

\ \ \ ' -function enable_oekaki() { +function init_oekaki() { // Add oekaki after the file input $('input[type="file"]').parent().parent().after(oekaki_form); // Add "edit in oekaki" links @@ -28,33 +28,9 @@ function enable_oekaki() { context.strokeStyle = context.fillStyle = "black"; // Attach canvas events attach_events(); - localStorage['oekaki'] = true; } -function disable_oekaki(){ - $("#oekaki").detach(); - $(".edit_in_oekaki").detach(); - localStorage['oekaki'] = false; -} - -if (localStorage['oekaki'] === undefined) { localStorage['oekaki'] = true } - -$('hr:first').before('
-
'); -$('div#oekaki-status a').text(_('Oekaki')+' (' + (localStorage['oekaki'] === 'true' ? _('enabled') : _('disabled')) + ')'); - -$('div#oekaki-status a').on('click', function(){ - var enabled = !JSON.parse(localStorage['oekaki']); - - if(enabled){ - enable_oekaki(); - } else { - disable_oekaki(); - } - - $('div#oekaki-status a').text(_('Oekaki')+' (' + (enabled ? _('enabled') : _('disabled')) + ')'); -}); - -if (localStorage['oekaki'] === "true") { enable_oekaki(); } +init_oekaki(); //http://stackoverflow.com/a/5624139/1901658 function hexToRgb(hex) { @@ -226,6 +202,11 @@ $(".edit_in_oekaki").on("click", function(){ context.drawImage(img, 0, 0); } img.src = $(img_link).attr("href"); + + if (typeof enable_oekaki === 'function') { // for upload-selection.js + enable_oekaki(); + } + return false; }); }