forked from kossnocorp/role-rails
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added role.js as a submodule. Version bump
- Loading branch information
Pavel Pravosud
committed
Apr 19, 2012
1 parent
8aff99c
commit a32e811
Showing
8 changed files
with
50 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "role"] | ||
path = role | ||
url = git://github.com/kossnocorp/role.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module RoleRails | ||
VERSION = '1.1.0' | ||
VERSION = '1.2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,19 @@ | ||
// Role.js, jQuery adapter v1.0.2 ~ https://github.com/kossnocorp/role | ||
|
||
(function($) { | ||
var matchesSelectorOrigin, type; | ||
if ($ == null) $ = jQuery; | ||
$.expr.match['ROLE'] = /@((?:[\w\u00c0-\uFFFF\-]|\\.)+)/; | ||
$.expr.preFilter['ROLE'] = function(match) { | ||
return ' ' + match[1] + ' '; | ||
}; | ||
$.expr.filter['ROLE'] = function(el, match) { | ||
return (el.getAttribute != null) && (" " + (el.getAttribute('role')) + " ").indexOf(match) !== -1; | ||
}; | ||
for (type in $.expr.match) { | ||
$.expr.match[type] = new RegExp($.expr.match[type].source + /(?![^\[]*\])(?![^\(]*\))/.source); | ||
$.expr.leftMatch[type] = new RegExp(/(^(?:.|\r|\n)*?)/.source + $.expr.match[type].source.replace(/\\(\d+)/g, function(all, num) { | ||
return "\\" + (num - 0 + 1); | ||
})); | ||
} | ||
if (!(document.documentElement.matchesSelector != null) && (document.documentElement.mozMatchesSelector != null)) { | ||
matchesSelectorOrigin = $.find.matchesSelector; | ||
return $.find.matchesSelector = function(node, expr) { | ||
return matchesSelectorOrigin(node, expr.replace(/(@[\w\-]+)/g, function($0) { | ||
return $0.replace(/^@([\w\-]+)$/, function(__, $1) { | ||
return "[role~=\"" + $1 + "\"]"; | ||
}); | ||
})); | ||
!function($){ | ||
function rewriteSelector(context, name, argPos){ | ||
var original = context[name]; | ||
|
||
if (!original) return; | ||
|
||
context[name] = function(){ | ||
arguments[argPos] = arguments[argPos].replace(/@([\w\u00c0-\uFFFF\-]+)/g, '[role~="$1"]') | ||
return original.apply(context, arguments); | ||
}; | ||
|
||
$.extend(context[name], original); | ||
} | ||
})($); | ||
|
||
rewriteSelector($, 'find', 0); | ||
rewriteSelector($, 'multiFilter', 0); | ||
rewriteSelector($.find, 'matchesSelector', 1); | ||
rewriteSelector($.find, 'matches', 0); | ||
}(jQuery) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
// Role.js, extension for querySelectorAll function v1.0.2 ~ https://github.com/kossnocorp/role | ||
|
||
(function() { | ||
var elements, elm, _fn, _i, _len; | ||
|
||
elements = []; | ||
|
||
if (typeof Document !== "undefined" && Document !== null) elements << Document; | ||
|
||
if (typeof Element !== "undefined" && Element !== null) elements << Element; | ||
|
||
_fn = function(elm) { | ||
var nativeQuery; | ||
nativeQuery = elm.prototype.querySelectorAll; | ||
return elm.prototype.querySelectorAll = function(selector) { | ||
return nativeQuery.call(this, selector.replace(/@(\w+)/g, "[role~=\"$1\"]")); | ||
}; | ||
}; | ||
for (_i = 0, _len = elements.length; _i < _len; _i++) { | ||
elm = elements[_i]; | ||
_fn(elm); | ||
!function(window, methods){ | ||
function overrideMethod(klass, methodName){ | ||
var original; | ||
if (klass && (original = klass.prototype[methodName])) { | ||
klass.prototype[methodName] = function(){ | ||
arguments[0] = arguments[0].replace(/@([\w\u00c0-\uFFFF\-]+)/g, '[role~="$1"]'); | ||
return original.apply(this, arguments); | ||
}; | ||
} | ||
} | ||
|
||
}).call(this); | ||
|
||
function overridePrototype(klass){ | ||
for(var i=0; i<methods.length; i++) | ||
overrideMethod(klass, methods[i]); | ||
} | ||
|
||
overridePrototype(window.Element); overridePrototype(window.Document); | ||
}(this, ['querySelector', 'querySelectorAll']); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.