diff --git a/README.md b/README.md index 59caa51..61c62e8 100755 --- a/README.md +++ b/README.md @@ -120,6 +120,8 @@ Gulp Boilerplate is licensed under the [MIT License](http://gomakethings.com/mit ## Changelog +* v0.2.2 - August 8, 2014 + * Added polyfills for `Functions.prototype.bind` and `element.classList`. * v0.2.1 - July 21, 2014 * Updated `getDataOptions` method to use JSON. * Removed auto-dating from minified files. diff --git a/dist/css/myplugin.css b/dist/css/myplugin.css index 2f8eaab..305e4d0 100644 --- a/dist/css/myplugin.css +++ b/dist/css/myplugin.css @@ -1,5 +1,5 @@ /** - * gulp-boilerplate v0.2.1 + * gulp-boilerplate v0.2.2 * My Gulp.js boilerplate for creating new web projects, by Chris Ferdinandi. * http://github.com/cferdinandi/Plugin * diff --git a/dist/css/myplugin.min.css b/dist/css/myplugin.min.css index d1712c6..b7bbd35 100644 --- a/dist/css/myplugin.min.css +++ b/dist/css/myplugin.min.css @@ -1 +1 @@ -/** gulp-boilerplate v0.2.1, by Chris Ferdinandi | http://github.com/cferdinandi/Plugin | Licensed under MIT: http://gomakethings.com/mit/ */ +/** gulp-boilerplate v0.2.2, by Chris Ferdinandi | http://github.com/cferdinandi/Plugin | Licensed under MIT: http://gomakethings.com/mit/ */ diff --git a/dist/js/bind-polyfill.js b/dist/js/bind-polyfill.js new file mode 100644 index 0000000..5f4603a --- /dev/null +++ b/dist/js/bind-polyfill.js @@ -0,0 +1,35 @@ +/** + * gulp-boilerplate v0.2.2 + * My Gulp.js boilerplate for creating new web projects, by Chris Ferdinandi. + * http://github.com/cferdinandi/Plugin + * + * Free to use under the MIT License. + * http://gomakethings.com/mit/ + */ + +/* + * Polyfill Function.prototype.bind support for otherwise ECMA Script 5 compliant browsers + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Compatibility + */ + +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 + // internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1); + var fToBind = this; + fNOP = function () {}; + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} \ No newline at end of file diff --git a/dist/js/bind-polyfill.min.js b/dist/js/bind-polyfill.min.js new file mode 100644 index 0000000..0c42f3c --- /dev/null +++ b/dist/js/bind-polyfill.min.js @@ -0,0 +1,2 @@ +/** gulp-boilerplate v0.2.2, by Chris Ferdinandi | http://github.com/cferdinandi/Plugin | Licensed under MIT: http://gomakethings.com/mit/ */ +Function.prototype.bind||(Function.prototype.bind=function(t){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var o=Array.prototype.slice.call(arguments,1),n=this;return fNOP=function(){},fBound=function(){return n.apply(this instanceof fNOP&&t?this:t,o.concat(Array.prototype.slice.call(arguments)))},fNOP.prototype=this.prototype,fBound.prototype=new fNOP,fBound}); \ No newline at end of file diff --git a/dist/js/classList.js b/dist/js/classList.js new file mode 100644 index 0000000..f27e26c --- /dev/null +++ b/dist/js/classList.js @@ -0,0 +1,176 @@ +/** + * gulp-boilerplate v0.2.2 + * My Gulp.js boilerplate for creating new web projects, by Chris Ferdinandi. + * http://github.com/cferdinandi/Plugin + * + * Free to use under the MIT License. + * http://gomakethings.com/mit/ + */ + +/* + * classList.js: Cross-browser full element.classList implementation. + * 2014-01-31 + * + * By Eli Grey, http://eligrey.com + * Public Domain. + * NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. + */ + +/*global self, document, DOMException */ + +/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js*/ + +if ("document" in self && !("classList" in document.createElement("_"))) { + + (function (view) { + + "use strict"; + + if (!('Element' in view)) return; + + var + classListProp = "classList", + protoProp = "prototype", + elemCtrProto = view.Element[protoProp], + objCtr = Object, + strTrim = String[protoProp].trim || function () { + return this.replace(/^\s+|\s+$/g, ""); + }, + arrIndexOf = Array[protoProp].indexOf || function (item) { + var + i = 0, + len = this.length; + for (; i < len; i++) { + if (i in this && this[i] === item) { + return i; + } + } + return -1; + }, + // Vendors: please allow content code to instantiate DOMExceptions + DOMEx = function (type, message) { + this.name = type; + this.code = DOMException[type]; + this.message = message; + }, + checkTokenAndGetIndex = function (classList, token) { + if (token === "") { + throw new DOMEx( + "SYNTAX_ERR", + "An invalid or illegal string was specified" + ); + } + if (/\s/.test(token)) { + throw new DOMEx( + "INVALID_CHARACTER_ERR", + "String contains an invalid character" + ); + } + return arrIndexOf.call(classList, token); + }, + ClassList = function (elem) { + var + trimmedClasses = strTrim.call(elem.getAttribute("class") || ""), + classes = trimmedClasses ? trimmedClasses.split(/\s+/) : [], + i = 0, + len = classes.length; + for (; i < len; i++) { + this.push(classes[i]); + } + this._updateClassName = function () { + elem.setAttribute("class", this.toString()); + }; + }, + classListProto = ClassList[protoProp] = [], + classListGetter = function () { + return new ClassList(this); + }; + // Most DOMException implementations don't allow calling DOMException's toString() + // on non-DOMExceptions. Error's toString() is sufficient here. + DOMEx[protoProp] = Error[protoProp]; + classListProto.item = function (i) { + return this[i] || null; + }; + classListProto.contains = function (token) { + token += ""; + return checkTokenAndGetIndex(this, token) !== -1; + }; + classListProto.add = function () { + var + tokens = arguments, + i = 0, + l = tokens.length, + token, + updated = false; + do { + token = tokens[i] + ""; + if (checkTokenAndGetIndex(this, token) === -1) { + this.push(token); + updated = true; + } + } + while (++i < l); + + if (updated) { + this._updateClassName(); + } + }; + classListProto.remove = function () { + var + tokens = arguments, + i = 0, + l = tokens.length, + token, + updated = false; + do { + token = tokens[i] + ""; + var index = checkTokenAndGetIndex(this, token); + if (index !== -1) { + this.splice(index, 1); + updated = true; + } + } + while (++i < l); + + if (updated) { + this._updateClassName(); + } + }; + classListProto.toggle = function (token, force) { + token += ""; + + var + result = this.contains(token), + method = result ? force !== true && "remove" : force !== false && "add"; + + if (method) { + this[method](token); + } + + return !result; + }; + classListProto.toString = function () { + return this.join(" "); + }; + + if (objCtr.defineProperty) { + var classListPropDesc = { + get: classListGetter, + enumerable: true, + configurable: true + }; + try { + objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); + } catch (ex) { // IE 8 doesn't support enumerable:true + if (ex.number === -0x7FF5EC54) { + classListPropDesc.enumerable = false; + objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc); + } + } + } else if (objCtr[protoProp].__defineGetter__) { + elemCtrProto.__defineGetter__(classListProp, classListGetter); + } + + }(self)); + +} \ No newline at end of file diff --git a/dist/js/classList.min.js b/dist/js/classList.min.js new file mode 100644 index 0000000..613fde1 --- /dev/null +++ b/dist/js/classList.min.js @@ -0,0 +1,2 @@ +/** gulp-boilerplate v0.2.2, by Chris Ferdinandi | http://github.com/cferdinandi/Plugin | Licensed under MIT: http://gomakethings.com/mit/ */ +"document"in self&&!("classList"in document.createElement("_"))&&!function(t){"use strict";if("Element"in t){var e="classList",n="prototype",i=t.Element[n],r=Object,s=String[n].trim||function(){return this.replace(/^\s+|\s+$/g,"")},a=Array[n].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},o=function(t,e){this.name=t,this.code=DOMException[t],this.message=e},u=function(t,e){if(""===e)throw new o("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new o("INVALID_CHARACTER_ERR","String contains an invalid character");return a.call(t,e)},c=function(t){for(var e=s.call(t.getAttribute("class")||""),n=e?e.split(/\s+/):[],i=0,r=n.length;r>i;i++)this.push(n[i]);this._updateClassName=function(){t.setAttribute("class",this.toString())}},l=c[n]=[],h=function(){return new c(this)};if(o[n]=Error[n],l.item=function(t){return this[t]||null},l.contains=function(t){return t+="",-1!==u(this,t)},l.add=function(){var t,e=arguments,n=0,i=e.length,r=!1;do t=e[n]+"",-1===u(this,t)&&(this.push(t),r=!0);while(++n