jets_js_rails 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0cfa3d3f6810ba8e71de8af26cb12fde35586a02
4
+ data.tar.gz: 6dd0ac0e564585e7cd2ca146c52274fff292aca3
5
+ SHA512:
6
+ metadata.gz: 72eef01f2648f029f4bd7fa3f2399c3668c321735a6659c3881ac6efe2a848592049aac611d8a49238d8bd6bdce34443e2ab1b378022f496e13ff88900451407
7
+ data.tar.gz: 2318a0972fc0b0c0795c7faea3d3064a575d654a33bbef1401f1b93ff1e50aac9c534494ea349449c85e783445d808f9790b4b5129064b86a32c763561511fcd
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jets_js_rails.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Guinsly Mondesir
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # JetsJsRails
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'jets_js_rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install jets_js_rails
20
+
21
+ Into Rails
22
+ ```ruby
23
+ #application.js
24
+ //= require jets
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ [Demo, usage, etc…](http://nexts.github.io/Jets.js/)
30
+
31
+ [![example](http://nexts.github.io/Jets.js/img/demo_hover.gif)](http://nexts.github.io/Jets.js/)
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com:guinslym/jets_js_rails.git )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jets_js_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jets_js_rails"
8
+ spec.version = JetsJsRails::VERSION
9
+ spec.authors = ["Guinsly Mondesir"]
10
+ spec.email = ["guinslym@gmail.com"]
11
+ spec.summary = %q{Adding Jets.js into your Rails app}
12
+ spec.description = %q{Jets.js is a native CSS search engine}
13
+ spec.homepage = "https://github.com/guinslym/jets_js_rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rails", ">= 3.1"
24
+ end
@@ -0,0 +1,11 @@
1
+ require "jets_js_rails/version"
2
+
3
+ module JetsJsRails
4
+ module Rails
5
+ if defined?(::Rails) and Gem::Requirement.new('>= 3.1').satisfied_by?(Gem::Version.new ::Rails.version)
6
+ class Rails::Engine < ::Rails::Engine
7
+ # this class enables the asset pipeline
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module JetsJsRails
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,128 @@
1
+ /*! Jets.js - v0.1.0 - 2015-09-10
2
+ * http://NeXTs.github.com/Jets.js/
3
+ * Copyright (c) 2015 Denis Lukov; Licensed MIT */
4
+
5
+ ;(function(name, definition) {
6
+ if (typeof module != 'undefined') module.exports = definition();
7
+ else if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
8
+ else this[name] = definition();
9
+ }('Jets', function() {
10
+ "use strict"
11
+
12
+ function Jets(opts) {
13
+ if( ! (this instanceof Jets)) {
14
+ return new Jets(opts);
15
+ }
16
+
17
+ var self = this;
18
+ ['searchTag', 'contentTag'].forEach(function(param) {
19
+ var name = param.replace('Tag', '');
20
+ self[name + '_tag'] = document.querySelector(opts[param]);
21
+ self[name + '_param'] = opts[param];
22
+ if( ! self[name + '_tag']) {
23
+ throw new Error('Error! Could not find ' + param + ' element');
24
+ }
25
+ });
26
+
27
+ self.options = {};
28
+ ['columns', 'addImportant', 'searchSelector', 'manualContentHandling'].forEach(function(name) {
29
+ self.options[name] = opts[name];
30
+ });
31
+
32
+ var last_search_query,
33
+ callSearch = function() {
34
+ if(last_search_query != (last_search_query = self.search_tag.value))
35
+ self._applyCSS();
36
+ };
37
+ self._onSearch = function(event) {
38
+ if(event.type == 'keydown')
39
+ return setTimeout(callSearch, 0);
40
+ callSearch();
41
+ };
42
+ self.destroy = function() {
43
+ self._processEventListeners('remove');
44
+ self._destroy();
45
+ };
46
+
47
+ self._processEventListeners('add');
48
+ self._addStyleTag();
49
+ self._setJets();
50
+ self._applyCSS();
51
+ }
52
+
53
+ Jets.prototype = {
54
+ constructor: Jets,
55
+ _processEventListeners: function(action) {
56
+ ['input', 'keydown', 'change'].forEach(function(event_type) {
57
+ this.search_tag[action + 'EventListener'](event_type, this._onSearch);
58
+ }.bind(this));
59
+ },
60
+ _applyCSS: function() {
61
+ var value = this.search_tag.value.trim().toLowerCase(),
62
+ css = this.content_param + '>:not([data-jets' + (this.options.searchSelector || '*') +
63
+ '="' + value + '"]){display:none' + (this.options.addImportant ? '!important' : '') + '}';
64
+ this.styleTag.innerHTML = value ? css : '';
65
+ },
66
+ _addStyleTag: function() {
67
+ this.styleTag = document.createElement('style');
68
+ document.head.appendChild(this.styleTag);
69
+ },
70
+ _getText: function(tag) {
71
+ return tag && (tag.innerText || tag.textContent) || '';
72
+ },
73
+ _getContentTags: function(query) {
74
+ return Array.prototype.slice.call(this.content_tag.querySelectorAll(query || ':scope > *'));
75
+ },
76
+ _setJets: function(query, force) {
77
+ var self = this,
78
+ tags = self._getContentTags(force ? '' : query), text;
79
+ for(var i = 0, tag; tag = tags[i]; i++) {
80
+ if(tag.hasAttribute('data-jets') && ! force) continue;
81
+ text = this.options.manualContentHandling
82
+ ? this.options.manualContentHandling(tag)
83
+ : self.options.columns && self.options.columns.length
84
+ ? self.options.columns.map(function(column) {
85
+ return self._getText(tag.children[column]);
86
+ }).join(' ')
87
+ : self._getText(tag);
88
+ tag.setAttribute('data-jets', text.trim().replace(/\s+/g, ' ').toLowerCase());
89
+ };
90
+ },
91
+ update: function(force) {
92
+ this._setJets(':scope > :not([data-jets])', force);
93
+ },
94
+ _destroy: function() {
95
+ this.styleTag.parentNode && document.head.removeChild(this.styleTag);
96
+ var tags = this._getContentTags();
97
+ for(var i = 0, tag; tag = tags[i]; i++) {
98
+ tag.removeAttribute('data-jets');
99
+ }
100
+ }
101
+ }
102
+
103
+ // :scope polyfill
104
+ // http://stackoverflow.com/a/17989803/1221082
105
+ ;(function(doc, proto) {
106
+ try {
107
+ doc.querySelector(':scope body');
108
+ } catch (err) {
109
+ ['querySelector', 'querySelectorAll'].forEach(function(method) {
110
+ var nativ = proto[method];
111
+ proto[method] = function(selectors) {
112
+ if (/(^|,)\s*:scope/.test(selectors)) {
113
+ var id = this.id;
114
+ this.id = 'ID_' + Date.now();
115
+ selectors = selectors.replace(/((^|,)\s*):scope/g, '$1#' + this.id);
116
+ var result = doc[method](selectors);
117
+ this.id = id;
118
+ return result;
119
+ } else {
120
+ return nativ.call(this, selectors);
121
+ }
122
+ }
123
+ });
124
+ }
125
+ })(window.document, Element.prototype);
126
+
127
+ return Jets;
128
+ }));
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jets_js_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Guinsly Mondesir
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-09-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ description: Jets.js is a native CSS search engine
56
+ email:
57
+ - guinslym@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - jets_js_rails.gemspec
68
+ - lib/jets_js_rails.rb
69
+ - lib/jets_js_rails/version.rb
70
+ - vendor/assets/javascripts/jets.js
71
+ homepage: https://github.com/guinslym/jets_js_rails
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.2.2
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Adding Jets.js into your Rails app
95
+ test_files: []