Add sizzle to ext/.
This commit is contained in:
parent
678774cbd6
commit
cdb41a170f
9
Rakefile
9
Rakefile
@ -43,7 +43,7 @@ module PrototypeHelper
|
||||
}.merge(options)
|
||||
|
||||
require_sprockets
|
||||
load_path = [SRC_DIR]
|
||||
load_path = [SRC_DIR, File.join(ROOT_DIR, 'ext', 'sizzle')]
|
||||
|
||||
if selector = options[:selector_engine]
|
||||
get_selector_engine(selector)
|
||||
@ -98,10 +98,11 @@ module PrototypeHelper
|
||||
end
|
||||
|
||||
def self.get_selector_engine(name)
|
||||
file = File.join(ROOT_DIR, 'vendor', name, 'repository')
|
||||
unless File.exists?(file)
|
||||
submodule = File.join(ROOT_DIR, 'vendor', name, 'repository')
|
||||
ext = File.join(ROOT_DIR, 'ext', name)
|
||||
unless File.exist?(submodule) || File.exist?(ext)
|
||||
get_submodule('the required selector engine', "#{name}/repository")
|
||||
unless File.exists?(file)
|
||||
unless File.exist?(submodule)
|
||||
puts "The selector engine you required isn't available at vendor/#{name}.\n\n"
|
||||
exit
|
||||
end
|
||||
|
1015
ext/sizzle/repository/sizzle.js
Normal file
1015
ext/sizzle/repository/sizzle.js
Normal file
File diff suppressed because it is too large
Load Diff
34
ext/sizzle/selector_engine.js
Normal file
34
ext/sizzle/selector_engine.js
Normal file
@ -0,0 +1,34 @@
|
||||
Prototype._original_property = window.Sizzle;
|
||||
//= require "repository/sizzle"
|
||||
|
||||
Prototype.Selector = (function(engine) {
|
||||
function extend(elements) {
|
||||
for (var i = 0, length = elements.length; i < length; i++) {
|
||||
Element.extend(elements[i]);
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
function select(selector, scope) {
|
||||
return extend(engine(selector, scope || document));
|
||||
}
|
||||
|
||||
function match(element, selector) {
|
||||
return engine.matches(selector, [element]).length == 1;
|
||||
}
|
||||
|
||||
function filter(elements, selector) {
|
||||
return extend(engine.matches(selector, elements));
|
||||
}
|
||||
|
||||
return {
|
||||
engine: engine,
|
||||
select: select,
|
||||
match: match,
|
||||
filter: filter
|
||||
};
|
||||
})(Sizzle);
|
||||
|
||||
// Restore globals.
|
||||
window.Sizzle = Prototype._original_property;
|
||||
delete Prototype._original_property;
|
Loading…
Reference in New Issue
Block a user