# HG changeset patch # User Anthony Ly # Date 1371733393 -7200 # Node ID 5ce3313fb21d0737ed5a366bf8a1c0aa534e0c0b # Parent 211680696ab750425167fbd0002cd9f29d19879e add tag it plugin diff -r 211680696ab7 -r 5ce3313fb21d integration/v2/13-detail_image.html --- a/integration/v2/13-detail_image.html Wed Jun 19 15:15:05 2013 +0200 +++ b/integration/v2/13-detail_image.html Thu Jun 20 15:03:13 2013 +0200 @@ -112,12 +112,31 @@ -
+ +
+

Fragments de cette image :

+

Pas de fragment

+
+
+

Collections liées à cette image :

+

Pas de collection

+
diff -r 211680696ab7 -r 5ce3313fb21d integration/v2/14-creation_fragment.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/integration/v2/14-creation_fragment.html Thu Jun 20 15:03:13 2013 +0200 @@ -0,0 +1,190 @@ + + + + + + + + + + eGonomy : Détail image + + + + + + + + + + + +
+
+

egonomy

+
+ + +
+
+
+
+

MEDÉE / Nouveau fragment

+
+
+
    +
  • +
  • +
+ +
+
+
+
+ +
+
+ +
+
+ +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Auteur :
Image source :Médée
Auteur :Delacroix Eugène (1798-1863)
Période :Période contemporaine de 1789 à 1914,19e siècle
Site de production :-
Localisation :Lille, Palais des Beaux-Arts
+
+
+
+
+ + + + + + + + + +
Mots clés :
Mots clés de l’image source : + +
+
+ Annuler + +
+
+
+ +
+

Fragments de cette image :

+

Pas de fragment

+
+
+

Collections liées à cette image :

+

Pas de collection

+
+
+ +
+
+
EGONOMY est un projet de l’IRI et de la réunion des Musées Nationaux
+

Mai 2013

+
+
+ + + + + + + + + diff -r 211680696ab7 -r 5ce3313fb21d integration/v2/15-detail_fragment.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/integration/v2/15-detail_fragment.html Thu Jun 20 15:03:13 2013 +0200 @@ -0,0 +1,154 @@ + + + + + + + + + + eGonomy : Détail image + + + + + + + + + +
+
+

egonomy

+
+ + +
+
+
+
+

MEDÉE

+
+
+
    +
  • +
  • +
+ +
+
+
+
+ +
+
+ +
+
+ +
+ +
+
+ + + + + + + + + + + + + + + +
Auteur :Delacroix Eugène (1798-1863)
Période :Période contemporaine de 1789 à 1914,19e siècle,
Description :Lorem ipsum dolor sit amet, consectetur adipisicing elit. In sapiente consectetur amet ipsam rem quae culpa voluptatem excepturi aperiam pariatur eaque explicabo. Voluptates natus nulla repellat dolorem animi ut voluptate.
+
+ +
+

Fragments de cette image :

+

Pas de fragment

+
+
+

Collections liées à cette image :

+

Pas de collection

+
+
+ +
+
+
EGONOMY est un projet de l’IRI et de la réunion des Musées Nationaux
+

Mai 2013

+
+
+ + + + + + + diff -r 211680696ab7 -r 5ce3313fb21d integration/v2/css/fonts.css --- a/integration/v2/css/fonts.css Wed Jun 19 15:15:05 2013 +0200 +++ b/integration/v2/css/fonts.css Thu Jun 20 15:03:13 2013 +0200 @@ -232,7 +232,7 @@ } @font-face { - font-family: 'LatoBold'; + font-family: 'Lato'; src: url('fonts/lato/Lato-BolIta-webfont.eot'); src: url('fonts/lato/Lato-BolIta-webfont.eot?#iefix') format('embedded-opentype'), url('fonts/lato/Lato-BolIta-webfont.woff') format('woff'), diff -r 211680696ab7 -r 5ce3313fb21d integration/v2/css/style.css --- a/integration/v2/css/style.css Wed Jun 19 15:15:05 2013 +0200 +++ b/integration/v2/css/style.css Thu Jun 20 15:03:13 2013 +0200 @@ -3,7 +3,7 @@ .wrap{width: 950px; margin: 0 auto; } .uppercase{text-transform: uppercase;} .fragment{width: 225px; height: 225px;} - +.va-top{vertical-align: top;} header, footer{width:100%;background: url(../img/border-bottom-header.png) center bottom no-repeat;} footer{margin-bottom: 60px;background-position: top center; padding-top: 20px;font-size: 15px; font-family: 'Lato'; font-weight: 300;} footer h6{float: left;} @@ -107,7 +107,8 @@ .list-projets-3 .project-title{position:relative; padding-left: 14px; font-size: 18px;height: 60px; border-bottom: 1px solid #CCC;} .project-title h3{ font-family: 'Lato'; font-weight : bold; padding-top: 12px; margin-bottom: 4px; } .project-title h4{ font-family: 'Lato'; font-weight: 300; font-style: italic;} -.project-title a.edit{ position: absolute; top: 10px; right: 10px;} +.project-title a.edit{ position: absolute; top: 10px; right: 10px; opacity: 0.7;} +.project-title a.edit:hover{opacity: 1;} .list-projets-3 .col-right p{max-height:200px; overflow: auto; padding: 10px 12px;font-size: 14px; font-family: 'Lato'; line-height: 18px;} .list-projets-3>li:hover{-webkit-box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);-moz-box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);} @@ -141,6 +142,7 @@ .tool.trash:hover{background-position: -140px 0;} .box-shadow{ -webkit-box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);-moz-box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);box-shadow: 1px 1px 5px rgba(50, 50, 50, 0.75);} +.box-shadow-2{ -webkit-box-shadow: 1px 1px 2px rgba(50, 50, 50, 0.75);-moz-box-shadow: 1px 1px 2px rgba(50, 50, 50, 0.75);box-shadow: 1px 1px 2px rgba(50, 50, 50, 0.75);} .popin-wrap{width: 100%; height: 100%; position: fixed; z-index: 100; background-color:rgba(255,255,255,.7);} .popin{width: 460px; background-color: #fff; top: 10%; position: absolute; left: 50%; margin-left: -230px;} .popin h2{ font-size: 14px; font-family: 'Lato'; padding: 14px 0 10px 12px;} @@ -165,10 +167,29 @@ .slideshow .share{position: absolute; bottom: 24px; right: 0;} .slideshow .share li{float: left; margin-left: 8px;} .image-wrap{display: inline-block;} -.info{font-family: 'Lato'; font-size: 14px; text-align: left;} -.info th{color: #777; min-width: 140px; } -.info td{color: #000; line-height: 16px;} -.info table{border-collapse:separate;border-spacing:0 5px;} +.edition{font-family: 'Lato'; font-size: 14px; text-align: left;} + +.edition th{color: #777; min-width: 140px; } +.edition td{width:100%;color: #000; line-height: 16px;} +.edition table{width: 100%; border-collapse:separate;border-spacing:0 5px;} .box-edition{padding: 16px 0; border-bottom: 1px solid #CCC;} .box-edition h3{color: #777;font-family: 'Lato'; font-size: 14px; margin-bottom: 6px;} -.list-key-search a{display: inline-block;} \ No newline at end of file + +.list-key-search a{ background-image: url(../img/icon-search.png);} +.list-key-add a{ background-image: url(../img/icon-plus-15.png);} + +.list-keywords li{display: inline-block; float: left; margin: 0 8px 8px 0;} +.list-keywords a{color: #7F7F7F; font-family: 'Lato'; font-size: 12px; display: inline-block; height: 28px; line-height: 28px; padding: 0 30px 0 6px; +background-position: right 4px center; background-repeat: no-repeat; background-color: #fff;} +.list-keywords a:hover{-webkit-box-shadow: none;-moz-box-shadow: none;box-shadow: none;} + +.f-right{float: right;} +.fs-normal{font-style: normal;} +.pt-6{padding-top: 6px;} +.null{font-weight: bold;font-style: italic; font-family: 'Lato'; color: #CCC; font-style: 18px; line-height: 50px; text-align: center;} +.box-edition:last-child{border-bottom: none;} +.edition input[type=text], .edition textarea{border: 1px solid #CACACA;} +.edition textarea{width:100%; max-width: 754px;} +.edition input[type=text]{height: 23px; line-height: 23px; padding: 0 6px;} +.no-before:before{content:"" ; display: block;} +.tagit{font-family: 'Lato' !important;} diff -r 211680696ab7 -r 5ce3313fb21d integration/v2/js/main.js --- a/integration/v2/js/main.js Wed Jun 19 15:15:05 2013 +0200 +++ b/integration/v2/js/main.js Thu Jun 20 15:03:13 2013 +0200 @@ -26,5 +26,15 @@ $('.popin').bind('click', function(e){ e.stopPropagation(); }); - +//tag it + var keywordsTagIt = $('.tag-it').tagit({ + allowSpaces : true + }); + $('.list-key-add a').bind('click', function(e){ + e.preventDefault(); + var tag = $(this).attr('data-tag'); + keywordsTagIt.tagit("createTag", tag); + }); + + });//ready diff -r 211680696ab7 -r 5ce3313fb21d integration/v2/lib/tag-it/css/jquery.tagit.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/integration/v2/lib/tag-it/css/jquery.tagit.css Thu Jun 20 15:03:13 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; +} diff -r 211680696ab7 -r 5ce3313fb21d integration/v2/lib/tag-it/css/tagit.ui-zendesk.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/integration/v2/lib/tag-it/css/tagit.ui-zendesk.css Thu Jun 20 15:03:13 2013 +0200 @@ -0,0 +1,56 @@ + +/* Optional scoped theme for tag-it which mimics the zendesk widget. */ + + +ul.tagit { + border-style: solid; + border-width: 1px; + border-color: #C6C6C6; + background: inherit; +} +ul.tagit li.tagit-choice { + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-border-radius: 6px; + border: 1px solid #CAD8F3; + + background: none; + background-color: #DEE7F8; + + font-weight: normal; +} +ul.tagit li.tagit-choice .tagit-label:not(a) { + color: #555; +} +ul.tagit li.tagit-choice a.tagit-close { + text-decoration: none; +} +ul.tagit li.tagit-choice .tagit-close { + right: .4em; +} +ul.tagit li.tagit-choice .ui-icon { + display: none; +} +ul.tagit li.tagit-choice .tagit-close .text-icon { + display: inline; + font-family: arial, sans-serif; + font-size: 16px; + line-height: 16px; + color: #777; +} +ul.tagit li.tagit-choice:hover, ul.tagit li.tagit-choice.remove { + background-color: #bbcef1; + border-color: #6d95e0; +} +ul.tagit li.tagit-choice a.tagLabel:hover, +ul.tagit li.tagit-choice a.tagit-close .text-icon:hover { + color: #222; +} +ul.tagit input[type="text"] { + color: #333333; + background: none; +} +.ui-widget { + font-size: 1.1em; +} + diff -r 211680696ab7 -r 5ce3313fb21d integration/v2/lib/tag-it/js/tag-it.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/integration/v2/lib/tag-it/js/tag-it.js Thu Jun 20 15:03:13 2013 +0200 @@ -0,0 +1,541 @@ +/* +* jQuery UI Tag-it! +* +* @version v2.0 (06/2011) +* +* Copyright 2011, Levy Carneiro Jr. +* Released under the MIT license. +* http://aehlke.github.com/tag-it/LICENSE +* +* Homepage: +* http://aehlke.github.com/tag-it/ +* +* Authors: +* Levy Carneiro Jr. +* Martin Rehfeld +* Tobias Schmidt +* Skylar Challand +* Alex Ehlke +* +* Maintainer: +* Alex Ehlke - Twitter: @aehlke +* +* Dependencies: +* jQuery v1.4+ +* jQuery UI v1.8+ +*/ +(function($) { + + $.widget('ui.tagit', { + options: { + allowDuplicates : false, + caseSensitive : true, + fieldName : 'tags', + placeholderText : null, // Sets `placeholder` attr on input field. + readOnly : false, // Disables editing. + removeConfirmation: false, // Require confirmation to remove tags. + tagLimit : null, // Max number of tags allowed (null for unlimited). + + // Used for autocomplete, unless you override `autocomplete.source`. + availableTags : [], + + // Use to override or add any options to the autocomplete widget. + // + // By default, autocomplete.source will map to availableTags, + // unless overridden. + autocomplete: {}, + + // Shows autocomplete before the user even types anything. + showAutocompleteOnFocus: false, + + // When enabled, quotes are unneccesary for inputting multi-word tags. + allowSpaces: false, + + // The below options are for using a single field instead of several + // for our form values. + // + // When enabled, will use a single hidden field for the form, + // rather than one per tag. It will delimit tags in the field + // with singleFieldDelimiter. + // + // The easiest way to use singleField is to just instantiate tag-it + // on an INPUT element, in which case singleField is automatically + // set to true, and singleFieldNode is set to that element. This + // way, you don't need to fiddle with these options. + singleField: false, + + // This is just used when preloading data from the field, and for + // populating the field with delimited tags as the user adds them. + singleFieldDelimiter: ',', + + // Set this to an input DOM node to use an existing form field. + // Any text in it will be erased on init. But it will be + // populated with the text of tags as they are created, + // delimited by singleFieldDelimiter. + // + // If this is not set, we create an input node for it, + // with the name given in settings.fieldName. + singleFieldNode: null, + + // Whether to animate tag removals or not. + animate: true, + + // Optionally set a tabindex attribute on the input that gets + // created for tag-it. + tabIndex: null, + + // Event callbacks. + beforeTagAdded : null, + afterTagAdded : null, + + beforeTagRemoved : null, + afterTagRemoved : null, + + onTagClicked : null, + onTagLimitExceeded : null, + + + // DEPRECATED: + // + // /!\ These event callbacks are deprecated and WILL BE REMOVED at some + // point in the future. They're here for backwards-compatibility. + // Use the above before/after event callbacks instead. + onTagAdded : null, + onTagRemoved: null, + // `autocomplete.source` is the replacement for tagSource. + tagSource: null + // Do not use the above deprecated options. + }, + + _create: function() { + // for handling static scoping inside callbacks + var that = this; + + // There are 2 kinds of DOM nodes this widget can be instantiated on: + // 1. UL, OL, or some element containing either of these. + // 2. INPUT, in which case 'singleField' is overridden to true, + // a UL is created and the INPUT is hidden. + if (this.element.is('input')) { + this.tagList = $('').insertAfter(this.element); + this.options.singleField = true; + this.options.singleFieldNode = this.element; + this.element.css('display', 'none'); + } else { + this.tagList = this.element.find('ul, ol').andSelf().last(); + } + + this.tagInput = $('').addClass('ui-widget-content'); + + if (this.options.readOnly) this.tagInput.attr('disabled', 'disabled'); + + if (this.options.tabIndex) { + this.tagInput.attr('tabindex', this.options.tabIndex); + } + + if (this.options.placeholderText) { + this.tagInput.attr('placeholder', this.options.placeholderText); + } + + if (!this.options.autocomplete.source) { + this.options.autocomplete.source = function(search, showChoices) { + var filter = search.term.toLowerCase(); + var choices = $.grep(this.options.availableTags, function(element) { + // Only match autocomplete options that begin with the search term. + // (Case insensitive.) + return (element.toLowerCase().indexOf(filter) === 0); + }); + if (!this.options.allowDuplicates) { + choices = this._subtractArray(choices, this.assignedTags()); + } + showChoices(choices); + }; + } + + if (this.options.showAutocompleteOnFocus) { + this.tagInput.focus(function(event, ui) { + that._showAutocomplete(); + }); + + if (typeof this.options.autocomplete.minLength === 'undefined') { + this.options.autocomplete.minLength = 0; + } + } + + // Bind autocomplete.source callback functions to this context. + if ($.isFunction(this.options.autocomplete.source)) { + this.options.autocomplete.source = $.proxy(this.options.autocomplete.source, this); + } + + // DEPRECATED. + if ($.isFunction(this.options.tagSource)) { + this.options.tagSource = $.proxy(this.options.tagSource, this); + } + + this.tagList + .addClass('tagit') + .addClass('ui-widget ui-widget-content ui-corner-all') + // Create the input field. + .append($('
  • ').append(this.tagInput)) + .click(function(e) { + var target = $(e.target); + if (target.hasClass('tagit-label')) { + var tag = target.closest('.tagit-choice'); + if (!tag.hasClass('removed')) { + that._trigger('onTagClicked', e, {tag: tag, tagLabel: that.tagLabel(tag)}); + } + } else { + // Sets the focus() to the input field, if the user + // clicks anywhere inside the UL. This is needed + // because the input field needs to be of a small size. + that.tagInput.focus(); + } + }); + + // Single field support. + var addedExistingFromSingleFieldNode = false; + if (this.options.singleField) { + if (this.options.singleFieldNode) { + // Add existing tags from the input field. + var node = $(this.options.singleFieldNode); + var tags = node.val().split(this.options.singleFieldDelimiter); + node.val(''); + $.each(tags, function(index, tag) { + that.createTag(tag, null, true); + addedExistingFromSingleFieldNode = true; + }); + } else { + // Create our single field input after our list. + this.options.singleFieldNode = $(''); + this.tagList.after(this.options.singleFieldNode); + } + } + + // Add existing tags from the list, if any. + if (!addedExistingFromSingleFieldNode) { + this.tagList.children('li').each(function() { + if (!$(this).hasClass('tagit-new')) { + that.createTag($(this).text(), $(this).attr('class'), true); + $(this).remove(); + } + }); + } + + // Events. + this.tagInput + .keydown(function(event) { + // Backspace is not detected within a keypress, so it must use keydown. + if (event.which == $.ui.keyCode.BACKSPACE && that.tagInput.val() === '') { + var tag = that._lastTag(); + if (!that.options.removeConfirmation || tag.hasClass('remove')) { + // When backspace is pressed, the last tag is deleted. + that.removeTag(tag); + } else if (that.options.removeConfirmation) { + tag.addClass('remove ui-state-highlight'); + } + } else if (that.options.removeConfirmation) { + that._lastTag().removeClass('remove ui-state-highlight'); + } + + // Comma/Space/Enter are all valid delimiters for new tags, + // except when there is an open quote or if setting allowSpaces = true. + // Tab will also create a tag, unless the tag input is empty, + // in which case it isn't caught. + if ( + event.which === $.ui.keyCode.COMMA || + event.which === $.ui.keyCode.ENTER || + ( + event.which == $.ui.keyCode.TAB && + that.tagInput.val() !== '' + ) || + ( + event.which == $.ui.keyCode.SPACE && + that.options.allowSpaces !== true && + ( + $.trim(that.tagInput.val()).replace( /^s*/, '' ).charAt(0) != '"' || + ( + $.trim(that.tagInput.val()).charAt(0) == '"' && + $.trim(that.tagInput.val()).charAt($.trim(that.tagInput.val()).length - 1) == '"' && + $.trim(that.tagInput.val()).length - 1 !== 0 + ) + ) + ) + ) { + // Enter submits the form if there's no text in the input. + if (!(event.which === $.ui.keyCode.ENTER && that.tagInput.val() === '')) { + event.preventDefault(); + } + + // Autocomplete will create its own tag from a selection and close automatically. + if (!that.tagInput.data('autocomplete-open')) { + that.createTag(that._cleanedInput()); + } + } + }).blur(function(e){ + // Create a tag when the element loses focus. + // If autocomplete is enabled and suggestion was clicked, don't add it. + if (!that.tagInput.data('autocomplete-open')) { + that.createTag(that._cleanedInput()); + } + }); + + // Autocomplete. + if (this.options.availableTags || this.options.tagSource || this.options.autocomplete.source) { + var autocompleteOptions = { + select: function(event, ui) { + that.createTag(ui.item.value); + // Preventing the tag input to be updated with the chosen value. + return false; + } + }; + $.extend(autocompleteOptions, this.options.autocomplete); + + // tagSource is deprecated, but takes precedence here since autocomplete.source is set by default, + // while tagSource is left null by default. + autocompleteOptions.source = this.options.tagSource || autocompleteOptions.source; + + this.tagInput.autocomplete(autocompleteOptions).bind('autocompleteopen', function(event, ui) { + that.tagInput.data('autocomplete-open', true); + }).bind('autocompleteclose', function(event, ui) { + that.tagInput.data('autocomplete-open', false) + }); + } + }, + + _cleanedInput: function() { + // Returns the contents of the tag input, cleaned and ready to be passed to createTag + return $.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() { + // Returns an array of tag string values + var that = this; + var tags = []; + if (this.options.singleField) { + tags = $(this.options.singleFieldNode).val().split(this.options.singleFieldDelimiter); + if (tags[0] === '') { + tags = []; + } + } else { + this._tags().each(function() { + tags.push(that.tagLabel(this)); + }); + } + return tags; + }, + + _updateSingleTagsField: function(tags) { + // Takes a list of tag string values, updates this.options.singleFieldNode.val to the tags delimited by this.options.singleFieldDelimiter + $(this.options.singleFieldNode).val(tags.join(this.options.singleFieldDelimiter)).trigger('change'); + }, + + _subtractArray: function(a1, a2) { + var result = []; + for (var i = 0; i < a1.length; i++) { + if ($.inArray(a1[i], a2) == -1) { + result.push(a1[i]); + } + } + return result; + }, + + tagLabel: function(tag) { + // Returns the tag's string label. + if (this.options.singleField) { + return $(tag).find('.tagit-label:first').text(); + } else { + return $(tag).find('input:first').val(); + } + }, + + _showAutocomplete: function() { + this.tagInput.autocomplete('search', ''); + }, + + _findTagByLabel: function(name) { + var that = this; + var tag = null; + this._tags().each(function(i) { + if (that._formatStr(name) == that._formatStr(that.tagLabel(this))) { + tag = $(this); + return false; + } + }); + return tag; + }, + + _isNew: function(name) { + return !this._findTagByLabel(name); + }, + + _formatStr: function(str) { + if (this.options.caseSensitive) { + return str; + } + return $.trim(str.toLowerCase()); + }, + + _effectExists: function(name) { + return Boolean($.effects && ($.effects[name] || ($.effects.effect && $.effects.effect[name]))); + }, + + createTag: function(value, additionalClass, duringInitialization) { + var that = this; + + value = $.trim(value); + + if(this.options.preprocessTag) { + value = this.options.preprocessTag(value); + } + + if (value === '') { + return false; + } + + if (!this.options.allowDuplicates && !this._isNew(value)) { + var existingTag = this._findTagByLabel(value); + if (this._trigger('onTagExists', null, { + existingTag: existingTag, + duringInitialization: duringInitialization + }) !== false) { + if (this._effectExists('highlight')) { + existingTag.effect('highlight'); + } + } + return false; + } + + if (this.options.tagLimit && this._tags().length >= this.options.tagLimit) { + this._trigger('onTagLimitExceeded', null, {duringInitialization: duringInitialization}); + return false; + } + + var label = $(this.options.onTagClicked ? '' : '').text(value); + + // Create tag. + var tag = $('
  • ') + .addClass('tagit-choice ui-widget-content ui-state-default ui-corner-all') + .addClass(additionalClass) + .append(label); + + if (this.options.readOnly){ + tag.addClass('tagit-choice-read-only'); + } else { + tag.addClass('tagit-choice-editable'); + // Button for removing the tag. + var removeTagIcon = $('') + .addClass('ui-icon ui-icon-close'); + var removeTag = $('\xd7') // \xd7 is an X + .addClass('tagit-close') + .append(removeTagIcon) + .click(function(e) { + // Removes a tag when the little 'x' is clicked. + that.removeTag(tag); + }); + tag.append(removeTag); + } + + // Unless options.singleField is set, each tag has a hidden input field inline. + if (!this.options.singleField) { + var escapedValue = label.html(); + tag.append(''); + } + + if (this._trigger('beforeTagAdded', null, { + tag: tag, + tagLabel: this.tagLabel(tag), + duringInitialization: duringInitialization + }) === false) { + return; + } + + if (this.options.singleField) { + var tags = this.assignedTags(); + tags.push(value); + this._updateSingleTagsField(tags); + } + + // DEPRECATED. + this._trigger('onTagAdded', null, tag); + + this.tagInput.val(''); + + // Insert tag. + this.tagInput.parent().before(tag); + + this._trigger('afterTagAdded', null, { + tag: tag, + tagLabel: this.tagLabel(tag), + duringInitialization: duringInitialization + }); + + if (this.options.showAutocompleteOnFocus && !duringInitialization) { + setTimeout(function () { that._showAutocomplete(); }, 0); + } + }, + + removeTag: function(tag, animate) { + animate = typeof animate === 'undefined' ? this.options.animate : animate; + + tag = $(tag); + + // DEPRECATED. + this._trigger('onTagRemoved', null, tag); + + if (this._trigger('beforeTagRemoved', null, {tag: tag, tagLabel: this.tagLabel(tag)}) === false) { + return; + } + + if (this.options.singleField) { + var tags = this.assignedTags(); + var removedTagLabel = this.tagLabel(tag); + tags = $.grep(tags, function(el){ + return el != removedTagLabel; + }); + this._updateSingleTagsField(tags); + } + + if (animate) { + tag.addClass('removed'); // Excludes this tag from _tags. + var hide_args = this._effectExists('blind') ? ['blind', {direction: 'horizontal'}, 'fast'] : ['fast']; + + var thisTag = this; + hide_args.push(function() { + tag.remove(); + thisTag._trigger('afterTagRemoved', null, {tag: tag, tagLabel: thisTag.tagLabel(tag)}); + }); + + tag.fadeOut('fast').hide.apply(tag, hide_args).dequeue(); + } else { + tag.remove(); + this._trigger('afterTagRemoved', null, {tag: tag, tagLabel: this.tagLabel(tag)}); + } + + }, + + removeTagByLabel: function(tagLabel, animate) { + var toRemove = this._findTagByLabel(tagLabel); + if (!toRemove) { + throw "No such tag exists with the name '" + tagLabel + "'"; + } + this.removeTag(toRemove, animate); + }, + + removeAll: function() { + // Removes all tags. + var that = this; + this._tags().each(function(index, tag) { + that.removeTag(tag, false); + }); + } + + }); +})(jQuery); + diff -r 211680696ab7 -r 5ce3313fb21d integration/v2/lib/tag-it/js/tag-it.min.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/integration/v2/lib/tag-it/js/tag-it.min.js Thu Jun 20 15:03:13 2013 +0200 @@ -0,0 +1,17 @@ +(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("").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('').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('
  • ').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(''),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=this.options.tagLimit)return this._trigger("onTagLimitExceeded",null,{duringInitialization:c}),!1;var g=b(this.options.onTagClicked?'':'').text(a),f=b("
  • ").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("").addClass("ui-icon ui-icon-close"), +d=b('\u00d7').addClass("tagit-close").append(d).click(function(){e.removeTag(f)}),f.append(d));this.options.singleField||(g=g.html(),f.append(''));!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); +jQuery.curCSS = jQuery.css; \ No newline at end of file