Commit 973b71d63435f48659459970b9d06eb06e3c9564
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'task_taggable' into production
Showing
1 changed file
with
22 additions
and
8 deletions
Show diff stats
public/javascripts/inputosaurus.js
| ... | ... | @@ -316,7 +316,7 @@ |
| 316 | 316 | v.key === tagKey && (tagName = v.value); |
| 317 | 317 | }); |
| 318 | 318 | |
| 319 | - widget.beforeEditValue = widget.element.val(); | |
| 319 | + widget.beforeEditValue = widget.element.val().replace(/,\s*/g,','); | |
| 320 | 320 | widget.elements.input.val(tagName); |
| 321 | 321 | |
| 322 | 322 | widget._removeTag(ev); |
| ... | ... | @@ -444,18 +444,21 @@ |
| 444 | 444 | return value; |
| 445 | 445 | }, |
| 446 | 446 | |
| 447 | - _setValue : function(value) { | |
| 447 | + _setValue : function(value,ev) { | |
| 448 | 448 | |
| 449 | - if(arguments[1] && (arguments[1].type == 'dblclick' && value == '')){ | |
| 450 | - return false; | |
| 451 | - } | |
| 452 | 449 | var val = this.element.val().replace(/,\s*/g,','); |
| 453 | 450 | |
| 454 | 451 | if(val !== value){ |
| 455 | 452 | this.element.val(value); |
| 456 | 453 | this._trigger('change'); |
| 454 | + | |
| 457 | 455 | if($.isPlainObject(this.options.submitTags)){ |
| 458 | - this._sendTags(); | |
| 456 | + | |
| 457 | + if(ev && ev.type == 'dblclick'){ | |
| 458 | + return false; | |
| 459 | + } | |
| 460 | + | |
| 461 | + this._sendTags(ev); | |
| 459 | 462 | } |
| 460 | 463 | } |
| 461 | 464 | }, |
| ... | ... | @@ -496,6 +499,12 @@ |
| 496 | 499 | |
| 497 | 500 | indexFound !== false && widget._chosenValues.splice(indexFound, 1); |
| 498 | 501 | |
| 502 | + if (!widget.beforeEditValue) { | |
| 503 | + ev.data.sourceEvent = 'remove'; | |
| 504 | + }else{ | |
| 505 | + ev.data.sourceEvent = 'edit'; | |
| 506 | + } | |
| 507 | + | |
| 499 | 508 | widget._setValue(widget._buildValue(),ev); |
| 500 | 509 | |
| 501 | 510 | $(ev.currentTarget).closest('li').remove(); |
| ... | ... | @@ -560,10 +569,15 @@ |
| 560 | 569 | |
| 561 | 570 | }, |
| 562 | 571 | |
| 563 | - _sendTags: function(){ | |
| 572 | + _sendTags: function(ev){ | |
| 564 | 573 | |
| 565 | 574 | var requestTags = this.options.submitTags; |
| 566 | - if(this.element.val() != '' && this.beforeEditValue != this.element.val()) { | |
| 575 | + var event = ev || {type:'',data:{}}; | |
| 576 | + | |
| 577 | + if((event.data.sourceEvent == 'remove') | |
| 578 | + || (this.element.val() != '' && this.beforeEditValue != this.element.val())) { | |
| 579 | + | |
| 580 | + this.beforeEditValue = ''; | |
| 567 | 581 | |
| 568 | 582 | opts = $.extend({ |
| 569 | 583 | url: requestTags.url, | ... | ... |