Reorder repository to allow for custom selector engines to be included instead of Sizzle (the current default). Selector engines belong in the vendor directory and must have a selector_engine.js file. To build a Prototype with your engine of choice just spepcify it at build time using the SELECTOR_ENGINE option. For example, to build a version with NSMatcher: rake dist SELECTOR_ENGINE=nwmatcher.
This commit is contained in:
parent
3e19f959a2
commit
7762e002cb
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -11,6 +11,6 @@
|
||||
path = vendor/sprockets
|
||||
url = git://github.com/sstephenson/sprockets.git
|
||||
|
||||
[submodule "vendor/sizzle"]
|
||||
path = vendor/sizzle
|
||||
[submodule "vendor/sizzle/sizzle"]
|
||||
path = vendor/sizzle/sizzle
|
||||
url = git://github.com/jeresig/sizzle.git
|
||||
|
18
Rakefile
18
Rakefile
@ -42,7 +42,7 @@ module PrototypeHelper
|
||||
require_sizzle
|
||||
secretary = Sprockets::Secretary.new(
|
||||
:root => File.join(ROOT_DIR, path),
|
||||
:load_path => [SRC_DIR, SIZZLE_DIR],
|
||||
:load_path => self.load_path,
|
||||
:source_files => [source],
|
||||
:strip_comments => strip_comments
|
||||
)
|
||||
@ -51,6 +51,18 @@ module PrototypeHelper
|
||||
secretary.concatenation.save_to(destination)
|
||||
end
|
||||
|
||||
def self.load_path
|
||||
selector = ENV['SELECTOR_ENGINE'] || 'sizzle'
|
||||
selector_path = File.join(ROOT_DIR, 'vendor', selector)
|
||||
if File.exists?(selector_path)
|
||||
[SRC_DIR, selector_path]
|
||||
else
|
||||
puts "\nYou seem to be missing vendor/#{selector}."
|
||||
puts "Built Prototype using Sizzle instead.\n\n"
|
||||
[SRC_DIR, SIZZLE_DIR]
|
||||
end
|
||||
end
|
||||
|
||||
def self.build_doc_for(file)
|
||||
mkdir_p TMP_DIR
|
||||
temp_path = File.join(TMP_DIR, "prototype.temp.js")
|
||||
@ -83,8 +95,8 @@ module PrototypeHelper
|
||||
end
|
||||
|
||||
def self.require_sizzle
|
||||
if !File.exists?(File.join(SIZZLE_DIR, 'sizzle.js'))
|
||||
exit unless get_submodule("Sizzle", "sizzle")
|
||||
if !File.exists?(File.join(SIZZLE_DIR, 'sizzle', 'sizzle.js'))
|
||||
exit unless get_submodule("Sizzle", "sizzle/sizzle")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
|
||||
//= require "dom/dom"
|
||||
//= require "dom/sizzle_adapter"
|
||||
//= require <selector_engine>
|
||||
//= require "dom/selector"
|
||||
//= require "dom/form"
|
||||
//= require "dom/event"
|
||||
|
1441
vendor/nwmatcher/nwmatcher-1.1.1.js
vendored
Normal file
1441
vendor/nwmatcher/nwmatcher-1.1.1.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
37
vendor/nwmatcher/selector_engine.js
vendored
Normal file
37
vendor/nwmatcher/selector_engine.js
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
Prototype._original_nw = window.NW;
|
||||
//= require <nwmatcher-1.1.1>
|
||||
Prototype.NW = window.NW;
|
||||
|
||||
// Restore globals.
|
||||
window.NW = Prototype._original_nw;
|
||||
delete Prototype._original_nw;
|
||||
|
||||
Prototype.Selector = (function(NW) {
|
||||
function extend(elements) {
|
||||
for (var i = 0, length = elements.length; i < length; i++)
|
||||
elements[i] = Element.extend(elements[i]);
|
||||
return elements;
|
||||
}
|
||||
|
||||
function select(selector, scope) {
|
||||
return extend(NW.select(selector, scope || document));
|
||||
}
|
||||
|
||||
function filter(elements, selector) {
|
||||
var results = [], element;
|
||||
for (var i = 0, length = elements.length; i < length; i++) {
|
||||
element = elements[i];
|
||||
if (NW.match(element, selector)) {
|
||||
results.push(Element.extend(element))
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
return {
|
||||
select: select,
|
||||
match: NW.match,
|
||||
filter: filter
|
||||
};
|
||||
})(Prototype.NW.Dom);
|
||||
|
1
vendor/sizzle
vendored
1
vendor/sizzle
vendored
@ -1 +0,0 @@
|
||||
Subproject commit e0f5cbc75d12aa78f3ef30930414b2f88da7b2b8
|
@ -1,5 +1,5 @@
|
||||
Prototype._original_sizzle = window.Sizzle;
|
||||
//= require <sizzle>
|
||||
//= require <sizzle/sizzle>
|
||||
Prototype.Sizzle = window.Sizzle;
|
||||
|
||||
// Restore globals.
|
1
vendor/sizzle/sizzle
vendored
Submodule
1
vendor/sizzle/sizzle
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 415e466f70e5a53f589161b1f2944e5485007409
|
Loading…
Reference in New Issue
Block a user