Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
84 additions
and
84 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
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,93 +1,93 @@ | ||
/*! | ||
* vibe 0.9.3+201311230520 | ||
* https://github.com/ryanve/vibe | ||
* MIT License 2013 Ryan Van Etten | ||
*/ | ||
|
||
/*! | ||
* vibe 0.9.4+201403131410 | ||
* https://github.com/ryanve/vibe | ||
* MIT License (c) 2014 Ryan Van Etten | ||
*/ | ||
|
||
(function(root, name, make) { | ||
typeof module != 'undefined' && module['exports'] ? module['exports'] = make() : root[name] = make(); | ||
if (typeof module != 'undefined' && module['exports']) module['exports'] = make(); | ||
else root[name] = make(); | ||
}(this, 'vibe', function() { | ||
|
||
var classList = 'classList' | ||
, subject = document.documentElement[classList] | ||
, hasApi = !!(subject && subject.contains && subject.add && subject.remove) | ||
, whitespace = /\s+/g | ||
, ssv = /\S+/g | ||
, space = ' ' | ||
, contains = function(str, token) { | ||
return !!~(space + str.replace(whitespace, space) + space).indexOf(space + token + space); | ||
} | ||
var classList = 'classList' | ||
, subject = typeof document != 'undefined' && document.documentElement[classList] | ||
, hasApi = !!(subject && subject.contains && subject.add && subject.remove) | ||
, whitespace = /\s+/g | ||
, ssv = /\S+/g | ||
, space = ' ' | ||
, contains = function(str, token) { | ||
return !!~(space + str.replace(whitespace, space) + space).indexOf(space + token + space); | ||
} | ||
|
||
, addClass = hasApi ? function(el, c) { | ||
'' === c || el[classList].add(c); | ||
} : function(el, c) { | ||
contains(el.className, c) || (el.className += space + c); | ||
} | ||
, addClass = hasApi ? function(el, c) { | ||
'' === c || el[classList].add(c); | ||
} : function(el, c) { | ||
contains(el.className, c) || (el.className += space + c); | ||
} | ||
|
||
, removeClass = hasApi ? function(el, c) { | ||
'' === c || el[classList].remove(c); | ||
} : function(el, c) { | ||
var diff = 0, s = '', classes = el.className.match(ssv), i = classes && classes.length; | ||
for (c = s + c; i--;) c === classes[i] ? ++diff : s = classes[i] + (s ? space : s) + s; | ||
if (diff) el.className = s; | ||
} | ||
, removeClass = hasApi ? function(el, c) { | ||
'' === c || el[classList].remove(c); | ||
} : function(el, c) { | ||
var diff = 0, s = '', classes = el.className.match(ssv), i = classes && classes.length; | ||
for (c = s + c; i--;) c === classes[i] ? ++diff : s = classes[i] + (s ? space : s) + s; | ||
if (diff) el.className = s; | ||
} | ||
|
||
, hasClass = hasApi ? function(el, c) { | ||
return '' === c || !!el[classList].contains(c); | ||
} : function(el, c) { | ||
return contains(el.className, c); | ||
} | ||
, hasClass = hasApi ? function(el, c) { | ||
return '' === c || !!el[classList].contains(c); | ||
} : function(el, c) { | ||
return contains(el.className, c); | ||
} | ||
|
||
, toggleClass = function(el, c, force) { | ||
if ('' === c) return true; | ||
force = typeof force == 'boolean' ? force : !hasClass(el, c); | ||
(force ? addClass : removeClass)(el, c); | ||
return force; | ||
}; | ||
, toggleClass = function(el, c, force) { | ||
if ('' === c) return true; | ||
force = typeof force == 'boolean' ? force : !hasClass(el, c); | ||
(force ? addClass : removeClass)(el, c); | ||
return force; | ||
}; | ||
|
||
/** | ||
* @param {{length:number}} els | ||
* @param {Function} fn method | ||
* @param {string|Array|Function} list of classes or callback to determine them | ||
*/ | ||
function bulk(els, fn, list) { | ||
var j, n, i = 0, l = els.length; | ||
if (typeof list == 'function') { | ||
while (i < l) { | ||
n = list.call(els[i]); | ||
if (false === n) break; | ||
bulk([els[i++]], fn, n); | ||
} | ||
} else if (typeof list == 'string' ? list = list.match(ssv) : list) { | ||
for (n = list.length; i < l; i++) { | ||
for (j = 0; j < n; j++) { | ||
fn(els[i], list[j]); | ||
} | ||
} | ||
/** | ||
* @param {{length:number}} els | ||
* @param {Function} fn method | ||
* @param {string|Array|Function} list of classes or callback to determine them | ||
*/ | ||
function bulk(els, fn, list) { | ||
var j, n, i = 0, l = els.length; | ||
if (typeof list == 'function') { | ||
while (i < l) { | ||
n = list.call(els[i]); | ||
if (false === n) break; | ||
bulk([els[i++]], fn, n); | ||
} | ||
} else if (typeof list == 'string' ? list = list.match(ssv) : list) { | ||
for (n = list.length; i < l; i++) { | ||
for (j = 0; j < n; j++) { | ||
fn(els[i], list[j]); | ||
} | ||
return els; | ||
} | ||
} | ||
return els; | ||
} | ||
|
||
return { | ||
'addClass': addClass | ||
, 'removeClass': removeClass | ||
, 'toggleClass': toggleClass | ||
, 'hasClass': hasClass | ||
, 'fn': { | ||
'addClass': function(list) { | ||
return bulk(this, addClass, list); | ||
} | ||
, 'removeClass': function(list) { | ||
return bulk(this, removeClass, list); | ||
} | ||
, 'toggleClass': function(list, state) { | ||
return bulk(this, true === state ? addClass : false === state ? removeClass : toggleClass, list); | ||
} | ||
, 'hasClass': function(c) { | ||
for (var i = 0, l = this.length; i < l;) | ||
if (hasClass(this[i++], c)) return true; | ||
return false; | ||
} | ||
return { | ||
'addClass': addClass | ||
, 'removeClass': removeClass | ||
, 'toggleClass': toggleClass | ||
, 'hasClass': hasClass | ||
, 'fn': { | ||
'addClass': function(list) { | ||
return bulk(this, addClass, list); | ||
} | ||
}; | ||
, 'removeClass': function(list) { | ||
return bulk(this, removeClass, list); | ||
} | ||
, 'toggleClass': function(list, state) { | ||
return bulk(this, true === state ? addClass : false === state ? removeClass : toggleClass, list); | ||
} | ||
, 'hasClass': function(c) { | ||
for (var i = 0, l = this.length; i < l;) if (hasClass(this[i++], c)) return true; | ||
return false; | ||
} | ||
} | ||
}; | ||
})); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.