Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Let commas occur in quoted tags

  • Loading branch information...
commit 3d67d4b03a7fcb24dfae5b165aca585e8d2a4544 1 parent c461975
Chris Leishman authored

Showing 1 changed file with 15 additions and 9 deletions. Show diff stats Hide diff stats

  1. +15 9 js/tag-it.js
24 js/tag-it.js
@@ -177,23 +177,19 @@
177 177 // except when there is an open quote or if setting allowSpaces = true.
178 178 // Tab will also create a tag, unless the tag input is empty, in which case it isn't caught.
179 179 if (
180   - event.which == $.ui.keyCode.COMMA ||
181 180 event.which == $.ui.keyCode.ENTER ||
182 181 (
183 182 event.which == $.ui.keyCode.TAB &&
184 183 that._tagInput.val() !== ''
185 184 ) ||
186 185 (
  186 + event.which == $.ui.keyCode.COMMA &&
  187 + that._tagInputHasClosedQuotes()
  188 + ) ||
  189 + (
187 190 event.which == $.ui.keyCode.SPACE &&
188 191 that.options.allowSpaces !== true &&
189   - (
190   - $.trim(that._tagInput.val()).replace( /^s*/, '' ).charAt(0) != '"' ||
191   - (
192   - $.trim(that._tagInput.val()).charAt(0) == '"' &&
193   - $.trim(that._tagInput.val()).charAt($.trim(that._tagInput.val()).length - 1) == '"' &&
194   - $.trim(that._tagInput.val()).length - 1 !== 0
195   - )
196   - )
  192 + that._tagInputHasClosedQuotes()
197 193 )
198 194 ) {
199 195 event.preventDefault();
@@ -240,6 +236,16 @@
240 236 return this.tagList.children('.tagit-choice:last');
241 237 },
242 238
  239 + _tagInputHasClosedQuotes: function() {
  240 + var inputVal = this._tagInput.val();
  241 + return $.trim(inputVal).replace( /^s*/, '' ).charAt(0) != '"' ||
  242 + (
  243 + $.trim(inputVal).charAt(0) == '"' &&
  244 + $.trim(inputVal).charAt($.trim(inputVal).length - 1) == '"' &&
  245 + $.trim(inputVal).length - 1 !== 0
  246 + )
  247 + },
  248 +
243 249 assignedTags: function() {
244 250 // Returns an array of tag string values
245 251 var that = this;

0 comments on commit 3d67d4b

Please sign in to comment.
Something went wrong with that request. Please try again.