+1
-2
@@ -570,4 +570,3 @@ /*! | ||
| , replaceWith: function (node) { | ||
| bonzo(normalize(node)).insertAfter(this) | ||
| return this.remove() | ||
| return bonzo(this[0].parentNode.replaceChild(bonzo(normalize(node))[0], this[0])) | ||
| } | ||
@@ -574,0 +573,0 @@ |
+1
-1
@@ -6,2 +6,2 @@ /*! | ||
| */ | ||
| (function(e,t,n){typeof module!="undefined"&&module.exports?module.exports=n():typeof define=="function"&&define.amd?define(n):t[e]=n()})("bonzo",this,function(){function D(e){return e&&e.nodeName&&(e.nodeType==1||e.nodeType==11)}function P(e,t,n){var r,i,s;if(typeof e=="string")return et.create(e);D(e)&&(e=[e]);if(n){s=[];for(r=0,i=e.length;r<i;r++)s[r]=Q(t,e[r]);return s}return e}function H(e){return new RegExp("(^|\\s+)"+e+"(\\s+|$)")}function B(e,t,n,r){var i,s=0,o=e.length;for(;s<o;s++)i=r?e.length-s-1:s,t.call(n||e[i],e[i],i,e);return e}function j(e,t,n){for(var r=0,i=e.length;r<i;r++)D(e[r])&&(j(e[r].childNodes,t,n),t.call(n||e[r],e[r],r,e));return e}function F(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})}function I(e){return e?e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase():e}function q(e){e[x]("data-node-uid")||e[S]("data-node-uid",++y);var t=e[x]("data-node-uid");return g[t]||(g[t]={})}function R(e){var t=e[x]("data-node-uid");t&&delete g[t]}function U(e){var t;try{return e===null||e===undefined?undefined:e==="true"?!0:e==="false"?!1:e==="null"?null:(t=parseFloat(e))==e?t:e}catch(n){}return undefined}function z(e,t,n){for(var r=0,i=e.length;r<i;++r)if(t.call(n||null,e[r],r,e))return!0;return!1}function W(e){return e=="transform"&&(e=N.transform)||/^transform-?[Oo]rigin$/.test(e)&&(e=N.transform+"Origin")||e=="float"&&(e=N.cssFloat),e?F(e):null}function X(e,t,n,r){var i=0,s=t||this,o=[],u=O&&typeof e=="string"&&e.charAt(0)!="<"?O(e):e;return B(P(u),function(e,t){B(s,function(r){n(e,o[i++]=t>0?Q(s,r):r)},null,r)},this,r),s.length=i,B(o,function(e){s[--i]=e},null,!r),s}function V(e,t,n){var r=et(e),i=r.css("position"),s=r.offset(),o="relative",u=i==o,a=[parseInt(r.css("left"),10),parseInt(r.css("top"),10)];i=="static"&&(r.css("position",o),i=o),isNaN(a[0])&&(a[0]=u?0:e.offsetLeft),isNaN(a[1])&&(a[1]=u?0:e.offsetTop),t!=null&&(e.style.left=t-s.left+a[0]+E),n!=null&&(e.style.top=n-s.top+a[1]+E)}function $(e,t){return typeof t=="function"?t(e):t}function J(t,n,r){var i=this[0];return i?t==null&&n==null?(G(i)?Y():{x:i.scrollLeft,y:i.scrollTop})[r]:(G(i)?e.scrollTo(t,n):(t!=null&&(i.scrollLeft=t),n!=null&&(i.scrollTop=n)),this):this}function K(e){this.length=0;if(e){e=typeof e!="string"&&!e.nodeType&&typeof e.length!="undefined"?e:[e],this.length=e.length;for(var t=0;t<e.length;t++)this[t]=e[t]}}function Q(e,t){var n=t.cloneNode(!0),r,i,s;if(e.$&&typeof e.cloneEvents=="function"){e.$(n).cloneEvents(t),r=e.$(n).find("*"),i=e.$(t).find("*");for(s=0;s<i.length;s++)e.$(r[s]).cloneEvents(i[s])}return n}function G(t){return t===e||/^(?:body|html)$/i.test(t.tagName)}function Y(){return{x:e.pageXOffset||n.scrollLeft,y:e.pageYOffset||n.scrollTop}}function Z(e){var t=document.createElement("script"),n=e.match(o);return t.src=n[1],t}function et(e){return new K(e)}var e=window,t=e.document,n=t.documentElement,r="parentNode",i=/^(checked|value|selected|disabled)$/i,s=/^(select|fieldset|table|tbody|tfoot|td|tr|colgroup)$/i,o=/\s*<script +src=['"]([^'"]+)['"]>/,u=["<table>","</table>",1],a=["<table><tbody><tr>","</tr></tbody></table>",3],f=["<select>","</select>",1],l=["_","",0,1],c={thead:u,tbody:u,tfoot:u,colgroup:u,caption:u,tr:["<table><tbody>","</tbody></table>",2],th:a,td:a,col:["<table><colgroup>","</colgroup></table>",2],fieldset:["<form>","</form>",1],legend:["<form><fieldset>","</fieldset></form>",2],option:f,optgroup:f,script:l,style:l,link:l,param:l,base:l},h=/^(checked|selected|disabled)$/,p=/msie/i.test(navigator.userAgent),d,v,m,g={},y=0,b=/^-?[\d\.]+$/,w=/^data-(.+)$/,E="px",S="setAttribute",x="getAttribute",T="getElementsByTagName",N=function(){var e=t.createElement("p");return e.innerHTML='<a href="#x">x</a><table style="float:left;"></table>',{hrefExtended:e[T]("a")[0][x]("href")!="#x",autoTbody:e[T]("tbody").length!==0,computedStyle:t.defaultView&&t.defaultView.getComputedStyle,cssFloat:e[T]("table")[0].style.styleFloat?"styleFloat":"cssFloat",transform:function(){var t=["transform","webkitTransform","MozTransform","OTransform","msTransform"],n;for(n=0;n<t.length;n++)if(t[n]in e.style)return t[n]}(),classList:"classList"in e,opasity:function(){return typeof t.createElement("a").style.opacity!="undefined"}()}}(),C=/(^\s*|\s*$)/g,k=/\s+/,L=String.prototype.toString,A={lineHeight:1,zoom:1,zIndex:1,opacity:1,boxFlex:1,WebkitBoxFlex:1,MozBoxFlex:1},O=t.querySelectorAll&&function(e){return t.querySelectorAll(e)},M=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(C,"")},_=N.computedStyle?function(e,n){var r=null,i=t.defaultView.getComputedStyle(e,"");return i&&(r=i[n]),e.style[n]||r}:!p||!n.currentStyle?function(e,t){return e.style[t]}:function(e,t){var n,r;if(t=="opacity"&&!N.opasity){n=100;try{n=e.filters["DXImageTransform.Microsoft.Alpha"].opacity}catch(i){try{n=e.filters("alpha").opacity}catch(s){}}return n/100}return r=e.currentStyle?e.currentStyle[t]:null,e.style[t]||r};return N.classList?(d=function(e,t){return e.classList.contains(t)},v=function(e,t){e.classList.add(t)},m=function(e,t){e.classList.remove(t)}):(d=function(e,t){return H(t).test(e.className)},v=function(e,t){e.className=M(e.className+" "+t)},m=function(e,t){e.className=M(e.className.replace(H(t)," "))}),K.prototype={get:function(e){return this[e]||null},each:function(e,t){return B(this,e,t)},deepEach:function(e,t){return j(this,e,t)},map:function(e,t){var n=[],r,i;for(i=0;i<this.length;i++)r=e.call(this,this[i],i),t?t(r)&&n.push(r):n.push(r);return n},html:function(e,t){var r=t?n.textContent===undefined?"innerText":"textContent":"innerHTML",i=this,o=function(t,n){B(P(e,i,n),function(e){t.appendChild(e)})},u=function(n,i){try{if(t||typeof e=="string"&&!s.test(n.tagName))return n[r]=e}catch(u){}o(n,i)};return typeof e!="undefined"?this.empty().each(u):this[0]?this[0][r]:""},text:function(e){return this.html(e,!0)},append:function(e){var t=this;return this.each(function(n,r){B(P(e,t,r),function(e){n.appendChild(e)})})},prepend:function(e){var t=this;return this.each(function(n,r){var i=n.firstChild;B(P(e,t,r),function(e){n.insertBefore(e,i)})})},appendTo:function(e,t){return X.call(this,e,t,function(e,t){e.appendChild(t)})},prependTo:function(e,t){return X.call(this,e,t,function(e,t){e.insertBefore(t,e.firstChild)},1)},before:function(e){var t=this;return this.each(function(n,i){B(P(e,t,i),function(e){n[r].insertBefore(e,n)})})},after:function(e){var t=this;return this.each(function(n,i){B(P(e,t,i),function(e){n[r].insertBefore(e,n.nextSibling)},null,1)})},insertBefore:function(e,t){return X.call(this,e,t,function(e,t){e[r].insertBefore(t,e)})},insertAfter:function(e,t){return X.call(this,e,t,function(e,t){var n=e.nextSibling;n?e[r].insertBefore(t,n):e[r].appendChild(t)},1)},replaceWith:function(e){return et(P(e)).insertAfter(this),this.remove()},clone:function(e){var t=[],n,r;for(r=0,n=this.length;r<n;r++)t[r]=Q(e||this,this[r]);return et(t)},addClass:function(e){return e=L.call(e).split(k),this.each(function(t){B(e,function(e){e&&!d(t,$(t,e))&&v(t,$(t,e))})})},removeClass:function(e){return e=L.call(e).split(k),this.each(function(t){B(e,function(e){e&&d(t,$(t,e))&&m(t,$(t,e))})})},hasClass:function(e){return e=L.call(e).split(k),z(this,function(t){return z(e,function(e){return e&&d(t,e)})})},toggleClass:function(e,t){return e=L.call(e).split(k),this.each(function(n){B(e,function(e){e&&(typeof t!="undefined"?t?!d(n,e)&&v(n,e):m(n,e):d(n,e)?m(n,e):v(n,e))})})},show:function(e){return e=typeof e=="string"?e:"",this.each(function(t){t.style.display=e})},hide:function(){return this.each(function(e){e.style.display="none"})},toggle:function(e,t){return t=typeof t=="string"?t:"",typeof e!="function"&&(e=null),this.each(function(n){n.style.display=n.offsetWidth||n.offsetHeight?"none":t,e&&e.call(n)})},first:function(){return et(this.length?this[0]:[])},last:function(){return et(this.length?this[this.length-1]:[])},next:function(){return this.related("nextSibling")},previous:function(){return this.related("previousSibling")},parent:function(){return this.related(r)},related:function(e){return et(this.map(function(t){t=t[e];while(t&&t.nodeType!==1)t=t[e];return t||0},function(e){return e}))},focus:function(){return this.length&&this[0].focus(),this},blur:function(){return this.length&&this[0].blur(),this},css:function(n,r){function o(e,t,n){for(var r in s)if(s.hasOwnProperty(r)){n=s[r],(t=W(r))&&b.test(n)&&!(t in A)&&(n+=E);try{e.style[t]=$(e,n)}catch(i){}}}var i,s=n;return r===undefined&&typeof n=="string"?(r=this[0],r?r===t||r===e?(i=r===t?et.doc():et.viewport(),n=="width"?i.width:n=="height"?i.height:""):(n=W(n))?_(r,n):null:null):(typeof n=="string"&&(s={},s[n]=r),!N.opasity&&"opacity"in s&&(s.filter=s.opacity!=null&&s.opacity!==""?"alpha(opacity="+s.opacity*100+")":"",s.zoom=n.zoom||1,delete s.opacity),this.each(o))},offset:function(e,n){if(!e||typeof e!="object"||typeof e.top!="number"&&typeof e.left!="number"){if(typeof e=="number"||typeof n=="number")return this.each(function(t){V(t,e,n)});if(!this[0])return{top:0,left:0,height:0,width:0};var r=this[0],i=r.ownerDocument.documentElement,s=r.getBoundingClientRect(),o=Y(),u=r.offsetWidth,a=r.offsetHeight,f=s.top+o.y-Math.max(0,i&&i.clientTop,t.body.clientTop),l=s.left+o.x-Math.max(0,i&&i.clientLeft,t.body.clientLeft);return{top:f,left:l,height:a,width:u}}return this.each(function(t){V(t,e.left,e.top)})},dim:function(){if(!this.length)return{height:0,width:0};var e=this[0],t=e.nodeType==9&&e.documentElement,n=!t&&!!e.style&&!e.offsetWidth&&!e.offsetHeight?function(t){var n={position:e.style.position||"",visibility:e.style.visibility||"",display:e.style.display||""};return t.first().css({position:"absolute",visibility:"hidden",display:"block"}),n}(this):null,r=t?Math.max(e.body.scrollWidth,e.body.offsetWidth,t.scrollWidth,t.offsetWidth,t.clientWidth):e.offsetWidth,i=t?Math.max(e.body.scrollHeight,e.body.offsetHeight,t.scrollHeight,t.offsetHeight,t.clientHeight):e.offsetHeight;return n&&this.first().css(n),{height:i,width:r}},attr:function(e,t){var n=this[0],r;if(typeof e=="string"||e instanceof String)return typeof t=="undefined"?n?i.test(e)?h.test(e)&&typeof n[e]=="string"?!0:n[e]:e!="href"&&e!="src"||!N.hrefExtended?n[x](e):n[x](e,2):null:this.each(function(n){i.test(e)?n[e]=$(n,t):n[S](e,$(n,t))});for(r in e)e.hasOwnProperty(r)&&this.attr(r,e[r]);return this},removeAttr:function(e){return this.each(function(t){h.test(e)?t[e]=!1:t.removeAttribute(e)})},val:function(e){return typeof e=="string"||typeof e=="number"?this.attr("value",e):this.length?this[0].value:null},data:function(e,t){var n=this[0],r,i;return typeof t=="undefined"?n?(r=q(n),typeof e=="undefined"?(B(n.attributes,function(e){(i=(""+e.name).match(w))&&(r[F(i[1])]=U(e.value))}),r):(typeof r[e]=="undefined"&&(r[e]=U(this.attr("data-"+I(e)))),r[e])):null:this.each(function(n){q(n)[e]=t})},remove:function(){return this.deepEach(R),this.detach()},empty:function(){return this.each(function(e){j(e.childNodes,R);while(e.firstChild)e.removeChild(e.firstChild)})},detach:function(){return this.each(function(e){e[r]&&e[r].removeChild(e)})},scrollTop:function(e){return J.call(this,null,e,"y")},scrollLeft:function(e){return J.call(this,e,null,"x")}},et.setQueryEngine=function(e){O=e,delete et.setQueryEngine},et.aug=function(e,t){for(var n in e)e.hasOwnProperty(n)&&((t||K.prototype)[n]=e[n])},et.create=function(e){return typeof e=="string"&&e!==""?function(){if(o.test(e))return[Z(e)];var n=e.match(/^\s*<([^\s>]+)/),i=t.createElement("div"),s=[],u=n?c[n[1].toLowerCase()]:null,a=u?u[2]+1:1,f=u&&u[3],l=r,h=N.autoTbody&&u&&u[0]=="<table>"&&!/<tbody/i.test(e);i.innerHTML=u?u[0]+e+u[1]:e;while(a--)i=i.firstChild;f&&i&&i.nodeType!==1&&(i=i.nextSibling);do(!n||i.nodeType==1)&&(!h||i.tagName&&i.tagName!="TBODY")&&s.push(i);while(i=i.nextSibling);return B(s,function(e){e[l]&&e[l].removeChild(e)}),s}():D(e)?[e.cloneNode(!0)]:[]},et.doc=function(){var e=et.viewport();return{width:Math.max(t.body.scrollWidth,n.scrollWidth,e.width),height:Math.max(t.body.scrollHeight,n.scrollHeight,e.height)}},et.firstChild=function(e){for(var t=e.childNodes,n=0,r=t&&t.length||0,i;n<r;n++)t[n].nodeType===1&&(i=t[r=n]);return i},et.viewport=function(){return{width:p?n.clientWidth:e.innerWidth,height:p?n.clientHeight:e.innerHeight}},et.isAncestor="compareDocumentPosition"in n?function(e,t){return(e.compareDocumentPosition(t)&16)==16}:"contains"in n?function(e,t){return e!==t&&e.contains(t)}:function(e,t){while(t=t[r])if(t===e)return!0;return!1},et}) | ||
| (function(e,t,n){typeof module!="undefined"&&module.exports?module.exports=n():typeof define=="function"&&define.amd?define(n):t[e]=n()})("bonzo",this,function(){function D(e){return e&&e.nodeName&&(e.nodeType==1||e.nodeType==11)}function P(e,t,n){var r,i,s;if(typeof e=="string")return et.create(e);D(e)&&(e=[e]);if(n){s=[];for(r=0,i=e.length;r<i;r++)s[r]=Q(t,e[r]);return s}return e}function H(e){return new RegExp("(^|\\s+)"+e+"(\\s+|$)")}function B(e,t,n,r){var i,s=0,o=e.length;for(;s<o;s++)i=r?e.length-s-1:s,t.call(n||e[i],e[i],i,e);return e}function j(e,t,n){for(var r=0,i=e.length;r<i;r++)D(e[r])&&(j(e[r].childNodes,t,n),t.call(n||e[r],e[r],r,e));return e}function F(e){return e.replace(/-(.)/g,function(e,t){return t.toUpperCase()})}function I(e){return e?e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase():e}function q(e){e[x]("data-node-uid")||e[S]("data-node-uid",++y);var t=e[x]("data-node-uid");return g[t]||(g[t]={})}function R(e){var t=e[x]("data-node-uid");t&&delete g[t]}function U(e){var t;try{return e===null||e===undefined?undefined:e==="true"?!0:e==="false"?!1:e==="null"?null:(t=parseFloat(e))==e?t:e}catch(n){}return undefined}function z(e,t,n){for(var r=0,i=e.length;r<i;++r)if(t.call(n||null,e[r],r,e))return!0;return!1}function W(e){return e=="transform"&&(e=N.transform)||/^transform-?[Oo]rigin$/.test(e)&&(e=N.transform+"Origin")||e=="float"&&(e=N.cssFloat),e?F(e):null}function X(e,t,n,r){var i=0,s=t||this,o=[],u=O&&typeof e=="string"&&e.charAt(0)!="<"?O(e):e;return B(P(u),function(e,t){B(s,function(r){n(e,o[i++]=t>0?Q(s,r):r)},null,r)},this,r),s.length=i,B(o,function(e){s[--i]=e},null,!r),s}function V(e,t,n){var r=et(e),i=r.css("position"),s=r.offset(),o="relative",u=i==o,a=[parseInt(r.css("left"),10),parseInt(r.css("top"),10)];i=="static"&&(r.css("position",o),i=o),isNaN(a[0])&&(a[0]=u?0:e.offsetLeft),isNaN(a[1])&&(a[1]=u?0:e.offsetTop),t!=null&&(e.style.left=t-s.left+a[0]+E),n!=null&&(e.style.top=n-s.top+a[1]+E)}function $(e,t){return typeof t=="function"?t(e):t}function J(t,n,r){var i=this[0];return i?t==null&&n==null?(G(i)?Y():{x:i.scrollLeft,y:i.scrollTop})[r]:(G(i)?e.scrollTo(t,n):(t!=null&&(i.scrollLeft=t),n!=null&&(i.scrollTop=n)),this):this}function K(e){this.length=0;if(e){e=typeof e!="string"&&!e.nodeType&&typeof e.length!="undefined"?e:[e],this.length=e.length;for(var t=0;t<e.length;t++)this[t]=e[t]}}function Q(e,t){var n=t.cloneNode(!0),r,i,s;if(e.$&&typeof e.cloneEvents=="function"){e.$(n).cloneEvents(t),r=e.$(n).find("*"),i=e.$(t).find("*");for(s=0;s<i.length;s++)e.$(r[s]).cloneEvents(i[s])}return n}function G(t){return t===e||/^(?:body|html)$/i.test(t.tagName)}function Y(){return{x:e.pageXOffset||n.scrollLeft,y:e.pageYOffset||n.scrollTop}}function Z(e){var t=document.createElement("script"),n=e.match(o);return t.src=n[1],t}function et(e){return new K(e)}var e=window,t=e.document,n=t.documentElement,r="parentNode",i=/^(checked|value|selected|disabled)$/i,s=/^(select|fieldset|table|tbody|tfoot|td|tr|colgroup)$/i,o=/\s*<script +src=['"]([^'"]+)['"]>/,u=["<table>","</table>",1],a=["<table><tbody><tr>","</tr></tbody></table>",3],f=["<select>","</select>",1],l=["_","",0,1],c={thead:u,tbody:u,tfoot:u,colgroup:u,caption:u,tr:["<table><tbody>","</tbody></table>",2],th:a,td:a,col:["<table><colgroup>","</colgroup></table>",2],fieldset:["<form>","</form>",1],legend:["<form><fieldset>","</fieldset></form>",2],option:f,optgroup:f,script:l,style:l,link:l,param:l,base:l},h=/^(checked|selected|disabled)$/,p=/msie/i.test(navigator.userAgent),d,v,m,g={},y=0,b=/^-?[\d\.]+$/,w=/^data-(.+)$/,E="px",S="setAttribute",x="getAttribute",T="getElementsByTagName",N=function(){var e=t.createElement("p");return e.innerHTML='<a href="#x">x</a><table style="float:left;"></table>',{hrefExtended:e[T]("a")[0][x]("href")!="#x",autoTbody:e[T]("tbody").length!==0,computedStyle:t.defaultView&&t.defaultView.getComputedStyle,cssFloat:e[T]("table")[0].style.styleFloat?"styleFloat":"cssFloat",transform:function(){var t=["transform","webkitTransform","MozTransform","OTransform","msTransform"],n;for(n=0;n<t.length;n++)if(t[n]in e.style)return t[n]}(),classList:"classList"in e,opasity:function(){return typeof t.createElement("a").style.opacity!="undefined"}()}}(),C=/(^\s*|\s*$)/g,k=/\s+/,L=String.prototype.toString,A={lineHeight:1,zoom:1,zIndex:1,opacity:1,boxFlex:1,WebkitBoxFlex:1,MozBoxFlex:1},O=t.querySelectorAll&&function(e){return t.querySelectorAll(e)},M=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(C,"")},_=N.computedStyle?function(e,n){var r=null,i=t.defaultView.getComputedStyle(e,"");return i&&(r=i[n]),e.style[n]||r}:!p||!n.currentStyle?function(e,t){return e.style[t]}:function(e,t){var n,r;if(t=="opacity"&&!N.opasity){n=100;try{n=e.filters["DXImageTransform.Microsoft.Alpha"].opacity}catch(i){try{n=e.filters("alpha").opacity}catch(s){}}return n/100}return r=e.currentStyle?e.currentStyle[t]:null,e.style[t]||r};return N.classList?(d=function(e,t){return e.classList.contains(t)},v=function(e,t){e.classList.add(t)},m=function(e,t){e.classList.remove(t)}):(d=function(e,t){return H(t).test(e.className)},v=function(e,t){e.className=M(e.className+" "+t)},m=function(e,t){e.className=M(e.className.replace(H(t)," "))}),K.prototype={get:function(e){return this[e]||null},each:function(e,t){return B(this,e,t)},deepEach:function(e,t){return j(this,e,t)},map:function(e,t){var n=[],r,i;for(i=0;i<this.length;i++)r=e.call(this,this[i],i),t?t(r)&&n.push(r):n.push(r);return n},html:function(e,t){var r=t?n.textContent===undefined?"innerText":"textContent":"innerHTML",i=this,o=function(t,n){B(P(e,i,n),function(e){t.appendChild(e)})},u=function(n,i){try{if(t||typeof e=="string"&&!s.test(n.tagName))return n[r]=e}catch(u){}o(n,i)};return typeof e!="undefined"?this.empty().each(u):this[0]?this[0][r]:""},text:function(e){return this.html(e,!0)},append:function(e){var t=this;return this.each(function(n,r){B(P(e,t,r),function(e){n.appendChild(e)})})},prepend:function(e){var t=this;return this.each(function(n,r){var i=n.firstChild;B(P(e,t,r),function(e){n.insertBefore(e,i)})})},appendTo:function(e,t){return X.call(this,e,t,function(e,t){e.appendChild(t)})},prependTo:function(e,t){return X.call(this,e,t,function(e,t){e.insertBefore(t,e.firstChild)},1)},before:function(e){var t=this;return this.each(function(n,i){B(P(e,t,i),function(e){n[r].insertBefore(e,n)})})},after:function(e){var t=this;return this.each(function(n,i){B(P(e,t,i),function(e){n[r].insertBefore(e,n.nextSibling)},null,1)})},insertBefore:function(e,t){return X.call(this,e,t,function(e,t){e[r].insertBefore(t,e)})},insertAfter:function(e,t){return X.call(this,e,t,function(e,t){var n=e.nextSibling;n?e[r].insertBefore(t,n):e[r].appendChild(t)},1)},replaceWith:function(e){return et(this[0].parentNode.replaceChild(et(P(e))[0],this[0]))},clone:function(e){var t=[],n,r;for(r=0,n=this.length;r<n;r++)t[r]=Q(e||this,this[r]);return et(t)},addClass:function(e){return e=L.call(e).split(k),this.each(function(t){B(e,function(e){e&&!d(t,$(t,e))&&v(t,$(t,e))})})},removeClass:function(e){return e=L.call(e).split(k),this.each(function(t){B(e,function(e){e&&d(t,$(t,e))&&m(t,$(t,e))})})},hasClass:function(e){return e=L.call(e).split(k),z(this,function(t){return z(e,function(e){return e&&d(t,e)})})},toggleClass:function(e,t){return e=L.call(e).split(k),this.each(function(n){B(e,function(e){e&&(typeof t!="undefined"?t?!d(n,e)&&v(n,e):m(n,e):d(n,e)?m(n,e):v(n,e))})})},show:function(e){return e=typeof e=="string"?e:"",this.each(function(t){t.style.display=e})},hide:function(){return this.each(function(e){e.style.display="none"})},toggle:function(e,t){return t=typeof t=="string"?t:"",typeof e!="function"&&(e=null),this.each(function(n){n.style.display=n.offsetWidth||n.offsetHeight?"none":t,e&&e.call(n)})},first:function(){return et(this.length?this[0]:[])},last:function(){return et(this.length?this[this.length-1]:[])},next:function(){return this.related("nextSibling")},previous:function(){return this.related("previousSibling")},parent:function(){return this.related(r)},related:function(e){return et(this.map(function(t){t=t[e];while(t&&t.nodeType!==1)t=t[e];return t||0},function(e){return e}))},focus:function(){return this.length&&this[0].focus(),this},blur:function(){return this.length&&this[0].blur(),this},css:function(n,r){function o(e,t,n){for(var r in s)if(s.hasOwnProperty(r)){n=s[r],(t=W(r))&&b.test(n)&&!(t in A)&&(n+=E);try{e.style[t]=$(e,n)}catch(i){}}}var i,s=n;return r===undefined&&typeof n=="string"?(r=this[0],r?r===t||r===e?(i=r===t?et.doc():et.viewport(),n=="width"?i.width:n=="height"?i.height:""):(n=W(n))?_(r,n):null:null):(typeof n=="string"&&(s={},s[n]=r),!N.opasity&&"opacity"in s&&(s.filter=s.opacity!=null&&s.opacity!==""?"alpha(opacity="+s.opacity*100+")":"",s.zoom=n.zoom||1,delete s.opacity),this.each(o))},offset:function(e,n){if(!e||typeof e!="object"||typeof e.top!="number"&&typeof e.left!="number"){if(typeof e=="number"||typeof n=="number")return this.each(function(t){V(t,e,n)});if(!this[0])return{top:0,left:0,height:0,width:0};var r=this[0],i=r.ownerDocument.documentElement,s=r.getBoundingClientRect(),o=Y(),u=r.offsetWidth,a=r.offsetHeight,f=s.top+o.y-Math.max(0,i&&i.clientTop,t.body.clientTop),l=s.left+o.x-Math.max(0,i&&i.clientLeft,t.body.clientLeft);return{top:f,left:l,height:a,width:u}}return this.each(function(t){V(t,e.left,e.top)})},dim:function(){if(!this.length)return{height:0,width:0};var e=this[0],t=e.nodeType==9&&e.documentElement,n=!t&&!!e.style&&!e.offsetWidth&&!e.offsetHeight?function(t){var n={position:e.style.position||"",visibility:e.style.visibility||"",display:e.style.display||""};return t.first().css({position:"absolute",visibility:"hidden",display:"block"}),n}(this):null,r=t?Math.max(e.body.scrollWidth,e.body.offsetWidth,t.scrollWidth,t.offsetWidth,t.clientWidth):e.offsetWidth,i=t?Math.max(e.body.scrollHeight,e.body.offsetHeight,t.scrollHeight,t.offsetHeight,t.clientHeight):e.offsetHeight;return n&&this.first().css(n),{height:i,width:r}},attr:function(e,t){var n=this[0],r;if(typeof e=="string"||e instanceof String)return typeof t=="undefined"?n?i.test(e)?h.test(e)&&typeof n[e]=="string"?!0:n[e]:e!="href"&&e!="src"||!N.hrefExtended?n[x](e):n[x](e,2):null:this.each(function(n){i.test(e)?n[e]=$(n,t):n[S](e,$(n,t))});for(r in e)e.hasOwnProperty(r)&&this.attr(r,e[r]);return this},removeAttr:function(e){return this.each(function(t){h.test(e)?t[e]=!1:t.removeAttribute(e)})},val:function(e){return typeof e=="string"||typeof e=="number"?this.attr("value",e):this.length?this[0].value:null},data:function(e,t){var n=this[0],r,i;return typeof t=="undefined"?n?(r=q(n),typeof e=="undefined"?(B(n.attributes,function(e){(i=(""+e.name).match(w))&&(r[F(i[1])]=U(e.value))}),r):(typeof r[e]=="undefined"&&(r[e]=U(this.attr("data-"+I(e)))),r[e])):null:this.each(function(n){q(n)[e]=t})},remove:function(){return this.deepEach(R),this.detach()},empty:function(){return this.each(function(e){j(e.childNodes,R);while(e.firstChild)e.removeChild(e.firstChild)})},detach:function(){return this.each(function(e){e[r]&&e[r].removeChild(e)})},scrollTop:function(e){return J.call(this,null,e,"y")},scrollLeft:function(e){return J.call(this,e,null,"x")}},et.setQueryEngine=function(e){O=e,delete et.setQueryEngine},et.aug=function(e,t){for(var n in e)e.hasOwnProperty(n)&&((t||K.prototype)[n]=e[n])},et.create=function(e){return typeof e=="string"&&e!==""?function(){if(o.test(e))return[Z(e)];var n=e.match(/^\s*<([^\s>]+)/),i=t.createElement("div"),s=[],u=n?c[n[1].toLowerCase()]:null,a=u?u[2]+1:1,f=u&&u[3],l=r,h=N.autoTbody&&u&&u[0]=="<table>"&&!/<tbody/i.test(e);i.innerHTML=u?u[0]+e+u[1]:e;while(a--)i=i.firstChild;f&&i&&i.nodeType!==1&&(i=i.nextSibling);do(!n||i.nodeType==1)&&(!h||i.tagName&&i.tagName!="TBODY")&&s.push(i);while(i=i.nextSibling);return B(s,function(e){e[l]&&e[l].removeChild(e)}),s}():D(e)?[e.cloneNode(!0)]:[]},et.doc=function(){var e=et.viewport();return{width:Math.max(t.body.scrollWidth,n.scrollWidth,e.width),height:Math.max(t.body.scrollHeight,n.scrollHeight,e.height)}},et.firstChild=function(e){for(var t=e.childNodes,n=0,r=t&&t.length||0,i;n<r;n++)t[n].nodeType===1&&(i=t[r=n]);return i},et.viewport=function(){return{width:p?n.clientWidth:e.innerWidth,height:p?n.clientHeight:e.innerHeight}},et.isAncestor="compareDocumentPosition"in n?function(e,t){return(e.compareDocumentPosition(t)&16)==16}:"contains"in n?function(e,t){return e!==t&&e.contains(t)}:function(e,t){while(t=t[r])if(t===e)return!0;return!1},et}) |
+28
-21
| { | ||
| "name": "bonzo" | ||
| , "description": "Library agnostic, extensible DOM utility" | ||
| , "version": "1.3.7" | ||
| , "homepage": "https://github.com/ded/bonzo" | ||
| , "author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)" | ||
| , "contributors": [ | ||
| "Rod Vagg <rod@vagg.org> (https://github.com/rvagg)" | ||
| ] | ||
| , "keywords": ["ender", "dom", "nodes", "jquery", "iteration", "css"] | ||
| , "main": "./bonzo.js" | ||
| , "ender": "./src/ender.js" | ||
| , "repository": { | ||
| "type": "git" | ||
| , "url": "https://github.com/ded/bonzo.git" | ||
| } | ||
| , "devDependencies": { | ||
| "qwery": "*" | ||
| , "bowser": "*" | ||
| , "sink-test": "*" | ||
| , "smoosh": "0.4.0" | ||
| } | ||
| "name": "bonzo", | ||
| "description": "Library agnostic, extensible DOM utility", | ||
| "version": "1.4.0", | ||
| "homepage": "https://github.com/ded/bonzo", | ||
| "author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)", | ||
| "contributors": [ | ||
| "Rod Vagg <rod@vagg.org> (https://github.com/rvagg)" | ||
| ], | ||
| "keywords": [ | ||
| "ender", | ||
| "dom", | ||
| "nodes", | ||
| "jquery", | ||
| "iteration", | ||
| "css" | ||
| ], | ||
| "main": "./bonzo.js", | ||
| "ender": "./src/ender.js", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/ded/bonzo.git" | ||
| }, | ||
| "devDependencies": { | ||
| "qwery": "*", | ||
| "bowser": "*", | ||
| "sink-test": "*", | ||
| "smoosh": "0.4.0" | ||
| } | ||
| } |
+658
-90
@@ -56,2 +56,4 @@ Bonzo | ||
| See <a href="#api-setQueryEngine"><code>bonzo.setQueryEngine()</code></a> for more details. | ||
| <a name="extensions"></a> | ||
@@ -78,100 +80,667 @@ Bonzo extension API | ||
| * each(callback) | ||
| - callback (element, index) | ||
| * map(callback, reject) | ||
| - callback (element, index) | ||
| - reject (element) | ||
| * html | ||
| - html() get | ||
| - html(str) set | ||
| * text | ||
| - text() get | ||
| - text(str) set | ||
| * addClass(c) | ||
| * removeClass(c) | ||
| * hasClass(c) | ||
| * toggleClass(c) | ||
| * show() | ||
| * hide() | ||
| * first() | ||
| * last() | ||
| * focus() | ||
| * blur() | ||
| * next() | ||
| * previous() | ||
| * parent() | ||
| * append(html || node) | ||
| * appendTo(target || selector) | ||
| * prepend(html || node) | ||
| * prependTo(target || selector) | ||
| * before(html || node) | ||
| * insertBefore(target || selector) | ||
| * after(html || node) | ||
| * insertAfter(target || selector) | ||
| * replaceWith(html || node) | ||
| * clone() | ||
| * css() | ||
| - css(prop) get | ||
| - css(prop, val) set | ||
| - css({properties}) set | ||
| * offset() | ||
| - offset(x, y) set | ||
| - offset() get | ||
| - top | ||
| - left | ||
| - width | ||
| - height | ||
| * dim() | ||
| - width | ||
| - height | ||
| * attr | ||
| - attr(k) get | ||
| - attr(k, v) set | ||
| - attr(obj) set | ||
| * removeAttr(k) | ||
| * val | ||
| - val() get | ||
| - val(s) set | ||
| * data | ||
| - data() get all | ||
| - data(k) get | ||
| - data(k, v) set | ||
| * remove() | ||
| * empty() | ||
| * detach() | ||
| * scrollLeft | ||
| - scrollLeft() get | ||
| - scrollLeft(x) set | ||
| * scrollTop | ||
| - scrollTop() get | ||
| - scrollTop(y) set | ||
| * bonzo.aug({ properties }) | ||
| * bonzo.doc() | ||
| - width | ||
| - height | ||
| * bonzo.viewport() | ||
| - width | ||
| - height | ||
| * bonzo.isAncestor(container, child) | ||
| * bonzo.noConflict | ||
| * <a href="#api-ctor"><code>bonzo()</code></a> | ||
| Added in the Ender bridge | ||
| <a name="instance"></a> | ||
| ### Instance methods | ||
| * parents(selector) | ||
| * closest(selector) | ||
| * siblings() | ||
| * children() | ||
| * width() | ||
| * height() | ||
| * <a href="#api-get"><code>bonzo().<b>get()</b></code></a> | ||
| * <a href="#api-each"><code>bonzo().<b>each()</b></code></a> | ||
| * <a href="#api-deepEach"><code>bonzo().<b>deepEach()</b></code></a> | ||
| * <a href="#api-map"><code>bonzo().<b>map()</b></code></a> | ||
| * <a href="#api-html"><code>bonzo().<b>html()</b></code></a> | ||
| * <a href="#api-text"><code>bonzo().<b>text()</b></code></a> | ||
| * <a href="#api-addClass"><code>bonzo().<b>addClass()</b></code></a> | ||
| * <a href="#api-removeClass"><code>bonzo().<b>removeClass()</b></code></a> | ||
| * <a href="#api-hasClass"><code>bonzo().<b>hasClass()</b></code></a> | ||
| * <a href="#api-toggleClass"><code>bonzo().<b>toggleClass()</b></code></a> | ||
| * <a href="#api-show"><code>bonzo().<b>show()</b></code></a> | ||
| * <a href="#api-hide"><code>bonzo().<b>hide()</b></code></a> | ||
| * <a href="#api-toggle"><code>bonzo().<b>toggle()</b></code></a> | ||
| * <a href="#api-first"><code>bonzo().<b>first()</b></code></a> | ||
| * <a href="#api-last"><code>bonzo().<b>last()</b></code></a> | ||
| * <a href="#api-next"><code>bonzo().<b>next()</b></code></a> | ||
| * <a href="#api-previous"><code>bonzo().<b>previous()</b></code></a> | ||
| * <a href="#api-parent"><code>bonzo().<b>parent()</b></code></a> | ||
| * <a href="#api-focus"><code>bonzo().<b>focus()</b></code></a> | ||
| * <a href="#api-blur"><code>bonzo().<b>blur()</b></code></a> | ||
| * <a href="#api-append"><code>bonzo().<b>append()</b></code></a> | ||
| * <a href="#api-appendTo"><code>bonzo().<b>appendTo()</b></code></a> | ||
| * <a href="#api-prepend"><code>bonzo().<b>prepend()</b></code></a> | ||
| * <a href="#api-prependTo"><code>bonzo().<b>prependTo()</b></code></a> | ||
| * <a href="#api-before"><code>bonzo().<b>before()</b></code></a> | ||
| * <a href="#api-insertBefore"><code>bonzo().<b>insertBefore()</b></code></a> | ||
| * <a href="#api-after"><code>bonzo().<b>after()</b></code></a> | ||
| * <a href="#api-insertAfter"><code>bonzo().<b>insertAfter()</b></code></a> | ||
| * <a href="#api-replaceWith"><code>bonzo().<b>replaceWith()</b></code></a> | ||
| * <a href="#api-css"><code>bonzo().<b>css()</b></code></a> | ||
| * <a href="#api-offset"><code>bonzo().<b>offset()</b></code></a> | ||
| * <a href="#api-dim"><code>bonzo().<b>dim()</b></code></a> | ||
| * <a href="#api-attr"><code>bonzo().<b>attr()</b></code></a> | ||
| * <a href="#api-removeAttr"><code>bonzo().<b>removeAttr()</b></code></a> | ||
| * <a href="#api-val"><code>bonzo().<b>val()</b></code></a> | ||
| * <a href="#api-data"><code>bonzo().<b>data()</b></code></a> | ||
| * <a href="#api-remove"><code>bonzo().<b>remove()</b></code></a> | ||
| * <a href="#api-empty"><code>bonzo().<b>empty()</b></code></a> | ||
| * <a href="#api-detach"><code>bonzo().<b>detach()</b></code></a> | ||
| * <a href="#api-scrollLeft"><code>bonzo().<b>scrollLeft()</b></code></a> | ||
| * <a href="#api-scrollTop"><code>bonzo().<b>scrollTop()</b></code></a> | ||
| <a name="static"></a> | ||
| ### Static methods | ||
| ### Setting a query engine host | ||
| * <a href="#api-aug"><code>bonzo.<b>aug()</b></code></a> | ||
| * <a href="#api-doc"><code>bonzo.<b>doc()</b></code></a> | ||
| * <a href="#api-viewport"><code>bonzo.<b>viewport()</b></code></a> | ||
| * <a href="#api-firstChild"><code>bonzo.<b>firstChild()</b></code></a> | ||
| * <a href="#api-isAncestor"><code>bonzo.<b>isAncestor()</b></code></a> | ||
| * <a href="#api-create"><code>bonzo.<b>create()</b></code></a> | ||
| * <a href="#api-setQueryEngine"><code>bonzo.<b>setQueryEngine()</b></code></a> | ||
| Added in the Ender bridge: | ||
| * <a href="#api-parents"><code>$().<b>parents()</b></code></a> | ||
| * <a href="#api-closest"><code>$().<b>closest()</b></code></a> | ||
| * <a href="#api-siblings"><code>$().<b>siblings()</b></code></a> | ||
| * <a href="#api-children"><code>$().<b>children()</b></code></a> | ||
| * <a href="#api-width"><code>$().<b>width()</b></code></a> | ||
| * <a href="#api-height"><code>$().<b>height()</b></code></a> | ||
| ------------------------------------------------ | ||
| <a name="api-ctor"></a> | ||
| ### bonzo(DOMElement | ArrayLikeDOMElementCollection) | ||
| Factory function for bonzo objects. Takes in either a single `DOMElement`, or an array-like object or array of them. Returns an array-like `Bonzo` object possessing all of the [instance methods](#instance) documented below. | ||
| ```js | ||
| var elem = document.getElementById('foo'); | ||
| var $elem = bonzo(elem); | ||
| // $elem now has all the special powers listed below... | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-get"></a> | ||
| ### bonzo().get(index) | ||
| Returns the raw `DOMElement` held at `index`. Because Bonzo objects are array-like, this is identical to saying `bonzo()[index]`. | ||
| ```js | ||
| var elem = document.getElementById('bar'); | ||
| var $elem = bonzo(elem); | ||
| var sameElem = $elem.get(0); | ||
| var sameElemAgain = $elem[0]; | ||
| // elem === sameElem && sameElem === sameElemAgain | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-each"></a> | ||
| ### bonzo().each(fn[, scope]) | ||
| Allows you to iterate over the raw elements contained in `bonzo` collections. `fn` gets called once for each element in the collection, with each element, in turn, as its first argument. If the optional `scope` argument is supplied, then it is used as the `this` value of the function. Otherwise, the same element that is passed as the first argument is used. The index of the element is passed as the second argument, and the collection itself is passed as the third. | ||
| ------------------------------------------------ | ||
| <a name="api-deepEach"></a> | ||
| ### bonzo().deepEach(fn[, scope]) | ||
| `deepEach()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-map"></a> | ||
| ### bonzo().map(fn[, rejectFn]) | ||
| `map()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-html"></a> | ||
| ### bonzo().html([content]) | ||
| `bonzo.html()` either sets or gets the elements' `innerHTML` to `content`, depending if the optional `content` argument is pased in. If called without the argument, `.html()` returns the element's `innerHTML`. | ||
| * `content` is an *optional* argument. If it is passed in, it will **set** the `innerHTML` of a given element and return a `Bonzo` object. | ||
| #### Examples | ||
| ```js | ||
| bonzo(element).html('<p>foo</p>'); | ||
| bonzo(element).html(); // <p>foo</p> | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-text"></a> | ||
| ### bonzo().text([content]) | ||
| `bonzo.text()` is very similar to [`.html`](#api-html), but uses the elements` `textContent` instead of `innerHTML` when setting the `content`. Thus, the `content` will not get parsed as markup. | ||
| This method either **gets** or **sets** the text of a given element, depending if the optional *content* argument is passed in. | ||
| * `content` is an *optional* argument. If it is passed in, it will **set** the text value of a given element and return a `Bonzo` object. | ||
| If no `content` is specified, the `.text()` method will return the text that makes up that element. | ||
| If the element has children (i.e. a `ul` containing several `li` children), the children's text is included in the return value. | ||
| #### Examples | ||
| ``` js | ||
| bonzo("<h1>hello, world</h1>").text() | ||
| // → returns "hello, world" | ||
| bonzo("<h1>i'm going to change</h1>").text("changed you!") | ||
| // the <h1> now says "changed you!" | ||
| // → returns a Bonzo object | ||
| bonzo("<ul><li>one</li><li>two</li></ul>").text() | ||
| // → returns "one | ||
| // two" | ||
| bonzo("<ul><li>one</li><li>two</li></ul>").text('hello') | ||
| // the html is now <ul>hello</ul> | ||
| // → returns a Bonzo object | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-addClass"></a> | ||
| ### bonzo().addClass(class | classList) | ||
| `bonzo.addClass(class | classList)` adds the specified `class` to the given element. It returns a `Bonzo` object. | ||
| * `class` is a *required* argument. It is the name of the class you wish to add to the given element. | ||
| * If you'd like to add multiple classes at once, simply use a | ||
| space-separated string, a `classList` (i.e. "classOne classTwo"). | ||
| #### Examples | ||
| ``` js | ||
| bonzo("<h1>hello, world</h1>").addClass('big') | ||
| // the html is now <h1 class="big">hello, world</h1> | ||
| // → returns a Bonzo object | ||
| bonzo("<h1>hello, world</h1>").addClass() | ||
| // throws an error, since the argument is required | ||
| bonzo("<p>i want lots of classes</p>").addClass("one two three") | ||
| // the html is now <p class="one two three">i want lots of classes</p> | ||
| // → returns a Bonzo object | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-removeClass"></a> | ||
| ### bonzo().removeClass(class | classList) | ||
| `bonzo.removeClass(class)` removes the specified `class` from the given element. It returns a `Bonzo` object. | ||
| * `class` is a *required* argument. It is the name of the class you wish to remove from the given element. | ||
| * If you'd like to remove multiple classes at once, simply use a | ||
| space-separated string, a `classList` (i.e. "classOne classTwo"). | ||
| #### Examples | ||
| ``` js | ||
| bonzo("<h1 class='small'>hello, world</h1>").removeClass('small') | ||
| // the html is now <h1 class>hello, world</h1> | ||
| // → returns a Bonzo object | ||
| bonzo("<h1 class='removeMe'>hello, world</h1>").removeClass() | ||
| // throws an error, since the argument is required | ||
| bonzo("<p class='one two three'>i have lots of classes</p>").removeClass("one two three") | ||
| // the html is now <p>i have lots of classes</p> | ||
| // → returns a Bonzo object | ||
| bonzo("<h1 class='error'>hello, world</h1>").removeClass('does_not_exist') | ||
| // → since the argument does not match a classlist the <h1> has, nothing happens and a Bonzo object is returned | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-hasClass"></a> | ||
| ### bonzo().hasClass(class | classList) | ||
| `bonzo.hasClass(class)` returns **true** or **false**, based on whether | ||
| or not the specified element has a given *class*. It returns **true** if | ||
| the specified element *does* have the `class`, and returns **false** if | ||
| the specified element **does not** have the `class`. | ||
| * `class` is a *required* argument. It is the name of the class you wish to check for in a given element. | ||
| * **NOTE**: if you pass in a space-separated `classList` like you can | ||
| in <a href="#api-addClass">addClass</a> and <a | ||
| href="#api-removeClass">removeClass</a>, this method will return | ||
| **true** if **any** of the space-separated `classList` classes are present in the element. | ||
| #### Examples | ||
| ``` js | ||
| bonzo("<p class='alert'>something went wrong</p>").hasClass('alert') | ||
| // → returns true | ||
| bonzo("<p class='alert'>something went wrong</p>").hasClass('normal') | ||
| // → returns false | ||
| bonzo("<p class='one'>something went wrong</p>").hasClass('one two three') | ||
| // → returns true | ||
| bonzo("<p class='one'>something went wrong</p>").hasClass('three two one') | ||
| // → returns true | ||
| bonzo("<p class='large'>something went wrong</p>").hasClass('small tiny') | ||
| // → returns false | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-toggleClass"></a> | ||
| ### bonzo().toggleClass(class | classList) | ||
| `bonzo.toggleClass(class)` either adds or removes a specified `class` to the given element, depending on whether or not the given element already has a class with that `class` or not. | ||
| If the element **does** have a class named `class`, calling `toggleClass()` will **remove** the `class` class from it. If the element **does not** have a class with the specified `class`, calling `toggleClass()` will **add** a class with that `class`. | ||
| * `class` is a *required* argument. It is the name of the class you wish to toggle. | ||
| * If you'd like to toggle multiple classes at once, simply use a | ||
| space-separated string, a `classList` (i.e. "classOne classTwo"). | ||
| #### Examples | ||
| ``` js | ||
| bonzo("<p class='alert'>something went wrong</p>").toggleClass('alert') | ||
| // the html is now <p class>something went wrong</p> | ||
| // → returns a Bonzo object | ||
| bonzo("<p class='alert'>something went wrong</p>").toggleClass('different') | ||
| // the html is now <p class="alert different">something went wrong</p> | ||
| // → returns a Bonzo object | ||
| bonzo("<p class='one'>something went wrong</p>").toggleClass('three two one') | ||
| // the html is now <p class="three two">something went wrong</p> | ||
| // → returns a Bonzo object | ||
| bonzo("<p class='large'>something went wrong</p>").toggleClass('small tiny') | ||
| // the html is now <p class="small tiny large">something went wrong</p> | ||
| // → returns a Bonzo object | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-show"></a> | ||
| ### bonzo().show([type]) | ||
| `bonzo.show()` sets a given element or set of elements' `display` style property. By passing in an optional `type` argument, you can specify the attribute of the `display` property Bonzo gives the element(s). | ||
| * `type` is an *optional* argument. It is the display type you wish to | ||
| utilize. | ||
| If you specify an unsupported `type` (i.e. something other than `block`, `compact`, `inline-block`, `inline`, `inline-table`, `list-item`, `run-in`, `table`, `table-caption`, `table-cell`, `table-column`, `table-column-group`, `table-footer-group`, `table-header-group`, `table-row`, or `table-row-group`), Bonzo will ignore the invalid `type`. | ||
| #### Examples | ||
| ``` js | ||
| bonzo("<p style=\"display: none;\">I was hidden</p>").show() | ||
| // html is now <p style>I was hidden</p> | ||
| // → returns a Bonzo object | ||
| bonzo("<p style=\"display: none;\">I was hidden</p>").show('inline-block') | ||
| // html is now <p style="display: inline-block;">I was hidden</p> | ||
| // → returns a Bonzo object | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-hide"></a> | ||
| ### bonzo().hide() | ||
| `bonzo.hide()` adds a `display: none;` to the specified element. | ||
| #### Examples | ||
| ``` js | ||
| bonzo("<p>Hello, world</p>").hide() | ||
| // html is now <p style="display: none;">Hello, world</p> | ||
| // → returns a Bonzo object | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-toggle"></a> | ||
| ### bonzo().toggle([callback[, type]]) | ||
| `toggle()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-first"></a> | ||
| ### bonzo().first() | ||
| `bonzo.first()` returns a Bonzo object referencing the first element in a set of elements. If the set is empty, the a Bonzo object will still be returned, but it won't contain any children. | ||
| #### Examples | ||
| ``` js | ||
| var firstItem = bonzo("<li>one</li><li>two</li><li>three</li>").first() | ||
| firstItem.text() // "one" | ||
| firstItem.length // 1 | ||
| // → returns a Bonzo object | ||
| var el = bonzo("").first() | ||
| el.text() // "" | ||
| el.length // 0 | ||
| // → returns a Bonzo object | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-last"></a> | ||
| ### bonzo().last() | ||
| `bonzo.last()` returns a Bonzo object referencing the last element in a set of elements. If the set is empty, the a Bonzo object will still be returned, but it won't contain any children. | ||
| #### Examples | ||
| ``` js | ||
| var lastItem = bonzo("<li>one</li><li>two</li><li>three</li>").last() | ||
| lastItem.text() // "three" | ||
| lastItem.length // 1 | ||
| // → returns a Bonzo object | ||
| var el = bonzo("").last() | ||
| el.text() // "" | ||
| el.length // 0 | ||
| // → returns a Bonzo object | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-next"></a> | ||
| ### bonzo().next() | ||
| `bonzo.next()` returns a `Bonzo` object with a list of the next element siblings in the initial collection. | ||
| ------------------------------------------------ | ||
| <a name="api-previous"></a> | ||
| ### bonzo().previous() | ||
| `bonzo.previous()` returns a `Bonzo` object with a list of the previous element siblings in the initial collection. | ||
| ------------------------------------------------ | ||
| <a name="api-parent"></a> | ||
| ### bonzo().parent() | ||
| `bonzo.parent()` returns a `Bonzo` object with a list of the `parentNode`'s of each item in the initial collection. | ||
| ------------------------------------------------ | ||
| <a name="api-focus"></a> | ||
| ### bonzo().focus() | ||
| `bonzo.focus()` will send the browser's focus event to an input element. This will only work on the first (zeroith index) item in the `Bonzo` collection. | ||
| ------------------------------------------------ | ||
| <a name="api-blur"></a> | ||
| ### bonzo().blur() | ||
| `bonzo.blur()` will send the browser's blur event to an input element. This will only work on the first (zeroith index) item in the `Bonzo` collection. | ||
| ------------------------------------------------ | ||
| <a name="api-append"></a> | ||
| ### bonzo().append(html | element | collection) | ||
| `bonzo.append()` will insert the supplied html | element | collection at the initial supplied collection. | ||
| #### Examples | ||
| ``` js | ||
| bonzo([element1, element2]).append('<p>hello</p><p>world</p>') | ||
| bonzo(document.createElement('div')).append(document.createElement('p')) | ||
| bonzo(element).append(document.getElementsByTagName('p')) | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-appendTo"></a> | ||
| ### bonzo().appendTo(target) | ||
| `bonzo.appendTo()` will insert the initial collection at the supplied `target`. It's the backwards version of `bonzo.append` | ||
| #### Examples | ||
| ``` js | ||
| bonzo('<p>hello</p>').appendTo(document.body) | ||
| bonzo(document.createElement('div')).appendTo(document.querySelectorAll('p')) | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-prepend"></a> | ||
| ### bonzo().prepend(html | element | collection) | ||
| `bonzo.prepend()` is similar to <a href="#api-append">bonzo.append()</a>, but inserts at the top of a collection (it prepends ;). | ||
| ------------------------------------------------ | ||
| <a name="api-prependTo"></a> | ||
| ### bonzo().prependTo(target) | ||
| `prependTo()` is similar to <a href="#api-append">bonzo.appendTo()</a>, but, you know, prepends. | ||
| ------------------------------------------------ | ||
| <a name="api-before"></a> | ||
| ### bonzo().before(html | element | collection) | ||
| `bonzo.before()` inserts the supplied content before each item in the initial collection. | ||
| #### Examples | ||
| ``` js | ||
| bonzo(document.querySelectorAll('p')).before('<b>hello</b>') | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-insertBefore"></a> | ||
| ### bonzo().insertBefore(target) | ||
| `bonzo.insertBefore()` will insert the items in the initial collection before the supplied targets. | ||
| #### Examples | ||
| ``` js | ||
| bonzo('<p>hello</p>').insertBefore(document.querySelectorAll('div')) | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-after"></a> | ||
| ### bonzo().after(html | element | collection) | ||
| `bonzo.after()` will insert the supplied content after each item in the initial collection. | ||
| #### Examples | ||
| ``` js | ||
| bonzo(document.querySelectorAll('p')).after('<b>, huh</b>') | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-insertAfter"></a> | ||
| ### bonzo().insertAfter(target) | ||
| `insertAfter()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-replaceWith"></a> | ||
| ### bonzo().replaceWith(html | element | collection) | ||
| `bonzo.replaceWith()` will replace each item in the initial collection with the supplied content. | ||
| #### Examples | ||
| ``` js | ||
| bonzo(document.querySelectorAll('p')).replaceWith('<p>you have been replaced</p>') | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-css"></a> | ||
| ### bonzo().css(property | hash[, value]) | ||
| Sets or returns CSS properties of the element. If a single string argument is passed, then the value of that CSS property is returned. If two string arguments are passed, the CSS property specified by the first is set to the value specified by the second. If a single hash argument is passed, then the CSS property corresponding to each property is set to the value designated by the hash property's value. | ||
| ```js | ||
| bonzo(elem).css({ | ||
| background: 'blue', | ||
| color: green; | ||
| }).css('border', '2px solid red').css('color'); // "green" | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-offset"></a> | ||
| ### bonzo().offset([ x, y ] | [ hash ]) | ||
| `bonzo.offset()` is an overloaded setter and getter. When setting the offset of a collection, it will set an element to an explicit x/y coordinate position on the page. When getting the offset, the function returns an object containing the four properties `top`, `left`, `width`, and `height`. | ||
| #### Examples | ||
| ``` js | ||
| bonzo(el).offset() // returns { top: n, left: n, width: n, height: n } | ||
| bonzo(el).offset(50, 100) // sets left to 50, and top to 100 | ||
| bonzo(el).offset({ left: 50, top: 100 }) // sets left to 50, and top to 100 | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-dim"></a> | ||
| ### bonzo().dim() | ||
| `bonzo.dim()` returns the entire `width` and `height` dimensions of an element, including the `scrollHeight`. | ||
| ------------------------------------------------ | ||
| <a name="api-attr"></a> | ||
| ### bonzo().attr(key[, value] | hash) | ||
| Sets or returns attributes of the element. If the first argument is a hash, then each property of the hash is read and the corresponding attribute of the element is set to the hash property's value. If the first argument is a string and no second argument is provided, the value of the element's attribute with the same name is returned. If a second argument *is* supplied, then the element's attribute of the same name as the first argument is set to the value of the second argument. | ||
| ------------------------------------------------ | ||
| <a name="api-removeAttr"></a> | ||
| ### bonzo().removeAttr(key) | ||
| `bonzo.removeAttr()` removes the supplied attribute from each item in the initial collection. | ||
| ------------------------------------------------ | ||
| <a name="api-val"></a> | ||
| ### bonzo().val([ value ]) | ||
| `bonzo.val()` is an overloaded setter and getter. it returns the content from the first element `value` attribute. When setting it sets the `value` attribute of each item in the initial collection. | ||
| ------------------------------------------------ | ||
| <a name="api-data"></a> | ||
| ### bonzo().data([ key[, value ] ] | [ hash ]) | ||
| `bonzo.data()` is an overloaded setter and getter. `data` can be set to any value and referenced further when getting the data. | ||
| #### Examples | ||
| ``` js | ||
| bonzo(el).data('username', 'ded') | ||
| bonzo(el).data('username') // returns 'ded' | ||
| bonzo(another).data('userinfo', { | ||
| id: 911, | ||
| name: 'agent' | ||
| age: 2 | ||
| }) | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-remove"></a> | ||
| ### bonzo().remove() | ||
| `bonzo.remove()` removes the initial supplied collection from the DOM | ||
| #### Examples | ||
| ``` js | ||
| bonzo(document.querySelectorAll('p')).remove() | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-empty"></a> | ||
| ### bonzo().empty() | ||
| `bonzo.empty()` will empty out the content of the initial supplied collection, but not remove the nodes themselves. | ||
| ------------------------------------------------ | ||
| <a name="api-detach"></a> | ||
| ### bonzo().detach() | ||
| `bonzo.detach()` returns a `Bonzo` object containing the supplied collection, but detached from the DOM. This is useful if you wish to do heavy operations an offline Node, and then inserting it back into the DOM again. | ||
| #### Examples | ||
| ``` js | ||
| bonzo(document.querySelectorAll('p')).detach().addClass('eyo').html('<p>stuff</p>').appendTo(document.body) | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-scrollLeft"></a> | ||
| ### bonzo().scrollLeft([ x ]) | ||
| `bonzo.scrollLeft()` is an overloaded setter and getter. it returns the `scrollLeft` of an element when no argument is supplied, otherwise, sets it. | ||
| ------------------------------------------------ | ||
| <a name="api-scrollTop"></a> | ||
| ### bonzo().scrollTop([ y ] | ||
| `bonzo.scrollTop()` is an overloaded setter and getter. it returns the `scrollTop` of an element when no argument is supplied, otherwise, sets it. | ||
| ------------------------------------------------ | ||
| <a name="api-aug"></a> | ||
| ### bonzo.aug(hash) | ||
| `bonzo.aug()` will agument the `Bonzo` prototype so that you can customize and include additions to your liking. | ||
| #### Examples | ||
| ``` js | ||
| bonzo.aug({ | ||
| color: function (c) { | ||
| // `this` is the scope of the `Bonzo` instance | ||
| return this.css('color', c) | ||
| } | ||
| }) | ||
| // you can now do the following | ||
| $('p').color('aqua') | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-doc"></a> | ||
| ### bonzo.doc() | ||
| `bonzo.doc()` returns an object containing `width` and `height` information regarding the document size. This includes `scrollWidth` and `scrollHeight`. | ||
| ------------------------------------------------ | ||
| <a name="api-viewport"></a> | ||
| ### bonzo.viewport() | ||
| `bonzo.viewport()` returns an object containing `width` and `height` information regarding the document viewport. This is usually the same as using `bonzo.doc()`, but can be smaller given it's only what you *see* in the viewport, and not the entire document (with scrolling). | ||
| ------------------------------------------------ | ||
| <a name="api-firstChild"></a> | ||
| ### bonzo.firstChild(element) | ||
| `firstChild()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-isAncestor"></a> | ||
| ### bonzo.isAncestor(container, element) | ||
| `isAncestor()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-create"></a> | ||
| ### bonzo.create(container, element) | ||
| `create()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-parents"></a> | ||
| ### $().parents() | ||
| `parents()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-setQueryEngine"></a> | ||
| ### bonzo.setQueryEngine(engine) | ||
| `bonzo.setQueryEngine()` is a useful utility that allows you to pair `Bonzo` with a selector engine. | ||
| For the insertion methods you can set a query selector host: | ||
| #### Examples | ||
| ``` js | ||
| bonzo.setQueryEngine(qwery) | ||
| // using Ender supported modules | ||
| bonzo.setQueryEngine(require('qwery')) | ||
| bonzo(bonzo.create('<div>')).insertAfter('.boosh a') | ||
| // or Sizzle | ||
| bonzo.setQueryEngine(Sizzle) | ||
| ``` | ||
| ------------------------------------------------ | ||
| <a name="api-closest"></a> | ||
| ### $().closest() | ||
| `closest()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-siblings"></a> | ||
| ### $().siblings() | ||
| `siblings()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-children"></a> | ||
| ### $().children() | ||
| `children()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-width"></a> | ||
| ### $().width([ value ]) | ||
| `width()` ... | ||
| ------------------------------------------------ | ||
| <a name="api-height"></a> | ||
| ### $().height([ value ]) | ||
| `height()` ... | ||
| ------------------------------------------------ | ||
| <a name="aboutname"></a> | ||
@@ -221,3 +790,3 @@ About the name "Bonzo" | ||
| Bonzo is a registered npm package and fits in nicely with the [Ender](http://ender.no.de) framework. If you don't have Ender, you should install now, and never look back, *ever*. As a side note the *query engine host* is set for you when you include it with Ender. | ||
| Bonzo is a registered npm package and fits in nicely with the [Ender](http://enderjs.com) framework. If you don't have Ender, you should install now, and never look back, *ever*. As a side note the *query engine host* is set for you when you include it with Ender. | ||
@@ -235,3 +804,2 @@ ```sh | ||
| or, add it to your existing ender package | ||
| ```sh | ||
@@ -255,2 +823,2 @@ $ ender add bonzo | ||
| Bonzo is Copyright © 2012 Dustin Diaz [@ded](https://twitter.com/ded) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. | ||
| Bonzo is Copyright © 2012 Dustin Diaz [@ded](https://twitter.com/ded) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. |
+3
-4
@@ -329,7 +329,7 @@ (function (name, context, definition) { | ||
| * @param {Element} el | ||
| * @param {function (Element)|string} | ||
| * @param {function (Element)|string} v | ||
| * @return {string} | ||
| */ | ||
| function setter(el, v) { | ||
| return typeof v == 'function' ? v(el) : v | ||
| return typeof v == 'function' ? v.call(el, el) : v | ||
| } | ||
@@ -566,4 +566,3 @@ | ||
| , replaceWith: function (node) { | ||
| bonzo(normalize(node)).insertAfter(this) | ||
| return this.remove() | ||
| return bonzo(this[0].parentNode.replaceChild(bonzo(normalize(node))[0], this[0])) | ||
| } | ||
@@ -570,0 +569,0 @@ |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
404251
6.32%820
226.69%8136
-0.02%