tagify 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 977ff70e79b306bcbf7172a0c9d4a01b91104afc
4
- data.tar.gz: cc307aa99be30ad55716f8f24ab3a15d33a6998a
3
+ metadata.gz: 13ea563706bbc3376a30438a2880e3bb64461020
4
+ data.tar.gz: 9c6bda4025579ec5a8dcf6cc7182bffa71b785a3
5
5
  SHA512:
6
- metadata.gz: 5052f0434337c5238e746790f49e320893a8ce9eb9fad5c0a36c904ea58e59f7afaf23452d5b459ce8737c49d8e31b4483795e30a14e785ffda25197991b7cde
7
- data.tar.gz: 9507b679004b976f01f4c4ec23df3ac287f321709f257ebc44e0d9537ee6be679abe55f966723628edf704fd1856df822aa017fd9d4447173fe2fccbdeabfd8a
6
+ metadata.gz: 1689de89ed8c25d96023cf12c7c04f4529cc51f808831f4c35b33ba0dff63b264eb36098195b9eff9a3f0b5171e08de89153f2d74797eabb8dc897e077f4457b
7
+ data.tar.gz: 7cb6fcbdf7ca6c31068ac5327b88e57e1a5d576f9b743cb23f4e4b54a585c24f42e43c70af99471e9cf32a609a95f6ecd35dd7842cb2dd6f82b8c8d5e8183383
@@ -11,7 +11,7 @@ $ ->
11
11
 
12
12
  getCurrentValues = (target) ->
13
13
  inputField = getInputField(target)
14
- if !!inputField.val() then JSON.parse(inputField.val()) else []
14
+ currentValues = if !!inputField.val() then JSON.parse(inputField.val()) else []
15
15
 
16
16
  getInputField = (target) ->
17
17
  getWrapperField(target).next()
@@ -22,6 +22,12 @@ $ ->
22
22
  enterNewValue = (selectedValue, target) ->
23
23
  inputField = getInputField(target)
24
24
  currentValues = getCurrentValues(target)
25
+
26
+ if !!target.data('max') && currentValues.length >= target.data('max')
27
+ shiftedValue = currentValues.shift()
28
+ wrapper = getWrapperField(target)
29
+ wrapper.find('.token').first().remove()
30
+
25
31
  currentValues.push(selectedValue)
26
32
  inputField.val(JSON.stringify(currentValues))
27
33
 
@@ -51,8 +57,7 @@ $ ->
51
57
  return
52
58
  tokens
53
59
 
54
- $('.tagify').each ->
55
-
60
+ initTagify = ->
56
61
  $this = $(this)
57
62
  filename = $this.data('file')
58
63
 
@@ -72,6 +77,15 @@ $ ->
72
77
  .on 'tokenfield:removedtoken', (e) ->
73
78
  selectedValue = e.attrs.value
74
79
  removeExistingValue(selectedValue, $this)
80
+ .on 'tokenfield:createtoken', (e) ->
81
+ if e.attrs.value is e.attrs.label
82
+ false
75
83
 
76
84
  tokens = retrieveExistingTokens(data, $this)
77
85
  $this.tokenfield('setTokens', tokens);
86
+
87
+ $('.tagify').each ->
88
+ initTagify.apply this
89
+
90
+ $(document).on 'mouseenter focus', '.tagify', ->
91
+ initTagify.apply this
@@ -1,3 +1,3 @@
1
1
  module Tagify
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tagify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Azzurrio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-29 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-rails