Improved interactions on text annotator
authorveltr
Tue, 25 Jun 2013 18:46:43 +0200
changeset 32 3612737630f4
parent 31 059e197617bb
child 33 8d7e6a9018fc
Improved interactions on text annotator
integration/annotation-article.html
integration/css/annotation-article.css
integration/css/jquery.tagit.css
integration/js/annotation-article.js
integration/js/vendor/tag-it.min.js
--- a/integration/annotation-article.html	Wed Jun 19 18:28:56 2013 +0200
+++ b/integration/annotation-article.html	Tue Jun 25 18:46:43 2013 +0200
@@ -11,6 +11,8 @@
         <meta http-equiv="Content-Language" content="fr">
         <link rel="apple-touch-icon" type="image/png" href="http://static.mediapart.fr/sites/all/themes/mediapart/mediapart_v4/images/apple-touch-icon.png">
         <link type="text/css" rel="stylesheet" media="all" href="css/mediapart.css">
+        <link type="text/css" rel="stylesheet" media="all" href="css/ui-red/jquery-ui.css">
+        <link type="text/css" rel="stylesheet" media="all" href="css/jquery.tagit.css">
         <link type="text/css" rel="stylesheet" media="all" href="css/annotation-article.css">
         <title>Les enjeux cachés du duel Moscovici-Montebourg | Mediapart</title>
     </head>
@@ -309,12 +311,16 @@
                     </div>
                     <div class="block tools_article">
                         <div class="facebook-recommanded">
+<!--
                             <iframe allowtransparency="true" class="facebook-iframe" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.mediapart.fr%2Fjournal%2Feconomie%2F030912%2Fles-enjeux-caches-du-duel-moscovici-montebourg&layout=button_count&show_faces=false&width=140&action=recommend&font&colorscheme=light&height=21" frameborder="0"></iframe>
                             <iframe allowtransparency="true" class="google-iframe" src="https://plusone.google.com/_/+1/fastbutton?bsv&size=medium&hl=fr&origin=https%3A%2F%2Fplusone.google.com&url=http%3A%2F%2Fwww.mediapart.fr%2Fjournal%2Feconomie%2F030912%2Fles-enjeux-caches-du-duel-moscovici-montebourg&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.fr.8uOkYkn2gb0.O%2Fm%3D__features__%2Fam%3DUQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAItRSTNmPMNo09lMWzZYftQYbs1Wo4_awA#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled&id=I4_1366704337380&parent=&pfname=%2FI0_1366704315687&rpctoken=98073847" frameborder="0"></iframe>
+-->
                         </div>
 
                         <div class="twitter-offer">
+<!--
                             <iframe data-count="horizontal" allowtransparency="true" class="twitter-share-button twitter-count-horizontal" src="http://platform.twitter.com/widgets/tweet_button.html?count=horizontal&enableNewSizing=false&id=twitter-widget-0&lang=fr&url=http%3A%2F%2Fwww.mediapart.fr%2Fjournal%2Feconomie%2F030912%2Fles-enjeux-caches-du-duel-moscovici-montebourg&size=m&text=Les%20enjeux%20cach%C3%A9s%20du%20duel%20Moscovici-Montebourg&related=mediapart&via=mediapart" frameborder="0"></iframe>
+-->
                             <a href="http://www.mediapart.fr/offrir_article/233850" title="Offrir un article à un ami"><img src="http://static.mediapart.fr/sites/all/themes/mediapart/mediapart_v4/images/offrir-article-big.png" alt="Offrir l'article à un ami" title="" height="22" width="91"></a>
                         </div>
 
@@ -365,12 +371,17 @@
             <div class="right-region">
                 <div class="block tools_article">
                     <div class="facebook-recommanded">
+<!--
                         <iframe allowtransparency="true" class="facebook-iframe" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.mediapart.fr%2Fjournal%2Feconomie%2F030912%2Fles-enjeux-caches-du-duel-moscovici-montebourg&layout=button_count&show_faces=false&width=140&action=recommend&font&colorscheme=light&height=21" frameborder="0"></iframe>
                         <iframe allowtransparency="true" class="google-iframe" src="https://plusone.google.com/_/+1/fastbutton?bsv&size=medium&hl=fr&origin=https%3A%2F%2Fplusone.google.com&url=http%3A%2F%2Fwww.mediapart.fr%2Fjournal%2Feconomie%2F030912%2Fles-enjeux-caches-du-duel-moscovici-montebourg&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.fr.8uOkYkn2gb0.O%2Fm%3D__features__%2Fam%3DUQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAItRSTNmPMNo09lMWzZYftQYbs1Wo4_awA#_methods=onPlusOne%2C_ready%2C_close%2C_open%2C_resizeMe%2C_renderstart%2Concircled&id=I4_1366704337380&parent=&pfname=%2FI0_1366704315687&rpctoken=98073847" frameborder="0"></iframe>
+-->
                     </div>
 
                     <div class="twitter-offer">
-                        <iframe data-count="horizontal" allowtransparency="true" class="twitter-share-button twitter-count-horizontal" src="http://platform.twitter.com/widgets/tweet_button.html?count=horizontal&enableNewSizing=false&id=twitter-widget-0&lang=fr&url=http%3A%2F%2Fwww.mediapart.fr%2Fjournal%2Feconomie%2F030912%2Fles-enjeux-caches-du-duel-moscovici-montebourg&size=m&text=Les%20enjeux%20cach%C3%A9s%20du%20duel%20Moscovici-Montebourg&related=mediapart&via=mediapart" frameborder="0"></iframe><a href="http://www.mediapart.fr/offrir_article/233850" title="Offrir un article à un ami"><img src="http://static.mediapart.fr/sites/all/themes/mediapart/mediapart_v4/images/offrir-article-big.png" alt="Offrir l'article à un ami" title="" height="22" width="91"></a>
+<!--
+                        <iframe data-count="horizontal" allowtransparency="true" class="twitter-share-button twitter-count-horizontal" src="http://platform.twitter.com/widgets/tweet_button.html?count=horizontal&enableNewSizing=false&id=twitter-widget-0&lang=fr&url=http%3A%2F%2Fwww.mediapart.fr%2Fjournal%2Feconomie%2F030912%2Fles-enjeux-caches-du-duel-moscovici-montebourg&size=m&text=Les%20enjeux%20cach%C3%A9s%20du%20duel%20Moscovici-Montebourg&related=mediapart&via=mediapart" frameborder="0"></iframe>
+-->
+                        <a href="http://www.mediapart.fr/offrir_article/233850" title="Offrir un article à un ami"><img src="http://static.mediapart.fr/sites/all/themes/mediapart/mediapart_v4/images/offrir-article-big.png" alt="Offrir l'article à un ami" title="" height="22" width="91"></a>
                     </div>
 
                     <div class="item-list">
@@ -531,7 +542,9 @@
         <div class="annotation-frames"></div>
         <script src="js/lib/underscore-min.js"></script>
         <script src="js/vendor/jquery-1.8.0.min.js"></script>
+        <script src="js/vendor/jquery-ui-1.8.24.custom.min.js"></script>
         <script src="js/vendor/jquery.fancybox-1.3.4.pack.js"></script>
+        <script src="js/vendor/tag-it.min.js"></script>
         <script src="js/annotation-article.js"></script>
         <script>
             var annotations = [{
@@ -539,6 +552,7 @@
                 "endOffset" : 185,
                 "color" : "#8f8",
                 "comment" : "Ne pas confondre avec la Bibliothèque Publique d'Information du Centre Pompidou",
+                "tags": [ "Banque", "Publique", "Investissement" ],
                 "annotatedText" : "Banque publique d’investissement",
                 "beforeText" : "Arnaud Montebourg au sujet de la ",
                 "afterText" : " (BPI) et se sont longuement attardés"
@@ -547,6 +561,7 @@
                 "endOffset" : 770,
                 "color" : "#8ff",
                 "comment" : "Le Premier Ministre",
+                "tags": [ "Chef du gouvernement" ],
                 "annotatedText" : "Jean-Marc Ayrault",
                 "beforeText" : "certains ministres du gouvernement de ",
                 "afterText" : ". Il révèle aussi que les deux"
--- a/integration/css/annotation-article.css	Wed Jun 19 18:28:56 2013 +0200
+++ b/integration/css/annotation-article.css	Tue Jun 25 18:46:43 2013 +0200
@@ -1,3 +1,9 @@
+input::-moz-focus-inner /*Remove button padding in FF*/
+{ 
+    border: 0;
+    padding: 0;
+}
+
 /* TOP BAR */
 
 .periplus-barre {
@@ -100,20 +106,37 @@
 
 .annotation-frame {
     position: absolute; float: left; clear: both; display: none; border: 2px solid;
-    margin: -4px 0 0 -4px;
+    margin: -4px 0 0 -4px; box-shadow: 0 0 4px #000000;
 }
 .annotation-area {
     float: left; clear: both; width: 490px; padding: 2px; opacity: .2;
 }
 .annotation-form {
-    float: left; clear: both; width: 490px; padding: 2px; background: rgba(200,200,200,.8);
+    float: left; clear: both; width: 490px; padding: 2px; background: rgba(200,200,200,.9);
 }
 .annotation-form h3 {
-    color: #197CAA; font-size: 14px; font-weight: bold;
+    color: #197CAA; font-size: 14px; font-weight: bold; margin: 2px 5px 0;
 }
 .annotation-textarea {
     margin: 5px; height: 120px; resize: none; border: 1px solid #666; padding: 2px; width: 474px;
 }
+ul.annotation-tags-form {
+    font-size: 12px; margin: 5px; border-radius: 0; border: 1px solid #666;
+}
+.annotation-submit, .annotation-remove {
+    width: 235px; height: 20px; line-height: 20px; font-size: 14px;
+    padding: 0; margin: 5px; color: #ffffff; font-weight: bold; border: none;
+}
+.annotation-submit:hover, .annotation-remove:hover {
+    opacity: .8;
+}
+.annotation-submit {
+    background: #197CAA;
+}
+.annotation-remove {
+    background: #990000;
+}
+
 .annotation-list li {
     margin-bottom: 5px; border: 2px solid; padding: 0 4px; font-size: 13px; cursor: hand;
 }
@@ -124,7 +147,7 @@
     margin: 4px 0;
 }
 .annotation-list li.selected {
-    background: #f8f8f8;
+    background: #e0e0e0;
 }
 .annotation-text {
     font-style: italic; color: #666;
@@ -141,7 +164,7 @@
 }
 
 .annotation-frame-box div {
-    position: absolute; background: rgba(128,128,128,0.5);
+    position: absolute; background: rgba(200,200,200,0.5);
 }
 
 .annotation-fb-top {
@@ -158,4 +181,4 @@
 
 .annotation-fb-bottom {
     left: 0; right: 0;
-}
\ No newline at end of file
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/integration/css/jquery.tagit.css	Tue Jun 25 18:46:43 2013 +0200
@@ -0,0 +1,67 @@
+ul.tagit {
+    padding: 1px 5px;
+    overflow: auto;
+    margin-left: inherit; /* usually we don't want the regular ul margins. */
+    margin-right: inherit;
+}
+ul.tagit li {
+    display: block;
+    float: left;
+    margin: 2px 5px 2px 0;
+}
+ul.tagit li.tagit-choice {    
+    position: relative;
+    line-height: inherit;
+}
+
+ul.tagit li.tagit-choice-read-only { 
+    padding: .2em .5em .2em .5em; 
+} 
+
+ul.tagit li.tagit-choice-editable { 
+    padding: .2em 18px .2em .5em; 
+} 
+
+ul.tagit li.tagit-new {
+    padding: .25em 4px .25em 0;
+}
+
+ul.tagit li.tagit-choice a.tagit-label {
+    cursor: pointer;
+    text-decoration: none;
+}
+ul.tagit li.tagit-choice .tagit-close {
+    cursor: pointer;
+    position: absolute;
+    right: .1em;
+    top: 50%;
+    margin-top: -8px;
+    line-height: 17px;
+}
+
+/* used for some custom themes that don't need image icons */
+ul.tagit li.tagit-choice .tagit-close .text-icon {
+    display: none;
+}
+
+ul.tagit li.tagit-choice input {
+    display: block;
+    float: left;
+    margin: 2px 5px 2px 0;
+}
+ul.tagit input[type="text"] {
+    -moz-box-sizing:    border-box;
+    -webkit-box-sizing: border-box;
+    box-sizing:         border-box;
+
+    -moz-box-shadow: none;
+    -webkit-box-shadow: none;
+    box-shadow: none;
+
+    border: none;
+    margin: 0;
+    padding: 0;
+    width: inherit;
+    background-color: inherit;
+    outline: none;
+}
--- a/integration/js/annotation-article.js	Wed Jun 19 18:28:56 2013 +0200
+++ b/integration/js/annotation-article.js	Tue Jun 25 18:46:43 2013 +0200
@@ -36,6 +36,7 @@
         currentVisibleFrame = null,
         ncol = 0,
         mousedown = false,
+        shownByClick = false,
         dragging = false;
     
     function cleanText(txt, keepbefore, keepafter) {
@@ -108,6 +109,7 @@
             endOffset: end,
             color: color,
             comment: "",
+            tags: [],
             annotatedText: textinfo.text.substring(start, end),
             beforeText: textinfo.text.substring(start - 40, start).replace(/^[\S]*\s+/,''),
             afterText: textinfo.text.substring(end, end + 40).replace(/\s+[\S]*$/,'')
@@ -119,15 +121,20 @@
     var frameTpl = _.template(
         '<div class="annotation-frame" style="border-color: <%- annotation.color %>; top: <%-top %>px; left: <%- left %>px;">'
         + '<div class="annotation-area" style="background-color: <%- annotation.color %>; height: <%- height %>px;"></div>'
-        + '<form class="annotation-form"><h3>Annoter&nbsp;:</h3>'
+        + '<form class="annotation-form"><h3>Commentaire&nbsp;:</h3>'
         + '<textarea class="annotation-textarea" placeholder="Mon commentaire&hellip;"><%- annotation.comment || "" %></textarea>'
+        + '<h3>Mots-clés&nbsp;:</h3>'
+        + '<ul class="annotation-tags-form"><% _(annotation.tags).forEach(function(tag) { %><li><%- tag %></li><% }) %></ul>'
+        + '<div><button class="annotation-remove">Supprimer</button><input class="annotation-submit" type="submit" value="Enregistrer" /></div>'
         + '</form></div>'
     );
     
     var liTpl = _.template(
         '<li style="border-color: <%- annotation.color %>;"><h3>Texte annoté</h3>'
         + '<p class="annotation-text"><%- annotation.beforeText %><b><%- annotation.annotatedText %></b><%- annotation.afterText %></p>'
-        + '<h3>Commentaire</h3><p class="annotation-comment"><%- annotation.comment || "(Sans commentaire)" %></p>'
+        + '<h3>Commentaire&nbsp;:</h3><p class="annotation-comment"><%- annotation.comment || "(Sans commentaire)" %></p>'
+        + '<h3>Mots-clés&nbsp;:</h3><p class="annotation-tags"><%- (annotation.tags || []).join(", ") || "(aucun mot-clé)" %></p>'
+        + '</li>'
     );
     
     function showFrameBox() {
@@ -154,6 +161,7 @@
                 top: fbbtop,
                 height: ($("body").height() - fbbtop)
             });
+            currentVisibleFrame.find(".annotation-textarea").focus();
         } else {
             $(".annotation-frame-box").hide();
         }
@@ -166,7 +174,7 @@
         
         currentVisibleFrame = null;
         showFrameBox();
-        $(".annotations-list li").removeClass("selected");
+        $(".annotation-list li").removeClass("selected");
     }
     
     function showAnnotation(annotation) {
@@ -210,34 +218,72 @@
             li.find(".annotation-comment").text(annotation.comment || "(Sans commentaire)");
         });
         
+        var ontagchange = function(evt, ui) {
+            annotation.tags = $(this).tagit("assignedTags");
+            li.find(".annotation-tags").text((annotation.tags || []).join(", ") || "(aucun mot-clé)");
+        };
+        
+        frame.find(".annotation-tags-form").tagit({
+            afterTagAdded: ontagchange,
+            afterTagRemoved: ontagchange
+        });
+        
         var show = function() {
             if (mousedown) {
                 return;
             }
+            shownByClick = false;
             currentVisibleFrame = frame;
             frame.show();
             showFrameBox();
             li.addClass("selected");
         }
+                
+        $(spans).mouseenter(show);
         
-        $(spans).hover(show, hideAllFrames);
-        frame.hover(show, hideAllFrames);
-        li.hover(
-            function() {
+        frame
+            .mouseleave(function() {
+                if (!shownByClick) {
+                    hideAllFrames();
+                }
+            })
+            .click(function() {
+                shownByClick = true;
+            });
+        
+        frame.find(".annotation-form").submit(function() {
+            hideAllFrames();
+            return false;
+        });
+        
+        frame.find(".annotation-remove").click(function() {
+            annotations = _(annotations).reject(function(a) {
+                return a === annotation
+            });
+            $(spans).css("background-color","").off("mouseenter",show);
+            li.remove();
+            frame.remove();
+            hideAllFrames();
+            return false;
+        });
+        
+        li
+            .mouseenter(function() {
                 $(spans).addClass("annotation-selected");
                 li.addClass("selected");
-            },
-            function() {
+            })
+            .mouseleave(function() {
                 $(spans).removeClass("annotation-selected");
                 li.removeClass("selected");
-            }
-        ).click(function() {
-            show();
-            $(window).scrollTop(currentVisibleFrame.offset().top - 100);
-        });
+            })
+            .click(function() {
+                show();
+                shownByClick = true;
+                $(window).scrollTop(currentVisibleFrame.offset().top - 100);
+            });
     }
     
-    window.annotations.forEach(function(annotation) {
+    annotations.forEach(function(annotation) {
         showAnnotation(annotation);
     });
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/integration/js/vendor/tag-it.min.js	Tue Jun 25 18:46:43 2013 +0200
@@ -0,0 +1,16 @@
+(function(b){b.widget("ui.tagit",{options:{allowDuplicates:!1,caseSensitive:!0,fieldName:"tags",placeholderText:null,readOnly:!1,removeConfirmation:!1,tagLimit:null,availableTags:[],autocomplete:{},showAutocompleteOnFocus:!1,allowSpaces:!1,singleField:!1,singleFieldDelimiter:",",singleFieldNode:null,animate:!0,tabIndex:null,beforeTagAdded:null,afterTagAdded:null,beforeTagRemoved:null,afterTagRemoved:null,onTagClicked:null,onTagLimitExceeded:null,onTagAdded:null,onTagRemoved:null,tagSource:null},_create:function(){var a=
+this;this.element.is("input")?(this.tagList=b("<ul></ul>").insertAfter(this.element),this.options.singleField=!0,this.options.singleFieldNode=this.element,this.element.css("display","none")):this.tagList=this.element.find("ul, ol").andSelf().last();this.tagInput=b('<input type="text" />').addClass("ui-widget-content");this.options.readOnly&&this.tagInput.attr("disabled","disabled");this.options.tabIndex&&this.tagInput.attr("tabindex",this.options.tabIndex);this.options.placeholderText&&this.tagInput.attr("placeholder",
+this.options.placeholderText);this.options.autocomplete.source||(this.options.autocomplete.source=function(a,c){var d=a.term.toLowerCase(),e=b.grep(this.options.availableTags,function(a){return 0===a.toLowerCase().indexOf(d)});this.options.allowDuplicates||(e=this._subtractArray(e,this.assignedTags()));c(e)});this.options.showAutocompleteOnFocus&&(this.tagInput.focus(function(){a._showAutocomplete()}),"undefined"===typeof this.options.autocomplete.minLength&&(this.options.autocomplete.minLength=0));
+b.isFunction(this.options.autocomplete.source)&&(this.options.autocomplete.source=b.proxy(this.options.autocomplete.source,this));b.isFunction(this.options.tagSource)&&(this.options.tagSource=b.proxy(this.options.tagSource,this));this.tagList.addClass("tagit").addClass("ui-widget ui-widget-content ui-corner-all").append(b('<li class="tagit-new"></li>').append(this.tagInput)).click(function(c){var d=b(c.target);d.hasClass("tagit-label")?(d=d.closest(".tagit-choice"),d.hasClass("removed")||a._trigger("onTagClicked",
+c,{tag:d,tagLabel:a.tagLabel(d)})):a.tagInput.focus()});var d=!1;if(this.options.singleField)if(this.options.singleFieldNode){var c=b(this.options.singleFieldNode),e=c.val().split(this.options.singleFieldDelimiter);c.val("");b.each(e,function(b,c){a.createTag(c,null,!0);d=!0})}else this.options.singleFieldNode=b('<input type="hidden" style="display:none;" value="" name="'+this.options.fieldName+'" />'),this.tagList.after(this.options.singleFieldNode);d||this.tagList.children("li").each(function(){b(this).hasClass("tagit-new")||
+(a.createTag(b(this).text(),b(this).attr("class"),!0),b(this).remove())});this.tagInput.keydown(function(c){if(c.which==b.ui.keyCode.BACKSPACE&&""===a.tagInput.val()){var d=a._lastTag();!a.options.removeConfirmation||d.hasClass("remove")?a.removeTag(d):a.options.removeConfirmation&&d.addClass("remove ui-state-highlight")}else a.options.removeConfirmation&&a._lastTag().removeClass("remove ui-state-highlight");if(c.which===b.ui.keyCode.COMMA||c.which===b.ui.keyCode.ENTER||c.which==b.ui.keyCode.TAB&&
+""!==a.tagInput.val()||c.which==b.ui.keyCode.SPACE&&!0!==a.options.allowSpaces&&('"'!=b.trim(a.tagInput.val()).replace(/^s*/,"").charAt(0)||'"'==b.trim(a.tagInput.val()).charAt(0)&&'"'==b.trim(a.tagInput.val()).charAt(b.trim(a.tagInput.val()).length-1)&&0!==b.trim(a.tagInput.val()).length-1))c.which===b.ui.keyCode.ENTER&&""===a.tagInput.val()||c.preventDefault(),a.tagInput.data("autocomplete-open")||a.createTag(a._cleanedInput())}).blur(function(){a.tagInput.data("autocomplete-open")||a.createTag(a._cleanedInput())});
+if(this.options.availableTags||this.options.tagSource||this.options.autocomplete.source)c={select:function(b,c){a.createTag(c.item.value);return!1}},b.extend(c,this.options.autocomplete),c.source=this.options.tagSource||c.source,this.tagInput.autocomplete(c).bind("autocompleteopen",function(){a.tagInput.data("autocomplete-open",!0)}).bind("autocompleteclose",function(){a.tagInput.data("autocomplete-open",!1)})},_cleanedInput:function(){return b.trim(this.tagInput.val().replace(/^"(.*)"$/,"$1"))},
+_lastTag:function(){return this.tagList.find(".tagit-choice:last:not(.removed)")},_tags:function(){return this.tagList.find(".tagit-choice:not(.removed)")},assignedTags:function(){var a=this,d=[];this.options.singleField?(d=b(this.options.singleFieldNode).val().split(this.options.singleFieldDelimiter),""===d[0]&&(d=[])):this._tags().each(function(){d.push(a.tagLabel(this))});return d},_updateSingleTagsField:function(a){b(this.options.singleFieldNode).val(a.join(this.options.singleFieldDelimiter)).trigger("change")},
+_subtractArray:function(a,d){for(var c=[],e=0;e<a.length;e++)-1==b.inArray(a[e],d)&&c.push(a[e]);return c},tagLabel:function(a){return this.options.singleField?b(a).find(".tagit-label:first").text():b(a).find("input:first").val()},_showAutocomplete:function(){this.tagInput.autocomplete("search","")},_findTagByLabel:function(a){var d=this,c=null;this._tags().each(function(){if(d._formatStr(a)==d._formatStr(d.tagLabel(this)))return c=b(this),!1});return c},_isNew:function(a){return!this._findTagByLabel(a)},
+_formatStr:function(a){return this.options.caseSensitive?a:b.trim(a.toLowerCase())},_effectExists:function(a){return Boolean(b.effects&&(b.effects[a]||b.effects.effect&&b.effects.effect[a]))},createTag:function(a,d,c){var e=this;a=b.trim(a);this.options.preprocessTag&&(a=this.options.preprocessTag(a));if(""===a)return!1;if(!this.options.allowDuplicates&&!this._isNew(a))return a=this._findTagByLabel(a),!1!==this._trigger("onTagExists",null,{existingTag:a,duringInitialization:c})&&this._effectExists("highlight")&&
+a.effect("highlight"),!1;if(this.options.tagLimit&&this._tags().length>=this.options.tagLimit)return this._trigger("onTagLimitExceeded",null,{duringInitialization:c}),!1;var g=b(this.options.onTagClicked?'<a class="tagit-label"></a>':'<span class="tagit-label"></span>').text(a),f=b("<li></li>").addClass("tagit-choice ui-widget-content ui-state-default ui-corner-all").addClass(d).append(g);this.options.readOnly?f.addClass("tagit-choice-read-only"):(f.addClass("tagit-choice-editable"),d=b("<span></span>").addClass("ui-icon ui-icon-close"),
+d=b('<a><span class="text-icon">\u00d7</span></a>').addClass("tagit-close").append(d).click(function(){e.removeTag(f)}),f.append(d));this.options.singleField||(g=g.html(),f.append('<input type="hidden" style="display:none;" value="'+g+'" name="'+this.options.fieldName+'" />'));!1!==this._trigger("beforeTagAdded",null,{tag:f,tagLabel:this.tagLabel(f),duringInitialization:c})&&(this.options.singleField&&(g=this.assignedTags(),g.push(a),this._updateSingleTagsField(g)),this._trigger("onTagAdded",null,
+f),this.tagInput.val(""),this.tagInput.parent().before(f),this._trigger("afterTagAdded",null,{tag:f,tagLabel:this.tagLabel(f),duringInitialization:c}),this.options.showAutocompleteOnFocus&&!c&&setTimeout(function(){e._showAutocomplete()},0))},removeTag:function(a,d){d="undefined"===typeof d?this.options.animate:d;a=b(a);this._trigger("onTagRemoved",null,a);if(!1!==this._trigger("beforeTagRemoved",null,{tag:a,tagLabel:this.tagLabel(a)})){if(this.options.singleField){var c=this.assignedTags(),e=this.tagLabel(a),
+c=b.grep(c,function(a){return a!=e});this._updateSingleTagsField(c)}if(d){a.addClass("removed");var c=this._effectExists("blind")?["blind",{direction:"horizontal"},"fast"]:["fast"],g=this;c.push(function(){a.remove();g._trigger("afterTagRemoved",null,{tag:a,tagLabel:g.tagLabel(a)})});a.fadeOut("fast").hide.apply(a,c).dequeue()}else a.remove(),this._trigger("afterTagRemoved",null,{tag:a,tagLabel:this.tagLabel(a)})}},removeTagByLabel:function(a,b){var c=this._findTagByLabel(a);if(!c)throw"No such tag exists with the name '"+
+a+"'";this.removeTag(c,b)},removeAll:function(){var a=this;this._tags().each(function(b,c){a.removeTag(c,!1)})}})})(jQuery);