livequery-rails-cis 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/Gemfile +4 -0
- data/README.md +141 -0
- data/Rakefile +2 -0
- data/lib/generators/livequery/install/USAGE +8 -0
- data/lib/generators/livequery/install/install_generator.rb +37 -0
- data/lib/livequery-rails-cis.rb +1 -0
- data/lib/livequery/assert_select.rb +25 -0
- data/lib/livequery/rails.rb +10 -0
- data/lib/livequery/rails/engine.rb +6 -0
- data/lib/livequery/rails/railtie.rb +13 -0
- data/lib/livequery/rails/version.rb +6 -0
- data/livequery-rails-cis.gemspec +22 -0
- data/vendor/assets/javascripts/livequery.js +226 -0
- data/vendor/assets/javascripts/livequery.min.js +9 -0
- metadata +77 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
# LiveQuery::Rails
|
2
|
+
|
3
|
+
Live Query utilizes the power of jQuery selectors by binding events or firing callbacks for matched elements auto-magically, even after the page has been loaded and the DOM updated.
|
4
|
+
|
5
|
+
Live Query! For Rails!
|
6
|
+
|
7
|
+
This gem provides:
|
8
|
+
|
9
|
+
* LiveQuery 1.1.1 - [livequery](https://github.com/brandonaaron/livequery)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
For Rails 3.0 apps, add the mozart-rails gem to your Gemfile.
|
16
|
+
|
17
|
+
gem 'livequery-rails-cis'
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle install
|
22
|
+
|
23
|
+
Or install it yourself via:
|
24
|
+
|
25
|
+
$ bundle exec rake build
|
26
|
+
$ gem install --local pkg/livequery-rails-cis-0.0.1.gem
|
27
|
+
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
### Rails 3.1 or greater
|
32
|
+
|
33
|
+
The LiveQuery files and all dependencies will be added to the asset pipeline and be
|
34
|
+
available for you to use. If they're not already in app/assets/javascripts/application.js,
|
35
|
+
add these lines:
|
36
|
+
|
37
|
+
//= require livequery-rails-cis
|
38
|
+
|
39
|
+
LiveQuery has a dependency on the `jQuery-rails` gem.
|
40
|
+
|
41
|
+
## Examples
|
42
|
+
|
43
|
+
For example you could use the following code to bind a click event to all A tags, even any A tags you might add via AJAX.
|
44
|
+
|
45
|
+
$('a')
|
46
|
+
.livequery('click', function(event) {
|
47
|
+
alert('clicked');
|
48
|
+
return false;
|
49
|
+
});
|
50
|
+
|
51
|
+
Once you add new A tags to your document, Live Query will bind the click event and there is nothing else that needs to be called or done.
|
52
|
+
|
53
|
+
When an element no longer matches a selector the events Live Query bound to it are unbound. The Live Query can be expired which will no longer bind anymore events and unbind all the events it previously bound.
|
54
|
+
|
55
|
+
Live Query can even be used with the more powerful jQuery selectors. The following Live Query will match and bind a click event to all A tags that have a rel attribute with the word "friend" in it. If one of the A tags is modified by removing the word "friend" from the rel attribute, the click event will be unbound since it is no longer matched by the Live Query.
|
56
|
+
|
57
|
+
$('a[rel*=friend]')
|
58
|
+
.livequery('click', function(event) {
|
59
|
+
doSomething();
|
60
|
+
});
|
61
|
+
|
62
|
+
Live Query also has the ability to fire a function (callback) when it matches a new element and another function (callback) for when an element is no longer matched. This provides ultimate flexibility and untold use-cases. For example the following code uses a function based Live Query to implement the jQuery hover helper method and remove it when the element is no longer matched.
|
63
|
+
|
64
|
+
$('li')
|
65
|
+
.livequery(function(){
|
66
|
+
// use the helper function hover to bind a mouseover and mouseout event
|
67
|
+
$(this)
|
68
|
+
.hover(function() {
|
69
|
+
$(this).addClass('hover');
|
70
|
+
}, function() {
|
71
|
+
$(this).removeClass('hover');
|
72
|
+
});
|
73
|
+
}, function() {
|
74
|
+
// unbind the mouseover and mouseout events
|
75
|
+
$(this)
|
76
|
+
.unbind('mouseover')
|
77
|
+
.unbind('mouseout');
|
78
|
+
});
|
79
|
+
|
80
|
+
## API
|
81
|
+
|
82
|
+
### `livequery` Signatures
|
83
|
+
|
84
|
+
The `livequery` method has 3 different signatures or ways to call it.
|
85
|
+
|
86
|
+
The first, and most typical usage, is to pass an event type and an event handler:
|
87
|
+
|
88
|
+
// eventType: such as click or submit
|
89
|
+
// eventHandler: the function to execute when the event happens
|
90
|
+
$(selector).livequery( eventType, eventHandler );
|
91
|
+
|
92
|
+
The second and third signature is to pass one or two functions to `livequery`. Doing this, `livequery` will call the first passed function when an element is newly matched and will call the second passed function when an element is removed or no longer matched. The second function is optional. The `this` or context of the first function will be the newly matched element. For the second function it will be the element that is no longer matched.
|
93
|
+
|
94
|
+
// matchedFn: the function to execute when a new element is matched
|
95
|
+
$(selector).livequery( matchedFn );
|
96
|
+
|
97
|
+
// matchedFn: the function to execute when a new element is matched
|
98
|
+
// unmatchedFn: the function to execute when an element is no longer matched
|
99
|
+
$(selector).livequery( matchedFn, unmatchFn );
|
100
|
+
|
101
|
+
### `expire` Signatures
|
102
|
+
|
103
|
+
The `expire` method has 5 different signatures or ways to call it.
|
104
|
+
|
105
|
+
The first way will stop/expire all live queries associated with the selector.
|
106
|
+
|
107
|
+
$(selector).expire();
|
108
|
+
|
109
|
+
The second way will stop/expire all live queries associated with the selector and event type.
|
110
|
+
|
111
|
+
// eventType: such as click or submit
|
112
|
+
$(selctor).expire( eventType );
|
113
|
+
|
114
|
+
The third way will stop/expire all live queries associated with the selector, event type, and event handler reference.
|
115
|
+
|
116
|
+
// eventType: such as click or submit
|
117
|
+
// eventHandler: the function to execute when the event happens
|
118
|
+
$(selector).expire( eventType, eventHandler );
|
119
|
+
|
120
|
+
The fourth way will stop/expire all live queries associated with the selector and matchedFn.
|
121
|
+
|
122
|
+
// matchedFn: the function to execute when a new element is matched
|
123
|
+
$(selector).expire( matchedFn );
|
124
|
+
|
125
|
+
The fifth way will stop/expire all live queries associated with the selector, matchedFn, and unmatchedFn.
|
126
|
+
|
127
|
+
// matchedFn: the function to execute when a new element is matched
|
128
|
+
// unmatchedFn: the function to execute when an element is no longer matched
|
129
|
+
$(selector).expire( matchedFn, unmatchFn );
|
130
|
+
|
131
|
+
## For Plugin Developers
|
132
|
+
|
133
|
+
If your plugin modifies the DOM without using the built-in DOM Modification methods (append, addClass, etc), you can register your plugin with Live Query like this.
|
134
|
+
|
135
|
+
if (jQuery.livequery)
|
136
|
+
jQuery.livequery.registerPlugin("pluginMethodName");
|
137
|
+
|
138
|
+
You can register several plugin methods at once by just passing them as additional arguments to the registerPlugin method.
|
139
|
+
|
140
|
+
if (jQuery.livequery)
|
141
|
+
jQuery.livequery.registerPlugin("method1", "method2", "method3");
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
# Supply generator for Rails 3.0.x or if asset pipeline is not enabled
|
4
|
+
if ::Rails.version < "3.1" || !::Rails.application.config.assets.enabled || !File.exist?('app/assets/javascripts/application.js') || !File.exist?('app/assets/javascripts/application.js.coffee')
|
5
|
+
module Livequery
|
6
|
+
module Generators
|
7
|
+
class InstallGenerator < ::Rails::Generators::Base
|
8
|
+
|
9
|
+
desc "This generator installs Livequery #{Livequery::Rails::LIVEQUERY_VERSION}"
|
10
|
+
source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__)
|
11
|
+
|
12
|
+
def copy_livequery
|
13
|
+
say_status("copying", "livequery (#{Livequery::Rails::LIVEQUERY_VERSION})", :green)
|
14
|
+
copy_file "livequery.js", "public/javascripts/Livequery.js"
|
15
|
+
copy_file "livequery.min.js", "public/javascripts/Livequery.min.js"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
else
|
21
|
+
module Livequery
|
22
|
+
module Generators
|
23
|
+
class InstallGenerator < ::Rails::Generators::Base
|
24
|
+
desc "This generator add Livequery #{Livequery::Rails::LIVEQUERY_VERSION} to application.js or application.js.coffee"
|
25
|
+
source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__)
|
26
|
+
def add_assets
|
27
|
+
insert_into_file "app/assets/javascripts/application#{detect_js_format[0]}", "#{detect_js_format[1]} require livequery\n", :after => "jquery_ujs\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
def detect_js_format
|
31
|
+
return ['.js.coffee', '#='] if File.exist?('app/assets/javascripts/application.js.coffee')
|
32
|
+
return ['.js', '//='] if File.exist?('app/assets/javascripts/application.js')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'livequery/rails'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ActionDispatch
|
2
|
+
module Assertions
|
3
|
+
module SelectorAssertions
|
4
|
+
|
5
|
+
PATTERN_HTML = %Q{"((\\\\\"|[^\"])*)"}
|
6
|
+
PATTERN_UNICODE_ESCAPED_CHAR = /\\u([0-9a-zA-Z]{4})/
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
# Unescapes a JS string.
|
11
|
+
def unescape_js(js_string)
|
12
|
+
# js encodes double quotes and line breaks.
|
13
|
+
unescaped= js_string.gsub('\"', '"')
|
14
|
+
unescaped.gsub!('\\\'', "'")
|
15
|
+
unescaped.gsub!(/\\\//, '/')
|
16
|
+
unescaped.gsub!('\n', "\n")
|
17
|
+
unescaped.gsub!('\076', '>')
|
18
|
+
unescaped.gsub!('\074', '<')
|
19
|
+
# js encodes non-ascii characters.
|
20
|
+
unescaped.gsub!(PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
|
21
|
+
unescaped
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Used to ensure that Rails 3.0.x, as well as Rails >= 3.1 with asset pipeline disabled
|
2
|
+
# get the minified version of the scripts included into the layout in production.
|
3
|
+
module Livequery
|
4
|
+
module Rails
|
5
|
+
class Railtie < ::Rails::Railtie
|
6
|
+
config.before_configuration do
|
7
|
+
if config.action_view.javascript_expansions
|
8
|
+
livequery_defaults = ::Rails.env.production? || ::Rails.env.test? ? %w(livequery.min) : %w(livequery)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/livequery/rails/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "livequery-rails-cis"
|
6
|
+
s.date = '2013-10-04'
|
7
|
+
s.version = Livequery::Rails::VERSION
|
8
|
+
s.authors = ["Anup, CISROR Team"]
|
9
|
+
s.homepage = "https://github.com/cisror/livequery-rails-cis"
|
10
|
+
s.summary = %q{Get up and running with Livequery in seconds.}
|
11
|
+
s.description = %q{Live Query utilizes the power of jQuery selectors by binding events or firing callbacks for matched elements auto-magically, even after the page has been loaded and the DOM updated.}
|
12
|
+
|
13
|
+
s.required_rubygems_version = ">= 1.3.6"
|
14
|
+
s.rubyforge_project = "jquery-rails"
|
15
|
+
|
16
|
+
s.add_dependency "railties", ">= 3.0"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
end
|
@@ -0,0 +1,226 @@
|
|
1
|
+
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
|
2
|
+
* Dual licensed under the MIT (MIT_LICENSE.txt)
|
3
|
+
* and GPL Version 2 (GPL_LICENSE.txt) licenses.
|
4
|
+
*
|
5
|
+
* Version: 1.1.1
|
6
|
+
* Requires jQuery 1.3+
|
7
|
+
* Docs: http://docs.jquery.com/Plugins/livequery
|
8
|
+
*/
|
9
|
+
|
10
|
+
(function($) {
|
11
|
+
|
12
|
+
$.extend($.fn, {
|
13
|
+
livequery: function(type, fn, fn2) {
|
14
|
+
var self = this, q;
|
15
|
+
|
16
|
+
// Handle different call patterns
|
17
|
+
if ($.isFunction(type))
|
18
|
+
fn2 = fn, fn = type, type = undefined;
|
19
|
+
|
20
|
+
// See if Live Query already exists
|
21
|
+
$.each( $.livequery.queries, function(i, query) {
|
22
|
+
if ( self.selector == query.selector && self.context == query.context &&
|
23
|
+
type == query.type && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) )
|
24
|
+
// Found the query, exit the each loop
|
25
|
+
return (q = query) && false;
|
26
|
+
});
|
27
|
+
|
28
|
+
// Create new Live Query if it wasn't found
|
29
|
+
q = q || new $.livequery(this.selector, this.context, type, fn, fn2);
|
30
|
+
|
31
|
+
// Make sure it is running
|
32
|
+
q.stopped = false;
|
33
|
+
|
34
|
+
// Run it immediately for the first time
|
35
|
+
q.run();
|
36
|
+
|
37
|
+
// Contnue the chain
|
38
|
+
return this;
|
39
|
+
},
|
40
|
+
|
41
|
+
expire: function(type, fn, fn2) {
|
42
|
+
var self = this;
|
43
|
+
|
44
|
+
// Handle different call patterns
|
45
|
+
if ($.isFunction(type))
|
46
|
+
fn2 = fn, fn = type, type = undefined;
|
47
|
+
|
48
|
+
// Find the Live Query based on arguments and stop it
|
49
|
+
$.each( $.livequery.queries, function(i, query) {
|
50
|
+
if ( self.selector == query.selector && self.context == query.context &&
|
51
|
+
(!type || type == query.type) && (!fn || fn.$lqguid == query.fn.$lqguid) && (!fn2 || fn2.$lqguid == query.fn2.$lqguid) && !this.stopped )
|
52
|
+
$.livequery.stop(query.id);
|
53
|
+
});
|
54
|
+
|
55
|
+
// Continue the chain
|
56
|
+
return this;
|
57
|
+
}
|
58
|
+
});
|
59
|
+
|
60
|
+
$.livequery = function(selector, context, type, fn, fn2) {
|
61
|
+
this.selector = selector;
|
62
|
+
this.context = context;
|
63
|
+
this.type = type;
|
64
|
+
this.fn = fn;
|
65
|
+
this.fn2 = fn2;
|
66
|
+
this.elements = [];
|
67
|
+
this.stopped = false;
|
68
|
+
|
69
|
+
// The id is the index of the Live Query in $.livequery.queries
|
70
|
+
this.id = $.livequery.queries.push(this)-1;
|
71
|
+
|
72
|
+
// Mark the functions for matching later on
|
73
|
+
fn.$lqguid = fn.$lqguid || $.livequery.guid++;
|
74
|
+
if (fn2) fn2.$lqguid = fn2.$lqguid || $.livequery.guid++;
|
75
|
+
|
76
|
+
// Return the Live Query
|
77
|
+
return this;
|
78
|
+
};
|
79
|
+
|
80
|
+
$.livequery.prototype = {
|
81
|
+
stop: function() {
|
82
|
+
var query = this;
|
83
|
+
|
84
|
+
if ( this.type )
|
85
|
+
// Unbind all bound events
|
86
|
+
this.elements.unbind(this.type, this.fn);
|
87
|
+
else if (this.fn2)
|
88
|
+
// Call the second function for all matched elements
|
89
|
+
this.elements.each(function(i, el) {
|
90
|
+
query.fn2.apply(el);
|
91
|
+
});
|
92
|
+
|
93
|
+
// Clear out matched elements
|
94
|
+
this.elements = [];
|
95
|
+
|
96
|
+
// Stop the Live Query from running until restarted
|
97
|
+
this.stopped = true;
|
98
|
+
},
|
99
|
+
|
100
|
+
run: function() {
|
101
|
+
// Short-circuit if stopped
|
102
|
+
if ( this.stopped ) return;
|
103
|
+
var query = this;
|
104
|
+
|
105
|
+
var oEls = this.elements,
|
106
|
+
els = $(this.selector, this.context),
|
107
|
+
nEls = els.not(oEls);
|
108
|
+
|
109
|
+
// Set elements to the latest set of matched elements
|
110
|
+
this.elements = els;
|
111
|
+
|
112
|
+
if (this.type) {
|
113
|
+
// Bind events to newly matched elements
|
114
|
+
nEls.bind(this.type, this.fn);
|
115
|
+
|
116
|
+
// Unbind events to elements no longer matched
|
117
|
+
if (oEls.length > 0)
|
118
|
+
$.each(oEls, function(i, el) {
|
119
|
+
if ( $.inArray(el, els) < 0 )
|
120
|
+
$.event.remove(el, query.type, query.fn);
|
121
|
+
});
|
122
|
+
}
|
123
|
+
else {
|
124
|
+
// Call the first function for newly matched elements
|
125
|
+
nEls.each(function() {
|
126
|
+
query.fn.apply(this);
|
127
|
+
});
|
128
|
+
|
129
|
+
// Call the second function for elements no longer matched
|
130
|
+
if ( this.fn2 && oEls.length > 0 )
|
131
|
+
$.each(oEls, function(i, el) {
|
132
|
+
if ( $.inArray(el, els) < 0 )
|
133
|
+
query.fn2.apply(el);
|
134
|
+
});
|
135
|
+
}
|
136
|
+
}
|
137
|
+
};
|
138
|
+
|
139
|
+
$.extend($.livequery, {
|
140
|
+
guid: 0,
|
141
|
+
queries: [],
|
142
|
+
queue: [],
|
143
|
+
running: false,
|
144
|
+
timeout: null,
|
145
|
+
|
146
|
+
checkQueue: function() {
|
147
|
+
if ( $.livequery.running && $.livequery.queue.length ) {
|
148
|
+
var length = $.livequery.queue.length;
|
149
|
+
// Run each Live Query currently in the queue
|
150
|
+
while ( length-- )
|
151
|
+
$.livequery.queries[ $.livequery.queue.shift() ].run();
|
152
|
+
}
|
153
|
+
},
|
154
|
+
|
155
|
+
pause: function() {
|
156
|
+
// Don't run anymore Live Queries until restarted
|
157
|
+
$.livequery.running = false;
|
158
|
+
},
|
159
|
+
|
160
|
+
play: function() {
|
161
|
+
// Restart Live Queries
|
162
|
+
$.livequery.running = true;
|
163
|
+
// Request a run of the Live Queries
|
164
|
+
$.livequery.run();
|
165
|
+
},
|
166
|
+
|
167
|
+
registerPlugin: function() {
|
168
|
+
$.each( arguments, function(i,n) {
|
169
|
+
// Short-circuit if the method doesn't exist
|
170
|
+
if (!$.fn[n]) return;
|
171
|
+
|
172
|
+
// Save a reference to the original method
|
173
|
+
var old = $.fn[n];
|
174
|
+
|
175
|
+
// Create a new method
|
176
|
+
$.fn[n] = function() {
|
177
|
+
// Call the original method
|
178
|
+
var r = old.apply(this, arguments);
|
179
|
+
|
180
|
+
// Request a run of the Live Queries
|
181
|
+
$.livequery.run();
|
182
|
+
|
183
|
+
// Return the original methods result
|
184
|
+
return r;
|
185
|
+
}
|
186
|
+
});
|
187
|
+
},
|
188
|
+
|
189
|
+
run: function(id) {
|
190
|
+
if (id != undefined) {
|
191
|
+
// Put the particular Live Query in the queue if it doesn't already exist
|
192
|
+
if ( $.inArray(id, $.livequery.queue) < 0 )
|
193
|
+
$.livequery.queue.push( id );
|
194
|
+
}
|
195
|
+
else
|
196
|
+
// Put each Live Query in the queue if it doesn't already exist
|
197
|
+
$.each( $.livequery.queries, function(id) {
|
198
|
+
if ( $.inArray(id, $.livequery.queue) < 0 )
|
199
|
+
$.livequery.queue.push( id );
|
200
|
+
});
|
201
|
+
|
202
|
+
// Clear timeout if it already exists
|
203
|
+
if ($.livequery.timeout) clearTimeout($.livequery.timeout);
|
204
|
+
// Create a timeout to check the queue and actually run the Live Queries
|
205
|
+
$.livequery.timeout = setTimeout($.livequery.checkQueue, 20);
|
206
|
+
},
|
207
|
+
|
208
|
+
stop: function(id) {
|
209
|
+
if (id != undefined)
|
210
|
+
// Stop are particular Live Query
|
211
|
+
$.livequery.queries[ id ].stop();
|
212
|
+
else
|
213
|
+
// Stop all Live Queries
|
214
|
+
$.each( $.livequery.queries, function(id) {
|
215
|
+
$.livequery.queries[ id ].stop();
|
216
|
+
});
|
217
|
+
}
|
218
|
+
});
|
219
|
+
|
220
|
+
// Register core DOM manipulation methods
|
221
|
+
$.livequery.registerPlugin('append', 'prepend', 'after', 'before', 'wrap', 'attr', 'removeAttr', 'addClass', 'removeClass', 'toggleClass', 'empty', 'remove', 'html');
|
222
|
+
|
223
|
+
// Run Live Queries when the Document is ready
|
224
|
+
$(function() { $.livequery.play(); });
|
225
|
+
|
226
|
+
})(jQuery);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
|
2
|
+
* Dual licensed under the MIT (MIT_LICENSE.txt)
|
3
|
+
* and GPL Version 2 (GPL_LICENSE.txt) licenses.
|
4
|
+
*
|
5
|
+
* Version: 1.1.1
|
6
|
+
* Requires jQuery 1.3+
|
7
|
+
* Docs: http://docs.jquery.com/Plugins/livequery
|
8
|
+
*/
|
9
|
+
(function(e){e.extend(e.fn,{livequery:function(t,n,r){var i=this,s;if(e.isFunction(t))r=n,n=t,t=undefined;e.each(e.livequery.queries,function(e,o){if(i.selector==o.selector&&i.context==o.context&&t==o.type&&(!n||n.$lqguid==o.fn.$lqguid)&&(!r||r.$lqguid==o.fn2.$lqguid))return(s=o)&&false});s=s||new e.livequery(this.selector,this.context,t,n,r);s.stopped=false;s.run();return this},expire:function(t,n,r){var i=this;if(e.isFunction(t))r=n,n=t,t=undefined;e.each(e.livequery.queries,function(s,o){if(i.selector==o.selector&&i.context==o.context&&(!t||t==o.type)&&(!n||n.$lqguid==o.fn.$lqguid)&&(!r||r.$lqguid==o.fn2.$lqguid)&&!this.stopped)e.livequery.stop(o.id)});return this}});e.livequery=function(t,n,r,i,s){this.selector=t;this.context=n;this.type=r;this.fn=i;this.fn2=s;this.elements=[];this.stopped=false;this.id=e.livequery.queries.push(this)-1;i.$lqguid=i.$lqguid||e.livequery.guid++;if(s)s.$lqguid=s.$lqguid||e.livequery.guid++;return this};e.livequery.prototype={stop:function(){var e=this;if(this.type)this.elements.unbind(this.type,this.fn);else if(this.fn2)this.elements.each(function(t,n){e.fn2.apply(n)});this.elements=[];this.stopped=true},run:function(){if(this.stopped)return;var t=this;var n=this.elements,r=e(this.selector,this.context),i=r.not(n);this.elements=r;if(this.type){i.bind(this.type,this.fn);if(n.length>0)e.each(n,function(n,i){if(e.inArray(i,r)<0)e.event.remove(i,t.type,t.fn)})}else{i.each(function(){t.fn.apply(this)});if(this.fn2&&n.length>0)e.each(n,function(n,i){if(e.inArray(i,r)<0)t.fn2.apply(i)})}}};e.extend(e.livequery,{guid:0,queries:[],queue:[],running:false,timeout:null,checkQueue:function(){if(e.livequery.running&&e.livequery.queue.length){var t=e.livequery.queue.length;while(t--)e.livequery.queries[e.livequery.queue.shift()].run()}},pause:function(){e.livequery.running=false},play:function(){e.livequery.running=true;e.livequery.run()},registerPlugin:function(){e.each(arguments,function(t,n){if(!e.fn[n])return;var r=e.fn[n];e.fn[n]=function(){var t=r.apply(this,arguments);e.livequery.run();return t}})},run:function(t){if(t!=undefined){if(e.inArray(t,e.livequery.queue)<0)e.livequery.queue.push(t)}else e.each(e.livequery.queries,function(t){if(e.inArray(t,e.livequery.queue)<0)e.livequery.queue.push(t)});if(e.livequery.timeout)clearTimeout(e.livequery.timeout);e.livequery.timeout=setTimeout(e.livequery.checkQueue,20)},stop:function(t){if(t!=undefined)e.livequery.queries[t].stop();else e.each(e.livequery.queries,function(t){e.livequery.queries[t].stop()})}});e.livequery.registerPlugin("append","prepend","after","before","wrap","attr","removeAttr","addClass","removeClass","toggleClass","empty","remove","html");e(function(){e.livequery.play()})})(jQuery)
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: livequery-rails-cis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Anup, CISROR Team
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
description: Live Query utilizes the power of jQuery selectors by binding events or
|
31
|
+
firing callbacks for matched elements auto-magically, even after the page has been
|
32
|
+
loaded and the DOM updated.
|
33
|
+
email:
|
34
|
+
executables: []
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- Gemfile
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- lib/generators/livequery/install/USAGE
|
43
|
+
- lib/generators/livequery/install/install_generator.rb
|
44
|
+
- lib/livequery-rails-cis.rb
|
45
|
+
- lib/livequery/assert_select.rb
|
46
|
+
- lib/livequery/rails.rb
|
47
|
+
- lib/livequery/rails/engine.rb
|
48
|
+
- lib/livequery/rails/railtie.rb
|
49
|
+
- lib/livequery/rails/version.rb
|
50
|
+
- livequery-rails-cis.gemspec
|
51
|
+
- vendor/assets/javascripts/livequery.js
|
52
|
+
- vendor/assets/javascripts/livequery.min.js
|
53
|
+
homepage: https://github.com/cisror/livequery-rails-cis
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.3.6
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project: jquery-rails
|
73
|
+
rubygems_version: 1.8.24
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Get up and running with Livequery in seconds.
|
77
|
+
test_files: []
|