Permalink
Browse files

new .jshintrc, some JSHint-induced changed

1 parent 211f2cd commit 4328537470a0c819c8689cad49cbc10f8066726d @rvagg rvagg committed Jan 31, 2013
Showing with 255 additions and 165 deletions.
  1. +52 −17 .jshintrc
  2. +2 −1 Makefile
  3. +70 −57 bonzo.js
  4. +1 −1 bonzo.min.js
  5. +0 −35 make/build.js
  6. +73 −0 make/build.json
  7. +57 −54 src/bonzo.js
View
@@ -1,26 +1,61 @@
{
- "predef": ["assert", "refute", "define", "self"]
- , "boss": true
- , "shadow": true
- , "trailing": true
- , "latedef": true
- , "forin": false
+ "predef": [ "define", "ActiveXObject" ]
+ , "bitwise": false
+ , "camelcase": false
, "curly": false
- , "debug": true
- , "devel": false
- , "evil": true
+ , "eqeqeq": false
+ , "forin": false
+ , "immed": false
+ , "latedef": false
+ , "newcap": true
+ , "noarg": true
+ , "noempty": true
+ , "nonew": true
+ , "plusplus": false
+ , "quotmark": true
, "regexp": false
, "undef": true
- , "sub": true
- , "white": false
+ , "unused": true
+ , "strict": false
+ , "trailing": true
+ , "maxlen": 120
, "asi": true
- , "laxbreak": true
+ , "boss": true
+ , "debug": true
, "eqnull": true
+ , "es5": true
+ , "esnext": true
+ , "evil": true
+ , "expr": true
+ , "funcscope": false
+ , "globalstrict": false
+ , "iterator": false
+ , "lastsemic": true
+ , "laxbreak": true
+ , "laxcomma": true
+ , "loopfunc": true
+ , "multistr": false
+ , "onecase": false
+ , "proto": false
+ , "regexdash": false
+ , "scripturl": true
+ , "smarttabs": false
+ , "shadow": false
+ , "sub": true
+ , "supernew": false
+ , "validthis": true
, "browser": true
+ , "couch": false
+ , "devel": false
+ , "dojo": false
+ , "mootools": false
, "node": true
- , "laxcomma": true
- , "proto": true
- , "expr": true
- , "es5": true
- , "strict": false
+ , "nonstandard": true
+ , "prototypejs": false
+ , "rhino": false
+ , "worker": true
+ , "wsh": false
+ , "nomen": false
+ , "onevar": true
+ , "passfail": false
}
View
@@ -1,7 +1,8 @@
.PHONY: release
boosh:
- node_modules/smoosh/bin/smoosh make make/build.js
+ @node -e "var json = require('./make/build');json.JSHINT_OPTS=JSON.parse(require('fs').readFileSync('./.jshintrc'));require('fs').writeFileSync('./make/build.json', JSON.stringify(json, null, 2))"
+ @node_modules/smoosh/bin/smoosh make make/build.json
# for repo owners only
release:
View
127 bonzo.js
@@ -13,7 +13,8 @@
, html = doc.documentElement
, parentNode = 'parentNode'
, specialAttributes = /^(checked|value|selected|disabled)$/i
- , specialTags = /^(select|fieldset|table|tbody|tfoot|td|tr|colgroup)$/i // tags that we have trouble inserting *into*
+ // tags that we have trouble inserting *into*
+ , specialTags = /^(select|fieldset|table|tbody|tfoot|td|tr|colgroup)$/i
, simpleScriptTagRe = /\s*<script +src=['"]([^'"]+)['"]>/
, table = ['<table>', '</table>', 1]
, td = ['<table><tbody><tr>', '</tr></tbody></table>', 3]
@@ -73,6 +74,39 @@
return s.replace(trimReplace, '')
}
+ , getStyle = features.computedStyle
+ ? function (el, property) {
+ var value = null
+ , computed = doc.defaultView.getComputedStyle(el, '')
+ computed && (value = computed[property])
+ return el.style[property] || value
+ }
+ : !(ie && html.currentStyle)
+ ? function (el, property) {
+ return el.style[property]
+ }
+ :
+ /**
+ * @param {Element} el
+ * @param {string} property
+ * @return {string|number}
+ */
+ function (el, property) {
+ var val, value
+ if (property == 'opacity' && !features.opasity) {
+ val = 100
+ try {
+ val = el['filters']['DXImageTransform.Microsoft.Alpha'].opacity
+ } catch (e1) {
+ try {
+ val = el['filters']('alpha').opacity
+ } catch (e2) {}
+ }
+ return val / 100
+ }
+ value = el.currentStyle ? el.currentStyle[property] : null
+ return el.style[property] || value
+ }
function isNode(node) {
return node && node.nodeName && (node.nodeType == 1 || node.nodeType == 11)
@@ -91,13 +125,12 @@
return node
}
-
/**
* @param {string} c a class name to test
* @return {boolean}
*/
function classReg(c) {
- return new RegExp("(^|\\s+)" + c + "(\\s+|$)")
+ return new RegExp('(^|\\s+)' + c + '(\\s+|$)')
}
@@ -216,41 +249,6 @@
return p ? camelize(p) : null
}
- var getStyle = features.computedStyle ?
- function (el, property) {
- var value = null
- , computed = doc.defaultView.getComputedStyle(el, '')
- computed && (value = computed[property])
- return el.style[property] || value
- } :
-
- (ie && html.currentStyle) ?
-
- /**
- * @param {Element} el
- * @param {string} property
- * @return {string|number}
- */
- function (el, property) {
- if (property == 'opacity' && !features.opasity) {
- var val = 100
- try {
- val = el['filters']['DXImageTransform.Microsoft.Alpha'].opacity
- } catch (e1) {
- try {
- val = el['filters']('alpha').opacity
- } catch (e2) {}
- }
- return val / 100
- }
- var value = el.currentStyle ? el.currentStyle[property] : null
- return el.style[property] || value
- } :
-
- function (el, property) {
- return el.style[property]
- }
-
// this insert method is intense
function insert(target, host, fn, rev) {
var i = 0, self = host || this, r = []
@@ -340,6 +338,21 @@
return typeof v == 'function' ? v(el) : v
}
+ function scroll(x, y, type) {
+ var el = this[0]
+ if (!el) return this
+ if (x == null && y == null) {
+ return (isBody(el) ? getWindowScroll() : { x: el.scrollLeft, y: el.scrollTop })[type]
+ }
+ if (isBody(el)) {
+ win.scrollTo(x, y)
+ } else {
+ x != null && (el.scrollLeft = x)
+ y != null && (el.scrollTop = y)
+ }
+ return this
+ }
+
/**
* @constructor
* @param {Array.<Element>|Element|Node|string} elements
@@ -558,6 +571,17 @@
return this.remove()
}
+ /**
+ * @param {Object=} opt_host an optional host scope (primarily used when integrated with Ender)
+ * @return {Bonzo}
+ */
+ , clone: function (opt_host) {
+ var ret = [] // don't change original array
+ , l, i
+ for (i = 0, l = this.length; i < l; i++) ret[i] = cloneNode(opt_host || this, this[i])
+ return bonzo(ret)
+ }
+
// class management
/**
@@ -710,7 +734,7 @@
* @return {Element|Node}
*/
, related: function (method) {
- return this.map(
+ return bonzo(this.map(
function (el) {
el = el[method]
while (el && el.nodeType !== 1) {
@@ -721,7 +745,7 @@
function (el) {
return el
}
- )
+ ))
}
@@ -874,12 +898,15 @@
*/
, attr: function (k, opt_v) {
var el = this[0]
+ , n
+
if (typeof k != 'string' && !(k instanceof String)) {
- for (var n in k) {
+ for (n in k) {
k.hasOwnProperty(n) && this.attr(n, k[n])
}
return this
}
+
return typeof opt_v == 'undefined' ?
!el ? null : specialAttributes.test(k) ?
stateAttributes.test(k) && typeof el[k] == 'string' ?
@@ -997,6 +1024,7 @@
var c = el.cloneNode(true)
, cloneElems
, elElems
+ , i
// check for existence of an event cloner
// preferably https://github.com/fat/bean
@@ -1008,27 +1036,12 @@
cloneElems = host.$(c).find('*')
elElems = host.$(el).find('*')
- for (var i = 0; i < elElems.length; i++)
+ for (i = 0; i < elElems.length; i++)
host.$(cloneElems[i]).cloneEvents(elElems[i])
}
return c
}
- function scroll(x, y, type) {
- var el = this[0]
- if (!el) return this
- if (x == null && y == null) {
- return (isBody(el) ? getWindowScroll() : { x: el.scrollLeft, y: el.scrollTop })[type]
- }
- if (isBody(el)) {
- win.scrollTo(x, y)
- } else {
- x != null && (el.scrollLeft = x)
- y != null && (el.scrollTop = y)
- }
- return this
- }
-
function isBody(element) {
return element === win || (/^(?:body|html)$/i).test(element.tagName)
}
Oops, something went wrong.

0 comments on commit 4328537

Please sign in to comment.