Skip to content

Instantly share code, notes, and snippets.

@tamoot
Created June 21, 2010 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamoot/447067 to your computer and use it in GitHub Desktop.
Save tamoot/447067 to your computer and use it in GitHub Desktop.
Index: category.rb
===================================================================
--- category.rb (revision 3640)
+++ category.rb (working copy)
@@ -616,9 +616,10 @@
if @conf['category.edit_support'] then
add_header_proc do
%Q[\t<script type="text/javascript"><!--
- function inj_c(str) {
+ function inj_c() {
var textarea = window.document.forms[0].body;
textarea.focus();
+ var str = '[' + window.document.getElementById('category_dropdown').value + ']';
if (document.selection) { // IE, Opera
var range = document.selection.createRange();
range.text = str;
@@ -640,10 +641,12 @@
unless @categories.size == 0 then
ret << '<div class="field title">'
ret << "#{@category_conf_label}:\n"
+ ret << '<form name="dropdown">'
+ ret << '<select id="category_dropdown" onChange="inj_c()">'
@categories.sort_by{|e| e.downcase}.each do |c|
- ret << %Q!| <a href="javascript:inj_c(&quot;[#{h c}]&quot;)">#{h c}</a>\n!
+ ret << %Q!<option value="#{h c}">#{h c}</option>!
end
- ret << "|\n</div>\n<br>\n"
+ ret << "\n</select></form>\n</div>\n<br>\n"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment