Add sizzle to ext/.

This commit is contained in:
Tobie Langel 2009-11-30 11:12:26 +01:00
parent 678774cbd6
commit cdb41a170f
3 changed files with 1054 additions and 4 deletions

View File

@ -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

File diff suppressed because it is too large Load Diff

View 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;