taggle 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/app/assets/javascripts/taggle-ie8.js +1 -1
- data/app/assets/javascripts/taggle-ie9.js +1 -1
- data/app/assets/javascripts/taggle.js +58 -6
- data/lib/taggle/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37183f82783eade92d55b15e5556ed947042c08e
|
4
|
+
data.tar.gz: aabeb3cea4f3c5a6d4a96c797126486f58307ca0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 502c13206028b4b1ae7a6e39ec5c8cf661cc71cf265a7ea08857b71822c88431e73b798743c4a863534844796af099d4a867944c2b96a1749663004243234c6c
|
7
|
+
data.tar.gz: 98b8c67947e5f532361f6cdca30eb21793d82728fcc3fda8b070d032174ce29c35b93ff04fc5688b0558fadfa3441f5fe87ae195f7209ed9664561301a074199
|
data/README.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
# Taggle
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/taggle.svg)](https://badge.fury.io/rb/taggle)
|
3
3
|
|
4
|
-
This gem is a wrapper of the [Taggle.js project](https://sean.is/poppin/tags), that allows you to include Taggle.js in your Rails app, using the asset pipeline.
|
4
|
+
This gem is a wrapper of the [Taggle.js project](https://sean.is/poppin/tags), that allows you to include Taggle.js in your Rails app, using the asset pipeline.
|
5
|
+
|
6
|
+
The gem currently includes **Taggle.js version 1.12.0**.
|
7
|
+
|
8
|
+
|
5
9
|
|
6
10
|
## Installation
|
7
11
|
|
@@ -19,6 +23,7 @@ Or install it yourself as:
|
|
19
23
|
|
20
24
|
$ gem install taggle
|
21
25
|
|
26
|
+
|
22
27
|
## Usage
|
23
28
|
|
24
29
|
Include the taggle javascript in your `app/assets/javascripts/application.js` or `app/assets/javascripts/vendor.js`:
|
@@ -28,16 +33,18 @@ Include the taggle javascript in your `app/assets/javascripts/application.js` or
|
|
28
33
|
|
29
34
|
This will include `taggle-ie8.js`, `taggle-ie9.js` and `taggle.js`. You can also require each one of these three files individually if you prefer.
|
30
35
|
|
36
|
+
|
37
|
+
|
31
38
|
## Stylesheets
|
32
39
|
I put together several styles based on the official examples of Taggle.js. These styles should be enough for you to get started but they probably require some overriding to fit your page design.
|
33
40
|
|
34
41
|
To use this unofficial set of styles, include in your `app/assets/stylesheets/application.js` or `app/assets/stylesheets/vendor.js`:
|
35
42
|
```
|
36
|
-
|
43
|
+
*= require taggle
|
37
44
|
```
|
38
45
|
|
39
46
|
And add the class `taggle` to the div you'll use to wrap the tags. Example:
|
40
|
-
```
|
47
|
+
```html
|
41
48
|
<div id="example" class='taggle'></div>
|
42
49
|
|
43
50
|
<%= javascript_tag do %>
|
@@ -45,6 +52,8 @@ And add the class `taggle` to the div you'll use to wrap the tags. Example:
|
|
45
52
|
<%= end %>
|
46
53
|
```
|
47
54
|
|
55
|
+
|
56
|
+
|
48
57
|
## License
|
49
58
|
|
50
59
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* !
|
2
2
|
* @author Sean Coker <sean@seancoker.com>
|
3
|
-
* @version 1.
|
3
|
+
* @version 1.12.0
|
4
4
|
* @url http://sean.is/poppin/tags
|
5
5
|
* @license MIT
|
6
6
|
* @description Taggle is a dependency-less tagging library
|
@@ -102,8 +102,10 @@
|
|
102
102
|
/**
|
103
103
|
* The default delimeter character to split tags on
|
104
104
|
* @type {String}
|
105
|
+
* @todo Change this to just "delimiter: ','"
|
105
106
|
*/
|
106
107
|
delimeter: ',',
|
108
|
+
delimiter: '',
|
107
109
|
|
108
110
|
/**
|
109
111
|
* Add an ID to each of the tags.
|
@@ -256,6 +258,13 @@
|
|
256
258
|
* @param {Object} options
|
257
259
|
*/
|
258
260
|
var Taggle = function(el, options) {
|
261
|
+
// @todo uncomment this in next major version
|
262
|
+
// for (var key in (options || {})) {
|
263
|
+
// if (!DEFAULTS.hasOwnProperty(key)) {
|
264
|
+
// throw new Error('"' + key + '" is not a valid option.');
|
265
|
+
// }
|
266
|
+
// }
|
267
|
+
|
259
268
|
this.settings = _extend({}, DEFAULTS, options);
|
260
269
|
this.measurements = {
|
261
270
|
container: {
|
@@ -275,6 +284,7 @@
|
|
275
284
|
this.sizer = document.createElement('div');
|
276
285
|
this.pasting = false;
|
277
286
|
this.placeholder = null;
|
287
|
+
this.data = null;
|
278
288
|
|
279
289
|
if (this.settings.placeholder) {
|
280
290
|
this.placeholder = document.createElement('span');
|
@@ -335,7 +345,7 @@
|
|
335
345
|
_setText(this.placeholder, this.settings.placeholder);
|
336
346
|
|
337
347
|
if (!this.settings.tags.length) {
|
338
|
-
this.
|
348
|
+
this._showPlaceholder();
|
339
349
|
}
|
340
350
|
}
|
341
351
|
|
@@ -471,7 +481,9 @@
|
|
471
481
|
values = _trim(this.input.value);
|
472
482
|
}
|
473
483
|
|
474
|
-
|
484
|
+
var delimiter = this.settings.delimiter || this.settings.delimeter;
|
485
|
+
|
486
|
+
values.split(delimiter).map(function(val) {
|
475
487
|
return self._formatTag(val);
|
476
488
|
}).forEach(function(val) {
|
477
489
|
if (!self._canAdd(e, val)) {
|
@@ -619,8 +631,8 @@
|
|
619
631
|
this._setInputWidth();
|
620
632
|
}
|
621
633
|
|
622
|
-
if (!this.tag.values.length &&
|
623
|
-
this.
|
634
|
+
if (!this.tag.values.length && !this.input.value) {
|
635
|
+
this._showPlaceholder();
|
624
636
|
}
|
625
637
|
};
|
626
638
|
|
@@ -749,6 +761,12 @@
|
|
749
761
|
return li;
|
750
762
|
};
|
751
763
|
|
764
|
+
Taggle.prototype._showPlaceholder = function() {
|
765
|
+
if (this.placeholder) {
|
766
|
+
this.placeholder.style.opacity = 1;
|
767
|
+
}
|
768
|
+
};
|
769
|
+
|
752
770
|
/**
|
753
771
|
* Removes tag from the tags collection
|
754
772
|
* @param {li} li List item to remove
|
@@ -877,6 +895,8 @@
|
|
877
895
|
this._remove(this.tag.elements[i]);
|
878
896
|
}
|
879
897
|
|
898
|
+
this._showPlaceholder();
|
899
|
+
|
880
900
|
return this;
|
881
901
|
};
|
882
902
|
|
@@ -886,5 +906,37 @@
|
|
886
906
|
return this;
|
887
907
|
};
|
888
908
|
|
909
|
+
Taggle.prototype.enable = function() {
|
910
|
+
var buttons = [].slice.call(this.container.querySelectorAll('button'));
|
911
|
+
var inputs = [].slice.call(this.container.querySelectorAll('input'));
|
912
|
+
|
913
|
+
buttons.concat(inputs).forEach(function(el) {
|
914
|
+
el.removeAttribute('disabled');
|
915
|
+
});
|
916
|
+
|
917
|
+
return this;
|
918
|
+
};
|
919
|
+
|
920
|
+
Taggle.prototype.disable = function() {
|
921
|
+
var buttons = [].slice.call(this.container.querySelectorAll('button'));
|
922
|
+
var inputs = [].slice.call(this.container.querySelectorAll('input'));
|
923
|
+
|
924
|
+
buttons.concat(inputs).forEach(function(el) {
|
925
|
+
el.setAttribute('disabled', '');
|
926
|
+
});
|
927
|
+
|
928
|
+
return this;
|
929
|
+
};
|
930
|
+
|
931
|
+
Taggle.prototype.setData = function(data) {
|
932
|
+
this.data = data;
|
933
|
+
|
934
|
+
return this;
|
935
|
+
};
|
936
|
+
|
937
|
+
Taggle.prototype.getData = function() {
|
938
|
+
return this.data;
|
939
|
+
};
|
940
|
+
|
889
941
|
return Taggle;
|
890
|
-
}));
|
942
|
+
}));
|
data/lib/taggle/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taggle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrique Gubert
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.6.8
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Wrapper gem for the Taggle.js project
|