Index: 0.11/trachacks/htdocs/js/trachacks.js
===================================================================
--- 0.11/trachacks/htdocs/js/trachacks.js (revision 13419)
+++ 0.11/trachacks/htdocs/js/trachacks.js (working copy)
@@ -1,98 +1,77 @@
-/* Add helpers to tag cloud. */
-var clean_tags = function(tags) {
-var split = tags.replace(/^ +| +$/g, '').split(/ +/);
+jQuery(document).ready(function($) {
+ var split_tags = function(text) {
+ return $.grep(text.split(/ +/g), function(v) { return !!v });
+ };
- split.sort();
- return split.join(' ');
-};
+ /* Highlight tags from the mini-cloud that are in the tags field. */
+ var highlight_tags = function() {
+ var tags = split_tags($('#tags').val());
-/* Highlight tags from the mini-cloud that are in the tags field. */
-var highlight_tags = function() {
-var tags = clean_tags($('#tags').attr('value')).split(/ +/);
+ $('#cloud a').each(function() {
+ var anchor = $(this);
+ var color = $.inArray(anchor.text(), tags) !== -1 ?
+ 'yellow' : 'transparent';
+ anchor.css('background-color', color);
+ });
+ };
- $('#cloud a').each(function() {
- if (tags.indexOf($(this).text()) != -1) {
- $(this).css('background-color', 'yellow');
- } else {
- $(this).css('background-color', 'transparent');
- }
- });
-};
+ // Move the label for each field into the hint block.
+ $('.hint').each(function() {
+ var hint = this;
+ var fieldid = this.id.slice(0, -4);
+ });
-$(document).ready(function() {
- // Move the label for each field into the hint block.
- $('.hint').each(function() {
- var hint = this;
- var fieldid = hint.id.slice(0, -4);
+ // Handle focus/blur of input fields
+ $.fn.handleInfo = function(hint, label) {
+ return this.each(function() {
+ var hintid = $(!hint ? '#' + this.id + 'hint' : hint);
- });
+ $(this).focus(function() { hintid.show() });
+ $(this).blur(function() { hintid.hide() });
- // Handle focus/blur of input fields
- $.fn.handleInfo = function(hint, label) {
- return this.each(function() {
- var hintid;
+ if (hintid.attr('copied_label') == undefined) {
+ var title = label;
+ hintid.attr('copied_label', true);
+ if (title == undefined) {
+ $('label[for="' + this.id + '"]').each(function() {
+ title = $(this).text();
+ });
+ }
+ hintid.prepend('' + title + '' +
+ ' ');
+ }
+ });
+ }
- if (hint == undefined)
- hintid = '#' + this.id + 'hint';
- else
- hintid = hint;
+ // Add hints to controls.
+ $('#name, #title, #description, #installation, #tags').handleInfo();
+ $('#cloud a').handleInfo('#tagshint');
+ $('input[name="type"]').handleInfo('#typehint', 'Type');
+ $('input[name="release"]').handleInfo('#releasehint', 'Compatibility');
- hintid = $(hintid);
+ // Focus first error control. If none, focus #name.
+ $('input[class="error"], textarea[class="error"], #name').filter(':first')
+ .focus();
- $(hintid).hide();
+ $('#tags').bind('keyup change', highlight_tags);
- $(this).focus(function() { hintid.show(); return true; });
- $(this).blur(function() { hintid.hide(); return true; });
-
- if (hintid.attr('copied_label') == undefined) {
- var title = label;
-
- hintid.attr('copied_label', true);
- if (title == undefined) {
- $('label[@for="' + this.id + '"]').each(function() {
- title = $(this).text();
- });
+ $('#cloud a').click(function() {
+ var anchor = $(this);
+ var tag = anchor.text();
+ var input = $('#tags');
+ var tags = split_tags(input.val());
+ var color;
+ if ($.inArray(tag, tags) !== -1) {
+ color = 'transparent';
+ tags = $.grep(tags, function(v) { return v !== tag });
+ } else {
+ color = 'yellow';
+ tags.push(tag);
}
- hintid.prepend('' + title + '' + ' ');
- }
+ anchor.css('background-color', color);
+ input.val(tags.sort().join(' ') + ' ').focus().trigger('focus');
+ return false;
});
- }
- // Add hints to controls.
- $('#name, #title, #description, #installation, #tags').handleInfo();
-
- $('#cloud a').handleInfo('#tagshint');
-
- $('input[@name="type"]').handleInfo('#typehint', 'Type');
- $('input[@name="release"]').handleInfo('#releasehint', 'Compatibility');
-
- // Focus first error control. If none, focus #name.
- var fields = $('input[@class="error"]:first, textarea[@class="error"]:first');
- if (fields.size()) {
- $(fields[0]).focus();
- }
-
- $('#tags').keyup(highlight_tags);
- $('#tags').change(highlight_tags);
-
- $('#cloud a').click(function() {
- var a = this;
- var tag = $(this).text();
-
- $('#tags').each(function() {
- if (-1 == this.value.search(tag)) {
- $(a).css('background-color', 'yellow');
- this.value = clean_tags(this.value + ' ' + tag);
- } else {
- $(a).css('background-color', 'transparent');
- this.value = clean_tags(this.value.replace(tag, ''));
- }
- $(this).focus();
- });
- return false;
- });
-
-
- highlight_tags();
-
+ highlight_tags();
});
Index: 0.11/trachacks/templates/hacks_new.html
===================================================================
--- 0.11/trachacks/templates/hacks_new.html (revision 13419)
+++ 0.11/trachacks/templates/hacks_new.html (working copy)
@@ -3,7 +3,8 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xml:lang="en">