From 5d8608b839d2cabb6aa10836861f680e9c9fcbe1 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 17 Aug 2013 16:56:22 -0400 Subject: [PATCH] Add upload selection javascript for decluttering the post form --- js/upload-selection.js | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 js/upload-selection.js diff --git a/js/upload-selection.js b/js/upload-selection.js new file mode 100644 index 00000000..3bd6b9ea --- /dev/null +++ b/js/upload-selection.js @@ -0,0 +1,55 @@ +$(function(){ + var enabled_file = true; + var enabled_url = $("#upload_url").length > 0; + var enabled_embed = $("#upload_embed").length > 0; + var enabled_oekaki = $("#oekaki").length > 0; + + var disable_all = function() { + $("#upload").hide(); + $("#upload_file").hide(); + $("#upload_url").hide(); + $("#upload_embed").hide(); + $("#oekaki").hide(); + }; + + enable_file = function() { + disable_all(); + $("#upload").show(); + $("#upload_file").show(); + }; + + enable_url = function() { + disable_all(); + $("#upload").show(); + $("#upload_url").show(); + + $('label[for="file_url"]').html(_("URL")); + }; + + enable_embed = function() { + disable_all(); + $("#upload_embed").show(); + }; + + enable_oekaki = function() { + disable_all(); + $("#oekaki").show(); + }; + + if (enabled_url || enabled_embed || enabled_oekaki) { + $(""+_("Select")+"").insertBefore("#upload"); + var my_html = ""+_("File")+""; + if (enabled_url) { + my_html += " / "+_("Remote")+""; + } + if (enabled_embed) { + my_html += " / "+_("Embed")+""; + } + if (enabled_oekaki) { + my_html += " / "+_("Oekaki")+""; + } + $("#upload_selection").html(my_html); + + enable_file(); + } +});