taggle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4685912cbd63a7d702f56cc4a3b2ccf731a6c1df
4
+ data.tar.gz: 9336e5b718c9035e10693c6434adc416aa6a5b33
5
+ SHA512:
6
+ metadata.gz: b6025e06e6ec661730e08c168705338287f515f79058852a14fd805635a5a8dedaa17f58e39222ecfa3f1399c2af4001e9cbb99940c8bf6b5477a64788601a9e
7
+ data.tar.gz: bd4ad9bc08899563788c49c587976b21a9d928a5e49800440b955026a590da8505ca3a31a1f74c1d61a6c6e0a90cb0c23f0478cf7f88991fcb579eda7b792f9a
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ taggle
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.3.1
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.4
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in taggle.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Henrique Gubert
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Taggle
2
+
3
+ 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. The gem currently includes v1.11.1 of Taggle.js.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'taggle'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install taggle
20
+
21
+ ## Usage
22
+
23
+ Include the taggle javascript in your `app/assets/javascripts/application.js` or `app/assets/javascripts/vendor.js`:
24
+ ```
25
+ //= require taggle-full
26
+ ```
27
+
28
+ 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.
29
+
30
+ ## Stylesheets
31
+ 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.
32
+
33
+ To use this unofficial set of styles, include in your `app/assets/stylesheets/application.js` or `app/assets/stylesheets/vendor.js`:
34
+ ```
35
+ //= require taggle
36
+ ```
37
+
38
+ And add the class `taggle` to the div you'll use to wrap the tags. Example:
39
+ ```
40
+ <div id="example" class='taggle'></div>
41
+
42
+ <%= javascript_tag do %>
43
+ new Taggle('example');
44
+ <%= end %>
45
+ ```
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,3 @@
1
+ //= require taggle-ie8
2
+ //= require taggle-ie9
3
+ //= require taggle
@@ -0,0 +1,218 @@
1
+ ;(function() {
2
+ //https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
3
+ if (!Function.prototype.bind) {
4
+ Function.prototype.bind = function (oThis) {
5
+ if (typeof this !== "function") {
6
+ // closest thing possible to the ECMAScript 5 internal IsCallable function
7
+ throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
8
+ }
9
+
10
+ var aArgs = Array.prototype.slice.call(arguments, 1),
11
+ fToBind = this,
12
+ fNOP = function () {},
13
+ fBound = function () {
14
+ return fToBind.apply(this instanceof fNOP && oThis ? this :
15
+ oThis, aArgs.concat(Array.prototype.slice.call(arguments)));
16
+ };
17
+
18
+ fNOP.prototype = this.prototype;
19
+ fBound.prototype = new fNOP();
20
+
21
+ return fBound;
22
+ };
23
+ }
24
+
25
+ // Cheap fill in for IE that works for Taggle
26
+ if (!window.getComputedStyle) {
27
+ window.getComputedStyle = function(el) {
28
+ return el.currentStyle;
29
+ };
30
+ }
31
+
32
+ // IE8 doesnt have array.indexof
33
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
34
+ if (!Array.prototype.indexOf) {
35
+ Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
36
+ 'use strict';
37
+ if (this == null) {
38
+ throw new TypeError();
39
+ }
40
+ var n, k, t = Object(this),
41
+ len = t.length >>> 0;
42
+
43
+ if (len === 0) {
44
+ return -1;
45
+ }
46
+ n = 0;
47
+ if (arguments.length > 1) {
48
+ n = Number(arguments[1]);
49
+ if (n != n) { // shortcut for verifying if it's NaN
50
+ n = 0;
51
+ } else if (n != 0 && n != Infinity && n != -Infinity) {
52
+ n = (n > 0 || -1) * Math.floor(Math.abs(n));
53
+ }
54
+ }
55
+ if (n >= len) {
56
+ return -1;
57
+ }
58
+ for (k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); k < len; k++) {
59
+ if (k in t && t[k] === searchElement) {
60
+ return k;
61
+ }
62
+ }
63
+ return -1;
64
+ };
65
+ }
66
+
67
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
68
+ // Production steps of ECMA-262, Edition 5, 15.4.4.18
69
+ // Reference: http://es5.github.io/#x15.4.4.18
70
+ if (!Array.prototype.forEach) {
71
+
72
+ Array.prototype.forEach = function(callback, thisArg) {
73
+
74
+ var T, k;
75
+
76
+ if (this == null) {
77
+ throw new TypeError(' this is null or not defined');
78
+ }
79
+
80
+ // 1. Let O be the result of calling ToObject passing the |this| value as the argument.
81
+ var O = Object(this);
82
+
83
+ // 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
84
+ // 3. Let len be ToUint32(lenValue).
85
+ var len = O.length >>> 0;
86
+
87
+ // 4. If IsCallable(callback) is false, throw a TypeError exception.
88
+ // See: http://es5.github.com/#x9.11
89
+ if (typeof callback !== "function") {
90
+ throw new TypeError(callback + ' is not a function');
91
+ }
92
+
93
+ // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
94
+ if (arguments.length > 1) {
95
+ T = thisArg;
96
+ }
97
+
98
+ // 6. Let k be 0
99
+ k = 0;
100
+
101
+ // 7. Repeat, while k < len
102
+ while (k < len) {
103
+
104
+ var kValue;
105
+
106
+ // a. Let Pk be ToString(k).
107
+ // This is implicit for LHS operands of the in operator
108
+ // b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
109
+ // This step can be combined with c
110
+ // c. If kPresent is true, then
111
+ if (k in O) {
112
+
113
+ // i. Let kValue be the result of calling the Get internal method of O with argument Pk.
114
+ kValue = O[k];
115
+
116
+ // ii. Call the Call internal method of callback with T as the this value and
117
+ // argument list containing kValue, k, and O.
118
+ callback.call(T, kValue, k, O);
119
+ }
120
+ // d. Increase k by 1.
121
+ k++;
122
+ }
123
+ // 8. return undefined
124
+ };
125
+ }
126
+
127
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
128
+ // Production steps of ECMA-262, Edition 5, 15.4.4.19
129
+ // Reference: http://es5.github.io/#x15.4.4.19
130
+ if (!Array.prototype.map) {
131
+
132
+ Array.prototype.map = function(callback, thisArg) {
133
+
134
+ var T, A, k;
135
+
136
+ if (this == null) {
137
+ throw new TypeError(' this is null or not defined');
138
+ }
139
+
140
+ // 1. Let O be the result of calling ToObject passing the |this|
141
+ // value as the argument.
142
+ var O = Object(this);
143
+
144
+ // 2. Let lenValue be the result of calling the Get internal
145
+ // method of O with the argument "length".
146
+ // 3. Let len be ToUint32(lenValue).
147
+ var len = O.length >>> 0;
148
+
149
+ // 4. If IsCallable(callback) is false, throw a TypeError exception.
150
+ // See: http://es5.github.com/#x9.11
151
+ if (typeof callback !== 'function') {
152
+ throw new TypeError(callback + ' is not a function');
153
+ }
154
+
155
+ // 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
156
+ if (arguments.length > 1) {
157
+ T = thisArg;
158
+ }
159
+
160
+ // 6. Let A be a new array created as if by the expression new Array(len)
161
+ // where Array is the standard built-in constructor with that name and
162
+ // len is the value of len.
163
+ A = new Array(len);
164
+
165
+ // 7. Let k be 0
166
+ k = 0;
167
+
168
+ // 8. Repeat, while k < len
169
+ while (k < len) {
170
+
171
+ var kValue, mappedValue;
172
+
173
+ // a. Let Pk be ToString(k).
174
+ // This is implicit for LHS operands of the in operator
175
+ // b. Let kPresent be the result of calling the HasProperty internal
176
+ // method of O with argument Pk.
177
+ // This step can be combined with c
178
+ // c. If kPresent is true, then
179
+ if (k in O) {
180
+
181
+ // i. Let kValue be the result of calling the Get internal
182
+ // method of O with argument Pk.
183
+ kValue = O[k];
184
+
185
+ // ii. Let mappedValue be the result of calling the Call internal
186
+ // method of callback with T as the this value and argument
187
+ // list containing kValue, k, and O.
188
+ mappedValue = callback.call(T, kValue, k, O);
189
+
190
+ // iii. Call the DefineOwnProperty internal method of A with arguments
191
+ // Pk, Property Descriptor
192
+ // { Value: mappedValue,
193
+ // Writable: true,
194
+ // Enumerable: true,
195
+ // Configurable: true },
196
+ // and false.
197
+
198
+ // In browsers that support Object.defineProperty, use the following:
199
+ // Object.defineProperty(A, k, {
200
+ // value: mappedValue,
201
+ // writable: true,
202
+ // enumerable: true,
203
+ // configurable: true
204
+ // });
205
+
206
+ // For best browser support, use the following:
207
+ A[k] = mappedValue;
208
+ }
209
+ // d. Increase k by 1.
210
+ k++;
211
+ }
212
+
213
+ // 9. return A
214
+ return A;
215
+ };
216
+ }
217
+
218
+ })();
@@ -0,0 +1,176 @@
1
+ /*
2
+ * classList.js: Cross-browser full element.classList implementation.
3
+ * 2012-11-15
4
+ *
5
+ * By Eli Grey, http://eligrey.com
6
+ * Public Domain.
7
+ * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
8
+ */
9
+
10
+ /*global self, document, DOMException */
11
+
12
+ /*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/
13
+ ;(function() {
14
+ if (typeof document !== "undefined" && !("classList" in document.documentElement)) {
15
+
16
+ (function (view) {
17
+
18
+ "use strict";
19
+
20
+ if (!('HTMLElement' in view) && !('Element' in view)) return;
21
+
22
+ var
23
+ classListProp = "classList"
24
+ , protoProp = "prototype"
25
+ , elemCtrProto = (view.HTMLElement || view.Element)[protoProp]
26
+ , objCtr = Object
27
+ , strTrim = String[protoProp].trim || function () {
28
+ return this.replace(/^\s+|\s+$/g, "");
29
+ }
30
+ , arrIndexOf = Array[protoProp].indexOf || function (item) {
31
+ var
32
+ i = 0
33
+ , len = this.length
34
+ ;
35
+ for (; i < len; i++) {
36
+ if (i in this && this[i] === item) {
37
+ return i;
38
+ }
39
+ }
40
+ return -1;
41
+ }
42
+ // Vendors: please allow content code to instantiate DOMExceptions
43
+ , DOMEx = function (type, message) {
44
+ this.name = type;
45
+ this.code = DOMException[type];
46
+ this.message = message;
47
+ }
48
+ , checkTokenAndGetIndex = function (classList, token) {
49
+ if (token === "") {
50
+ throw new DOMEx(
51
+ "SYNTAX_ERR"
52
+ , "An invalid or illegal string was specified"
53
+ );
54
+ }
55
+ if (/\s/.test(token)) {
56
+ throw new DOMEx(
57
+ "INVALID_CHARACTER_ERR"
58
+ , "String contains an invalid character"
59
+ );
60
+ }
61
+ return arrIndexOf.call(classList, token);
62
+ }
63
+ , ClassList = function (elem) {
64
+ var
65
+ trimmedClasses = strTrim.call(elem.className)
66
+ , classes = trimmedClasses ? trimmedClasses.split(/\s+/) : []
67
+ , i = 0
68
+ , len = classes.length
69
+ ;
70
+ for (; i < len; i++) {
71
+ this.push(classes[i]);
72
+ }
73
+ this._updateClassName = function () {
74
+ elem.className = this.toString();
75
+ };
76
+ }
77
+ , classListProto = ClassList[protoProp] = []
78
+ , classListGetter = function () {
79
+ return new ClassList(this);
80
+ }
81
+ ;
82
+ // Most DOMException implementations don't allow calling DOMException's toString()
83
+ // on non-DOMExceptions. Error's toString() is sufficient here.
84
+ DOMEx[protoProp] = Error[protoProp];
85
+ classListProto.item = function (i) {
86
+ return this[i] || null;
87
+ };
88
+ classListProto.contains = function (token) {
89
+ token += "";
90
+ return checkTokenAndGetIndex(this, token) !== -1;
91
+ };
92
+ classListProto.add = function () {
93
+ var
94
+ tokens = arguments
95
+ , i = 0
96
+ , l = tokens.length
97
+ , token
98
+ , updated = false
99
+ ;
100
+ do {
101
+ token = tokens[i] + "";
102
+ if (checkTokenAndGetIndex(this, token) === -1) {
103
+ this.push(token);
104
+ updated = true;
105
+ }
106
+ }
107
+ while (++i < l);
108
+
109
+ if (updated) {
110
+ this._updateClassName();
111
+ }
112
+ };
113
+ classListProto.remove = function () {
114
+ var
115
+ tokens = arguments
116
+ , i = 0
117
+ , l = tokens.length
118
+ , token
119
+ , updated = false
120
+ ;
121
+ do {
122
+ token = tokens[i] + "";
123
+ var index = checkTokenAndGetIndex(this, token);
124
+ if (index !== -1) {
125
+ this.splice(index, 1);
126
+ updated = true;
127
+ }
128
+ }
129
+ while (++i < l);
130
+
131
+ if (updated) {
132
+ this._updateClassName();
133
+ }
134
+ };
135
+ classListProto.toggle = function (token, forse) {
136
+ token += "";
137
+
138
+ var
139
+ result = this.contains(token)
140
+ , method = result ?
141
+ forse !== true && "remove"
142
+ :
143
+ forse !== false && "add"
144
+ ;
145
+
146
+ if (method) {
147
+ this[method](token);
148
+ }
149
+
150
+ return !result;
151
+ };
152
+ classListProto.toString = function () {
153
+ return this.join(" ");
154
+ };
155
+
156
+ if (objCtr.defineProperty) {
157
+ var classListPropDesc = {
158
+ get: classListGetter
159
+ , enumerable: true
160
+ , configurable: true
161
+ };
162
+ try {
163
+ objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
164
+ } catch (ex) { // IE 8 doesn't support enumerable:true
165
+ if (ex.number === -0x7FF5EC54) {
166
+ classListPropDesc.enumerable = false;
167
+ objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
168
+ }
169
+ }
170
+ } else if (objCtr[protoProp].__defineGetter__) {
171
+ elemCtrProto.__defineGetter__(classListProp, classListGetter);
172
+ }
173
+
174
+ }(self));
175
+ }
176
+ })();