Author: nick Date: 2008-10-18 16:34:04 +0100 (Sat, 18 Oct 2008) New Revision: 1229
Modified: trunk/templates/edit_form.tt Log: Make a start on JS to help you pick locales and categories, but not quite finished yet
Modified: trunk/templates/edit_form.tt =================================================================== --- trunk/templates/edit_form.tt 2008-10-18 14:51:09 UTC (rev 1228) +++ trunk/templates/edit_form.tt 2008-10-18 15:34:04 UTC (rev 1229) @@ -94,6 +94,7 @@ Current locales: [% ELSE %] Locales (one per line): + <span id="pick_locale"></span> [% END %] </label> <div class="edit_box"> @@ -118,6 +119,7 @@ Current categories: [% ELSE %] Categories (one per line): + <span id="pick_category"></span> [% END %] </label> <div class="edit_box"> @@ -136,6 +138,42 @@ [% END %] </div>
+ <script type="text/javascript"> + function pick(metadata_type, textbox_id) { + var textbox = document.getElementById(textbox_id); + + // For adding the new metadata to the textarea + var add_md = function(picked) { + var last = textbox.value.substring(textbox.value.length - 1); + if(last == "\r" || last == "\n") { + // Already has new line + } else { + textbox.value = textbox.value + "\r\n"; + } + + textbox.value = textbox.value + picked; + }; + + // Fetch the data + $.getJSON("[% cgi_url %]?action=metadata;format=json;type=" + metadata_type, function(data) { +// alert(data[metadata_type][0]); +// add_md(data[metadata_type][1]); + }); + } + + function pick_locale() { + pick("locale", "locales"); + } + function pick_category() { + pick("category", "categories"); + } + + $(document).ready(function() { + $("#pick_locale").html("<a href='javascript:pick_locale()'>pick Locale</a>"); + $("#pick_category").html("<a href='javascript:pick_category()'>pick Category</a>"); + }); + </script> + <div class="edit_form_group" id="summary_group"> [% IF conflict %] <label for="summary_input">Current summary:</label>