Author: wjohnald
Date: 2010-09-02 21:44:44 +0200 (Thu, 02 Sep 2010)
New Revision: 30813
Modified:
plugins/sfDoctrineActAsTaggablePlugin/trunk/web/js/pkTagahead.js
Log:
Tag widget neuters the enter key, moves popular tags back to the list, and
'add' updates the 'x' list.
Modified: plugins/sfDoctrineActAsTaggablePlugin/trunk/web/js/pkTagahead.js
===================================================================
--- plugins/sfDoctrineActAsTaggablePlugin/trunk/web/js/pkTagahead.js
2010-09-02 18:57:59 UTC (rev 30812)
+++ plugins/sfDoctrineActAsTaggablePlugin/trunk/web/js/pkTagahead.js
2010-09-02 19:44:44 UTC (rev 30813)
@@ -157,7 +157,6 @@
tagInput.parent().append(addButton);
-
// Add a list of popular tags to be added
function addTagsToForm(link)
{
@@ -186,6 +185,14 @@
tagInput.val(value);
link.remove();
+
+ if (typeof(popularTags[tag]) != 'undefined')
+ {
+ var linkLabel = tag + ' - ' + popularTags[tag];
+ var new_link = makeLink(existingTagsAttributes,
tag, linkLabel);
+ new_link.bind('click', function() {
addTagsToForm($(this)); return false; });
+ popularsDiv.append(new_link);
+ }
}
@@ -237,13 +244,23 @@
tagInput.val(value);
typeAheadBox.val('');
+ existingTags = {};
+ var lp = value.split(',');
+ for (x in lp)
+ {
+ existingTags[lp[x]] = lp[x];
+ }
+
+ existingDiv.html(makeTagContainer('Existing Tags',
existingTags, existingTagsAttributes, 'remove').html());
+ existingDiv.children('a').bind('click', function() {
removeTagsFromForm($(this)); return false; });
+
return false;
}
addButton.bind('click', function() { commitTagsToForm(); return
false; });
existingDiv = makeTagContainer('Existing Tags', existingTags,
existingTagsAttributes, 'remove');
- tagInput.parent().append(existingDiv);
+ tagInput.parent().prepend(existingDiv);
popularsDiv = makeTagContainer('Popular Tags', popularTags,
popularsAttributes, 'add');
tagInput.parent().append(popularsDiv);
@@ -254,6 +271,32 @@
{
multiple: true
});
+
+
+ // Catch that enter key, baby!
+ $(document).keyup(function(e)
+ {
+ if (e.keyCode == 13)
+ {
+ e.preventDefault();
+ }
+ });
+
+ $(document).keypress(function(e)
+ {
+ if (e.keyCode == 13)
+ {
+ e.preventDefault();
+ }
+ });
+
+ typeAheadBox.keyup(function(e)
+ {
+ if (e.keyCode == 13)
+ {
+ commitTagsToForm();
+ }
+ });
});
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.