From a23885c7355003a6259641c84c3ddb603fcf8f83 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 16 Aug 2015 14:02:52 +0200 Subject: [PATCH 01/26] Update srcset-info.js environment independent `exports` --- js/srcset-info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/srcset-info.js b/js/srcset-info.js index 3c40e15..29cc5dc 100644 --- a/js/srcset-info.js +++ b/js/srcset-info.js @@ -147,4 +147,4 @@ exports.SrcsetInfo = SrcsetInfo; -})(window); +})(this); From e2a236ab07be832e712915b97e6336b64468347b Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 16 Aug 2015 14:04:12 +0200 Subject: [PATCH 02/26] Update main.js --- js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index f9f22ca..b1424fa 100644 --- a/js/main.js +++ b/js/main.js @@ -46,4 +46,4 @@ } }, 10); -})(window); +})(this); From b5c7f97435e5964b95cfc8c03ac9accc8480cb38 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 16 Aug 2015 14:04:32 +0200 Subject: [PATCH 03/26] Update viewport-info.js --- js/viewport-info.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/viewport-info.js b/js/viewport-info.js index 15fe42b..9455382 100644 --- a/js/viewport-info.js +++ b/js/viewport-info.js @@ -131,4 +131,4 @@ exports.ViewportInfo = ViewportInfo; -})(window); +})(this); From 9c23d623318eeb755aa8504b2c1f8a95fb3b980d Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 16 Aug 2015 18:00:46 +0200 Subject: [PATCH 04/26] deps --- js/libs/jsuri-1.1.1.js | 9 +++++++-- js/main.js | 2 ++ js/srcset-info.js | 5 +++++ js/viewport-info.js | 5 +++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/js/libs/jsuri-1.1.1.js b/js/libs/jsuri-1.1.1.js index c5ecee8..1212ec3 100644 --- a/js/libs/jsuri-1.1.1.js +++ b/js/libs/jsuri-1.1.1.js @@ -13,7 +13,7 @@ * * Date: Mon Nov 14 20:06:34 2011 -0800 */ - +(function(exports) { var Query = function (queryString) { @@ -469,5 +469,10 @@ var Uri = function (uriString) { }; }; +exports.Query = Query; +exports.Uri = Uri; + /* add compatibility for users of jsUri <= 1.1.1 */ -var jsUri = Uri; +exports.jsUri = Uri; + +})(this); diff --git a/js/main.js b/js/main.js index b1424fa..7095440 100644 --- a/js/main.js +++ b/js/main.js @@ -1,4 +1,6 @@ (function(exports) { + var ViewportInfo = require('./viewport-info.js') || this.ViewportInfo; + var SrcsetInfo = require('./srcset-info') || exports.SrcsetInfo; function isSrcsetImplemented() { return 'srcset' in new Image(); diff --git a/js/srcset-info.js b/js/srcset-info.js index 29cc5dc..7cdd223 100644 --- a/js/srcset-info.js +++ b/js/srcset-info.js @@ -145,6 +145,11 @@ this.x = options.x || 1; } + + // Exports exports.SrcsetInfo = SrcsetInfo; + if (typeof module !== "undefined" && module !== null) { + module.exports = SrcsetInfo; + } })(this); diff --git a/js/viewport-info.js b/js/viewport-info.js index 9455382..827cd63 100644 --- a/js/viewport-info.js +++ b/js/viewport-info.js @@ -1,4 +1,5 @@ (function(exports) { + var SrcsetInfo = require('./srcset-info') || exports.SrcsetInfo; function ViewportInfo() { this.w = null; @@ -129,6 +130,10 @@ return bestMatch; }; + // Exports exports.ViewportInfo = ViewportInfo; + if (typeof module !== "undefined" && module !== null) { + module.exports = ViewportInfo; + } })(this); From eecc401ad5db4b7d2e4ce84cbf4369c7b2207a65 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 16 Aug 2015 21:16:23 +0200 Subject: [PATCH 05/26] revvamp main.js using a new implementation + new build system based on browserify --- Gruntfile.js | 31 - Makefile | 8 + README.md | 14 +- build/srcset.js | 1598 +++++++++++++++++++++++++------------ build/srcset.min.js | 2 +- demo/1024x768.png | Bin 0 -> 25644 bytes demo/1536x1152.png | Bin 0 -> 44996 bytes demo/160x120.png | Bin 0 -> 4270 bytes demo/2048x1536.png | Bin 0 -> 76726 bytes demo/320x240.png | Bin 0 -> 7206 bytes demo/640x480.png | Bin 0 -> 13618 bytes demo/768x576.png | Bin 0 -> 17090 bytes demo/banner-HD.jpeg | Bin 5456 -> 0 bytes demo/banner-phone-HD.jpeg | Bin 6016 -> 0 bytes demo/banner-phone.jpeg | Bin 4648 -> 0 bytes demo/banner.jpeg | Bin 3936 -> 0 bytes demo/index.html | 16 +- js/libs/jsuri-1.1.1.js | 478 ----------- js/main.js | 51 -- js/srcset-info.js | 6 +- js/srcset.js | 92 +++ js/viewport-info.js | 8 +- package.json | 10 +- 23 files changed, 1205 insertions(+), 1109 deletions(-) delete mode 100644 Gruntfile.js create mode 100644 Makefile create mode 100644 demo/1024x768.png create mode 100644 demo/1536x1152.png create mode 100644 demo/160x120.png create mode 100644 demo/2048x1536.png create mode 100644 demo/320x240.png create mode 100644 demo/640x480.png create mode 100644 demo/768x576.png delete mode 100644 demo/banner-HD.jpeg delete mode 100644 demo/banner-phone-HD.jpeg delete mode 100644 demo/banner-phone.jpeg delete mode 100644 demo/banner.jpeg delete mode 100644 js/libs/jsuri-1.1.1.js delete mode 100644 js/main.js create mode 100644 js/srcset.js diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index ee6e1a4..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,31 +0,0 @@ -module.exports = function(grunt) { - - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - jshint: { all: ['js/*.js'] }, - concat: { - dist: { - src: [ - 'js/libs/*', - 'js/srcset-info.js', - 'js/viewport-info.js', - 'js/main.js' - ], - dest: 'build/srcset.js' - } - }, - uglify: { - my_target: { - files: { - 'build/srcset.min.js': ['build/srcset.js'] - } - } - } - }); - - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-concat'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - - grunt.registerTask('default', ['jshint', 'concat', 'uglify']); -}; diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..17035cc --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +build/srcset.js: ./node_modules/.bin/browserify $(shell find -L js -name '*.js') + ./node_modules/.bin/browserify ./js/srcset.js > $@ + +build/srcset.min.js: build/srcset.js + ./node_modules/.bin/uglifyjs $^ -o $@ -m + +node_modules ./node_modules/%: + npm install \ No newline at end of file diff --git a/README.md b/README.md index 4b43035..d552a7a 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,18 @@ See [the specification][spec] for the reference algorithm. ## Usage -Use the `srcset` attribute of `` elements. For example: - - The Breakfast Combo +Use the `data-srcset` attribute of `` elements. For example: +```html +The Breakfast Combo +``` Include `build/srcset.min.js` in your page. + + ## Open questions - How to reliably check for srcset support in the browser (so as to not diff --git a/build/srcset.js b/build/srcset.js index c716112..c795ad7 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -1,478 +1,5 @@ -/*! - * jsUri v1.1.1 - * https://github.com/derek-watson/jsUri - * - * Copyright 2011, Derek Watson - * Released under the MIT license. - * http://jquery.org/license - * - * Includes parseUri regular expressions - * http://blog.stevenlevithan.com/archives/parseuri - * Copyright 2007, Steven Levithan - * Released under the MIT license. - * - * Date: Mon Nov 14 20:06:34 2011 -0800 - */ - - -var Query = function (queryString) { - - // query string parsing, parameter manipulation and stringification - - 'use strict'; - - var // parseQuery(q) parses the uri query string and returns a multi-dimensional array of the components - parseQuery = function (q) { - var arr = [], i, ps, p, keyval; - - if (typeof (q) === 'undefined' || q === null || q === '') { - return arr; - } - - if (q.indexOf('?') === 0) { - q = q.substring(1); - } - - ps = q.toString().split(/[&;]/); - - for (i = 0; i < ps.length; i++) { - p = ps[i]; - keyval = p.split('='); - arr.push([keyval[0], keyval[1]]); - } - - return arr; - }, - - params = parseQuery(queryString), - - // toString() returns a string representation of the internal state of the object - toString = function () { - var s = '', i, param; - for (i = 0; i < params.length; i++) { - param = params[i]; - if (s.length > 0) { - s += '&'; - } - s += param.join('='); - } - return s.length > 0 ? '?' + s : s; - }, - - decode = function (s) { - s = decodeURIComponent(s); - s = s.replace('+', ' '); - return s; - }, - - // getParamValues(key) returns the first query param value found for the key 'key' - getParamValue = function (key) { - var param, i; - for (i = 0; i < params.length; i++) { - param = params[i]; - if (decode(key) === decode(param[0])) { - return param[1]; - } - } - }, - - // getParamValues(key) returns an array of query param values for the key 'key' - getParamValues = function (key) { - var arr = [], i, param; - for (i = 0; i < params.length; i++) { - param = params[i]; - if (decode(key) === decode(param[0])) { - arr.push(param[1]); - } - } - return arr; - }, - - // deleteParam(key) removes all instances of parameters named (key) - // deleteParam(key, val) removes all instances where the value matches (val) - deleteParam = function (key, val) { - - var arr = [], i, param, keyMatchesFilter, valMatchesFilter; - - for (i = 0; i < params.length; i++) { - - param = params[i]; - keyMatchesFilter = decode(param[0]) === decode(key); - valMatchesFilter = decode(param[1]) === decode(val); - - if ((arguments.length === 1 && !keyMatchesFilter) || (arguments.length === 2 && !keyMatchesFilter && !valMatchesFilter)) { - arr.push(param); - } - } - - params = arr; - - return this; - }, - - // addParam(key, val) Adds an element to the end of the list of query parameters - // addParam(key, val, index) adds the param at the specified position (index) - addParam = function (key, val, index) { - - if (arguments.length === 3 && index !== -1) { - index = Math.min(index, params.length); - params.splice(index, 0, [key, val]); - } else if (arguments.length > 0) { - params.push([key, val]); - } - return this; - }, - - // replaceParam(key, newVal) deletes all instances of params named (key) and replaces them with the new single value - // replaceParam(key, newVal, oldVal) deletes only instances of params named (key) with the value (val) and replaces them with the new single value - // this function attempts to preserve query param ordering - replaceParam = function (key, newVal, oldVal) { - - var index = -1, i, param; - - if (arguments.length === 3) { - for (i = 0; i < params.length; i++) { - param = params[i]; - if (decode(param[0]) === decode(key) && decodeURIComponent(param[1]) === decode(oldVal)) { - index = i; - break; - } - } - deleteParam(key, oldVal).addParam(key, newVal, index); - } else { - for (i = 0; i < params.length; i++) { - param = params[i]; - if (decode(param[0]) === decode(key)) { - index = i; - break; - } - } - deleteParam(key); - addParam(key, newVal, index); - } - return this; - }; - - // public api - return { - getParamValue: getParamValue, - getParamValues: getParamValues, - deleteParam: deleteParam, - addParam: addParam, - replaceParam: replaceParam, - - toString: toString - }; -}; - -var Uri = function (uriString) { - - // uri string parsing, attribute manipulation and stringification - - 'use strict'; - - /*global Query: true */ - /*jslint regexp: false, plusplus: false */ - - var strictMode = false, - - // parseUri(str) parses the supplied uri and returns an object containing its components - parseUri = function (str) { - - /*jslint unparam: true */ - var parsers = { - strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, - loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ - }, - keys = ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"], - q = { - name: "queryKey", - parser: /(?:^|&)([^&=]*)=?([^&]*)/g - }, - m = parsers[strictMode ? "strict" : "loose"].exec(str), - uri = {}, - i = 14; - - while (i--) { - uri[keys[i]] = m[i] || ""; - } - - uri[q.name] = {}; - uri[keys[12]].replace(q.parser, function ($0, $1, $2) { - if ($1) { - uri[q.name][$1] = $2; - } - }); - - return uri; - }, - - uriParts = parseUri(uriString || ''), - - queryObj = new Query(uriParts.query), - - - /* - Basic get/set functions for all properties - */ - - protocol = function (val) { - if (typeof val !== 'undefined') { - uriParts.protocol = val; - } - return uriParts.protocol; - }, - - hasAuthorityPrefixUserPref = null, - - // hasAuthorityPrefix: if there is no protocol, the leading // can be enabled or disabled - hasAuthorityPrefix = function (val) { - - if (typeof val !== 'undefined') { - hasAuthorityPrefixUserPref = val; - } - - if (hasAuthorityPrefixUserPref === null) { - return (uriParts.source.indexOf('//') !== -1); - } else { - return hasAuthorityPrefixUserPref; - } - }, - - userInfo = function (val) { - if (typeof val !== 'undefined') { - uriParts.userInfo = val; - } - return uriParts.userInfo; - }, - - host = function (val) { - if (typeof val !== 'undefined') { - uriParts.host = val; - } - return uriParts.host; - }, - - port = function (val) { - if (typeof val !== 'undefined') { - uriParts.port = val; - } - return uriParts.port; - }, - - path = function (val) { - if (typeof val !== 'undefined') { - uriParts.path = val; - } - return uriParts.path; - }, - - query = function (val) { - if (typeof val !== 'undefined') { - queryObj = new Query(val); - } - return queryObj; - }, - - anchor = function (val) { - if (typeof val !== 'undefined') { - uriParts.anchor = val; - } - return uriParts.anchor; - }, - - - /* - Fluent setters for Uri uri properties - */ - - setProtocol = function (val) { - protocol(val); - return this; - }, - - setHasAuthorityPrefix = function (val) { - hasAuthorityPrefix(val); - return this; - }, - - setUserInfo = function (val) { - userInfo(val); - return this; - }, - - setHost = function (val) { - host(val); - return this; - }, - - setPort = function (val) { - port(val); - return this; - }, - - setPath = function (val) { - path(val); - return this; - }, - - setQuery = function (val) { - query(val); - return this; - }, - - setAnchor = function (val) { - anchor(val); - return this; - }, - - /* - Query method wrappers - */ - getQueryParamValue = function (key) { - return query().getParamValue(key); - }, - - getQueryParamValues = function (key) { - return query().getParamValues(key); - }, - - deleteQueryParam = function (key, val) { - if (arguments.length === 2) { - query().deleteParam(key, val); - } else { - query().deleteParam(key); - } - - return this; - }, - - addQueryParam = function (key, val, index) { - if (arguments.length === 3) { - query().addParam(key, val, index); - } else { - query().addParam(key, val); - } - return this; - }, - - replaceQueryParam = function (key, newVal, oldVal) { - if (arguments.length === 3) { - query().replaceParam(key, newVal, oldVal); - } else { - query().replaceParam(key, newVal); - } - - return this; - }, - - /* - Serialization - */ - - // toString() stringifies the current state of the uri - toString = function () { - - var s = '', - is = function (s) { - return (s !== null && s !== ''); - }; - - if (is(protocol())) { - s += protocol(); - if (protocol().indexOf(':') !== protocol().length - 1) { - s += ':'; - } - s += '//'; - } else { - if (hasAuthorityPrefix() && is(host())) { - s += '//'; - } - } - - if (is(userInfo()) && is(host())) { - s += userInfo(); - if (userInfo().indexOf('@') !== userInfo().length - 1) { - s += '@'; - } - } - - if (is(host())) { - s += host(); - if (is(port())) { - s += ':' + port(); - } - } - - if (is(path())) { - s += path(); - } else { - if (is(host()) && (is(query().toString()) || is(anchor()))) { - s += '/'; - } - } - if (is(query().toString())) { - if (query().toString().indexOf('?') !== 0) { - s += '?'; - } - s += query().toString(); - } - - if (is(anchor())) { - if (anchor().indexOf('#') !== 0) { - s += '#'; - } - s += anchor(); - } - - return s; - }, - - /* - Cloning - */ - - // clone() returns a new, identical Uri instance - clone = function () { - return new Uri(toString()); - }; - - // public api - return { - - protocol: protocol, - hasAuthorityPrefix: hasAuthorityPrefix, - userInfo: userInfo, - host: host, - port: port, - path: path, - query: query, - anchor: anchor, - - setProtocol: setProtocol, - setHasAuthorityPrefix: setHasAuthorityPrefix, - setUserInfo: setUserInfo, - setHost: setHost, - setPort: setPort, - setPath: setPath, - setQuery: setQuery, - setAnchor: setAnchor, - - getQueryParamValue: getQueryParamValue, - getQueryParamValues: getQueryParamValues, - deleteQueryParam: deleteQueryParam, - addQueryParam: addQueryParam, - replaceQueryParam: replaceQueryParam, - - toString: toString, - clone: clone - }; -}; - -/* add compatibility for users of jsUri <= 1.1.1 */ -var jsUri = Uri; - -(function(exports) { +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o with this image. - img.src = imageInfo.src; - // If there's no set size, then we scale the image if necessary - // (e.g. x != 1) - if (!(img.width || img.height || img.style.height || img.style.width)) { - img.style.webkitTransform = 'scale(' + (1/imageInfo.x) + ')'; - img.style.webkitTransformOrigin = '0 0'; - } - } - } - } +d.gs = function (dscr, get, set/*, options*/) { + var c, e, options, desc; + if (typeof dscr !== 'string') { + options = set; + set = get; + get = dscr; + dscr = null; + } else { + options = arguments[3]; + } + if (get == null) { + get = undefined; + } else if (!isCallable(get)) { + options = get; + get = set = undefined; + } else if (set == null) { + set = undefined; + } else if (!isCallable(set)) { + options = set; + set = undefined; + } + if (dscr == null) { + c = true; + e = false; + } else { + c = contains.call(dscr, 'c'); + e = contains.call(dscr, 'e'); + } + + desc = { get: get, set: set, configurable: c, enumerable: e }; + return !options ? desc : assign(normalizeOpts(options), desc); +}; - // Small cross browser document ready. - var readyTimer = setInterval(function () { - if (document.readyState === "complete") { - main(); - clearInterval(readyTimer); - } - }, 10); +},{"es5-ext/object/assign":11,"es5-ext/object/is-callable":17,"es5-ext/object/normalize-options":23,"es5-ext/string/#/contains":30}],9:[function(require,module,exports){ +// Inspired by Google Closure: +// http://closure-library.googlecode.com/svn/docs/ +// closure_goog_array_array.js.html#goog.array.clear + +'use strict'; + +var value = require('../../object/valid-value'); + +module.exports = function () { + value(this).length = 0; + return this; +}; + +},{"../../object/valid-value":29}],10:[function(require,module,exports){ +// Internal method, used by iteration functions. +// Calls a function for each key-value pair found in object +// Optionally takes compareFn to iterate object in specific order + +'use strict'; + +var isCallable = require('./is-callable') + , callable = require('./valid-callable') + , value = require('./valid-value') + + , call = Function.prototype.call, keys = Object.keys + , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; + +module.exports = function (method, defVal) { + return function (obj, cb/*, thisArg, compareFn*/) { + var list, thisArg = arguments[2], compareFn = arguments[3]; + obj = Object(value(obj)); + callable(cb); + + list = keys(obj); + if (compareFn) { + list.sort(isCallable(compareFn) ? compareFn.bind(obj) : undefined); + } + return list[method](function (key, index) { + if (!propertyIsEnumerable.call(obj, key)) return defVal; + return call.call(cb, thisArg, obj[key], key, obj, index); + }); + }; +}; + +},{"./is-callable":17,"./valid-callable":27,"./valid-value":29}],11:[function(require,module,exports){ +'use strict'; + +module.exports = require('./is-implemented')() + ? Object.assign + : require('./shim'); + +},{"./is-implemented":12,"./shim":13}],12:[function(require,module,exports){ +'use strict'; + +module.exports = function () { + var assign = Object.assign, obj; + if (typeof assign !== 'function') return false; + obj = { foo: 'raz' }; + assign(obj, { bar: 'dwa' }, { trzy: 'trzy' }); + return (obj.foo + obj.bar + obj.trzy) === 'razdwatrzy'; +}; + +},{}],13:[function(require,module,exports){ +'use strict'; + +var keys = require('../keys') + , value = require('../valid-value') + + , max = Math.max; + +module.exports = function (dest, src/*, …srcn*/) { + var error, i, l = max(arguments.length, 2), assign; + dest = Object(value(dest)); + assign = function (key) { + try { dest[key] = src[key]; } catch (e) { + if (!error) error = e; + } + }; + for (i = 1; i < l; ++i) { + src = arguments[i]; + keys(src).forEach(assign); + } + if (error !== undefined) throw error; + return dest; +}; + +},{"../keys":19,"../valid-value":29}],14:[function(require,module,exports){ +'use strict'; + +var assign = require('./assign') + , value = require('./valid-value'); + +module.exports = function (obj) { + var copy = Object(value(obj)); + if (copy !== obj) return copy; + return assign({}, obj); +}; + +},{"./assign":11,"./valid-value":29}],15:[function(require,module,exports){ +// Workaround for http://code.google.com/p/v8/issues/detail?id=2804 + +'use strict'; + +var create = Object.create, shim; + +if (!require('./set-prototype-of/is-implemented')()) { + shim = require('./set-prototype-of/shim'); +} + +module.exports = (function () { + var nullObject, props, desc; + if (!shim) return create; + if (shim.level !== 1) return create; + + nullObject = {}; + props = {}; + desc = { configurable: false, enumerable: false, writable: true, + value: undefined }; + Object.getOwnPropertyNames(Object.prototype).forEach(function (name) { + if (name === '__proto__') { + props[name] = { configurable: true, enumerable: false, writable: true, + value: undefined }; + return; + } + props[name] = desc; + }); + Object.defineProperties(nullObject, props); + + Object.defineProperty(shim, 'nullPolyfill', { configurable: false, + enumerable: false, writable: false, value: nullObject }); + + return function (prototype, props) { + return create((prototype === null) ? nullObject : prototype, props); + }; +}()); + +},{"./set-prototype-of/is-implemented":25,"./set-prototype-of/shim":26}],16:[function(require,module,exports){ +'use strict'; + +module.exports = require('./_iterate')('forEach'); + +},{"./_iterate":10}],17:[function(require,module,exports){ +// Deprecated + +'use strict'; + +module.exports = function (obj) { return typeof obj === 'function'; }; + +},{}],18:[function(require,module,exports){ +'use strict'; + +var map = { function: true, object: true }; + +module.exports = function (x) { + return ((x != null) && map[typeof x]) || false; +}; + +},{}],19:[function(require,module,exports){ +'use strict'; + +module.exports = require('./is-implemented')() + ? Object.keys + : require('./shim'); + +},{"./is-implemented":20,"./shim":21}],20:[function(require,module,exports){ +'use strict'; + +module.exports = function () { + try { + Object.keys('primitive'); + return true; + } catch (e) { return false; } +}; + +},{}],21:[function(require,module,exports){ +'use strict'; + +var keys = Object.keys; + +module.exports = function (object) { + return keys(object == null ? object : Object(object)); +}; + +},{}],22:[function(require,module,exports){ +'use strict'; + +var callable = require('./valid-callable') + , forEach = require('./for-each') + + , call = Function.prototype.call; + +module.exports = function (obj, cb/*, thisArg*/) { + var o = {}, thisArg = arguments[2]; + callable(cb); + forEach(obj, function (value, key, obj, index) { + o[key] = call.call(cb, thisArg, value, key, obj, index); + }); + return o; +}; + +},{"./for-each":16,"./valid-callable":27}],23:[function(require,module,exports){ +'use strict'; + +var forEach = Array.prototype.forEach, create = Object.create; + +var process = function (src, obj) { + var key; + for (key in src) obj[key] = src[key]; +}; + +module.exports = function (options/*, …options*/) { + var result = create(null); + forEach.call(arguments, function (options) { + if (options == null) return; + process(Object(options), result); + }); + return result; +}; + +},{}],24:[function(require,module,exports){ +'use strict'; + +module.exports = require('./is-implemented')() + ? Object.setPrototypeOf + : require('./shim'); + +},{"./is-implemented":25,"./shim":26}],25:[function(require,module,exports){ +'use strict'; + +var create = Object.create, getPrototypeOf = Object.getPrototypeOf + , x = {}; + +module.exports = function (/*customCreate*/) { + var setPrototypeOf = Object.setPrototypeOf + , customCreate = arguments[0] || create; + if (typeof setPrototypeOf !== 'function') return false; + return getPrototypeOf(setPrototypeOf(customCreate(null), x)) === x; +}; + +},{}],26:[function(require,module,exports){ +// Big thanks to @WebReflection for sorting this out +// https://gist.github.com/WebReflection/5593554 + +'use strict'; + +var isObject = require('../is-object') + , value = require('../valid-value') + + , isPrototypeOf = Object.prototype.isPrototypeOf + , defineProperty = Object.defineProperty + , nullDesc = { configurable: true, enumerable: false, writable: true, + value: undefined } + , validate; + +validate = function (obj, prototype) { + value(obj); + if ((prototype === null) || isObject(prototype)) return obj; + throw new TypeError('Prototype must be null or an object'); +}; + +module.exports = (function (status) { + var fn, set; + if (!status) return null; + if (status.level === 2) { + if (status.set) { + set = status.set; + fn = function (obj, prototype) { + set.call(validate(obj, prototype), prototype); + return obj; + }; + } else { + fn = function (obj, prototype) { + validate(obj, prototype).__proto__ = prototype; + return obj; + }; + } + } else { + fn = function self(obj, prototype) { + var isNullBase; + validate(obj, prototype); + isNullBase = isPrototypeOf.call(self.nullPolyfill, obj); + if (isNullBase) delete self.nullPolyfill.__proto__; + if (prototype === null) prototype = self.nullPolyfill; + obj.__proto__ = prototype; + if (isNullBase) defineProperty(self.nullPolyfill, '__proto__', nullDesc); + return obj; + }; + } + return Object.defineProperty(fn, 'level', { configurable: false, + enumerable: false, writable: false, value: status.level }); +}((function () { + var x = Object.create(null), y = {}, set + , desc = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__'); + + if (desc) { + try { + set = desc.set; // Opera crashes at this point + set.call(x, y); + } catch (ignore) { } + if (Object.getPrototypeOf(x) === y) return { set: set, level: 2 }; + } + + x.__proto__ = y; + if (Object.getPrototypeOf(x) === y) return { level: 2 }; + + x = {}; + x.__proto__ = y; + if (Object.getPrototypeOf(x) === y) return { level: 1 }; + + return false; +}()))); + +require('../create'); + +},{"../create":15,"../is-object":18,"../valid-value":29}],27:[function(require,module,exports){ +'use strict'; + +module.exports = function (fn) { + if (typeof fn !== 'function') throw new TypeError(fn + " is not a function"); + return fn; +}; + +},{}],28:[function(require,module,exports){ +'use strict'; + +var isObject = require('./is-object'); + +module.exports = function (value) { + if (!isObject(value)) throw new TypeError(value + " is not an Object"); + return value; +}; + +},{"./is-object":18}],29:[function(require,module,exports){ +'use strict'; + +module.exports = function (value) { + if (value == null) throw new TypeError("Cannot use null or undefined"); + return value; +}; + +},{}],30:[function(require,module,exports){ +'use strict'; + +module.exports = require('./is-implemented')() + ? String.prototype.contains + : require('./shim'); + +},{"./is-implemented":31,"./shim":32}],31:[function(require,module,exports){ +'use strict'; + +var str = 'razdwatrzy'; + +module.exports = function () { + if (typeof str.contains !== 'function') return false; + return ((str.contains('dwa') === true) && (str.contains('foo') === false)); +}; + +},{}],32:[function(require,module,exports){ +'use strict'; + +var indexOf = String.prototype.indexOf; + +module.exports = function (searchString/*, position*/) { + return indexOf.call(this, searchString, arguments[1]) > -1; +}; + +},{}],33:[function(require,module,exports){ +'use strict'; + +var toString = Object.prototype.toString + + , id = toString.call(''); + +module.exports = function (x) { + return (typeof x === 'string') || (x && (typeof x === 'object') && + ((x instanceof String) || (toString.call(x) === id))) || false; +}; + +},{}],34:[function(require,module,exports){ +'use strict'; + +var generated = Object.create(null) + + , random = Math.random; + +module.exports = function () { + var str; + do { str = random().toString(36).slice(2); } while (generated[str]); + return str; +}; + +},{}],35:[function(require,module,exports){ +'use strict'; + +var setPrototypeOf = require('es5-ext/object/set-prototype-of') + , contains = require('es5-ext/string/#/contains') + , d = require('d') + , Iterator = require('./') + + , defineProperty = Object.defineProperty + , ArrayIterator; + +ArrayIterator = module.exports = function (arr, kind) { + if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind); + Iterator.call(this, arr); + if (!kind) kind = 'value'; + else if (contains.call(kind, 'key+value')) kind = 'key+value'; + else if (contains.call(kind, 'key')) kind = 'key'; + else kind = 'value'; + defineProperty(this, '__kind__', d('', kind)); +}; +if (setPrototypeOf) setPrototypeOf(ArrayIterator, Iterator); + +ArrayIterator.prototype = Object.create(Iterator.prototype, { + constructor: d(ArrayIterator), + _resolve: d(function (i) { + if (this.__kind__ === 'value') return this.__list__[i]; + if (this.__kind__ === 'key+value') return [i, this.__list__[i]]; + return i; + }), + toString: d(function () { return '[object Array Iterator]'; }) +}); + +},{"./":38,"d":8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(require,module,exports){ +'use strict'; + +var callable = require('es5-ext/object/valid-callable') + , isString = require('es5-ext/string/is-string') + , get = require('./get') + + , isArray = Array.isArray, call = Function.prototype.call; + +module.exports = function (iterable, cb/*, thisArg*/) { + var mode, thisArg = arguments[2], result, doBreak, broken, i, l, char, code; + if (isArray(iterable)) mode = 'array'; + else if (isString(iterable)) mode = 'string'; + else iterable = get(iterable); + + callable(cb); + doBreak = function () { broken = true; }; + if (mode === 'array') { + iterable.some(function (value) { + call.call(cb, thisArg, value, doBreak); + if (broken) return true; + }); + return; + } + if (mode === 'string') { + l = iterable.length; + for (i = 0; i < l; ++i) { + char = iterable[i]; + if ((i + 1) < l) { + code = char.charCodeAt(0); + if ((code >= 0xD800) && (code <= 0xDBFF)) char += iterable[++i]; + } + call.call(cb, thisArg, char, doBreak); + if (broken) break; + } + return; + } + result = iterable.next(); + + while (!result.done) { + call.call(cb, thisArg, result.value, doBreak); + if (broken) return; + result = iterable.next(); + } +}; + +},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(require,module,exports){ +'use strict'; + +var isString = require('es5-ext/string/is-string') + , ArrayIterator = require('./array') + , StringIterator = require('./string') + , iterable = require('./valid-iterable') + , iteratorSymbol = require('es6-symbol').iterator; + +module.exports = function (obj) { + if (typeof iterable(obj)[iteratorSymbol] === 'function') return obj[iteratorSymbol](); + if (isString(obj)) return new StringIterator(obj); + return new ArrayIterator(obj); +}; + +},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(require,module,exports){ +'use strict'; + +var clear = require('es5-ext/array/#/clear') + , assign = require('es5-ext/object/assign') + , callable = require('es5-ext/object/valid-callable') + , value = require('es5-ext/object/valid-value') + , d = require('d') + , autoBind = require('d/auto-bind') + , Symbol = require('es6-symbol') + + , defineProperty = Object.defineProperty + , defineProperties = Object.defineProperties + , Iterator; + +module.exports = Iterator = function (list, context) { + if (!(this instanceof Iterator)) return new Iterator(list, context); + defineProperties(this, { + __list__: d('w', value(list)), + __context__: d('w', context), + __nextIndex__: d('w', 0) + }); + if (!context) return; + callable(context.on); + context.on('_add', this._onAdd); + context.on('_delete', this._onDelete); + context.on('_clear', this._onClear); +}; + +defineProperties(Iterator.prototype, assign({ + constructor: d(Iterator), + _next: d(function () { + var i; + if (!this.__list__) return; + if (this.__redo__) { + i = this.__redo__.shift(); + if (i !== undefined) return i; + } + if (this.__nextIndex__ < this.__list__.length) return this.__nextIndex__++; + this._unBind(); + }), + next: d(function () { return this._createResult(this._next()); }), + _createResult: d(function (i) { + if (i === undefined) return { done: true, value: undefined }; + return { done: false, value: this._resolve(i) }; + }), + _resolve: d(function (i) { return this.__list__[i]; }), + _unBind: d(function () { + this.__list__ = null; + delete this.__redo__; + if (!this.__context__) return; + this.__context__.off('_add', this._onAdd); + this.__context__.off('_delete', this._onDelete); + this.__context__.off('_clear', this._onClear); + this.__context__ = null; + }), + toString: d(function () { return '[object Iterator]'; }) +}, autoBind({ + _onAdd: d(function (index) { + if (index >= this.__nextIndex__) return; + ++this.__nextIndex__; + if (!this.__redo__) { + defineProperty(this, '__redo__', d('c', [index])); + return; + } + this.__redo__.forEach(function (redo, i) { + if (redo >= index) this.__redo__[i] = ++redo; + }, this); + this.__redo__.push(index); + }), + _onDelete: d(function (index) { + var i; + if (index >= this.__nextIndex__) return; + --this.__nextIndex__; + if (!this.__redo__) return; + i = this.__redo__.indexOf(index); + if (i !== -1) this.__redo__.splice(i, 1); + this.__redo__.forEach(function (redo, i) { + if (redo > index) this.__redo__[i] = --redo; + }, this); + }), + _onClear: d(function () { + if (this.__redo__) clear.call(this.__redo__); + this.__nextIndex__ = 0; + }) +}))); + +defineProperty(Iterator.prototype, Symbol.iterator, d(function () { + return this; +})); +defineProperty(Iterator.prototype, Symbol.toStringTag, d('', 'Iterator')); + +},{"d":8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(require,module,exports){ +'use strict'; + +var isString = require('es5-ext/string/is-string') + , iteratorSymbol = require('es6-symbol').iterator + + , isArray = Array.isArray; + +module.exports = function (value) { + if (value == null) return false; + if (isArray(value)) return true; + if (isString(value)) return true; + return (typeof value[iteratorSymbol] === 'function'); +}; + +},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(require,module,exports){ +// Thanks @mathiasbynens +// http://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols + +'use strict'; + +var setPrototypeOf = require('es5-ext/object/set-prototype-of') + , d = require('d') + , Iterator = require('./') + + , defineProperty = Object.defineProperty + , StringIterator; + +StringIterator = module.exports = function (str) { + if (!(this instanceof StringIterator)) return new StringIterator(str); + str = String(str); + Iterator.call(this, str); + defineProperty(this, '__length__', d('', str.length)); + +}; +if (setPrototypeOf) setPrototypeOf(StringIterator, Iterator); + +StringIterator.prototype = Object.create(Iterator.prototype, { + constructor: d(StringIterator), + _next: d(function () { + if (!this.__list__) return; + if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++; + this._unBind(); + }), + _resolve: d(function (i) { + var char = this.__list__[i], code; + if (this.__nextIndex__ === this.__length__) return char; + code = char.charCodeAt(0); + if ((code >= 0xD800) && (code <= 0xDBFF)) return char + this.__list__[this.__nextIndex__++]; + return char; + }), + toString: d(function () { return '[object String Iterator]'; }) +}); + +},{"./":38,"d":8,"es5-ext/object/set-prototype-of":24}],41:[function(require,module,exports){ +'use strict'; + +var isIterable = require('./is-iterable'); + +module.exports = function (value) { + if (!isIterable(value)) throw new TypeError(value + " is not iterable"); + return value; +}; + +},{"./is-iterable":39}],42:[function(require,module,exports){ +'use strict'; + +module.exports = require('./is-implemented')() ? Symbol : require('./polyfill'); + +},{"./is-implemented":43,"./polyfill":45}],43:[function(require,module,exports){ +'use strict'; + +module.exports = function () { + var symbol; + if (typeof Symbol !== 'function') return false; + symbol = Symbol('test symbol'); + try { String(symbol); } catch (e) { return false; } + if (typeof Symbol.iterator === 'symbol') return true; + + // Return 'true' for polyfills + if (typeof Symbol.isConcatSpreadable !== 'object') return false; + if (typeof Symbol.iterator !== 'object') return false; + if (typeof Symbol.toPrimitive !== 'object') return false; + if (typeof Symbol.toStringTag !== 'object') return false; + if (typeof Symbol.unscopables !== 'object') return false; + + return true; +}; + +},{}],44:[function(require,module,exports){ +'use strict'; + +module.exports = function (x) { + return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false; +}; + +},{}],45:[function(require,module,exports){ +'use strict'; + +var d = require('d') + , validateSymbol = require('./validate-symbol') + + , create = Object.create, defineProperties = Object.defineProperties + , defineProperty = Object.defineProperty, objPrototype = Object.prototype + , Symbol, HiddenSymbol, globalSymbols = create(null); + +var generateName = (function () { + var created = create(null); + return function (desc) { + var postfix = 0, name; + while (created[desc + (postfix || '')]) ++postfix; + desc += (postfix || ''); + created[desc] = true; + name = '@@' + desc; + defineProperty(objPrototype, name, d.gs(null, function (value) { + defineProperty(this, name, d(value)); + })); + return name; + }; +}()); + +HiddenSymbol = function Symbol(description) { + if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor'); + return Symbol(description); +}; +module.exports = Symbol = function Symbol(description) { + var symbol; + if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor'); + symbol = create(HiddenSymbol.prototype); + description = (description === undefined ? '' : String(description)); + return defineProperties(symbol, { + __description__: d('', description), + __name__: d('', generateName(description)) + }); +}; +defineProperties(Symbol, { + for: d(function (key) { + if (globalSymbols[key]) return globalSymbols[key]; + return (globalSymbols[key] = Symbol(String(key))); + }), + keyFor: d(function (s) { + var key; + validateSymbol(s); + for (key in globalSymbols) if (globalSymbols[key] === s) return key; + }), + hasInstance: d('', Symbol('hasInstance')), + isConcatSpreadable: d('', Symbol('isConcatSpreadable')), + iterator: d('', Symbol('iterator')), + match: d('', Symbol('match')), + replace: d('', Symbol('replace')), + search: d('', Symbol('search')), + species: d('', Symbol('species')), + split: d('', Symbol('split')), + toPrimitive: d('', Symbol('toPrimitive')), + toStringTag: d('', Symbol('toStringTag')), + unscopables: d('', Symbol('unscopables')) +}); +defineProperties(HiddenSymbol.prototype, { + constructor: d(Symbol), + toString: d('', function () { return this.__name__; }) +}); + +defineProperties(Symbol.prototype, { + toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }), + valueOf: d(function () { return validateSymbol(this); }) +}); +defineProperty(Symbol.prototype, Symbol.toPrimitive, d('', + function () { return validateSymbol(this); })); +defineProperty(Symbol.prototype, Symbol.toStringTag, d('c', 'Symbol')); + +defineProperty(HiddenSymbol.prototype, Symbol.toPrimitive, + d('c', Symbol.prototype[Symbol.toPrimitive])); +defineProperty(HiddenSymbol.prototype, Symbol.toStringTag, + d('c', Symbol.prototype[Symbol.toStringTag])); + +},{"./validate-symbol":46,"d":8}],46:[function(require,module,exports){ +'use strict'; + +var isSymbol = require('./is-symbol'); + +module.exports = function (value) { + if (!isSymbol(value)) throw new TypeError(value + " is not a symbol"); + return value; +}; + +},{"./is-symbol":44}],47:[function(require,module,exports){ +'use strict'; + +var setPrototypeOf = require('es5-ext/object/set-prototype-of') + , object = require('es5-ext/object/valid-object') + , value = require('es5-ext/object/valid-value') + , randomUniq = require('es5-ext/string/random-uniq') + , d = require('d') + , getIterator = require('es6-iterator/get') + , forOf = require('es6-iterator/for-of') + , toStringTagSymbol = require('es6-symbol').toStringTag + , isNative = require('./is-native-implemented') + + , isArray = Array.isArray, defineProperty = Object.defineProperty + , hasOwnProperty = Object.prototype.hasOwnProperty, getPrototypeOf = Object.getPrototypeOf + , WeakMapPoly; + +module.exports = WeakMapPoly = function (/*iterable*/) { + var iterable = arguments[0], self; + if (!(this instanceof WeakMapPoly)) throw new TypeError('Constructor requires \'new\''); + if (isNative && setPrototypeOf && (WeakMap !== WeakMapPoly)) { + self = setPrototypeOf(new WeakMap(), getPrototypeOf(this)); + } else { + self = this; + } + if (iterable != null) { + if (!isArray(iterable)) iterable = getIterator(iterable); + } + defineProperty(self, '__weakMapData__', d('c', '$weakMap$' + randomUniq())); + if (!iterable) return self; + forOf(iterable, function (val) { + value(val); + self.set(val[0], val[1]); + }); + return self; +}; -})(window); +if (isNative) { + if (setPrototypeOf) setPrototypeOf(WeakMapPoly, WeakMap); + WeakMapPoly.prototype = Object.create(WeakMap.prototype, { + constructor: d(WeakMapPoly) + }); +} + +Object.defineProperties(WeakMapPoly.prototype, { + delete: d(function (key) { + if (hasOwnProperty.call(object(key), this.__weakMapData__)) { + delete key[this.__weakMapData__]; + return true; + } + return false; + }), + get: d(function (key) { + if (hasOwnProperty.call(object(key), this.__weakMapData__)) { + return key[this.__weakMapData__]; + } + }), + has: d(function (key) { + return hasOwnProperty.call(object(key), this.__weakMapData__); + }), + set: d(function (key, value) { + defineProperty(object(key), this.__weakMapData__, d('c', value)); + return this; + }), + toString: d(function () { return '[object WeakMap]'; }) +}); +defineProperty(WeakMapPoly.prototype, toStringTagSymbol, d('c', 'WeakMap')); + +},{"./is-native-implemented":6,"d":8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); diff --git a/build/srcset.min.js b/build/srcset.min.js index 010fe61..2dd6f1c 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -var Query=function(t){"use strict";var e=function(t){var e,r,n,i,s=[];if(t===void 0||null===t||""===t)return s;for(0===t.indexOf("?")&&(t=t.substring(1)),r=(""+t).split(/[&;]/),e=0;r.length>e;e++)n=r[e],i=n.split("="),s.push([i[0],i[1]]);return s},r=e(t),n=function(){var t,e,n="";for(t=0;r.length>t;t++)e=r[t],n.length>0&&(n+="&"),n+=e.join("=");return n.length>0?"?"+n:n},i=function(t){return t=decodeURIComponent(t),t=t.replace("+"," ")},s=function(t){var e,n;for(n=0;r.length>n;n++)if(e=r[n],i(t)===i(e[0]))return e[1]},o=function(t){var e,n,s=[];for(e=0;r.length>e;e++)n=r[e],i(t)===i(n[0])&&s.push(n[1]);return s},a=function(t,e){var n,s,o,a,u=[];for(n=0;r.length>n;n++)s=r[n],o=i(s[0])===i(t),a=i(s[1])===i(e),(1===arguments.length&&!o||2===arguments.length&&!o&&!a)&&u.push(s);return r=u,this},u=function(t,e,n){return 3===arguments.length&&-1!==n?(n=Math.min(n,r.length),r.splice(n,0,[t,e])):arguments.length>0&&r.push([t,e]),this},h=function(t,e,n){var s,o,h=-1;if(3===arguments.length){for(s=0;r.length>s;s++)if(o=r[s],i(o[0])===i(t)&&decodeURIComponent(o[1])===i(n)){h=s;break}a(t,n).addParam(t,e,h)}else{for(s=0;r.length>s;s++)if(o=r[s],i(o[0])===i(t)){h=s;break}a(t),u(t,e,h)}return this};return{getParamValue:s,getParamValues:o,deleteParam:a,addParam:u,replaceParam:h,toString:n}},Uri=function(t){"use strict";var e=!1,r=function(t){for(var r={strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/},n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],i={name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},s=r[e?"strict":"loose"].exec(t),o={},a=14;a--;)o[n[a]]=s[a]||"";return o[i.name]={},o[n[12]].replace(i.parser,function(t,e,r){e&&(o[i.name][e]=r)}),o},n=r(t||""),i=new Query(n.query),s=function(t){return t!==void 0&&(n.protocol=t),n.protocol},o=null,a=function(t){return t!==void 0&&(o=t),null===o?-1!==n.source.indexOf("//"):o},u=function(t){return t!==void 0&&(n.userInfo=t),n.userInfo},h=function(t){return t!==void 0&&(n.host=t),n.host},c=function(t){return t!==void 0&&(n.port=t),n.port},f=function(t){return t!==void 0&&(n.path=t),n.path},l=function(t){return t!==void 0&&(i=new Query(t)),i},d=function(t){return t!==void 0&&(n.anchor=t),n.anchor},g=function(t){return s(t),this},p=function(t){return a(t),this},m=function(t){return u(t),this},v=function(t){return h(t),this},w=function(t){return c(t),this},x=function(t){return f(t),this},y=function(t){return l(t),this},I=function(t){return d(t),this},C=function(t){return l().getParamValue(t)},P=function(t){return l().getParamValues(t)},_=function(t,e){return 2===arguments.length?l().deleteParam(t,e):l().deleteParam(t),this},V=function(t,e,r){return 3===arguments.length?l().addParam(t,e,r):l().addParam(t,e),this},B=function(t,e,r){return 3===arguments.length?l().replaceParam(t,e,r):l().replaceParam(t,e),this},O=function(){var t="",e=function(t){return null!==t&&""!==t};return e(s())?(t+=s(),s().indexOf(":")!==s().length-1&&(t+=":"),t+="//"):a()&&e(h())&&(t+="//"),e(u())&&e(h())&&(t+=u(),u().indexOf("@")!==u().length-1&&(t+="@")),e(h())&&(t+=h(),e(c())&&(t+=":"+c())),e(f())?t+=f():e(h())&&(e(""+l())||e(d()))&&(t+="/"),e(""+l())&&(0!==(""+l()).indexOf("?")&&(t+="?"),t+=""+l()),e(d())&&(0!==d().indexOf("#")&&(t+="#"),t+=d()),t},Q=function(){return new Uri(O())};return{protocol:s,hasAuthorityPrefix:a,userInfo:u,host:h,port:c,path:f,query:l,anchor:d,setProtocol:g,setHasAuthorityPrefix:p,setUserInfo:m,setHost:v,setPort:w,setPath:x,setQuery:y,setAnchor:I,getQueryParamValue:C,getQueryParamValues:P,deleteQueryParam:_,addQueryParam:V,replaceQueryParam:B,toString:O,clone:Q}},jsUri=Uri;(function(t){function e(t){this.imageCandidates=[],this.srcValue=t.src,this.srcsetValue=t.srcset,this.isValid=!0,this.error="",this._parse(this.srcsetValue),this.isValid||console.error("Error: "+this.error)}function r(t){this.src=t.src,this.w=t.w||1/0,this.h=t.h||1/0,this.x=t.x||1}var n=/^[0-9]+$/;e.prototype._parse=function(){for(var t,e,n=this.srcsetValue,i=0,s=[];""!==n;){for(;" "===n.charAt(0);)n=n.slice(1);if(i=n.indexOf(" "),-1!==i){if(t=n.slice(0,i),""===t)break;n=n.slice(i+1),i=n.indexOf(","),-1===i?(e=n,n=""):(e=n.slice(0,i),n=n.slice(i+1)),s.push({url:t,descriptors:e})}else s.push({url:n,descriptors:""}),n=""}for(var o=0,a=s.length;a>o;o++){var u=s[o],h=this._parseDescriptors(u.descriptors);this._addCandidate(new r({src:u.url,x:h.x,w:h.w,h:h.h}))}this.srcValue&&this._addCandidate(new r({src:this.srcValue}))},e.prototype._addCandidate=function(t){for(var e=0;this.imageCandidates.length>e;e++){var r=this.imageCandidates[e];if(r.x==t.x&&r.w==t.w&&r.h==t.h)return}this.imageCandidates.push(t)},e.prototype._parseDescriptors=function(t){for(var e=t.split(/\s/),r={},i=0;e.length>i;i++){var s=e[i];if(s.length>0){var o=s[s.length-1],a=s.substring(0,s.length-1),u=parseInt(a,10),h=parseFloat(a);a.match(n)&&"w"===o?r[o]=u:a.match(n)&&"h"==o?r[o]=u:isNaN(h)||"x"!=o?(this.error='Invalid srcset descriptor found in "'+s+'".',this.isValid=!1):r[o]=h}}return r},t.SrcsetInfo=e})(window),function(t){function e(){this.w=null,this.h=null,this.x=null}e.prototype.compute=function(){this.w=window.innerWidth||document.documentElement.clientWidth,this.h=window.innerHeight||document.documentElement.clientHeight,this.x=window.devicePixelRatio},e.prototype.setForTesting=function(t){this.w=t.w,this.h=t.h,this.x=t.x},e.prototype.getBestImage=function(t){var e=t.imageCandidates.slice(0),r=this._getBestCandidateIf(e,function(t,e){return t.w>e.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xs.w}),this._getBestCandidateIf(e,function(t,e){return t.hs.h});var o=this._getBestCandidateIf(e,function(t,e){return t.xo.x}),e[0]},e.prototype._getBestCandidateIf=function(t,e){for(var r=t[0],n=0;t.length>n;n++){var i=t[n];e(i,r)&&(r=i)}return r},e.prototype._removeCandidatesIf=function(t,e){for(var r=t.length-1;r>=0;r--){var n=t[r];e(n)&&t.splice(r,1)}return t},e.prototype.getBestImage2=function(t){for(var e=null,r=t.imageCandidates,n=0;r.length>n;n++){var i=r[n],s=e?e.x:0;if(i.x>=s&&i.x<=this.x){if(null===e){e=i;continue}this.w<=i.w&&i.w<=e.w&&(e=i)}}return e},t.ViewportInfo=e}(window),function(){function t(){var t=new Image;return"srcset"in t}function e(){if(!t()){var e=new ViewportInfo;e.compute();for(var r=document.querySelectorAll("img"),n=0;r.length>n;n++){var i=r[n],s=i.getAttribute("srcset");if(s){var o=new SrcsetInfo({src:i.src,srcset:s}),a=e.getBestImage(o);i.src=a.src,i.width||i.height||i.style.height||i.style.width||(i.style.webkitTransform="scale("+1/a.x+")",i.style.webkitTransformOrigin="0 0")}}}}var r=setInterval(function(){"complete"===document.readyState&&(e(),clearInterval(r))},10)}(window); \ No newline at end of file +(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info.js");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}c.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,d,h;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){d=t[p];if(p+1<_){h=d.charCodeAt(0);if(h>=55296&&h<=56319)d+=t[++p]}a.call(e,u,d,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function d(t){var e;if(this instanceof d)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,d=Object.prototype.hasOwnProperty,h=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,h(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(d.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(d.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return d.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file diff --git a/demo/1024x768.png b/demo/1024x768.png new file mode 100644 index 0000000000000000000000000000000000000000..3cdf957c0271e904edf2f46443bafda882af48ca GIT binary patch literal 25644 zcmeHwc|6o@`}PQ zGaB2(U~FSDm@#I1zvF(M-?Mz)|KIoX`}k`X<9l7#c^&6*9_Mj=hlK0qM!SU%3xhzQ z-6qDDZh}Apz*ByZ;CA4lzFvGc2qb*b%h2$;iJ_s?^}qmkFJCth$ar^NM(FKZ_yh5n zM)k)2eJ7-3R}Y5^N&V0=78kgYU=nj3{3K2;#00T1`KB?#bD62l9p9l$;=bEAyol&L}i=zRHxF%0Fz= zcj)tZcw)o#@od?Nw}}GzcCTcAdAyC>;nsNDBpWnM|8rnqJ=YX;W`CAr4@oZHH{smn z{fCwks9=!b%WoQ=1NS^*Xn4Xw4+=b{o(d$GI2Y_4dgV1e+u^>kTzQM(d{*J*SF?$~ z9++ZQt9B)yk%%b^$hgcWYvY&Y`J9YAN+#RjW;_{aJmGlsEw)ZaIMZTTZV>~&mrYRVKqyim>NZf-c<##aC%z6ZzD@3u-}!8D(Km<> z;iIH5tIk9`4Cq2X(V%B_FEK5(3MBMm|1c3(al1TSP*`y7QcusWJ((C+HeHlUY}WAV z?fiN=7tt)S{CL*l#_UU>xCGCJ$J(*hsY| zP9J(pi1Td$?@Qfr|F!V>Sfw-I(@wjO#;DxoAD05f#Tbk7XYeZ-gT3?xDlY2&1R!|! zCtt`T@4KME*zkS<^M`78x7!I=HSfN=b61R!zVMTlYiIbzW4#0){uUK~bMa&9fp;QV z1~}0pwt``X7q4H~&);g8kSh8@pV2S(;ozx9AM*{b>#Y89|8Tva{iBW7JNl*0Z)fvG z#qE6s9=NmnC#WU{|4HkppwXA^UzZ+;=kAbb9+|jWdq8&&>Wjq0k>8-xj~&0H3F>zU z@_)Z#EqG-4l0mAq4BuX9pXVpufr~C@r|x-oq%O($`MoL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96 zG53%Jb3AZVTfuoOV~7B_`1nU6x({$9o0b=6X~1TbM2z5lY&hsnMUanuB;9~fJ!^zyUv79a~lK<7R=?vW=*r93ZmyG`p}8QNbO%A zN1z9M{DQ`TqXtJ6ka6BzE*15Ixf~Nl0BmK1^5%I~Z8O-PueLd_*o&8`%CUBMN?p8e z+Ix5*r|?+V83LeYYy5A@t=XLL)7l-YU6{XSvip!2^8Ln0jaqy3Y<_$_0lq@cV+DjS z&dCIJH_MU7T&ajpPH8lA($wEZV+H`Ys*P?u4{$O9=UT#8%kA{=QX%mW8(Tuq8mvry z(Md~a^)wgbdclQ!9hyNS9pYz>pZh*et8IvLS{Qx~Y5X}ok-d;iR^8;2dA1OrOR!XundHY{ymRex^q*hCYaegPd~QR&#R0CMt)C5d*l3sp*H`P%Ac=&vg%@TCntvilX zM}m*cT@6@DsL4y#KW;Y^ZtY^5maveI(jGiVd>{!uz7a|uuFfl~(xZ0#5dkelKqNYX z6!t7jwMMM@)}gez->EZlS1qnfM*eR3 zn91T8Zwm*<0N=)SeAjt3hQMA5txPNwxEeO==+pfZ!whVVmUIa#cgP^OOJh(S1d9c+ zom7stiZtm(1Se{W@a6-8SLTB-0>z~shZ$A}q zij=m}6|}1$sOw{bq27giX+bs0ytoeT6a>xpTJVmTc`td80G>>P;e6N4OQrtpE#PM# zfWkePQ~Y1wh3x_eYI;hTr^NqtiP&&HKK;hJr~h-s%_pzzfTO*w%Wefhe+vmfrv0x7 z!V^v6QxND-Ht%l%Z1KYuNp6;mtxB;~F8>w-TS(YK!WI(#M;mXY!&W+MrNdS_Y_`My z=$E%RVT%*CIAMzuwm3m*%WvFrN4MP3{~gBQmKnHZ25y;w|2!1i68T#q|Nn`|=SU={ Y4)?}flw<+_1q5Vr+5A$efz!kP15cP=T>t<8 literal 0 HcmV?d00001 diff --git a/demo/1536x1152.png b/demo/1536x1152.png new file mode 100644 index 0000000000000000000000000000000000000000..38afb92e7bb2b380541e7a37da04aacc4dce18d6 GIT binary patch literal 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&!W$0eB%%W4%ts1^b9=K8+QU&V{CjG)M*Zo7nJsUE*9x;R)`kSdKa7*Z)&+(=D2&&jFsAaPFh20R4?! zNSd{0iwb?7wUiAdtkJr$gUwxgo#&HZ+|csy?wX)1G$}&)FKMmKeQbd;=i^s%nnzex z4Dx9y`SlnA_k8=CD*`!p>-ld2#bs{T$>D9*0VT_(wI6!Wz5!r|+Io}7XId^TmYmHT zcora<98hrxzkE<;V6_(?R{DHTKr8i)=v>WwoR`K)H1+Jq{8qQw)VTpayvMr0t$@>) zm$w^IV4kbMZZxu|wA{RuwFmW!m6|fZI%!n_r36LcODu-8B4X)X0?_I54@Y`$^?FSV7!q|Z8rlx zQ4tD=<}Kh<0m!(KxS!A>tkt>Ij|L5u5NS;-TMX<_qj}L~3m9ePUSwsuy0SAzR(=NV z+$>}r;iL*@1vx-eiDPxDx3Mvl1MmNAPZS3BY<<$-aqxeS{QVs`@VikEf1LW~^Z)rd zAK-A>_0w!R`|pdi0q0(Fe!=O^{`)ZZ(!YrtH{ibs3OCLEv+UMun_FDJ0VOV^{HA)i zkn)?La3O^YDL=IW7f884%5F`$^zj>{)dt!|7YE~Yt3D2_D+NU zN0E)2;oJ=8W;l1F$bZUOuFU_>cyRYE{01f0gTkec-vox+D*PrWTu9+U3fDR0I)_~6 zkV~3Bao|7kkV~3e(qs!!ZmaO0rNLDnzbOr_`uN`@`TILuApK3Ya3SS?v!#vul+*tP zg==X1rh2%L@|&P=A?1IohYKm(M-sS?BygWf{!e7!(#QWt^bx`0D;1j)`h@2B1Ooo( N>s~&af5z_4{{e&!L3scG literal 0 HcmV?d00001 diff --git a/demo/160x120.png b/demo/160x120.png new file mode 100644 index 0000000000000000000000000000000000000000..a96da38880209ec6758f03b4342883a2270dfa00 GIT binary patch literal 4270 zcmd^D`9Bj5{N83|j1KJ{B`) zNQ^MITr<9X|BUbJ`@{2o|MI+^=l#R;{^f}>GC-bT7hnef0B2CTS`Yv2kN@BUIsI?G z%02J|0NB-?H8qV;nw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}?xhZvka`_nQrn9rAE>l@byXDrjzQCVu_;cyyaimv(n^%kS*$ zRDi>+U!5EtHq_w)0IMnc7?s@}xAvJz#4QGrgd;;~9`Ge6+vsLrDn@4IQ4D$tf%>T*i9ia1<)l zG>K0w;7E6-C9o>Sm)_Rarg1sY{X_ob_&Dkxd1->_R$tjn?|687c|EkcE`qnu6mkU* z7Y^2r`~9+KzNa2zs&H9B0!$bTCcvJ+d-@>Dkn!e*+ON5}IbwZ%hWO`c#oF516|9%r zs?C+{$wl_iNLdBb>FO!Qt8jYf;0xWAKK|1#FY!4*~hfFrAkW>ayvIA$=8 zqe6-=7K#spv|~6)$*D7~FRPkRVH2)*NB#2GoIAc#T$I;8+0&e#=i&Yf4i1jon6QaE zR0HFB)Xms@e0|aPly00SvQt^o!hHKoFg)svdsrIZ1CjtqVTxRJ)B`LJXsde zLB-}b!3zSFn=ia;bYUMb`5;W3@5?g}NI-v;PWfHKt*kTT{Homa>+bnGi?sCa-9xTo zoEqsuTCG))>511HNx}a;^(0K#6e`03yZqOtn4w&``{EsT>&w>j#Eq~PV#tWf z{Li0O);lJLqY}(T-UdBHRGzVpNYLKyZZy)&CVV-B=Ts(E@xk(y=e~)*Hp~BoI;JzG z5LeN&?Q&-{VC}fxu#w)VhlukQQ45ehj?|=lRP7!%2yLjkQ{ko9InrFj>T!j&k;BF2nEG(t^5N zs;zsP;C!cLW6|{sL-%0EGM6#Bq9QK@5&g)br8mYV`Y}r=gX^CUP)vgU|IjXY#tKuvlD?*U@UMpe NptKFNDm83F{s*bfAb literal 0 HcmV?d00001 diff --git a/demo/2048x1536.png b/demo/2048x1536.png new file mode 100644 index 0000000000000000000000000000000000000000..b7be6324cf9407eb23de98cf1e03a5a85f9b1472 GIT binary patch literal 76726 zcmeFac{r4P8$Ld!Nv2hLDlMY2l)Xig43cc2WM@!F_OfOfgI1+%jh&&AeaM<^&}KKn z*coLRW-v0=8DqY;_jxnkN40YdgeXi@g&hxykn~)niYP+@{-VOqR zc4??z)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1AQ-4> literal 0 HcmV?d00001 diff --git a/demo/640x480.png b/demo/640x480.png new file mode 100644 index 0000000000000000000000000000000000000000..e0bd2346feed5977962c3d908111b67a134d5840 GIT binary patch literal 13618 zcmeHu`9IX(`}df}+el?e$X-IqTC!vf8B$advW$J-CPElvD%nYeWJ{7{-`6o@8D*L5 z%V02B#~NmsG2G+xd4C_@`wzH(x*vXFJIV=F#lz{ z-_i0w=l0xWtUL31(T%OCk2H)qer%y;WXyRTK2i_3zyAXC!_SN%Og`I;bB)+y$#J%; zjSS>rV>n~R&^+Vh1cL1900;L`YN@H;^g1d?Ytms34LC{keKFtRLqy_5MeR%f08ZW> zQcw*Qwen=7flg(@1d%jUV zGq&OW)JM^ooLEq{^dk)V153=hveC z0s-LnZOV;L&&2F0yJP|azdHYk21V)HePti{;5xV1=|tJAFy6D1yZXNM-b`fRUF>${ zsd!oLuoCa&+YF-So~bU0t3~{)tLDS=E_>)PykMv?O|3JCYO*P|g3Y`Yn`w^sSSgf2 zaREq|o}>v>G$ok;Dn0+voSP{$S{DZVWdu}CrEdwo_OO22HhW5(C1z#C!EoWpZlQ8uhWtS8ffYi2k|jj<@H&=6yBL>Fz#tCI#z2BeNY6nw4F9ezr=c zXEk$ghA)~tSbWd?D$1oHToq~dM%v-zE5y(Yf=5A|>3nF0JEzMtC;%R=e7{zosnc5x zpe=IZl9xsh5KgpUlRMej)aX)_SmK*-E$Co@BE(`D?KN}v)XMiStCecGMfTx0-vu#lG=edHFqC`@Y(?h#zk~*y<(a6Vq>D`G05(@K@{~fCILt zM*-DgW2GwmV91ZIX`R4x=}g?sxS2b(Te@^@pk!|~dhpXc}A;LU%#_qB0u-zTmp%3;S z9^d7jS8!sxj@)~ZYd2K()l9rl!=G7!JuObE?XgXQjYVln*@;ox6&3z7nCA1d{63+z zJeJqIZWM!RSVv+T!icS>XT&xG8?Q`puD@Vy@!hZsxzKbH!H*EcCkS<*#osVL0lB|m zy^t(?$>Y)^HeT=onD&bOhx`NNHzU7`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ye;4LwZ|5D9tDL_Z#<=Akw z3qBW0{h&3wvWL?zS-HYzJDLn`xk>m*Dcs+fedrSd?|otIUoo5Of6^Zj6s089;KzC6 z1;YR3Vz=ykdohAXQkk!0X`uNG9c04*fsYL1*lQ8UTvoix4JvcV%1!|%pdyU}Or ziZYr%rF7${iIOgA`la5+ZK}Q*LvWkvxmLEGmM1}Y@vbN9d(7&r{G!S7fD_b^7C=hF z8oZX1p;LmIS_682aFws**=a1Zr4ilYp!fpoj519w0KpIMPVea+fG75YE4pApjRoax z65YAe?C{+=8N^;6nUCP-w2!K!^MCtI`NjVFkjEP_;gBI!eJNw*Zr|#nY z(}hYe>ah~jW+Q>&FT$I5&iQ~gDDg#^8D-5!{NdSpO*ndVBh@)`tezIDc*GXlbHd7G zV7yAw;GaLB6SX(BJQqZpn08kxuwJ60^vrFgGbYc;P})60Rq>26k|-_=utv)b<+uy8 z**cqoyX((GSWEhs@H@0ddPCWJ_5R36!UAlN_-4Aij`obAqBZ7-QHWoZ%6N^Rw{NUo z3QTBz&O-0h)j~-Jyew^fne^WY1P5Dp52m-U8i?NtNmnuFdS#k+XWR3C!IwLherXTm z^Ll)(#p8jYG$Iu0h(Fsy;ey;3=@zKxDba2(G@1?pg)nV|bo|Ox;EZHlRhso(=*`$x z4{PDLB@xe)*-HL1yEtEirmYT5HU!8NKeD>H%BOfGUgWWn+RosVZCTfLWbiJEj?CQt zwmjT$2Lm(A2!nL+pzQb!>(t^A=JcB86Ef)izYzlNxFa8f+@^Uf& literal 0 HcmV?d00001 diff --git a/demo/768x576.png b/demo/768x576.png new file mode 100644 index 0000000000000000000000000000000000000000..9fad221446649e3f4ed4e120dc1863dae24b6569 GIT binary patch literal 17090 zcmeHvc{o&m*#68k6=@-5Ut30Huj~vJNm(i>OV%m7B-xpvWXUp>q!=WX#8|$Tv6F40 zG6{nQ6GMZsFEeJwnBVbTuj{>jf4u*{{&KD}=kq+D<$3P=ex7qK@t4hw_v{ke1pNV=W?>{7SbVV$bSL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q^xuh9GX!8xnhydb=y+CJ$3M{}C z9CB(?3j=+EJOhROG9`AKdzk#TORLSbGpkJ-D0Wt{a~Q$Ajk?8l@f1{~XGr5%m)hc> z53*jP3&owXK-KhVzhF%9b4QFoah6_hg8XLzw;s;NmRp zZH2?yi@D~U)PAkD)+6hHoKCRj4&haz$m3-#m1F5KJmAuzYIIem`wY8={f%Hh-$0gT z*H0-6;VbqQ*DZCP&!Ji)6m-#gUG!l~nw-JwqNc;X4b0!%=@)q?A<*RG3jo_IkAzS& zyX}Lg-leH)e{;S6D9<6Tme#5Wr?~W1fpDvF9bOn>>6hg>%Gm*+FPi1uxGMj-)KPU5 zHCIhF2SiHl7wV$G$fB9Sie7RjZtl+MUI{7-pKqQK6N^BXexPguUGhP;X=IZhz#9}6 zNgE8=xjzoXkIPMrUsDl9`%1fviT3YqMX@o#_($It6Ix1VH9aNK1A*(pWRXI)Z0R=D zS?^N<$gw-7ex<7m5_$C2E6bniY`;YX&G=Q8?XVR9L*4<&mJvHT91Hefals zo&a04wIN#@@=tVcMaWjlY+=Y2sBW>$7VZ8e61H^6mN45=s$0_i&jMW%~ k6xCZB@_%YWxH~BkP1;i7*R6p6O#w17GB+$b>-6CN0WrYvOaK4? literal 0 HcmV?d00001 diff --git a/demo/banner-HD.jpeg b/demo/banner-HD.jpeg deleted file mode 100644 index a3a3c8876fa921e9510124ebd83fcac474e3a54e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5456 zcmeHJdpwle-e2Q+#=Q}_6v^b)RA^9Sca;0JWX8Cc9b+&VGt3O4M76uAY!SP5wR0hBjEP1bT>n zAjJD1)(co54_<(0a)1^vjy;3T;4DFkut+-K~?{uUcT z^MqI#$^)5vN7}4BmL1@-9b)J!mKDlz#^PW$&2*kMtR>Kd_+bdc5nE%J4*~)iHntG! zLA)X)(qT3};>3$`!{nkku_4wj5W_eKcelTjE5xc0ALDYU*jzAYB#Xha$L50Zk=x;X z*V!D9=WLb>HW%cJ5*R!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G-$F+wi`btAG41x!GS~us1@e2=VYLK;`jThWlxo4-iQHw?U z=0w!Bv(T@z;Xy~qq~R(K@sPVh6Q!#+{bz^a14&kn0*`x&gs1LTE=K75S|iZ*JiYnx zI@^4X9^;Z*`As{E({aB#-kI_^tcd?Pk(6P_&d+U)i3rtZC0O-_HB2;*G?g*o@f95E zq3}X^WVv3V`=t7C((N2Un08f{PoGg{v!BVKmaPm4;Yq;^_i%+)PlsoJZ z^rs!)?JF9wI9arI+B){={i%D-p?i-<`i_J#vtG)%pfgX- zFU`7LU&JxU4VGOMR)_0Ki7(Q;=9Y4cB2ZVJb{IPB;?(r8v{)~zs??;-qKcqb^ez4FYH2UG4-B$>0Xdz>n+?-=>Pu%Ke9 z`A%~?wL6S`IJa+Iu4i05-R48Kd3;*P_RIbDQIjSrV!Ej>3uF&%+qUNE<3~CIwoR6C o+9`4T%KokjYWb`D7m9M7Ia!H;hZQLn_`mvJHTVzqfQGR5pRFm#J^%m! diff --git a/demo/banner-phone-HD.jpeg b/demo/banner-phone-HD.jpeg deleted file mode 100644 index 38f44c14a41b076d219c206b4271b00b00bbf6ac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6016 zcmeHJc{r3^8$Yw5NRchXh%yOTN>W)H`#K?|vW&r4W|$d!HCm`Bp{#AzOp-RD((cXD zD*M`|-l$MQ+2%VBg}S=>-tYVC`{R4&I_LS#y`B4apYxn^xJ}#_V4k_LnK3}2P{0)a z0QVJdshN?Hi!I5<*vyg$6#(#Z+yVmp(0Bm+X)FfG#1QYaX)~U;8KA)ezz-w=zZ;nu zU|?%&3E+d+BJZD{!3F>$0Z^;*d;QPWzx?C(pfJe*p!lGi?!hGcLmUbK&W{|xU;)6> z3FX=$tN@64r6Cq!zyu*yL$KE*UXNh+N$fOXV^1=IHb}05WN$YQh_^$m>^?*8H3LuP z04-n~6AF#Oppx-OEo>QdPpThfLNVF>8}$s!KS6)LAjo;*k%7Gc(|3afd=n7v-V9UH zcbq|X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$XbTmltPO)^z8J=2@cNN7Mmo!v8qqsU^bpWA?PXUOPxgL zxCI_l3f^#LDw_H5Qrh&uwSw$|%W}uE%-<^IQcI=OJx@p}r0@4{{}Acg9w+79Q0W!l zQhM=ri>r4*^sfAiEwbP2xgR6-S9i7Z_}0@d2afrwDbfZ^imm*6!zk+Z23fafP8;3t z+I;Y85=n#3o;#j+zsTHWr0>@h`u#(djf-;T(K_#XbIzU==sP~aOz>%L9-DKmANaX! zx`NbLrV&~G#@a_9=0(s}iL_rU3`Vo}?s@jR@qAX$0qddUvpBW6on7tI6y0wh4M&_* zdPZsMWCdpQc_~&L%p0y$9eZgVnrsx`L`^KDn9161Ow>-yY#*|+vhX=_ur#a6u+`%g zv0pa7#Gy}@7@)x}Oxo@9liM{L3ywzp+4U;hJZ(&s&vg2K{3v&jk+n|Ce7|FMT*hOn zZ*xh>)a0~hv_p*De(RFJ^L=NkxPURPx+%y@wLnR$IXEbt*%8@QKKjtKE8MYb?hntM z6IA_zv57q5gQ$RDcTcOp{pZt#4|AST?9T!Z>~VdM`PX@MGN)yO zyjzR6T6Nepx6bPsw{n4{{7|Go*H~b2rN8^#`S9zSvVRoo{@Ry#9oP8V(bi9Q3K-%I z)uxxT<@>lGG(vT;dd96s-_>VRS<>(J4~QkAfuAlp#S^5s;H|yur66Myy}6mFKLOvZ azx_i%V}F2>=yOwTv47M2Uyt(K-hTrak=K9# diff --git a/demo/banner.jpeg b/demo/banner.jpeg deleted file mode 100644 index 602ba892a8dfdde906889c217bd63ee4ee2e8881..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3936 zcmbVO3p`Y58-HicF^DFVt%N3`5+bXTVr5)LxkSpX>@;SWW(>{@h1uHOw%zLcY{^%$ zl`gijgtS>ox@?zGk-mzEc1x6s7?n%d+2;%f`|J1Z_kFM5dCz~I%m4j9&-{3iED%B(NR48E)BsW7@}f*rVSmbOgemP*aM~i6 zkse$j-|-Qyv?C;hJ2`+^nXkONaAF7%BY{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@@ -2,15 +2,21 @@ Srcset Polyfill Demo - + + + + +

+ The Breakfast Combo +
-
The Breakfast Combo
+ diff --git a/js/libs/jsuri-1.1.1.js b/js/libs/jsuri-1.1.1.js deleted file mode 100644 index 1212ec3..0000000 --- a/js/libs/jsuri-1.1.1.js +++ /dev/null @@ -1,478 +0,0 @@ -/*! - * jsUri v1.1.1 - * https://github.com/derek-watson/jsUri - * - * Copyright 2011, Derek Watson - * Released under the MIT license. - * http://jquery.org/license - * - * Includes parseUri regular expressions - * http://blog.stevenlevithan.com/archives/parseuri - * Copyright 2007, Steven Levithan - * Released under the MIT license. - * - * Date: Mon Nov 14 20:06:34 2011 -0800 - */ -(function(exports) { - -var Query = function (queryString) { - - // query string parsing, parameter manipulation and stringification - - 'use strict'; - - var // parseQuery(q) parses the uri query string and returns a multi-dimensional array of the components - parseQuery = function (q) { - var arr = [], i, ps, p, keyval; - - if (typeof (q) === 'undefined' || q === null || q === '') { - return arr; - } - - if (q.indexOf('?') === 0) { - q = q.substring(1); - } - - ps = q.toString().split(/[&;]/); - - for (i = 0; i < ps.length; i++) { - p = ps[i]; - keyval = p.split('='); - arr.push([keyval[0], keyval[1]]); - } - - return arr; - }, - - params = parseQuery(queryString), - - // toString() returns a string representation of the internal state of the object - toString = function () { - var s = '', i, param; - for (i = 0; i < params.length; i++) { - param = params[i]; - if (s.length > 0) { - s += '&'; - } - s += param.join('='); - } - return s.length > 0 ? '?' + s : s; - }, - - decode = function (s) { - s = decodeURIComponent(s); - s = s.replace('+', ' '); - return s; - }, - - // getParamValues(key) returns the first query param value found for the key 'key' - getParamValue = function (key) { - var param, i; - for (i = 0; i < params.length; i++) { - param = params[i]; - if (decode(key) === decode(param[0])) { - return param[1]; - } - } - }, - - // getParamValues(key) returns an array of query param values for the key 'key' - getParamValues = function (key) { - var arr = [], i, param; - for (i = 0; i < params.length; i++) { - param = params[i]; - if (decode(key) === decode(param[0])) { - arr.push(param[1]); - } - } - return arr; - }, - - // deleteParam(key) removes all instances of parameters named (key) - // deleteParam(key, val) removes all instances where the value matches (val) - deleteParam = function (key, val) { - - var arr = [], i, param, keyMatchesFilter, valMatchesFilter; - - for (i = 0; i < params.length; i++) { - - param = params[i]; - keyMatchesFilter = decode(param[0]) === decode(key); - valMatchesFilter = decode(param[1]) === decode(val); - - if ((arguments.length === 1 && !keyMatchesFilter) || (arguments.length === 2 && !keyMatchesFilter && !valMatchesFilter)) { - arr.push(param); - } - } - - params = arr; - - return this; - }, - - // addParam(key, val) Adds an element to the end of the list of query parameters - // addParam(key, val, index) adds the param at the specified position (index) - addParam = function (key, val, index) { - - if (arguments.length === 3 && index !== -1) { - index = Math.min(index, params.length); - params.splice(index, 0, [key, val]); - } else if (arguments.length > 0) { - params.push([key, val]); - } - return this; - }, - - // replaceParam(key, newVal) deletes all instances of params named (key) and replaces them with the new single value - // replaceParam(key, newVal, oldVal) deletes only instances of params named (key) with the value (val) and replaces them with the new single value - // this function attempts to preserve query param ordering - replaceParam = function (key, newVal, oldVal) { - - var index = -1, i, param; - - if (arguments.length === 3) { - for (i = 0; i < params.length; i++) { - param = params[i]; - if (decode(param[0]) === decode(key) && decodeURIComponent(param[1]) === decode(oldVal)) { - index = i; - break; - } - } - deleteParam(key, oldVal).addParam(key, newVal, index); - } else { - for (i = 0; i < params.length; i++) { - param = params[i]; - if (decode(param[0]) === decode(key)) { - index = i; - break; - } - } - deleteParam(key); - addParam(key, newVal, index); - } - return this; - }; - - // public api - return { - getParamValue: getParamValue, - getParamValues: getParamValues, - deleteParam: deleteParam, - addParam: addParam, - replaceParam: replaceParam, - - toString: toString - }; -}; - -var Uri = function (uriString) { - - // uri string parsing, attribute manipulation and stringification - - 'use strict'; - - /*global Query: true */ - /*jslint regexp: false, plusplus: false */ - - var strictMode = false, - - // parseUri(str) parses the supplied uri and returns an object containing its components - parseUri = function (str) { - - /*jslint unparam: true */ - var parsers = { - strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, - loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ - }, - keys = ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"], - q = { - name: "queryKey", - parser: /(?:^|&)([^&=]*)=?([^&]*)/g - }, - m = parsers[strictMode ? "strict" : "loose"].exec(str), - uri = {}, - i = 14; - - while (i--) { - uri[keys[i]] = m[i] || ""; - } - - uri[q.name] = {}; - uri[keys[12]].replace(q.parser, function ($0, $1, $2) { - if ($1) { - uri[q.name][$1] = $2; - } - }); - - return uri; - }, - - uriParts = parseUri(uriString || ''), - - queryObj = new Query(uriParts.query), - - - /* - Basic get/set functions for all properties - */ - - protocol = function (val) { - if (typeof val !== 'undefined') { - uriParts.protocol = val; - } - return uriParts.protocol; - }, - - hasAuthorityPrefixUserPref = null, - - // hasAuthorityPrefix: if there is no protocol, the leading // can be enabled or disabled - hasAuthorityPrefix = function (val) { - - if (typeof val !== 'undefined') { - hasAuthorityPrefixUserPref = val; - } - - if (hasAuthorityPrefixUserPref === null) { - return (uriParts.source.indexOf('//') !== -1); - } else { - return hasAuthorityPrefixUserPref; - } - }, - - userInfo = function (val) { - if (typeof val !== 'undefined') { - uriParts.userInfo = val; - } - return uriParts.userInfo; - }, - - host = function (val) { - if (typeof val !== 'undefined') { - uriParts.host = val; - } - return uriParts.host; - }, - - port = function (val) { - if (typeof val !== 'undefined') { - uriParts.port = val; - } - return uriParts.port; - }, - - path = function (val) { - if (typeof val !== 'undefined') { - uriParts.path = val; - } - return uriParts.path; - }, - - query = function (val) { - if (typeof val !== 'undefined') { - queryObj = new Query(val); - } - return queryObj; - }, - - anchor = function (val) { - if (typeof val !== 'undefined') { - uriParts.anchor = val; - } - return uriParts.anchor; - }, - - - /* - Fluent setters for Uri uri properties - */ - - setProtocol = function (val) { - protocol(val); - return this; - }, - - setHasAuthorityPrefix = function (val) { - hasAuthorityPrefix(val); - return this; - }, - - setUserInfo = function (val) { - userInfo(val); - return this; - }, - - setHost = function (val) { - host(val); - return this; - }, - - setPort = function (val) { - port(val); - return this; - }, - - setPath = function (val) { - path(val); - return this; - }, - - setQuery = function (val) { - query(val); - return this; - }, - - setAnchor = function (val) { - anchor(val); - return this; - }, - - /* - Query method wrappers - */ - getQueryParamValue = function (key) { - return query().getParamValue(key); - }, - - getQueryParamValues = function (key) { - return query().getParamValues(key); - }, - - deleteQueryParam = function (key, val) { - if (arguments.length === 2) { - query().deleteParam(key, val); - } else { - query().deleteParam(key); - } - - return this; - }, - - addQueryParam = function (key, val, index) { - if (arguments.length === 3) { - query().addParam(key, val, index); - } else { - query().addParam(key, val); - } - return this; - }, - - replaceQueryParam = function (key, newVal, oldVal) { - if (arguments.length === 3) { - query().replaceParam(key, newVal, oldVal); - } else { - query().replaceParam(key, newVal); - } - - return this; - }, - - /* - Serialization - */ - - // toString() stringifies the current state of the uri - toString = function () { - - var s = '', - is = function (s) { - return (s !== null && s !== ''); - }; - - if (is(protocol())) { - s += protocol(); - if (protocol().indexOf(':') !== protocol().length - 1) { - s += ':'; - } - s += '//'; - } else { - if (hasAuthorityPrefix() && is(host())) { - s += '//'; - } - } - - if (is(userInfo()) && is(host())) { - s += userInfo(); - if (userInfo().indexOf('@') !== userInfo().length - 1) { - s += '@'; - } - } - - if (is(host())) { - s += host(); - if (is(port())) { - s += ':' + port(); - } - } - - if (is(path())) { - s += path(); - } else { - if (is(host()) && (is(query().toString()) || is(anchor()))) { - s += '/'; - } - } - if (is(query().toString())) { - if (query().toString().indexOf('?') !== 0) { - s += '?'; - } - s += query().toString(); - } - - if (is(anchor())) { - if (anchor().indexOf('#') !== 0) { - s += '#'; - } - s += anchor(); - } - - return s; - }, - - /* - Cloning - */ - - // clone() returns a new, identical Uri instance - clone = function () { - return new Uri(toString()); - }; - - // public api - return { - - protocol: protocol, - hasAuthorityPrefix: hasAuthorityPrefix, - userInfo: userInfo, - host: host, - port: port, - path: path, - query: query, - anchor: anchor, - - setProtocol: setProtocol, - setHasAuthorityPrefix: setHasAuthorityPrefix, - setUserInfo: setUserInfo, - setHost: setHost, - setPort: setPort, - setPath: setPath, - setQuery: setQuery, - setAnchor: setAnchor, - - getQueryParamValue: getQueryParamValue, - getQueryParamValues: getQueryParamValues, - deleteQueryParam: deleteQueryParam, - addQueryParam: addQueryParam, - replaceQueryParam: replaceQueryParam, - - toString: toString, - clone: clone - }; -}; - -exports.Query = Query; -exports.Uri = Uri; - -/* add compatibility for users of jsUri <= 1.1.1 */ -exports.jsUri = Uri; - -})(this); diff --git a/js/main.js b/js/main.js deleted file mode 100644 index 7095440..0000000 --- a/js/main.js +++ /dev/null @@ -1,51 +0,0 @@ -(function(exports) { - var ViewportInfo = require('./viewport-info.js') || this.ViewportInfo; - var SrcsetInfo = require('./srcset-info') || exports.SrcsetInfo; - - function isSrcsetImplemented() { - return 'srcset' in new Image(); - } - - function main() { - // If the browser supports @srcset natively, don't do any polyfill. - if (isSrcsetImplemented()) { - return; - } - - // Get the user agent's capabilities (viewport width, viewport height, dPR). - var viewportInfo = new ViewportInfo(); - viewportInfo.compute(); - // Go through all images on the page. - var images = document.querySelectorAll('img'); - // If they have srcset attributes, apply JS to handle that correctly. - for (var i = 0; i < images.length; i++) { - var img = images[i]; - // Parse the srcset from the image element. - var srcset = img.getAttribute('srcset'); - if (srcset) { - var srcsetInfo = new SrcsetInfo({src: img.src, - srcset: srcset}); - // Go through all the candidates, pick the best one that matches. - var imageInfo = viewportInfo.getBestImage(srcsetInfo); - // TODO: consider using -webkit-image-set instead (if available). - // Replace the with this image. - img.src = imageInfo.src; - // If there's no set size, then we scale the image if necessary - // (e.g. x != 1) - if (!(img.width || img.height || img.style.height || img.style.width)) { - img.style.webkitTransform = 'scale(' + (1/imageInfo.x) + ')'; - img.style.webkitTransformOrigin = '0 0'; - } - } - } - } - - // Small cross browser document ready. - var readyTimer = setInterval(function () { - if (document.readyState === "complete") { - main(); - clearInterval(readyTimer); - } - }, 10); - -})(this); diff --git a/js/srcset-info.js b/js/srcset-info.js index 7cdd223..4fb585d 100644 --- a/js/srcset-info.js +++ b/js/srcset-info.js @@ -1,4 +1,4 @@ -(function(exports) { +(function() { var INT_REGEXP = /^[0-9]+$/; function SrcsetInfo(options) { @@ -147,9 +147,9 @@ // Exports - exports.SrcsetInfo = SrcsetInfo; + this.SrcsetInfo = SrcsetInfo; if (typeof module !== "undefined" && module !== null) { - module.exports = SrcsetInfo; + module.exports = this.SrcsetInfo; } })(this); diff --git a/js/srcset.js b/js/srcset.js new file mode 100644 index 0000000..5297244 --- /dev/null +++ b/js/srcset.js @@ -0,0 +1,92 @@ +(function() { + var ViewportInfo = this.ViewportInfo || require('./viewport-info.js'); + var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); + var WeakMap = require('es6-weak-map'); + + var srcset = {}; + + var viewportInfo = new ViewportInfo(); + srcset.viewportInfo = viewportInfo; + viewportInfo.compute(); + + var windowResizedAt = (new Date).getTime(); + srcset.windowResizedAt = windowResizedAt; + + function imgloaded(src, cb) { + var img = document.createElement('img'); + img.onload = function () { + cb(null); + } + img.src = src; + } + + function SrcsetView(el) { + this.el = el; + + this.srcsetInfo = new SrcsetInfo({ + src: this.el.src, + srcset: this.el.dataset.srcset + }); + } + SrcsetView.prototype.update = function (options) { + options || (options = {}); + /*options = $.extend({}, options, { + force: false + });*/ + + var needUpdate = (!this.srcupdatedat || this.srcupdatedat < windowResizedAt); + if (!this.el.src || needUpdate || options.force) { + + if (this.srcsetInfo) { + var bestImageInfo = viewportInfo.getBestImage(this.srcsetInfo); + + // 'srcchanged' event + var srcchanged = new CustomEvent('srcchanged', { + previous: this.el.src, + actual: bestImageInfo.src + }); + + // Wait the new image is loaded + imgloaded(bestImageInfo.src, function () { + // Change src + this.el.src = bestImageInfo.src; + + // Dispatch 'srcchanged' + setTimeout(function () { + document.dispatchEvent(srcchanged); + }.bind(this), 0); + }.bind(this)); + } + + // Remember when updated to compare with window's resizeAt timestamp + this.srcupdatedat = (new Date).getTime(); + } + }; + + var srcsetViews = new WeakMap(); + srcset.imgs = srcsetViews; + function updateAllSrcset() { + // update timestamp + windowResizedAt = (new Date).getTime(); + viewportInfo.compute(); + + // Update every images + Array.prototype.forEach.call(document.querySelectorAll('img[data-srcset]'), function (el) { + var srcsetview = srcsetViews.get(el); + if (!srcsetview) { + srcsetview = new SrcsetView(el); + srcsetViews.set(el, srcsetview); + } + + srcsetview.update(); + }); + } + window.onresize = updateAllSrcset; + updateAllSrcset(); + + // Exports + this.srcset = srcset; + if (typeof module !== "undefined" && module !== null) { + module.exports = this.srcset; + } +})(this); diff --git a/js/viewport-info.js b/js/viewport-info.js index 827cd63..0afd071 100644 --- a/js/viewport-info.js +++ b/js/viewport-info.js @@ -1,5 +1,5 @@ -(function(exports) { - var SrcsetInfo = require('./srcset-info') || exports.SrcsetInfo; +(function() { + var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); function ViewportInfo() { this.w = null; @@ -131,9 +131,9 @@ }; // Exports - exports.ViewportInfo = ViewportInfo; + this.ViewportInfo = ViewportInfo; if (typeof module !== "undefined" && module !== null) { - module.exports = ViewportInfo; + module.exports = this.ViewportInfo; } })(this); diff --git a/package.json b/package.json index d29cf53..f5a39d6 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,10 @@ "name": "srcset-polyfill", "version": "0.1.0", "devDependencies": { - "grunt": "~0.4.0", - "grunt-contrib-jshint": "~0.1.1", - "grunt-contrib-nodeunit": "~0.1.2", - "grunt-contrib-concat": "~0.1.3", - "grunt-contrib-uglify": "~0.1.2" + "browserify": "^11.0.1", + "uglify-js": "^2.4.24" + }, + "dependencies": { + "es6-weak-map": "^1.0.2" } } From 802bbd77742cf3a5f60e67a8d18b7a9aac8d3f97 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 16 Aug 2015 21:24:45 +0200 Subject: [PATCH 06/26] srcset.update --- Makefile | 2 ++ build/srcset.js | 7 ++++--- build/srcset.min.js | 2 +- js/srcset.js | 7 ++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 17035cc..2c66060 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +all: build/srcset.js build/srcset.min.js + build/srcset.js: ./node_modules/.bin/browserify $(shell find -L js -name '*.js') ./node_modules/.bin/browserify ./js/srcset.js > $@ diff --git a/build/srcset.js b/build/srcset.js index c795ad7..bbfec8f 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -223,7 +223,7 @@ var srcsetViews = new WeakMap(); srcset.imgs = srcsetViews; - function updateAllSrcset() { + function update() { // update timestamp windowResizedAt = (new Date).getTime(); viewportInfo.compute(); @@ -239,8 +239,9 @@ srcsetview.update(); }); } - window.onresize = updateAllSrcset; - updateAllSrcset(); + window.onresize = update; + update(); + srcset.update = update; // Exports this.srcset = srcset; diff --git a/build/srcset.min.js b/build/srcset.min.js index 2dd6f1c..d9aad60 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info.js");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}c.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,d,h;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){d=t[p];if(p+1<_){h=d.charCodeAt(0);if(h>=55296&&h<=56319)d+=t[++p]}a.call(e,u,d,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function d(t){var e;if(this instanceof d)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,d=Object.prototype.hasOwnProperty,h=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,h(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(d.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(d.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return d.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file +(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info.js");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}c.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,d,h;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){d=t[p];if(p+1<_){h=d.charCodeAt(0);if(h>=55296&&h<=56319)d+=t[++p]}a.call(e,u,d,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function d(t){var e;if(this instanceof d)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,d=Object.prototype.hasOwnProperty,h=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,h(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(d.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(d.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return d.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index 5297244..18a8756 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -65,7 +65,7 @@ var srcsetViews = new WeakMap(); srcset.imgs = srcsetViews; - function updateAllSrcset() { + function update() { // update timestamp windowResizedAt = (new Date).getTime(); viewportInfo.compute(); @@ -81,8 +81,9 @@ srcsetview.update(); }); } - window.onresize = updateAllSrcset; - updateAllSrcset(); + window.onresize = update; + update(); + srcset.update = update; // Exports this.srcset = srcset; From e67c29b66bad5c45862a46b00bc9bcceb8b721e5 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Mon, 17 Aug 2015 08:54:48 +0200 Subject: [PATCH 07/26] adding main script --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index f5a39d6..048e356 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "srcset-polyfill", "version": "0.1.0", + "main": "build/srcset.js", "devDependencies": { "browserify": "^11.0.1", "uglify-js": "^2.4.24" From 8105d5a949926f6fa7d8137253c82614b6ee3dac Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Mon, 17 Aug 2015 09:08:12 +0200 Subject: [PATCH 08/26] adding debounce for resize --- build/srcset.js | 34 +++++++++++++++++++++++++++++++++- build/srcset.min.js | 2 +- js/srcset.js | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index bbfec8f..5fd09b0 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -178,6 +178,38 @@ img.src = src; } + function debounce(func, wait, immediate) { + var timeout, args, context, timestamp, result; + + var later = function() { + var last = new Date().getTime() - timestamp; + + if (last < wait && last >= 0) { + timeout = setTimeout(later, wait - last); + } else { + timeout = null; + if (!immediate) { + result = func.apply(context, args); + if (!timeout) context = args = null; + } + } + }; + + return function() { + context = this; + args = arguments; + timestamp = new Date().getTime(); + var callNow = immediate && !timeout; + if (!timeout) timeout = setTimeout(later, wait); + if (callNow) { + result = func.apply(context, args); + context = args = null; + } + + return result; + }; + } + function SrcsetView(el) { this.el = el; @@ -239,7 +271,7 @@ srcsetview.update(); }); } - window.onresize = update; + window.onresize = debounce(update, 200); update(); srcset.update = update; diff --git a/build/srcset.min.js b/build/srcset.min.js index d9aad60..ecb10ef 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info.js");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}c.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,d,h;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){d=t[p];if(p+1<_){h=d.charCodeAt(0);if(h>=55296&&h<=56319)d+=t[++p]}a.call(e,u,d,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function d(t){var e;if(this instanceof d)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,d=Object.prototype.hasOwnProperty,h=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,h(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(d.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(d.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return d.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file +(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info.js");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t,e,r){var n,i,o,s,a;var u=function(){var c=(new Date).getTime()-s;if(c=0){n=setTimeout(u,e-c)}else{n=null;if(!r){a=t.apply(o,i);if(!n)o=i=null}}};return function(){o=this;i=arguments;s=(new Date).getTime();var c=r&&!n;if(!n)n=setTimeout(u,e);if(c){a=t.apply(o,i);o=i=null}return a}}function l(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}l.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,d,h;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){d=t[p];if(p+1<_){h=d.charCodeAt(0);if(h>=55296&&h<=56319)d+=t[++p]}a.call(e,u,d,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function d(t){var e;if(this instanceof d)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,d=Object.prototype.hasOwnProperty,h=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,h(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(d.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(d.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return d.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index 18a8756..d21d77e 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -12,6 +12,7 @@ var windowResizedAt = (new Date).getTime(); srcset.windowResizedAt = windowResizedAt; + // https://gist.github.com/abernier/6461914#imgloaded function imgloaded(src, cb) { var img = document.createElement('img'); img.onload = function () { @@ -20,6 +21,39 @@ img.src = src; } + // Picked from underscore.js + function debounce(func, wait, immediate) { + var timeout, args, context, timestamp, result; + + var later = function() { + var last = new Date().getTime() - timestamp; + + if (last < wait && last >= 0) { + timeout = setTimeout(later, wait - last); + } else { + timeout = null; + if (!immediate) { + result = func.apply(context, args); + if (!timeout) context = args = null; + } + } + }; + + return function() { + context = this; + args = arguments; + timestamp = new Date().getTime(); + var callNow = immediate && !timeout; + if (!timeout) timeout = setTimeout(later, wait); + if (callNow) { + result = func.apply(context, args); + context = args = null; + } + + return result; + }; + } + function SrcsetView(el) { this.el = el; @@ -81,7 +115,7 @@ srcsetview.update(); }); } - window.onresize = update; + window.onresize = debounce(update, 200); update(); srcset.update = update; From 09d7c511d3b99262b5f9b33d6764a8342980d3c9 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Mon, 17 Aug 2015 09:22:01 +0200 Subject: [PATCH 09/26] doc --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d552a7a..8916309 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,12 @@ Use the `data-srcset` attribute of `` elements. For example: data-srcset="320x240.png 320w,640x480 320w 2x, 768x576.png 768w,1536x1152.png 768w 2x, 1024x768.png 1024w,2048x1536.png 1024w 2x, 2048x1536.png 5000w"> ``` -Include `build/srcset.min.js` in your page. +Include `build/srcset.min.js` in your page. Then, you'll have a `srcset` object with the following API : + - `srcset.update()` -- update all images in the page + - `srcset.imgs.get().update()` -- update one image +A `'srcchange'` event will also be triggered when the `src` of an image changes. ## Open questions From 006e791f3d003f68b85a561af2c2fa2d15abb961 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Mon, 17 Aug 2015 09:59:44 +0200 Subject: [PATCH 10/26] typo --- js/srcset.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/srcset.js b/js/srcset.js index d21d77e..4150211 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -1,5 +1,5 @@ (function() { - var ViewportInfo = this.ViewportInfo || require('./viewport-info.js'); + var ViewportInfo = this.ViewportInfo || require('./viewport-info'); var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); var WeakMap = require('es6-weak-map'); From 8e347a201a0a545e8048d3f45fb11963377d764b Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Mon, 17 Aug 2015 10:02:09 +0200 Subject: [PATCH 11/26] main --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 048e356..b5f4dd2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "srcset-polyfill", "version": "0.1.0", - "main": "build/srcset.js", + "main": "js/srcset.js", "devDependencies": { "browserify": "^11.0.1", "uglify-js": "^2.4.24" From cf650e229c3e348179d6835c35d382ef446bcb43 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Thu, 3 Sep 2015 23:51:21 +0200 Subject: [PATCH 12/26] fix --- build/srcset.js | 8 +++++--- build/srcset.min.js | 2 +- js/srcset.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index 5fd09b0..b14fce7 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -157,7 +157,7 @@ },{}],2:[function(require,module,exports){ (function() { - var ViewportInfo = this.ViewportInfo || require('./viewport-info.js'); + var ViewportInfo = this.ViewportInfo || require('./viewport-info'); var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); var WeakMap = require('es6-weak-map'); @@ -170,6 +170,7 @@ var windowResizedAt = (new Date).getTime(); srcset.windowResizedAt = windowResizedAt; + // https://gist.github.com/abernier/6461914#imgloaded function imgloaded(src, cb) { var img = document.createElement('img'); img.onload = function () { @@ -178,6 +179,7 @@ img.src = src; } + // Picked from underscore.js function debounce(func, wait, immediate) { var timeout, args, context, timestamp, result; @@ -243,7 +245,7 @@ // Dispatch 'srcchanged' setTimeout(function () { - document.dispatchEvent(srcchanged); + this.el.dispatchEvent(srcchanged); }.bind(this), 0); }.bind(this)); } @@ -282,7 +284,7 @@ } })(this); -},{"./srcset-info":1,"./viewport-info.js":3,"es6-weak-map":4}],3:[function(require,module,exports){ +},{"./srcset-info":1,"./viewport-info":3,"es6-weak-map":4}],3:[function(require,module,exports){ (function() { var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); diff --git a/build/srcset.min.js b/build/srcset.min.js index ecb10ef..727724d 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info.js");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t,e,r){var n,i,o,s,a;var u=function(){var c=(new Date).getTime()-s;if(c=0){n=setTimeout(u,e-c)}else{n=null;if(!r){a=t.apply(o,i);if(!n)o=i=null}}};return function(){o=this;i=arguments;s=(new Date).getTime();var c=r&&!n;if(!n)n=setTimeout(u,e);if(c){a=t.apply(o,i);o=i=null}return a}}function l(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}l.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,d,h;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){d=t[p];if(p+1<_){h=d.charCodeAt(0);if(h>=55296&&h<=56319)d+=t[++p]}a.call(e,u,d,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function d(t){var e;if(this instanceof d)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,d=Object.prototype.hasOwnProperty,h=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,h(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(d.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(d.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return d.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file +(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t,e,r){var n,i,o,s,a;var u=function(){var c=(new Date).getTime()-s;if(c=0){n=setTimeout(u,e-c)}else{n=null;if(!r){a=t.apply(o,i);if(!n)o=i=null}}};return function(){o=this;i=arguments;s=(new Date).getTime();var c=r&&!n;if(!n)n=setTimeout(u,e);if(c){a=t.apply(o,i);o=i=null}return a}}function l(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}l.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,d,h;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){d=t[p];if(p+1<_){h=d.charCodeAt(0);if(h>=55296&&h<=56319)d+=t[++p]}a.call(e,u,d,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function d(t){var e;if(this instanceof d)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,d=Object.prototype.hasOwnProperty,h=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,h(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(d.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(d.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return d.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index 4150211..cc6bd4c 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -87,7 +87,7 @@ // Dispatch 'srcchanged' setTimeout(function () { - document.dispatchEvent(srcchanged); + this.el.dispatchEvent(srcchanged); }.bind(this), 0); }.bind(this)); } From bec226e1f4d7056a5f490851ab8e5315367217a2 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Wed, 9 Sep 2015 20:02:37 +0200 Subject: [PATCH 13/26] bubbles --- build/srcset.js | 3 ++- build/srcset.min.js | 2 +- js/srcset.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index b14fce7..68250e6 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -235,7 +235,8 @@ // 'srcchanged' event var srcchanged = new CustomEvent('srcchanged', { previous: this.el.src, - actual: bestImageInfo.src + actual: bestImageInfo.src, + bubbles: true }); // Wait the new image is loaded diff --git a/build/srcset.min.js b/build/srcset.min.js index 727724d..1691235 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t,e,r){var n,i,o,s,a;var u=function(){var c=(new Date).getTime()-s;if(c=0){n=setTimeout(u,e-c)}else{n=null;if(!r){a=t.apply(o,i);if(!n)o=i=null}}};return function(){o=this;i=arguments;s=(new Date).getTime();var c=r&&!n;if(!n)n=setTimeout(u,e);if(c){a=t.apply(o,i);o=i=null}return a}}function l(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}l.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,d,h;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){d=t[p];if(p+1<_){h=d.charCodeAt(0);if(h>=55296&&h<=56319)d+=t[++p]}a.call(e,u,d,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function d(t){var e;if(this instanceof d)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,d=Object.prototype.hasOwnProperty,h=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,h(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(d.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(d.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return d.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file +(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t,e,r){var n,i,o,s,a;var u=function(){var c=(new Date).getTime()-s;if(c=0){n=setTimeout(u,e-c)}else{n=null;if(!r){a=t.apply(o,i);if(!n)o=i=null}}};return function(){o=this;i=arguments;s=(new Date).getTime();var c=r&&!n;if(!n)n=setTimeout(u,e);if(c){a=t.apply(o,i);o=i=null}return a}}function l(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}l.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,d,h;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){d=t[p];if(p+1<_){h=d.charCodeAt(0);if(h>=55296&&h<=56319)d+=t[++p]}a.call(e,u,d,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function d(t){var e;if(this instanceof d)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,d=Object.prototype.hasOwnProperty,h=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,h(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(d.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(d.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return d.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index cc6bd4c..cce2063 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -77,7 +77,8 @@ // 'srcchanged' event var srcchanged = new CustomEvent('srcchanged', { previous: this.el.src, - actual: bestImageInfo.src + actual: bestImageInfo.src, + bubbles: true }); // Wait the new image is loaded From 2b2eeaf59fdbadde7fe2533bd49deff049f987a2 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sat, 26 Dec 2015 12:49:56 +0100 Subject: [PATCH 14/26] Adding a srcsetchanging event --- js/srcset.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/js/srcset.js b/js/srcset.js index cce2063..6b3cda3 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -74,13 +74,26 @@ if (this.srcsetInfo) { var bestImageInfo = viewportInfo.getBestImage(this.srcsetInfo); + // + // 'srcchanging' event + // + + var srcchanging = new CustomEvent('srcchanging', { + previous: this.el.src, + actual: bestImageInfo.src, + bubbles: true + }); + this.el.dispatchEvent(srcchanging); + + // // 'srcchanged' event + // + var srcchanged = new CustomEvent('srcchanged', { previous: this.el.src, actual: bestImageInfo.src, bubbles: true }); - // Wait the new image is loaded imgloaded(bestImageInfo.src, function () { // Change src @@ -106,7 +119,7 @@ viewportInfo.compute(); // Update every images - Array.prototype.forEach.call(document.querySelectorAll('img[data-srcset]'), function (el) { + [].forEach.call(document.querySelectorAll('img[data-srcset]'), function (el) { var srcsetview = srcsetViews.get(el); if (!srcsetview) { srcsetview = new SrcsetView(el); From d36c156f31bd35cd29868dd7e07f6524cdd2f3e2 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sat, 26 Dec 2015 12:50:16 +0100 Subject: [PATCH 15/26] build --- build/srcset.js | 17 +++++++++++++++-- build/srcset.min.js | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index 68250e6..3114814 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -232,13 +232,26 @@ if (this.srcsetInfo) { var bestImageInfo = viewportInfo.getBestImage(this.srcsetInfo); + // + // 'srcchanging' event + // + + var srcchanging = new CustomEvent('srcchanging', { + previous: this.el.src, + actual: bestImageInfo.src, + bubbles: true + }); + this.el.dispatchEvent(srcchanging); + + // // 'srcchanged' event + // + var srcchanged = new CustomEvent('srcchanged', { previous: this.el.src, actual: bestImageInfo.src, bubbles: true }); - // Wait the new image is loaded imgloaded(bestImageInfo.src, function () { // Change src @@ -264,7 +277,7 @@ viewportInfo.compute(); // Update every images - Array.prototype.forEach.call(document.querySelectorAll('img[data-srcset]'), function (el) { + [].forEach.call(document.querySelectorAll('img[data-srcset]'), function (el) { var srcsetview = srcsetViews.get(el); if (!srcsetview) { srcsetview = new SrcsetView(el); diff --git a/build/srcset.min.js b/build/srcset.min.js index 1691235..c0c62da 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t,e,r){var n,i,o,s,a;var u=function(){var c=(new Date).getTime()-s;if(c=0){n=setTimeout(u,e-c)}else{n=null;if(!r){a=t.apply(o,i);if(!n)o=i=null}}};return function(){o=this;i=arguments;s=(new Date).getTime();var c=r&&!n;if(!n)n=setTimeout(u,e);if(c){a=t.apply(o,i);o=i=null}return a}}function l(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}l.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,d,h;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){d=t[p];if(p+1<_){h=d.charCodeAt(0);if(h>=55296&&h<=56319)d+=t[++p]}a.call(e,u,d,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function d(t){var e;if(this instanceof d)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,d=Object.prototype.hasOwnProperty,h=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,h(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(d.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(d.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return d.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file +(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t,e,r){var n,i,o,s,a;var u=function(){var c=(new Date).getTime()-s;if(c=0){n=setTimeout(u,e-c)}else{n=null;if(!r){a=t.apply(o,i);if(!n)o=i=null}}};return function(){o=this;i=arguments;s=(new Date).getTime();var c=r&&!n;if(!n)n=setTimeout(u,e);if(c){a=t.apply(o,i);o=i=null}return a}}function l(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}l.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,h,d;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){h=t[p];if(p+1<_){d=h.charCodeAt(0);if(d>=55296&&d<=56319)h+=t[++p]}a.call(e,u,h,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function h(t){var e;if(this instanceof h)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,h=Object.prototype.hasOwnProperty,d=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,d(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(h.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(h.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return h.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file From a1711b2071dbd7f8de61d6429abb2b94a0058336 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sat, 26 Dec 2015 12:56:01 +0100 Subject: [PATCH 16/26] doc --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8916309..c5f791b 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,13 @@ Include `build/srcset.min.js` in your page. Then, you'll have a `srcset` object - `srcset.update()` -- update all images in the page - `srcset.imgs.get().update()` -- update one image -A `'srcchange'` event will also be triggered when the `src` of an image changes. +A `'srcchange'` event will also be triggered when the `src` of an image changes : + +```javascript +myimg.addEventListener('srcchanged', function (data) { + console.log("img with previous src %s was changed to %s", data.previous, data.actual) +}, false); +``` ## Open questions From a986dac34c037a50faaac07dbdcc95b088892b9b Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 27 Dec 2015 12:20:46 +0100 Subject: [PATCH 17/26] better weakmap shim + MutationObserver on data-srcset changes --- build/srcset.js | 1736 +++++++++++++++++++------------------------ build/srcset.min.js | 2 +- js/srcset.js | 82 +- package.json | 2 +- 4 files changed, 824 insertions(+), 998 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index 3114814..36e91b7 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -156,10 +156,11 @@ })(this); },{}],2:[function(require,module,exports){ -(function() { +(function () { var ViewportInfo = this.ViewportInfo || require('./viewport-info'); var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); - var WeakMap = require('es6-weak-map'); + var WeakMap = require('weak-map'); + console.log('tataa'); var srcset = {}; @@ -212,13 +213,58 @@ }; } + // https://gist.github.com/stucox/5231211 + var hasMO = (function () { + var prefixes = ['WebKit', 'Moz', 'O', 'Ms', '']; + + for (var i=0; i < prefixes.length; i++) { + if ((prefixes[i] + 'MutationObserver') in window) { + return window[prefixes[i] + 'MutationObserver']; + } + } + + return false; + }()); + function SrcsetView(el) { this.el = el; - this.srcsetInfo = new SrcsetInfo({ + this.srcsetInfo = new SrcsetInfo(this.el, { src: this.el.src, srcset: this.el.dataset.srcset }); + + // + // Observe data-srcset attributes mutations to keep this.srcsetInfo up-to-date (if available) + // + + if (hasMO) { + this.mo = new MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + console.log(mutation); + + if (mutation.target === this.el && mutation.type === 'attributes') { + if (mutation.attributeName === 'src') { + this.srcsetInfo.srcValue = mutation.target.src; + } + + if (mutation.attributeName === 'data-srcset') { + this.srcsetInfo.imageCandidates = []; // reset imageCandidates + this.srcsetInfo.srcsetValue = mutation.target.dataset.srcset; + + this.srcsetInfo._parse(this.srcsetInfo.srcsetValue); + if (!this.srcsetInfo.isValid) { + console.error('Error: ' + this.srcsetInfo.error); + } + + this.update({force: true}); + } + } + }.bind(this)); + }.bind(this)); + + this.mo.observe(this.el, {attributes: true}); + } } SrcsetView.prototype.update = function (options) { options || (options = {}); @@ -232,30 +278,35 @@ if (this.srcsetInfo) { var bestImageInfo = viewportInfo.getBestImage(this.srcsetInfo); + var oldsrc = this.el.src; + var newsrc = bestImageInfo.src; + + if (newsrc === oldsrc) return false; // same, no need to update + + //console.log('updating src', this.el, oldsrc, newsrc); + + var eventdata = { + previous: oldsrc, + actual: newsrc, + bubbles: true + }; + // // 'srcchanging' event // - var srcchanging = new CustomEvent('srcchanging', { - previous: this.el.src, - actual: bestImageInfo.src, - bubbles: true - }); + var srcchanging = new CustomEvent('srcchanging', eventdata); this.el.dispatchEvent(srcchanging); // // 'srcchanged' event // - var srcchanged = new CustomEvent('srcchanged', { - previous: this.el.src, - actual: bestImageInfo.src, - bubbles: true - }); + var srcchanged = new CustomEvent('srcchanged', eventdata); // Wait the new image is loaded - imgloaded(bestImageInfo.src, function () { + imgloaded(newsrc, function () { // Change src - this.el.src = bestImageInfo.src; + this.el.src = newsrc; // Dispatch 'srcchanged' setTimeout(function () { @@ -278,6 +329,7 @@ // Update every images [].forEach.call(document.querySelectorAll('img[data-srcset]'), function (el) { + console.log('tata', el); var srcsetview = srcsetViews.get(el); if (!srcsetview) { srcsetview = new SrcsetView(el); @@ -298,7 +350,7 @@ } })(this); -},{"./srcset-info":1,"./viewport-info":3,"es6-weak-map":4}],3:[function(require,module,exports){ +},{"./srcset-info":1,"./viewport-info":3,"weak-map":4}],3:[function(require,module,exports){ (function() { var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); @@ -440,968 +492,690 @@ })(this); },{"./srcset-info":1}],4:[function(require,module,exports){ -'use strict'; - -module.exports = require('./is-implemented')() ? WeakMap : require('./polyfill'); - -},{"./is-implemented":5,"./polyfill":47}],5:[function(require,module,exports){ -'use strict'; - -module.exports = function () { - var weakMap, x; - if (typeof WeakMap !== 'function') return false; - if (String(WeakMap.prototype) !== '[object WeakMap]') return false; - try { - // WebKit doesn't support arguments and crashes - weakMap = new WeakMap([[x = {}, 'one'], [{}, 'two'], [{}, 'three']]); - } catch (e) { - return false; - } - if (typeof weakMap.set !== 'function') return false; - if (weakMap.set({}, 1) !== weakMap) return false; - if (typeof weakMap.delete !== 'function') return false; - if (typeof weakMap.has !== 'function') return false; - if (weakMap.get(x) !== 'one') return false; - - return true; -}; - -},{}],6:[function(require,module,exports){ -// Exports true if environment provides native `WeakMap` implementation, whatever that is. - -'use strict'; - -module.exports = (function () { - if (typeof WeakMap !== 'function') return false; - return (Object.prototype.toString.call(new WeakMap()) === '[object WeakMap]'); -}()); - -},{}],7:[function(require,module,exports){ -'use strict'; - -var copy = require('es5-ext/object/copy') - , map = require('es5-ext/object/map') - , callable = require('es5-ext/object/valid-callable') - , validValue = require('es5-ext/object/valid-value') - - , bind = Function.prototype.bind, defineProperty = Object.defineProperty - , hasOwnProperty = Object.prototype.hasOwnProperty - , define; - -define = function (name, desc, bindTo) { - var value = validValue(desc) && callable(desc.value), dgs; - dgs = copy(desc); - delete dgs.writable; - delete dgs.value; - dgs.get = function () { - if (hasOwnProperty.call(this, name)) return value; - desc.value = bind.call(value, (bindTo == null) ? this : this[bindTo]); - defineProperty(this, name, desc); - return this[name]; - }; - return dgs; -}; - -module.exports = function (props/*, bindTo*/) { - var bindTo = arguments[1]; - return map(props, function (desc, name) { - return define(name, desc, bindTo); - }); -}; - -},{"es5-ext/object/copy":14,"es5-ext/object/map":22,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29}],8:[function(require,module,exports){ -'use strict'; - -var assign = require('es5-ext/object/assign') - , normalizeOpts = require('es5-ext/object/normalize-options') - , isCallable = require('es5-ext/object/is-callable') - , contains = require('es5-ext/string/#/contains') - - , d; - -d = module.exports = function (dscr, value/*, options*/) { - var c, e, w, options, desc; - if ((arguments.length < 2) || (typeof dscr !== 'string')) { - options = value; - value = dscr; - dscr = null; - } else { - options = arguments[2]; - } - if (dscr == null) { - c = w = true; - e = false; - } else { - c = contains.call(dscr, 'c'); - e = contains.call(dscr, 'e'); - w = contains.call(dscr, 'w'); - } - - desc = { value: value, configurable: c, enumerable: e, writable: w }; - return !options ? desc : assign(normalizeOpts(options), desc); -}; - -d.gs = function (dscr, get, set/*, options*/) { - var c, e, options, desc; - if (typeof dscr !== 'string') { - options = set; - set = get; - get = dscr; - dscr = null; - } else { - options = arguments[3]; - } - if (get == null) { - get = undefined; - } else if (!isCallable(get)) { - options = get; - get = set = undefined; - } else if (set == null) { - set = undefined; - } else if (!isCallable(set)) { - options = set; - set = undefined; - } - if (dscr == null) { - c = true; - e = false; - } else { - c = contains.call(dscr, 'c'); - e = contains.call(dscr, 'e'); - } - - desc = { get: get, set: set, configurable: c, enumerable: e }; - return !options ? desc : assign(normalizeOpts(options), desc); -}; - -},{"es5-ext/object/assign":11,"es5-ext/object/is-callable":17,"es5-ext/object/normalize-options":23,"es5-ext/string/#/contains":30}],9:[function(require,module,exports){ -// Inspired by Google Closure: -// http://closure-library.googlecode.com/svn/docs/ -// closure_goog_array_array.js.html#goog.array.clear - -'use strict'; - -var value = require('../../object/valid-value'); - -module.exports = function () { - value(this).length = 0; - return this; -}; - -},{"../../object/valid-value":29}],10:[function(require,module,exports){ -// Internal method, used by iteration functions. -// Calls a function for each key-value pair found in object -// Optionally takes compareFn to iterate object in specific order - -'use strict'; - -var isCallable = require('./is-callable') - , callable = require('./valid-callable') - , value = require('./valid-value') - - , call = Function.prototype.call, keys = Object.keys - , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; - -module.exports = function (method, defVal) { - return function (obj, cb/*, thisArg, compareFn*/) { - var list, thisArg = arguments[2], compareFn = arguments[3]; - obj = Object(value(obj)); - callable(cb); - - list = keys(obj); - if (compareFn) { - list.sort(isCallable(compareFn) ? compareFn.bind(obj) : undefined); - } - return list[method](function (key, index) { - if (!propertyIsEnumerable.call(obj, key)) return defVal; - return call.call(cb, thisArg, obj[key], key, obj, index); - }); - }; -}; - -},{"./is-callable":17,"./valid-callable":27,"./valid-value":29}],11:[function(require,module,exports){ -'use strict'; - -module.exports = require('./is-implemented')() - ? Object.assign - : require('./shim'); - -},{"./is-implemented":12,"./shim":13}],12:[function(require,module,exports){ -'use strict'; - -module.exports = function () { - var assign = Object.assign, obj; - if (typeof assign !== 'function') return false; - obj = { foo: 'raz' }; - assign(obj, { bar: 'dwa' }, { trzy: 'trzy' }); - return (obj.foo + obj.bar + obj.trzy) === 'razdwatrzy'; -}; - -},{}],13:[function(require,module,exports){ -'use strict'; - -var keys = require('../keys') - , value = require('../valid-value') - - , max = Math.max; - -module.exports = function (dest, src/*, …srcn*/) { - var error, i, l = max(arguments.length, 2), assign; - dest = Object(value(dest)); - assign = function (key) { - try { dest[key] = src[key]; } catch (e) { - if (!error) error = e; - } - }; - for (i = 1; i < l; ++i) { - src = arguments[i]; - keys(src).forEach(assign); - } - if (error !== undefined) throw error; - return dest; -}; - -},{"../keys":19,"../valid-value":29}],14:[function(require,module,exports){ -'use strict'; - -var assign = require('./assign') - , value = require('./valid-value'); - -module.exports = function (obj) { - var copy = Object(value(obj)); - if (copy !== obj) return copy; - return assign({}, obj); -}; - -},{"./assign":11,"./valid-value":29}],15:[function(require,module,exports){ -// Workaround for http://code.google.com/p/v8/issues/detail?id=2804 - -'use strict'; - -var create = Object.create, shim; - -if (!require('./set-prototype-of/is-implemented')()) { - shim = require('./set-prototype-of/shim'); -} - -module.exports = (function () { - var nullObject, props, desc; - if (!shim) return create; - if (shim.level !== 1) return create; - - nullObject = {}; - props = {}; - desc = { configurable: false, enumerable: false, writable: true, - value: undefined }; - Object.getOwnPropertyNames(Object.prototype).forEach(function (name) { - if (name === '__proto__') { - props[name] = { configurable: true, enumerable: false, writable: true, - value: undefined }; - return; - } - props[name] = desc; - }); - Object.defineProperties(nullObject, props); - - Object.defineProperty(shim, 'nullPolyfill', { configurable: false, - enumerable: false, writable: false, value: nullObject }); - - return function (prototype, props) { - return create((prototype === null) ? nullObject : prototype, props); - }; -}()); - -},{"./set-prototype-of/is-implemented":25,"./set-prototype-of/shim":26}],16:[function(require,module,exports){ -'use strict'; - -module.exports = require('./_iterate')('forEach'); - -},{"./_iterate":10}],17:[function(require,module,exports){ -// Deprecated - -'use strict'; - -module.exports = function (obj) { return typeof obj === 'function'; }; - -},{}],18:[function(require,module,exports){ -'use strict'; - -var map = { function: true, object: true }; - -module.exports = function (x) { - return ((x != null) && map[typeof x]) || false; -}; - -},{}],19:[function(require,module,exports){ -'use strict'; - -module.exports = require('./is-implemented')() - ? Object.keys - : require('./shim'); - -},{"./is-implemented":20,"./shim":21}],20:[function(require,module,exports){ -'use strict'; - -module.exports = function () { - try { - Object.keys('primitive'); - return true; - } catch (e) { return false; } -}; - -},{}],21:[function(require,module,exports){ -'use strict'; - -var keys = Object.keys; - -module.exports = function (object) { - return keys(object == null ? object : Object(object)); -}; - -},{}],22:[function(require,module,exports){ -'use strict'; - -var callable = require('./valid-callable') - , forEach = require('./for-each') - - , call = Function.prototype.call; - -module.exports = function (obj, cb/*, thisArg*/) { - var o = {}, thisArg = arguments[2]; - callable(cb); - forEach(obj, function (value, key, obj, index) { - o[key] = call.call(cb, thisArg, value, key, obj, index); - }); - return o; -}; - -},{"./for-each":16,"./valid-callable":27}],23:[function(require,module,exports){ -'use strict'; - -var forEach = Array.prototype.forEach, create = Object.create; - -var process = function (src, obj) { - var key; - for (key in src) obj[key] = src[key]; -}; - -module.exports = function (options/*, …options*/) { - var result = create(null); - forEach.call(arguments, function (options) { - if (options == null) return; - process(Object(options), result); - }); - return result; -}; - -},{}],24:[function(require,module,exports){ -'use strict'; - -module.exports = require('./is-implemented')() - ? Object.setPrototypeOf - : require('./shim'); - -},{"./is-implemented":25,"./shim":26}],25:[function(require,module,exports){ -'use strict'; - -var create = Object.create, getPrototypeOf = Object.getPrototypeOf - , x = {}; - -module.exports = function (/*customCreate*/) { - var setPrototypeOf = Object.setPrototypeOf - , customCreate = arguments[0] || create; - if (typeof setPrototypeOf !== 'function') return false; - return getPrototypeOf(setPrototypeOf(customCreate(null), x)) === x; -}; - -},{}],26:[function(require,module,exports){ -// Big thanks to @WebReflection for sorting this out -// https://gist.github.com/WebReflection/5593554 - -'use strict'; - -var isObject = require('../is-object') - , value = require('../valid-value') - - , isPrototypeOf = Object.prototype.isPrototypeOf - , defineProperty = Object.defineProperty - , nullDesc = { configurable: true, enumerable: false, writable: true, - value: undefined } - , validate; - -validate = function (obj, prototype) { - value(obj); - if ((prototype === null) || isObject(prototype)) return obj; - throw new TypeError('Prototype must be null or an object'); -}; - -module.exports = (function (status) { - var fn, set; - if (!status) return null; - if (status.level === 2) { - if (status.set) { - set = status.set; - fn = function (obj, prototype) { - set.call(validate(obj, prototype), prototype); - return obj; - }; - } else { - fn = function (obj, prototype) { - validate(obj, prototype).__proto__ = prototype; - return obj; - }; - } - } else { - fn = function self(obj, prototype) { - var isNullBase; - validate(obj, prototype); - isNullBase = isPrototypeOf.call(self.nullPolyfill, obj); - if (isNullBase) delete self.nullPolyfill.__proto__; - if (prototype === null) prototype = self.nullPolyfill; - obj.__proto__ = prototype; - if (isNullBase) defineProperty(self.nullPolyfill, '__proto__', nullDesc); - return obj; - }; - } - return Object.defineProperty(fn, 'level', { configurable: false, - enumerable: false, writable: false, value: status.level }); -}((function () { - var x = Object.create(null), y = {}, set - , desc = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__'); - - if (desc) { - try { - set = desc.set; // Opera crashes at this point - set.call(x, y); - } catch (ignore) { } - if (Object.getPrototypeOf(x) === y) return { set: set, level: 2 }; - } - - x.__proto__ = y; - if (Object.getPrototypeOf(x) === y) return { level: 2 }; - - x = {}; - x.__proto__ = y; - if (Object.getPrototypeOf(x) === y) return { level: 1 }; - - return false; -}()))); - -require('../create'); - -},{"../create":15,"../is-object":18,"../valid-value":29}],27:[function(require,module,exports){ -'use strict'; - -module.exports = function (fn) { - if (typeof fn !== 'function') throw new TypeError(fn + " is not a function"); - return fn; -}; - -},{}],28:[function(require,module,exports){ -'use strict'; - -var isObject = require('./is-object'); - -module.exports = function (value) { - if (!isObject(value)) throw new TypeError(value + " is not an Object"); - return value; -}; - -},{"./is-object":18}],29:[function(require,module,exports){ -'use strict'; - -module.exports = function (value) { - if (value == null) throw new TypeError("Cannot use null or undefined"); - return value; -}; - -},{}],30:[function(require,module,exports){ -'use strict'; - -module.exports = require('./is-implemented')() - ? String.prototype.contains - : require('./shim'); - -},{"./is-implemented":31,"./shim":32}],31:[function(require,module,exports){ -'use strict'; - -var str = 'razdwatrzy'; - -module.exports = function () { - if (typeof str.contains !== 'function') return false; - return ((str.contains('dwa') === true) && (str.contains('foo') === false)); -}; - -},{}],32:[function(require,module,exports){ -'use strict'; - -var indexOf = String.prototype.indexOf; - -module.exports = function (searchString/*, position*/) { - return indexOf.call(this, searchString, arguments[1]) > -1; -}; - -},{}],33:[function(require,module,exports){ -'use strict'; - -var toString = Object.prototype.toString - - , id = toString.call(''); - -module.exports = function (x) { - return (typeof x === 'string') || (x && (typeof x === 'object') && - ((x instanceof String) || (toString.call(x) === id))) || false; -}; - -},{}],34:[function(require,module,exports){ -'use strict'; - -var generated = Object.create(null) - - , random = Math.random; - -module.exports = function () { - var str; - do { str = random().toString(36).slice(2); } while (generated[str]); - return str; -}; - -},{}],35:[function(require,module,exports){ -'use strict'; - -var setPrototypeOf = require('es5-ext/object/set-prototype-of') - , contains = require('es5-ext/string/#/contains') - , d = require('d') - , Iterator = require('./') - - , defineProperty = Object.defineProperty - , ArrayIterator; - -ArrayIterator = module.exports = function (arr, kind) { - if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind); - Iterator.call(this, arr); - if (!kind) kind = 'value'; - else if (contains.call(kind, 'key+value')) kind = 'key+value'; - else if (contains.call(kind, 'key')) kind = 'key'; - else kind = 'value'; - defineProperty(this, '__kind__', d('', kind)); -}; -if (setPrototypeOf) setPrototypeOf(ArrayIterator, Iterator); - -ArrayIterator.prototype = Object.create(Iterator.prototype, { - constructor: d(ArrayIterator), - _resolve: d(function (i) { - if (this.__kind__ === 'value') return this.__list__[i]; - if (this.__kind__ === 'key+value') return [i, this.__list__[i]]; - return i; - }), - toString: d(function () { return '[object Array Iterator]'; }) -}); - -},{"./":38,"d":8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(require,module,exports){ -'use strict'; - -var callable = require('es5-ext/object/valid-callable') - , isString = require('es5-ext/string/is-string') - , get = require('./get') - - , isArray = Array.isArray, call = Function.prototype.call; - -module.exports = function (iterable, cb/*, thisArg*/) { - var mode, thisArg = arguments[2], result, doBreak, broken, i, l, char, code; - if (isArray(iterable)) mode = 'array'; - else if (isString(iterable)) mode = 'string'; - else iterable = get(iterable); - - callable(cb); - doBreak = function () { broken = true; }; - if (mode === 'array') { - iterable.some(function (value) { - call.call(cb, thisArg, value, doBreak); - if (broken) return true; - }); - return; - } - if (mode === 'string') { - l = iterable.length; - for (i = 0; i < l; ++i) { - char = iterable[i]; - if ((i + 1) < l) { - code = char.charCodeAt(0); - if ((code >= 0xD800) && (code <= 0xDBFF)) char += iterable[++i]; - } - call.call(cb, thisArg, char, doBreak); - if (broken) break; - } - return; - } - result = iterable.next(); - - while (!result.done) { - call.call(cb, thisArg, result.value, doBreak); - if (broken) return; - result = iterable.next(); - } -}; - -},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(require,module,exports){ -'use strict'; - -var isString = require('es5-ext/string/is-string') - , ArrayIterator = require('./array') - , StringIterator = require('./string') - , iterable = require('./valid-iterable') - , iteratorSymbol = require('es6-symbol').iterator; - -module.exports = function (obj) { - if (typeof iterable(obj)[iteratorSymbol] === 'function') return obj[iteratorSymbol](); - if (isString(obj)) return new StringIterator(obj); - return new ArrayIterator(obj); -}; - -},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(require,module,exports){ -'use strict'; - -var clear = require('es5-ext/array/#/clear') - , assign = require('es5-ext/object/assign') - , callable = require('es5-ext/object/valid-callable') - , value = require('es5-ext/object/valid-value') - , d = require('d') - , autoBind = require('d/auto-bind') - , Symbol = require('es6-symbol') - - , defineProperty = Object.defineProperty - , defineProperties = Object.defineProperties - , Iterator; - -module.exports = Iterator = function (list, context) { - if (!(this instanceof Iterator)) return new Iterator(list, context); - defineProperties(this, { - __list__: d('w', value(list)), - __context__: d('w', context), - __nextIndex__: d('w', 0) - }); - if (!context) return; - callable(context.on); - context.on('_add', this._onAdd); - context.on('_delete', this._onDelete); - context.on('_clear', this._onClear); -}; - -defineProperties(Iterator.prototype, assign({ - constructor: d(Iterator), - _next: d(function () { - var i; - if (!this.__list__) return; - if (this.__redo__) { - i = this.__redo__.shift(); - if (i !== undefined) return i; - } - if (this.__nextIndex__ < this.__list__.length) return this.__nextIndex__++; - this._unBind(); - }), - next: d(function () { return this._createResult(this._next()); }), - _createResult: d(function (i) { - if (i === undefined) return { done: true, value: undefined }; - return { done: false, value: this._resolve(i) }; - }), - _resolve: d(function (i) { return this.__list__[i]; }), - _unBind: d(function () { - this.__list__ = null; - delete this.__redo__; - if (!this.__context__) return; - this.__context__.off('_add', this._onAdd); - this.__context__.off('_delete', this._onDelete); - this.__context__.off('_clear', this._onClear); - this.__context__ = null; - }), - toString: d(function () { return '[object Iterator]'; }) -}, autoBind({ - _onAdd: d(function (index) { - if (index >= this.__nextIndex__) return; - ++this.__nextIndex__; - if (!this.__redo__) { - defineProperty(this, '__redo__', d('c', [index])); - return; - } - this.__redo__.forEach(function (redo, i) { - if (redo >= index) this.__redo__[i] = ++redo; - }, this); - this.__redo__.push(index); - }), - _onDelete: d(function (index) { - var i; - if (index >= this.__nextIndex__) return; - --this.__nextIndex__; - if (!this.__redo__) return; - i = this.__redo__.indexOf(index); - if (i !== -1) this.__redo__.splice(i, 1); - this.__redo__.forEach(function (redo, i) { - if (redo > index) this.__redo__[i] = --redo; - }, this); - }), - _onClear: d(function () { - if (this.__redo__) clear.call(this.__redo__); - this.__nextIndex__ = 0; - }) -}))); - -defineProperty(Iterator.prototype, Symbol.iterator, d(function () { - return this; -})); -defineProperty(Iterator.prototype, Symbol.toStringTag, d('', 'Iterator')); - -},{"d":8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(require,module,exports){ -'use strict'; - -var isString = require('es5-ext/string/is-string') - , iteratorSymbol = require('es6-symbol').iterator - - , isArray = Array.isArray; - -module.exports = function (value) { - if (value == null) return false; - if (isArray(value)) return true; - if (isString(value)) return true; - return (typeof value[iteratorSymbol] === 'function'); -}; - -},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(require,module,exports){ -// Thanks @mathiasbynens -// http://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols - -'use strict'; - -var setPrototypeOf = require('es5-ext/object/set-prototype-of') - , d = require('d') - , Iterator = require('./') - - , defineProperty = Object.defineProperty - , StringIterator; - -StringIterator = module.exports = function (str) { - if (!(this instanceof StringIterator)) return new StringIterator(str); - str = String(str); - Iterator.call(this, str); - defineProperty(this, '__length__', d('', str.length)); - -}; -if (setPrototypeOf) setPrototypeOf(StringIterator, Iterator); - -StringIterator.prototype = Object.create(Iterator.prototype, { - constructor: d(StringIterator), - _next: d(function () { - if (!this.__list__) return; - if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++; - this._unBind(); - }), - _resolve: d(function (i) { - var char = this.__list__[i], code; - if (this.__nextIndex__ === this.__length__) return char; - code = char.charCodeAt(0); - if ((code >= 0xD800) && (code <= 0xDBFF)) return char + this.__list__[this.__nextIndex__++]; - return char; - }), - toString: d(function () { return '[object String Iterator]'; }) -}); - -},{"./":38,"d":8,"es5-ext/object/set-prototype-of":24}],41:[function(require,module,exports){ -'use strict'; - -var isIterable = require('./is-iterable'); - -module.exports = function (value) { - if (!isIterable(value)) throw new TypeError(value + " is not iterable"); - return value; -}; - -},{"./is-iterable":39}],42:[function(require,module,exports){ -'use strict'; - -module.exports = require('./is-implemented')() ? Symbol : require('./polyfill'); - -},{"./is-implemented":43,"./polyfill":45}],43:[function(require,module,exports){ -'use strict'; - -module.exports = function () { - var symbol; - if (typeof Symbol !== 'function') return false; - symbol = Symbol('test symbol'); - try { String(symbol); } catch (e) { return false; } - if (typeof Symbol.iterator === 'symbol') return true; - - // Return 'true' for polyfills - if (typeof Symbol.isConcatSpreadable !== 'object') return false; - if (typeof Symbol.iterator !== 'object') return false; - if (typeof Symbol.toPrimitive !== 'object') return false; - if (typeof Symbol.toStringTag !== 'object') return false; - if (typeof Symbol.unscopables !== 'object') return false; - - return true; -}; - -},{}],44:[function(require,module,exports){ -'use strict'; - -module.exports = function (x) { - return (x && ((typeof x === 'symbol') || (x['@@toStringTag'] === 'Symbol'))) || false; -}; - -},{}],45:[function(require,module,exports){ -'use strict'; - -var d = require('d') - , validateSymbol = require('./validate-symbol') - - , create = Object.create, defineProperties = Object.defineProperties - , defineProperty = Object.defineProperty, objPrototype = Object.prototype - , Symbol, HiddenSymbol, globalSymbols = create(null); - -var generateName = (function () { - var created = create(null); - return function (desc) { - var postfix = 0, name; - while (created[desc + (postfix || '')]) ++postfix; - desc += (postfix || ''); - created[desc] = true; - name = '@@' + desc; - defineProperty(objPrototype, name, d.gs(null, function (value) { - defineProperty(this, name, d(value)); - })); - return name; - }; -}()); - -HiddenSymbol = function Symbol(description) { - if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor'); - return Symbol(description); -}; -module.exports = Symbol = function Symbol(description) { - var symbol; - if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor'); - symbol = create(HiddenSymbol.prototype); - description = (description === undefined ? '' : String(description)); - return defineProperties(symbol, { - __description__: d('', description), - __name__: d('', generateName(description)) - }); -}; -defineProperties(Symbol, { - for: d(function (key) { - if (globalSymbols[key]) return globalSymbols[key]; - return (globalSymbols[key] = Symbol(String(key))); - }), - keyFor: d(function (s) { - var key; - validateSymbol(s); - for (key in globalSymbols) if (globalSymbols[key] === s) return key; - }), - hasInstance: d('', Symbol('hasInstance')), - isConcatSpreadable: d('', Symbol('isConcatSpreadable')), - iterator: d('', Symbol('iterator')), - match: d('', Symbol('match')), - replace: d('', Symbol('replace')), - search: d('', Symbol('search')), - species: d('', Symbol('species')), - split: d('', Symbol('split')), - toPrimitive: d('', Symbol('toPrimitive')), - toStringTag: d('', Symbol('toStringTag')), - unscopables: d('', Symbol('unscopables')) -}); -defineProperties(HiddenSymbol.prototype, { - constructor: d(Symbol), - toString: d('', function () { return this.__name__; }) -}); - -defineProperties(Symbol.prototype, { - toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }), - valueOf: d(function () { return validateSymbol(this); }) -}); -defineProperty(Symbol.prototype, Symbol.toPrimitive, d('', - function () { return validateSymbol(this); })); -defineProperty(Symbol.prototype, Symbol.toStringTag, d('c', 'Symbol')); - -defineProperty(HiddenSymbol.prototype, Symbol.toPrimitive, - d('c', Symbol.prototype[Symbol.toPrimitive])); -defineProperty(HiddenSymbol.prototype, Symbol.toStringTag, - d('c', Symbol.prototype[Symbol.toStringTag])); - -},{"./validate-symbol":46,"d":8}],46:[function(require,module,exports){ -'use strict'; - -var isSymbol = require('./is-symbol'); - -module.exports = function (value) { - if (!isSymbol(value)) throw new TypeError(value + " is not a symbol"); - return value; -}; - -},{"./is-symbol":44}],47:[function(require,module,exports){ -'use strict'; - -var setPrototypeOf = require('es5-ext/object/set-prototype-of') - , object = require('es5-ext/object/valid-object') - , value = require('es5-ext/object/valid-value') - , randomUniq = require('es5-ext/string/random-uniq') - , d = require('d') - , getIterator = require('es6-iterator/get') - , forOf = require('es6-iterator/for-of') - , toStringTagSymbol = require('es6-symbol').toStringTag - , isNative = require('./is-native-implemented') - - , isArray = Array.isArray, defineProperty = Object.defineProperty - , hasOwnProperty = Object.prototype.hasOwnProperty, getPrototypeOf = Object.getPrototypeOf - , WeakMapPoly; - -module.exports = WeakMapPoly = function (/*iterable*/) { - var iterable = arguments[0], self; - if (!(this instanceof WeakMapPoly)) throw new TypeError('Constructor requires \'new\''); - if (isNative && setPrototypeOf && (WeakMap !== WeakMapPoly)) { - self = setPrototypeOf(new WeakMap(), getPrototypeOf(this)); - } else { - self = this; - } - if (iterable != null) { - if (!isArray(iterable)) iterable = getIterator(iterable); - } - defineProperty(self, '__weakMapData__', d('c', '$weakMap$' + randomUniq())); - if (!iterable) return self; - forOf(iterable, function (val) { - value(val); - self.set(val[0], val[1]); - }); - return self; -}; - -if (isNative) { - if (setPrototypeOf) setPrototypeOf(WeakMapPoly, WeakMap); - WeakMapPoly.prototype = Object.create(WeakMap.prototype, { - constructor: d(WeakMapPoly) - }); -} - -Object.defineProperties(WeakMapPoly.prototype, { - delete: d(function (key) { - if (hasOwnProperty.call(object(key), this.__weakMapData__)) { - delete key[this.__weakMapData__]; - return true; - } - return false; - }), - get: d(function (key) { - if (hasOwnProperty.call(object(key), this.__weakMapData__)) { - return key[this.__weakMapData__]; - } - }), - has: d(function (key) { - return hasOwnProperty.call(object(key), this.__weakMapData__); - }), - set: d(function (key, value) { - defineProperty(object(key), this.__weakMapData__, d('c', value)); - return this; - }), - toString: d(function () { return '[object WeakMap]'; }) -}); -defineProperty(WeakMapPoly.prototype, toStringTagSymbol, d('c', 'WeakMap')); - -},{"./is-native-implemented":6,"d":8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); +// Copyright (C) 2011 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/** + * @fileoverview Install a leaky WeakMap emulation on platforms that + * don't provide a built-in one. + * + *

Assumes that an ES5 platform where, if {@code WeakMap} is + * already present, then it conforms to the anticipated ES6 + * specification. To run this file on an ES5 or almost ES5 + * implementation where the {@code WeakMap} specification does not + * quite conform, run repairES5.js first. + * + *

Even though WeakMapModule is not global, the linter thinks it + * is, which is why it is in the overrides list below. + * + *

NOTE: Before using this WeakMap emulation in a non-SES + * environment, see the note below about hiddenRecord. + * + * @author Mark S. Miller + * @requires crypto, ArrayBuffer, Uint8Array, navigator, console + * @overrides WeakMap, ses, Proxy + * @overrides WeakMapModule + */ + +/** + * This {@code WeakMap} emulation is observably equivalent to the + * ES-Harmony WeakMap, but with leakier garbage collection properties. + * + *

As with true WeakMaps, in this emulation, a key does not + * retain maps indexed by that key and (crucially) a map does not + * retain the keys it indexes. A map by itself also does not retain + * the values associated with that map. + * + *

However, the values associated with a key in some map are + * retained so long as that key is retained and those associations are + * not overridden. For example, when used to support membranes, all + * values exported from a given membrane will live for the lifetime + * they would have had in the absence of an interposed membrane. Even + * when the membrane is revoked, all objects that would have been + * reachable in the absence of revocation will still be reachable, as + * far as the GC can tell, even though they will no longer be relevant + * to ongoing computation. + * + *

The API implemented here is approximately the API as implemented + * in FF6.0a1 and agreed to by MarkM, Andreas Gal, and Dave Herman, + * rather than the offially approved proposal page. TODO(erights): + * upgrade the ecmascript WeakMap proposal page to explain this API + * change and present to EcmaScript committee for their approval. + * + *

The first difference between the emulation here and that in + * FF6.0a1 is the presence of non enumerable {@code get___, has___, + * set___, and delete___} methods on WeakMap instances to represent + * what would be the hidden internal properties of a primitive + * implementation. Whereas the FF6.0a1 WeakMap.prototype methods + * require their {@code this} to be a genuine WeakMap instance (i.e., + * an object of {@code [[Class]]} "WeakMap}), since there is nothing + * unforgeable about the pseudo-internal method names used here, + * nothing prevents these emulated prototype methods from being + * applied to non-WeakMaps with pseudo-internal methods of the same + * names. + * + *

Another difference is that our emulated {@code + * WeakMap.prototype} is not itself a WeakMap. A problem with the + * current FF6.0a1 API is that WeakMap.prototype is itself a WeakMap + * providing ambient mutability and an ambient communications + * channel. Thus, if a WeakMap is already present and has this + * problem, repairES5.js wraps it in a safe wrappper in order to + * prevent access to this channel. (See + * PATCH_MUTABLE_FROZEN_WEAKMAP_PROTO in repairES5.js). + */ + +/** + * If this is a full secureable ES5 platform and the ES-Harmony {@code WeakMap} is + * absent, install an approximate emulation. + * + *

If WeakMap is present but cannot store some objects, use our approximate + * emulation as a wrapper. + * + *

If this is almost a secureable ES5 platform, then WeakMap.js + * should be run after repairES5.js. + * + *

See {@code WeakMap} for documentation of the garbage collection + * properties of this WeakMap emulation. + */ +(function WeakMapModule() { + "use strict"; + + if (typeof ses !== 'undefined' && ses.ok && !ses.ok()) { + // already too broken, so give up + return; + } + + /** + * In some cases (current Firefox), we must make a choice betweeen a + * WeakMap which is capable of using all varieties of host objects as + * keys and one which is capable of safely using proxies as keys. See + * comments below about HostWeakMap and DoubleWeakMap for details. + * + * This function (which is a global, not exposed to guests) marks a + * WeakMap as permitted to do what is necessary to index all host + * objects, at the cost of making it unsafe for proxies. + * + * Do not apply this function to anything which is not a genuine + * fresh WeakMap. + */ + function weakMapPermitHostObjects(map) { + // identity of function used as a secret -- good enough and cheap + if (map.permitHostObjects___) { + map.permitHostObjects___(weakMapPermitHostObjects); + } + } + if (typeof ses !== 'undefined') { + ses.weakMapPermitHostObjects = weakMapPermitHostObjects; + } + + // IE 11 has no Proxy but has a broken WeakMap such that we need to patch + // it using DoubleWeakMap; this flag tells DoubleWeakMap so. + var doubleWeakMapCheckSilentFailure = false; + + // Check if there is already a good-enough WeakMap implementation, and if so + // exit without replacing it. + if (typeof WeakMap === 'function') { + var HostWeakMap = WeakMap; + // There is a WeakMap -- is it good enough? + if (typeof navigator !== 'undefined' && + /Firefox/.test(navigator.userAgent)) { + // We're now *assuming not*, because as of this writing (2013-05-06) + // Firefox's WeakMaps have a miscellany of objects they won't accept, and + // we don't want to make an exhaustive list, and testing for just one + // will be a problem if that one is fixed alone (as they did for Event). + + // If there is a platform that we *can* reliably test on, here's how to + // do it: + // var problematic = ... ; + // var testHostMap = new HostWeakMap(); + // try { + // testHostMap.set(problematic, 1); // Firefox 20 will throw here + // if (testHostMap.get(problematic) === 1) { + // return; + // } + // } catch (e) {} + + } else { + // IE 11 bug: WeakMaps silently fail to store frozen objects. + var testMap = new HostWeakMap(); + var testObject = Object.freeze({}); + testMap.set(testObject, 1); + if (testMap.get(testObject) !== 1) { + doubleWeakMapCheckSilentFailure = true; + // Fall through to installing our WeakMap. + } else { + module.exports = WeakMap; + return; + } + } + } + + var hop = Object.prototype.hasOwnProperty; + var gopn = Object.getOwnPropertyNames; + var defProp = Object.defineProperty; + var isExtensible = Object.isExtensible; + + /** + * Security depends on HIDDEN_NAME being both unguessable and + * undiscoverable by untrusted code. + * + *

Given the known weaknesses of Math.random() on existing + * browsers, it does not generate unguessability we can be confident + * of. + * + *

It is the monkey patching logic in this file that is intended + * to ensure undiscoverability. The basic idea is that there are + * three fundamental means of discovering properties of an object: + * The for/in loop, Object.keys(), and Object.getOwnPropertyNames(), + * as well as some proposed ES6 extensions that appear on our + * whitelist. The first two only discover enumerable properties, and + * we only use HIDDEN_NAME to name a non-enumerable property, so the + * only remaining threat should be getOwnPropertyNames and some + * proposed ES6 extensions that appear on our whitelist. We monkey + * patch them to remove HIDDEN_NAME from the list of properties they + * returns. + * + *

TODO(erights): On a platform with built-in Proxies, proxies + * could be used to trap and thereby discover the HIDDEN_NAME, so we + * need to monkey patch Proxy.create, Proxy.createFunction, etc, in + * order to wrap the provided handler with the real handler which + * filters out all traps using HIDDEN_NAME. + * + *

TODO(erights): Revisit Mike Stay's suggestion that we use an + * encapsulated function at a not-necessarily-secret name, which + * uses the Stiegler shared-state rights amplification pattern to + * reveal the associated value only to the WeakMap in which this key + * is associated with that value. Since only the key retains the + * function, the function can also remember the key without causing + * leakage of the key, so this doesn't violate our general gc + * goals. In addition, because the name need not be a guarded + * secret, we could efficiently handle cross-frame frozen keys. + */ + var HIDDEN_NAME_PREFIX = 'weakmap:'; + var HIDDEN_NAME = HIDDEN_NAME_PREFIX + 'ident:' + Math.random() + '___'; + + if (typeof crypto !== 'undefined' && + typeof crypto.getRandomValues === 'function' && + typeof ArrayBuffer === 'function' && + typeof Uint8Array === 'function') { + var ab = new ArrayBuffer(25); + var u8s = new Uint8Array(ab); + crypto.getRandomValues(u8s); + HIDDEN_NAME = HIDDEN_NAME_PREFIX + 'rand:' + + Array.prototype.map.call(u8s, function(u8) { + return (u8 % 36).toString(36); + }).join('') + '___'; + } + + function isNotHiddenName(name) { + return !( + name.substr(0, HIDDEN_NAME_PREFIX.length) == HIDDEN_NAME_PREFIX && + name.substr(name.length - 3) === '___'); + } + + /** + * Monkey patch getOwnPropertyNames to avoid revealing the + * HIDDEN_NAME. + * + *

The ES5.1 spec requires each name to appear only once, but as + * of this writing, this requirement is controversial for ES6, so we + * made this code robust against this case. If the resulting extra + * search turns out to be expensive, we can probably relax this once + * ES6 is adequately supported on all major browsers, iff no browser + * versions we support at that time have relaxed this constraint + * without providing built-in ES6 WeakMaps. + */ + defProp(Object, 'getOwnPropertyNames', { + value: function fakeGetOwnPropertyNames(obj) { + return gopn(obj).filter(isNotHiddenName); + } + }); + + /** + * getPropertyNames is not in ES5 but it is proposed for ES6 and + * does appear in our whitelist, so we need to clean it too. + */ + if ('getPropertyNames' in Object) { + var originalGetPropertyNames = Object.getPropertyNames; + defProp(Object, 'getPropertyNames', { + value: function fakeGetPropertyNames(obj) { + return originalGetPropertyNames(obj).filter(isNotHiddenName); + } + }); + } + + /** + *

To treat objects as identity-keys with reasonable efficiency + * on ES5 by itself (i.e., without any object-keyed collections), we + * need to add a hidden property to such key objects when we + * can. This raises several issues: + *

    + *
  • Arranging to add this property to objects before we lose the + * chance, and + *
  • Hiding the existence of this new property from most + * JavaScript code. + *
  • Preventing certification theft, where one object is + * created falsely claiming to be the key of an association + * actually keyed by another object. + *
  • Preventing value theft, where untrusted code with + * access to a key object but not a weak map nevertheless + * obtains access to the value associated with that key in that + * weak map. + *
+ * We do so by + *
    + *
  • Making the name of the hidden property unguessable, so "[]" + * indexing, which we cannot intercept, cannot be used to access + * a property without knowing the name. + *
  • Making the hidden property non-enumerable, so we need not + * worry about for-in loops or {@code Object.keys}, + *
  • monkey patching those reflective methods that would + * prevent extensions, to add this hidden property first, + *
  • monkey patching those methods that would reveal this + * hidden property. + *
+ * Unfortunately, because of same-origin iframes, we cannot reliably + * add this hidden property before an object becomes + * non-extensible. Instead, if we encounter a non-extensible object + * without a hidden record that we can detect (whether or not it has + * a hidden record stored under a name secret to us), then we just + * use the key object itself to represent its identity in a brute + * force leaky map stored in the weak map, losing all the advantages + * of weakness for these. + */ + function getHiddenRecord(key) { + if (key !== Object(key)) { + throw new TypeError('Not an object: ' + key); + } + var hiddenRecord = key[HIDDEN_NAME]; + if (hiddenRecord && hiddenRecord.key === key) { return hiddenRecord; } + if (!isExtensible(key)) { + // Weak map must brute force, as explained in doc-comment above. + return void 0; + } + + // The hiddenRecord and the key point directly at each other, via + // the "key" and HIDDEN_NAME properties respectively. The key + // field is for quickly verifying that this hidden record is an + // own property, not a hidden record from up the prototype chain. + // + // NOTE: Because this WeakMap emulation is meant only for systems like + // SES where Object.prototype is frozen without any numeric + // properties, it is ok to use an object literal for the hiddenRecord. + // This has two advantages: + // * It is much faster in a performance critical place + // * It avoids relying on Object.create(null), which had been + // problematic on Chrome 28.0.1480.0. See + // https://code.google.com/p/google-caja/issues/detail?id=1687 + hiddenRecord = { key: key }; + + // When using this WeakMap emulation on platforms where + // Object.prototype might not be frozen and Object.create(null) is + // reliable, use the following two commented out lines instead. + // hiddenRecord = Object.create(null); + // hiddenRecord.key = key; + + // Please contact us if you need this to work on platforms where + // Object.prototype might not be frozen and + // Object.create(null) might not be reliable. + + try { + defProp(key, HIDDEN_NAME, { + value: hiddenRecord, + writable: false, + enumerable: false, + configurable: false + }); + return hiddenRecord; + } catch (error) { + // Under some circumstances, isExtensible seems to misreport whether + // the HIDDEN_NAME can be defined. + // The circumstances have not been isolated, but at least affect + // Node.js v0.10.26 on TravisCI / Linux, but not the same version of + // Node.js on OS X. + return void 0; + } + } + + /** + * Monkey patch operations that would make their argument + * non-extensible. + * + *

The monkey patched versions throw a TypeError if their + * argument is not an object, so it should only be done to functions + * that should throw a TypeError anyway if their argument is not an + * object. + */ + (function(){ + var oldFreeze = Object.freeze; + defProp(Object, 'freeze', { + value: function identifyingFreeze(obj) { + getHiddenRecord(obj); + return oldFreeze(obj); + } + }); + var oldSeal = Object.seal; + defProp(Object, 'seal', { + value: function identifyingSeal(obj) { + getHiddenRecord(obj); + return oldSeal(obj); + } + }); + var oldPreventExtensions = Object.preventExtensions; + defProp(Object, 'preventExtensions', { + value: function identifyingPreventExtensions(obj) { + getHiddenRecord(obj); + return oldPreventExtensions(obj); + } + }); + })(); + + function constFunc(func) { + func.prototype = null; + return Object.freeze(func); + } + + var calledAsFunctionWarningDone = false; + function calledAsFunctionWarning() { + // Future ES6 WeakMap is currently (2013-09-10) expected to reject WeakMap() + // but we used to permit it and do it ourselves, so warn only. + if (!calledAsFunctionWarningDone && typeof console !== 'undefined') { + calledAsFunctionWarningDone = true; + console.warn('WeakMap should be invoked as new WeakMap(), not ' + + 'WeakMap(). This will be an error in the future.'); + } + } + + var nextId = 0; + + var OurWeakMap = function() { + if (!(this instanceof OurWeakMap)) { // approximate test for new ...() + calledAsFunctionWarning(); + } + + // We are currently (12/25/2012) never encountering any prematurely + // non-extensible keys. + var keys = []; // brute force for prematurely non-extensible keys. + var values = []; // brute force for corresponding values. + var id = nextId++; + + function get___(key, opt_default) { + var index; + var hiddenRecord = getHiddenRecord(key); + if (hiddenRecord) { + return id in hiddenRecord ? hiddenRecord[id] : opt_default; + } else { + index = keys.indexOf(key); + return index >= 0 ? values[index] : opt_default; + } + } + + function has___(key) { + var hiddenRecord = getHiddenRecord(key); + if (hiddenRecord) { + return id in hiddenRecord; + } else { + return keys.indexOf(key) >= 0; + } + } + + function set___(key, value) { + var index; + var hiddenRecord = getHiddenRecord(key); + if (hiddenRecord) { + hiddenRecord[id] = value; + } else { + index = keys.indexOf(key); + if (index >= 0) { + values[index] = value; + } else { + // Since some browsers preemptively terminate slow turns but + // then continue computing with presumably corrupted heap + // state, we here defensively get keys.length first and then + // use it to update both the values and keys arrays, keeping + // them in sync. + index = keys.length; + values[index] = value; + // If we crash here, values will be one longer than keys. + keys[index] = key; + } + } + return this; + } + + function delete___(key) { + var hiddenRecord = getHiddenRecord(key); + var index, lastIndex; + if (hiddenRecord) { + return id in hiddenRecord && delete hiddenRecord[id]; + } else { + index = keys.indexOf(key); + if (index < 0) { + return false; + } + // Since some browsers preemptively terminate slow turns but + // then continue computing with potentially corrupted heap + // state, we here defensively get keys.length first and then use + // it to update both the keys and the values array, keeping + // them in sync. We update the two with an order of assignments, + // such that any prefix of these assignments will preserve the + // key/value correspondence, either before or after the delete. + // Note that this needs to work correctly when index === lastIndex. + lastIndex = keys.length - 1; + keys[index] = void 0; + // If we crash here, there's a void 0 in the keys array, but + // no operation will cause a "keys.indexOf(void 0)", since + // getHiddenRecord(void 0) will always throw an error first. + values[index] = values[lastIndex]; + // If we crash here, values[index] cannot be found here, + // because keys[index] is void 0. + keys[index] = keys[lastIndex]; + // If index === lastIndex and we crash here, then keys[index] + // is still void 0, since the aliasing killed the previous key. + keys.length = lastIndex; + // If we crash here, keys will be one shorter than values. + values.length = lastIndex; + return true; + } + } + + return Object.create(OurWeakMap.prototype, { + get___: { value: constFunc(get___) }, + has___: { value: constFunc(has___) }, + set___: { value: constFunc(set___) }, + delete___: { value: constFunc(delete___) } + }); + }; + + OurWeakMap.prototype = Object.create(Object.prototype, { + get: { + /** + * Return the value most recently associated with key, or + * opt_default if none. + */ + value: function get(key, opt_default) { + return this.get___(key, opt_default); + }, + writable: true, + configurable: true + }, + + has: { + /** + * Is there a value associated with key in this WeakMap? + */ + value: function has(key) { + return this.has___(key); + }, + writable: true, + configurable: true + }, + + set: { + /** + * Associate value with key in this WeakMap, overwriting any + * previous association if present. + */ + value: function set(key, value) { + return this.set___(key, value); + }, + writable: true, + configurable: true + }, + + 'delete': { + /** + * Remove any association for key in this WeakMap, returning + * whether there was one. + * + *

Note that the boolean return here does not work like the + * {@code delete} operator. The {@code delete} operator returns + * whether the deletion succeeds at bringing about a state in + * which the deleted property is absent. The {@code delete} + * operator therefore returns true if the property was already + * absent, whereas this {@code delete} method returns false if + * the association was already absent. + */ + value: function remove(key) { + return this.delete___(key); + }, + writable: true, + configurable: true + } + }); + + if (typeof HostWeakMap === 'function') { + (function() { + // If we got here, then the platform has a WeakMap but we are concerned + // that it may refuse to store some key types. Therefore, make a map + // implementation which makes use of both as possible. + + // In this mode we are always using double maps, so we are not proxy-safe. + // This combination does not occur in any known browser, but we had best + // be safe. + if (doubleWeakMapCheckSilentFailure && typeof Proxy !== 'undefined') { + Proxy = undefined; + } + + function DoubleWeakMap() { + if (!(this instanceof OurWeakMap)) { // approximate test for new ...() + calledAsFunctionWarning(); + } + + // Preferable, truly weak map. + var hmap = new HostWeakMap(); + + // Our hidden-property-based pseudo-weak-map. Lazily initialized in the + // 'set' implementation; thus we can avoid performing extra lookups if + // we know all entries actually stored are entered in 'hmap'. + var omap = undefined; + + // Hidden-property maps are not compatible with proxies because proxies + // can observe the hidden name and either accidentally expose it or fail + // to allow the hidden property to be set. Therefore, we do not allow + // arbitrary WeakMaps to switch to using hidden properties, but only + // those which need the ability, and unprivileged code is not allowed + // to set the flag. + // + // (Except in doubleWeakMapCheckSilentFailure mode in which case we + // disable proxies.) + var enableSwitching = false; + + function dget(key, opt_default) { + if (omap) { + return hmap.has(key) ? hmap.get(key) + : omap.get___(key, opt_default); + } else { + return hmap.get(key, opt_default); + } + } + + function dhas(key) { + return hmap.has(key) || (omap ? omap.has___(key) : false); + } + + var dset; + if (doubleWeakMapCheckSilentFailure) { + dset = function(key, value) { + hmap.set(key, value); + if (!hmap.has(key)) { + if (!omap) { omap = new OurWeakMap(); } + omap.set(key, value); + } + return this; + }; + } else { + dset = function(key, value) { + if (enableSwitching) { + try { + hmap.set(key, value); + } catch (e) { + if (!omap) { omap = new OurWeakMap(); } + omap.set___(key, value); + } + } else { + hmap.set(key, value); + } + return this; + }; + } + + function ddelete(key) { + var result = !!hmap['delete'](key); + if (omap) { return omap.delete___(key) || result; } + return result; + } + + return Object.create(OurWeakMap.prototype, { + get___: { value: constFunc(dget) }, + has___: { value: constFunc(dhas) }, + set___: { value: constFunc(dset) }, + delete___: { value: constFunc(ddelete) }, + permitHostObjects___: { value: constFunc(function(token) { + if (token === weakMapPermitHostObjects) { + enableSwitching = true; + } else { + throw new Error('bogus call to permitHostObjects___'); + } + })} + }); + } + DoubleWeakMap.prototype = OurWeakMap.prototype; + module.exports = DoubleWeakMap; + + // define .constructor to hide OurWeakMap ctor + Object.defineProperty(WeakMap.prototype, 'constructor', { + value: WeakMap, + enumerable: false, // as default .constructor is + configurable: true, + writable: true + }); + })(); + } else { + // There is no host WeakMap, so we must use the emulation. + + // Emulated WeakMaps are incompatible with native proxies (because proxies + // can observe the hidden name), so we must disable Proxy usage (in + // ArrayLike and Domado, currently). + if (typeof Proxy !== 'undefined') { + Proxy = undefined; + } + + module.exports = OurWeakMap; + } +})(); + +},{}]},{},[2]); diff --git a/build/srcset.min.js b/build/srcset.min.js index c0c62da..cd36b54 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function t(e,r,n){function i(s,a){if(!r[s]){if(!e[s]){var u=typeof require=="function"&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}var o=typeof require=="function"&&require;for(var s=0;s0){var s=o[o.length-1];var a=o.substring(0,o.length-1);var u=parseInt(a,10);var c=parseFloat(a);if(a.match(t)&&s==="w"){n[s]=u}else if(a.match(t)&&s=="h"){n[s]=u}else if(!isNaN(c)&&s=="x"){n[s]=c}else{this.error='Invalid srcset descriptor found in "'+o+'".';this.isValid=false}}}return n};function n(t){this.src=t.src;this.w=t.w||Infinity;this.h=t.h||Infinity;this.x=t.x||1}this.SrcsetInfo=r;if(typeof e!=="undefined"&&e!==null){e.exports=this.SrcsetInfo}})(this)},{}],2:[function(t,e,r){(function(){var r=this.ViewportInfo||t("./viewport-info");var n=this.SrcsetInfo||t("./srcset-info");var i=t("es6-weak-map");var o={};var s=new r;o.viewportInfo=s;s.compute();var a=(new Date).getTime();o.windowResizedAt=a;function u(t,e){var r=document.createElement("img");r.onload=function(){e(null)};r.src=t}function c(t,e,r){var n,i,o,s,a;var u=function(){var c=(new Date).getTime()-s;if(c=0){n=setTimeout(u,e-c)}else{n=null;if(!r){a=t.apply(o,i);if(!n)o=i=null}}};return function(){o=this;i=arguments;s=(new Date).getTime();var c=r&&!n;if(!n)n=setTimeout(u,e);if(c){a=t.apply(o,i);o=i=null}return a}}function l(t){this.el=t;this.srcsetInfo=new n({src:this.el.src,srcset:this.el.dataset.srcset})}l.prototype.update=function(t){t||(t={});var e=!this.srcupdatedat||this.srcupdatedate.w});this._removeCandidatesIf(e,function(t){return function(e){return e.we.h});this._removeCandidatesIf(e,function(t){return function(e){return e.he.x});this._removeCandidatesIf(e,function(t){return function(e){return e.xo.w});var s=this._getBestCandidateIf(e,function(t,e){return t.ho.h});var a=this._getBestCandidateIf(e,function(t,e){return t.xa.x});return e[0]};n.prototype._getBestCandidateIf=function(t,e){var r=t[0];for(var n=0;n=0;r--){var n=t[r];if(e(n)){t.splice(r,1)}}return t};n.prototype.getBestImage2=function(t){var e=null;var r=t.imageCandidates;for(var n=0;n-1}},{}],33:[function(t,e,r){"use strict";var n=Object.prototype.toString,i=n.call("");e.exports=function(t){return typeof t==="string"||t&&typeof t==="object"&&(t instanceof String||n.call(t)===i)||false}},{}],34:[function(t,e,r){"use strict";var n=Object.create(null),i=Math.random;e.exports=function(){var t;do{t=i().toString(36).slice(2)}while(n[t]);return t}},{}],35:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/string/#/contains"),o=t("d"),s=t("./"),a=Object.defineProperty,u;u=e.exports=function(t,e){if(!(this instanceof u))return new u(t,e);s.call(this,t);if(!e)e="value";else if(i.call(e,"key+value"))e="key+value";else if(i.call(e,"key"))e="key";else e="value";a(this,"__kind__",o("",e))};if(n)n(u,s);u.prototype=Object.create(s.prototype,{constructor:o(u),_resolve:o(function(t){if(this.__kind__==="value")return this.__list__[t];if(this.__kind__==="key+value")return[t,this.__list__[t]];return t}),toString:o(function(){return"[object Array Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/string/#/contains":30}],36:[function(t,e,r){"use strict";var n=t("es5-ext/object/valid-callable"),i=t("es5-ext/string/is-string"),o=t("./get"),s=Array.isArray,a=Function.prototype.call;e.exports=function(t,e){var r,u=arguments[2],c,l,f,p,_,h,d;if(s(t))r="array";else if(i(t))r="string";else t=o(t);n(e);l=function(){f=true};if(r==="array"){t.some(function(t){a.call(e,u,t,l);if(f)return true});return}if(r==="string"){_=t.length;for(p=0;p<_;++p){h=t[p];if(p+1<_){d=h.charCodeAt(0);if(d>=55296&&d<=56319)h+=t[++p]}a.call(e,u,h,l);if(f)break}return}c=t.next();while(!c.done){a.call(e,u,c.value,l);if(f)return;c=t.next()}}},{"./get":37,"es5-ext/object/valid-callable":27,"es5-ext/string/is-string":33}],37:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("./array"),o=t("./string"),s=t("./valid-iterable"),a=t("es6-symbol").iterator;e.exports=function(t){if(typeof s(t)[a]==="function")return t[a]();if(n(t))return new o(t);return new i(t)}},{"./array":35,"./string":40,"./valid-iterable":41,"es5-ext/string/is-string":33,"es6-symbol":42}],38:[function(t,e,r){"use strict";var n=t("es5-ext/array/#/clear"),i=t("es5-ext/object/assign"),o=t("es5-ext/object/valid-callable"),s=t("es5-ext/object/valid-value"),a=t("d"),u=t("d/auto-bind"),c=t("es6-symbol"),l=Object.defineProperty,f=Object.defineProperties,p;e.exports=p=function(t,e){if(!(this instanceof p))return new p(t,e);f(this,{__list__:a("w",s(t)),__context__:a("w",e),__nextIndex__:a("w",0)});if(!e)return;o(e.on);e.on("_add",this._onAdd);e.on("_delete",this._onDelete);e.on("_clear",this._onClear)};f(p.prototype,i({constructor:a(p),_next:a(function(){var t;if(!this.__list__)return;if(this.__redo__){t=this.__redo__.shift();if(t!==undefined)return t}if(this.__nextIndex__=this.__nextIndex__)return;++this.__nextIndex__;if(!this.__redo__){l(this,"__redo__",a("c",[t]));return}this.__redo__.forEach(function(e,r){if(e>=t)this.__redo__[r]=++e},this);this.__redo__.push(t)}),_onDelete:a(function(t){var e;if(t>=this.__nextIndex__)return;--this.__nextIndex__;if(!this.__redo__)return;e=this.__redo__.indexOf(t);if(e!==-1)this.__redo__.splice(e,1);this.__redo__.forEach(function(e,r){if(e>t)this.__redo__[r]=--e},this)}),_onClear:a(function(){if(this.__redo__)n.call(this.__redo__);this.__nextIndex__=0})})));l(p.prototype,c.iterator,a(function(){return this}));l(p.prototype,c.toStringTag,a("","Iterator"))},{d:8,"d/auto-bind":7,"es5-ext/array/#/clear":9,"es5-ext/object/assign":11,"es5-ext/object/valid-callable":27,"es5-ext/object/valid-value":29,"es6-symbol":42}],39:[function(t,e,r){"use strict";var n=t("es5-ext/string/is-string"),i=t("es6-symbol").iterator,o=Array.isArray;e.exports=function(t){if(t==null)return false;if(o(t))return true;if(n(t))return true;return typeof t[i]==="function"}},{"es5-ext/string/is-string":33,"es6-symbol":42}],40:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("d"),o=t("./"),s=Object.defineProperty,a;a=e.exports=function(t){if(!(this instanceof a))return new a(t);t=String(t);o.call(this,t);s(this,"__length__",i("",t.length))};if(n)n(a,o);a.prototype=Object.create(o.prototype,{constructor:i(a),_next:i(function(){if(!this.__list__)return;if(this.__nextIndex__=55296&&r<=56319)return e+this.__list__[this.__nextIndex__++];return e}),toString:i(function(){return"[object String Iterator]"})})},{"./":38,d:8,"es5-ext/object/set-prototype-of":24}],41:[function(t,e,r){"use strict";var n=t("./is-iterable");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not iterable");return t}},{"./is-iterable":39}],42:[function(t,e,r){"use strict";e.exports=t("./is-implemented")()?Symbol:t("./polyfill")},{"./is-implemented":43,"./polyfill":45}],43:[function(t,e,r){"use strict";e.exports=function(){var t;if(typeof Symbol!=="function")return false;t=Symbol("test symbol");try{String(t)}catch(e){return false}if(typeof Symbol.iterator==="symbol")return true;if(typeof Symbol.isConcatSpreadable!=="object")return false;if(typeof Symbol.iterator!=="object")return false;if(typeof Symbol.toPrimitive!=="object")return false;if(typeof Symbol.toStringTag!=="object")return false;if(typeof Symbol.unscopables!=="object")return false;return true}},{}],44:[function(t,e,r){"use strict";e.exports=function(t){return t&&(typeof t==="symbol"||t["@@toStringTag"]==="Symbol")||false}},{}],45:[function(t,e,r){"use strict";var n=t("d"),i=t("./validate-symbol"),o=Object.create,s=Object.defineProperties,a=Object.defineProperty,u=Object.prototype,c,l,f=o(null);var p=function(){var t=o(null);return function(e){var r=0,i;while(t[e+(r||"")])++r;e+=r||"";t[e]=true;i="@@"+e;a(u,i,n.gs(null,function(t){a(this,i,n(t))}));return i}}();l=function _(t){if(this instanceof l)throw new TypeError("TypeError: Symbol is not a constructor");return _(t)};e.exports=c=function h(t){var e;if(this instanceof h)throw new TypeError("TypeError: Symbol is not a constructor");e=o(l.prototype);t=t===undefined?"":String(t);return s(e,{__description__:n("",t),__name__:n("",p(t))})};s(c,{"for":n(function(t){if(f[t])return f[t];return f[t]=c(String(t))}),keyFor:n(function(t){var e;i(t);for(e in f)if(f[e]===t)return e}),hasInstance:n("",c("hasInstance")),isConcatSpreadable:n("",c("isConcatSpreadable")),iterator:n("",c("iterator")),match:n("",c("match")),replace:n("",c("replace")),search:n("",c("search")),species:n("",c("species")),split:n("",c("split")),toPrimitive:n("",c("toPrimitive")),toStringTag:n("",c("toStringTag")),unscopables:n("",c("unscopables"))});s(l.prototype,{constructor:n(c),toString:n("",function(){return this.__name__})});s(c.prototype,{toString:n(function(){return"Symbol ("+i(this).__description__+")"}),valueOf:n(function(){return i(this)})});a(c.prototype,c.toPrimitive,n("",function(){return i(this)}));a(c.prototype,c.toStringTag,n("c","Symbol"));a(l.prototype,c.toPrimitive,n("c",c.prototype[c.toPrimitive]));a(l.prototype,c.toStringTag,n("c",c.prototype[c.toStringTag]))},{"./validate-symbol":46,d:8}],46:[function(t,e,r){"use strict";var n=t("./is-symbol");e.exports=function(t){if(!n(t))throw new TypeError(t+" is not a symbol");return t}},{"./is-symbol":44}],47:[function(t,e,r){"use strict";var n=t("es5-ext/object/set-prototype-of"),i=t("es5-ext/object/valid-object"),o=t("es5-ext/object/valid-value"),s=t("es5-ext/string/random-uniq"),a=t("d"),u=t("es6-iterator/get"),c=t("es6-iterator/for-of"),l=t("es6-symbol").toStringTag,f=t("./is-native-implemented"),p=Array.isArray,_=Object.defineProperty,h=Object.prototype.hasOwnProperty,d=Object.getPrototypeOf,v;e.exports=v=function(){var t=arguments[0],e;if(!(this instanceof v))throw new TypeError("Constructor requires 'new'");if(f&&n&&WeakMap!==v){e=n(new WeakMap,d(this))}else{e=this}if(t!=null){if(!p(t))t=u(t)}_(e,"__weakMapData__",a("c","$weakMap$"+s()));if(!t)return e;c(t,function(t){o(t);e.set(t[0],t[1])});return e};if(f){if(n)n(v,WeakMap);v.prototype=Object.create(WeakMap.prototype,{constructor:a(v)})}Object.defineProperties(v.prototype,{"delete":a(function(t){if(h.call(i(t),this.__weakMapData__)){delete t[this.__weakMapData__];return true}return false}),get:a(function(t){if(h.call(i(t),this.__weakMapData__)){return t[this.__weakMapData__]}}),has:a(function(t){return h.call(i(t),this.__weakMapData__)}),set:a(function(t,e){_(i(t),this.__weakMapData__,a("c",e));return this}),toString:a(function(){return"[object WeakMap]"})});_(v.prototype,l,a("c","WeakMap"))},{"./is-native-implemented":6,d:8,"es5-ext/object/set-prototype-of":24,"es5-ext/object/valid-object":28,"es5-ext/object/valid-value":29,"es5-ext/string/random-uniq":34,"es6-iterator/for-of":36,"es6-iterator/get":37,"es6-symbol":42}]},{},[2]); \ No newline at end of file +(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");console.log("tataa");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t){var r=document.createElement("img");r.onload=function(){t(null)};r.src=e}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(b.prototype,{get___:{value:g(n)},has___:{value:g(i)},set___:{value:g(s)},delete___:{value:g(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function k(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof b)){m()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new b}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new b}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(b.prototype,{get___:{value:g(a)},has___:{value:g(o)},set___:{value:g(u)},delete___:{value:g(f)},permitHostObjects___:{value:g(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=b.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=b}})()},{}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index 6b3cda3..c1243e3 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -1,7 +1,8 @@ -(function() { +(function () { var ViewportInfo = this.ViewportInfo || require('./viewport-info'); var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); - var WeakMap = require('es6-weak-map'); + var WeakMap = require('weak-map'); + console.log('tataa'); var srcset = {}; @@ -54,13 +55,58 @@ }; } + // https://gist.github.com/stucox/5231211 + var hasMO = (function () { + var prefixes = ['WebKit', 'Moz', 'O', 'Ms', '']; + + for (var i=0; i < prefixes.length; i++) { + if ((prefixes[i] + 'MutationObserver') in window) { + return window[prefixes[i] + 'MutationObserver']; + } + } + + return false; + }()); + function SrcsetView(el) { this.el = el; - this.srcsetInfo = new SrcsetInfo({ + this.srcsetInfo = new SrcsetInfo(this.el, { src: this.el.src, srcset: this.el.dataset.srcset }); + + // + // Observe data-srcset attributes mutations to keep this.srcsetInfo up-to-date (if available) + // + + if (hasMO) { + this.mo = new MutationObserver(function (mutations) { + mutations.forEach(function (mutation) { + console.log(mutation); + + if (mutation.target === this.el && mutation.type === 'attributes') { + if (mutation.attributeName === 'src') { + this.srcsetInfo.srcValue = mutation.target.src; + } + + if (mutation.attributeName === 'data-srcset') { + this.srcsetInfo.imageCandidates = []; // reset imageCandidates + this.srcsetInfo.srcsetValue = mutation.target.dataset.srcset; + + this.srcsetInfo._parse(this.srcsetInfo.srcsetValue); + if (!this.srcsetInfo.isValid) { + console.error('Error: ' + this.srcsetInfo.error); + } + + this.update({force: true}); + } + } + }.bind(this)); + }.bind(this)); + + this.mo.observe(this.el, {attributes: true}); + } } SrcsetView.prototype.update = function (options) { options || (options = {}); @@ -74,30 +120,35 @@ if (this.srcsetInfo) { var bestImageInfo = viewportInfo.getBestImage(this.srcsetInfo); + var oldsrc = this.el.src; + var newsrc = bestImageInfo.src; + + if (newsrc === oldsrc) return false; // same, no need to update + + //console.log('updating src', this.el, oldsrc, newsrc); + + var eventdata = { + previous: oldsrc, + actual: newsrc, + bubbles: true + }; + // // 'srcchanging' event // - var srcchanging = new CustomEvent('srcchanging', { - previous: this.el.src, - actual: bestImageInfo.src, - bubbles: true - }); + var srcchanging = new CustomEvent('srcchanging', eventdata); this.el.dispatchEvent(srcchanging); // // 'srcchanged' event // - var srcchanged = new CustomEvent('srcchanged', { - previous: this.el.src, - actual: bestImageInfo.src, - bubbles: true - }); + var srcchanged = new CustomEvent('srcchanged', eventdata); // Wait the new image is loaded - imgloaded(bestImageInfo.src, function () { + imgloaded(newsrc, function () { // Change src - this.el.src = bestImageInfo.src; + this.el.src = newsrc; // Dispatch 'srcchanged' setTimeout(function () { @@ -120,6 +171,7 @@ // Update every images [].forEach.call(document.querySelectorAll('img[data-srcset]'), function (el) { + console.log('tata', el); var srcsetview = srcsetViews.get(el); if (!srcsetview) { srcsetview = new SrcsetView(el); diff --git a/package.json b/package.json index b5f4dd2..e331cae 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,6 @@ "uglify-js": "^2.4.24" }, "dependencies": { - "es6-weak-map": "^1.0.2" + "weak-map": "^1.0.2" } } From d77f503d29ab1bfdceb942a305e8999f559fa1d3 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 27 Dec 2015 12:42:31 +0100 Subject: [PATCH 18/26] fix --- build/srcset.js | 2 +- build/srcset.min.js | 2 +- js/srcset.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index 36e91b7..00dda39 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -229,7 +229,7 @@ function SrcsetView(el) { this.el = el; - this.srcsetInfo = new SrcsetInfo(this.el, { + this.srcsetInfo = new SrcsetInfo({ src: this.el.src, srcset: this.el.dataset.srcset }); diff --git a/build/srcset.min.js b/build/srcset.min.js index cd36b54..2a3c45c 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");console.log("tataa");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t){var r=document.createElement("img");r.onload=function(){t(null)};r.src=e}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(b.prototype,{get___:{value:g(n)},has___:{value:g(i)},set___:{value:g(s)},delete___:{value:g(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function k(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof b)){m()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new b}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new b}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(b.prototype,{get___:{value:g(a)},has___:{value:g(o)},set___:{value:g(u)},delete___:{value:g(f)},permitHostObjects___:{value:g(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=b.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=b}})()},{}]},{},[2]); \ No newline at end of file +(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");console.log("tataa");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t){var r=document.createElement("img");r.onload=function(){t(null)};r.src=e}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(b.prototype,{get___:{value:g(n)},has___:{value:g(i)},set___:{value:g(s)},delete___:{value:g(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function k(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof b)){m()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new b}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new b}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(b.prototype,{get___:{value:g(a)},has___:{value:g(o)},set___:{value:g(u)},delete___:{value:g(f)},permitHostObjects___:{value:g(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=b.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=b}})()},{}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index c1243e3..78d04c4 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -71,7 +71,7 @@ function SrcsetView(el) { this.el = el; - this.srcsetInfo = new SrcsetInfo(this.el, { + this.srcsetInfo = new SrcsetInfo({ src: this.el.src, srcset: this.el.dataset.srcset }); From 34ce0bb0c1bf968b9ed28ed0e5c0059bf0f1f250 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 27 Dec 2015 13:14:38 +0100 Subject: [PATCH 19/26] improve for non-MO support browsers --- build/srcset.js | 34 +++++++++++++++++++--------------- build/srcset.min.js | 2 +- js/srcset.js | 34 +++++++++++++++++++--------------- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index 00dda39..f63fa2b 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -244,20 +244,8 @@ console.log(mutation); if (mutation.target === this.el && mutation.type === 'attributes') { - if (mutation.attributeName === 'src') { - this.srcsetInfo.srcValue = mutation.target.src; - } - - if (mutation.attributeName === 'data-srcset') { - this.srcsetInfo.imageCandidates = []; // reset imageCandidates - this.srcsetInfo.srcsetValue = mutation.target.dataset.srcset; - - this.srcsetInfo._parse(this.srcsetInfo.srcsetValue); - if (!this.srcsetInfo.isValid) { - console.error('Error: ' + this.srcsetInfo.error); - } - - this.update({force: true}); + if (mutation.attributeName === 'src' || mutation.attributeName === 'data-srcset') { + this.update(); } } }.bind(this)); @@ -271,8 +259,24 @@ /*options = $.extend({}, options, { force: false });*/ + + if (this.srcsetInfo.srcValue !== this.el.src) { + this.srcsetInfo.srcValue = mutation.target.src; + } + + var srcsetchanged; + if (this.srcsetInfo.srcsetValue !== this.el.dataset.srcset) { + srcsetchanged = true; + + this.srcsetInfo.imageCandidates = []; // reset imageCandidates + this.srcsetInfo.srcsetValue = this.el.dataset.srcset; + this.srcsetInfo._parse(this.srcsetInfo.srcsetValue); + if (!this.srcsetInfo.isValid) { + console.error('Error: ' + this.srcsetInfo.error); + } + } - var needUpdate = (!this.srcupdatedat || this.srcupdatedat < windowResizedAt); + var needUpdate = (!this.srcupdatedat || this.srcupdatedat < windowResizedAt || srcsetchanged); if (!this.el.src || needUpdate || options.force) { if (this.srcsetInfo) { diff --git a/build/srcset.min.js b/build/srcset.min.js index 2a3c45c..a3e71d1 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");console.log("tataa");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t){var r=document.createElement("img");r.onload=function(){t(null)};r.src=e}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(b.prototype,{get___:{value:g(n)},has___:{value:g(i)},set___:{value:g(s)},delete___:{value:g(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function k(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof b)){m()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new b}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new b}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(b.prototype,{get___:{value:g(a)},has___:{value:g(o)},set___:{value:g(u)},delete___:{value:g(f)},permitHostObjects___:{value:g(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=b.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=b}})()},{}]},{},[2]); \ No newline at end of file +(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");console.log("tataa");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t){var r=document.createElement("img");r.onload=function(){t(null)};r.src=e}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(b.prototype,{get___:{value:g(n)},has___:{value:g(i)},set___:{value:g(s)},delete___:{value:g(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function V(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof b)){m()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new b}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new b}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(b.prototype,{get___:{value:g(a)},has___:{value:g(o)},set___:{value:g(u)},delete___:{value:g(f)},permitHostObjects___:{value:g(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=b.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=b}})()},{}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index 78d04c4..ee8b305 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -86,20 +86,8 @@ console.log(mutation); if (mutation.target === this.el && mutation.type === 'attributes') { - if (mutation.attributeName === 'src') { - this.srcsetInfo.srcValue = mutation.target.src; - } - - if (mutation.attributeName === 'data-srcset') { - this.srcsetInfo.imageCandidates = []; // reset imageCandidates - this.srcsetInfo.srcsetValue = mutation.target.dataset.srcset; - - this.srcsetInfo._parse(this.srcsetInfo.srcsetValue); - if (!this.srcsetInfo.isValid) { - console.error('Error: ' + this.srcsetInfo.error); - } - - this.update({force: true}); + if (mutation.attributeName === 'src' || mutation.attributeName === 'data-srcset') { + this.update(); } } }.bind(this)); @@ -113,8 +101,24 @@ /*options = $.extend({}, options, { force: false });*/ + + if (this.srcsetInfo.srcValue !== this.el.src) { + this.srcsetInfo.srcValue = mutation.target.src; + } + + var srcsetchanged; + if (this.srcsetInfo.srcsetValue !== this.el.dataset.srcset) { + srcsetchanged = true; + + this.srcsetInfo.imageCandidates = []; // reset imageCandidates + this.srcsetInfo.srcsetValue = this.el.dataset.srcset; + this.srcsetInfo._parse(this.srcsetInfo.srcsetValue); + if (!this.srcsetInfo.isValid) { + console.error('Error: ' + this.srcsetInfo.error); + } + } - var needUpdate = (!this.srcupdatedat || this.srcupdatedat < windowResizedAt); + var needUpdate = (!this.srcupdatedat || this.srcupdatedat < windowResizedAt || srcsetchanged); if (!this.el.src || needUpdate || options.force) { if (this.srcsetInfo) { From bd871767f4340b36c640cb4031d2ee2b31ef039a Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 27 Dec 2015 13:17:43 +0100 Subject: [PATCH 20/26] -console.log --- build/srcset.js | 4 +--- build/srcset.min.js | 2 +- js/srcset.js | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index f63fa2b..2b11341 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -160,7 +160,6 @@ var ViewportInfo = this.ViewportInfo || require('./viewport-info'); var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); var WeakMap = require('weak-map'); - console.log('tataa'); var srcset = {}; @@ -241,7 +240,7 @@ if (hasMO) { this.mo = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { - console.log(mutation); + //console.log(mutation); if (mutation.target === this.el && mutation.type === 'attributes') { if (mutation.attributeName === 'src' || mutation.attributeName === 'data-srcset') { @@ -333,7 +332,6 @@ // Update every images [].forEach.call(document.querySelectorAll('img[data-srcset]'), function (el) { - console.log('tata', el); var srcsetview = srcsetViews.get(el); if (!srcsetview) { srcsetview = new SrcsetView(el); diff --git a/build/srcset.min.js b/build/srcset.min.js index a3e71d1..3933805 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");console.log("tataa");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t){var r=document.createElement("img");r.onload=function(){t(null)};r.src=e}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(b.prototype,{get___:{value:g(n)},has___:{value:g(i)},set___:{value:g(s)},delete___:{value:g(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function V(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof b)){m()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new b}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new b}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(b.prototype,{get___:{value:g(a)},has___:{value:g(o)},set___:{value:g(u)},delete___:{value:g(f)},permitHostObjects___:{value:g(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=b.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=b}})()},{}]},{},[2]); \ No newline at end of file +(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t){var r=document.createElement("img");r.onload=function(){t(null)};r.src=e}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(b.prototype,{get___:{value:w(n)},has___:{value:w(i)},set___:{value:w(s)},delete___:{value:w(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function V(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof b)){m()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new b}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new b}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(b.prototype,{get___:{value:w(a)},has___:{value:w(o)},set___:{value:w(u)},delete___:{value:w(f)},permitHostObjects___:{value:w(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=b.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=b}})()},{}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index ee8b305..2a3323b 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -2,7 +2,6 @@ var ViewportInfo = this.ViewportInfo || require('./viewport-info'); var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); var WeakMap = require('weak-map'); - console.log('tataa'); var srcset = {}; @@ -83,7 +82,7 @@ if (hasMO) { this.mo = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { - console.log(mutation); + //console.log(mutation); if (mutation.target === this.el && mutation.type === 'attributes') { if (mutation.attributeName === 'src' || mutation.attributeName === 'data-srcset') { @@ -175,7 +174,6 @@ // Update every images [].forEach.call(document.querySelectorAll('img[data-srcset]'), function (el) { - console.log('tata', el); var srcsetview = srcsetViews.get(el); if (!srcsetview) { srcsetview = new SrcsetView(el); From de30d8397983d4386e25d36af6e5a84a27e22fb6 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 27 Dec 2015 13:19:46 +0100 Subject: [PATCH 21/26] fix --- build/srcset.js | 2 +- build/srcset.min.js | 2 +- js/srcset.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index 2b11341..705aaab 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -260,7 +260,7 @@ });*/ if (this.srcsetInfo.srcValue !== this.el.src) { - this.srcsetInfo.srcValue = mutation.target.src; + this.srcsetInfo.srcValue = this.el.src; } var srcsetchanged; diff --git a/build/srcset.min.js b/build/srcset.min.js index 3933805..89cbb7e 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t){var r=document.createElement("img");r.onload=function(){t(null)};r.src=e}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(b.prototype,{get___:{value:w(n)},has___:{value:w(i)},set___:{value:w(s)},delete___:{value:w(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function V(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof b)){m()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new b}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new b}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(b.prototype,{get___:{value:w(a)},has___:{value:w(o)},set___:{value:w(u)},delete___:{value:w(f)},permitHostObjects___:{value:w(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=b.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=b}})()},{}]},{},[2]); \ No newline at end of file +(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t){var r=document.createElement("img");r.onload=function(){t(null)};r.src=e}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(b.prototype,{get___:{value:w(n)},has___:{value:w(i)},set___:{value:w(s)},delete___:{value:w(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function V(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof b)){m()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new b}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new b}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(b.prototype,{get___:{value:w(a)},has___:{value:w(o)},set___:{value:w(u)},delete___:{value:w(f)},permitHostObjects___:{value:w(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=b.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=b}})()},{}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index 2a3323b..a4fa9eb 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -102,7 +102,7 @@ });*/ if (this.srcsetInfo.srcValue !== this.el.src) { - this.srcsetInfo.srcValue = mutation.target.src; + this.srcsetInfo.srcValue = this.el.src; } var srcsetchanged; From 39674b05a8baec1d57acb47e015785ae4880f212 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 27 Dec 2015 15:48:44 +0100 Subject: [PATCH 22/26] progress --- build/srcset.js | 35 ++++++++++++++++++++++++++--------- build/srcset.min.js | 2 +- js/srcset.js | 35 ++++++++++++++++++++++++++--------- 3 files changed, 53 insertions(+), 19 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index 705aaab..6134d84 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -170,13 +170,25 @@ var windowResizedAt = (new Date).getTime(); srcset.windowResizedAt = windowResizedAt; - // https://gist.github.com/abernier/6461914#imgloaded - function imgloaded(src, cb) { - var img = document.createElement('img'); - img.onload = function () { + // https://gist.github.com/abernier/6461914#load-with-progress + function progress(url, tick, cb) { + tick || (tick = function () {}); + cb || (cb = function () {}); + + var xhr = new XMLHttpRequest(); + xhr.onprogress = function (e) { + if (e.lengthComputable) { + tick(e.loaded / e.total); + } + }; + xhr.onload = function () { cb(null); - } - img.src = src; + }; + xhr.onerror = function (er) { + cb(er); + }; + xhr.open("GET", url, true); + xhr.send(); } // Picked from underscore.js @@ -306,9 +318,14 @@ // var srcchanged = new CustomEvent('srcchanged', eventdata); - // Wait the new image is loaded - imgloaded(newsrc, function () { - // Change src + + // Wait the new image is loaded and send 'srcprogress' + progress(newsrc, function (percent) { + var srcprogress = new CustomEvent('srcprogress', percent); + this.el.dispatchEvent(srcprogress); + }.bind(this), function (er) { + if (er) return console.error(er); + this.el.src = newsrc; // Dispatch 'srcchanged' diff --git a/build/srcset.min.js b/build/srcset.min.js index 89cbb7e..16791f6 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t){var r=document.createElement("img");r.onload=function(){t(null)};r.src=e}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(b.prototype,{get___:{value:w(n)},has___:{value:w(i)},set___:{value:w(s)},delete___:{value:w(a)}})};b.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function V(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof b)){m()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new b}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new b}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(b.prototype,{get___:{value:w(a)},has___:{value:w(o)},set___:{value:w(u)},delete___:{value:w(f)},permitHostObjects___:{value:w(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=b.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=b}})()},{}]},{},[2]); \ No newline at end of file +(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t,r){t||(t=function(){});r||(r=function(){});var n=new XMLHttpRequest;n.onprogress=function(e){if(e.lengthComputable){t(e.loaded/e.total)}};n.onload=function(){r(null)};n.onerror=function(e){r(e)};n.open("GET",e,true);n.send()}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(y.prototype,{get___:{value:w(n)},has___:{value:w(i)},set___:{value:w(s)},delete___:{value:w(a)}})};y.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function E(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof y)){b()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new y}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new y}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(y.prototype,{get___:{value:w(a)},has___:{value:w(o)},set___:{value:w(u)},delete___:{value:w(f)},permitHostObjects___:{value:w(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=y.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=y}})()},{}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index a4fa9eb..5cc0a73 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -12,13 +12,25 @@ var windowResizedAt = (new Date).getTime(); srcset.windowResizedAt = windowResizedAt; - // https://gist.github.com/abernier/6461914#imgloaded - function imgloaded(src, cb) { - var img = document.createElement('img'); - img.onload = function () { + // https://gist.github.com/abernier/6461914#load-with-progress + function progress(url, tick, cb) { + tick || (tick = function () {}); + cb || (cb = function () {}); + + var xhr = new XMLHttpRequest(); + xhr.onprogress = function (e) { + if (e.lengthComputable) { + tick(e.loaded / e.total); + } + }; + xhr.onload = function () { cb(null); - } - img.src = src; + }; + xhr.onerror = function (er) { + cb(er); + }; + xhr.open("GET", url, true); + xhr.send(); } // Picked from underscore.js @@ -148,9 +160,14 @@ // var srcchanged = new CustomEvent('srcchanged', eventdata); - // Wait the new image is loaded - imgloaded(newsrc, function () { - // Change src + + // Wait the new image is loaded and send 'srcprogress' + progress(newsrc, function (percent) { + var srcprogress = new CustomEvent('srcprogress', percent); + this.el.dispatchEvent(srcprogress); + }.bind(this), function (er) { + if (er) return console.error(er); + this.el.src = newsrc; // Dispatch 'srcchanged' From 7e08f964a318f01cf143982c0ff2671dfdddb575 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 27 Dec 2015 15:52:28 +0100 Subject: [PATCH 23/26] fix --- build/srcset.js | 2 +- build/srcset.min.js | 2 +- js/srcset.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index 6134d84..3501122 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -321,7 +321,7 @@ // Wait the new image is loaded and send 'srcprogress' progress(newsrc, function (percent) { - var srcprogress = new CustomEvent('srcprogress', percent); + var srcprogress = new CustomEvent('srcprogress', {percent: percent}); this.el.dispatchEvent(srcprogress); }.bind(this), function (er) { if (er) return console.error(er); diff --git a/build/srcset.min.js b/build/srcset.min.js index 16791f6..30d67f5 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t,r){t||(t=function(){});r||(r=function(){});var n=new XMLHttpRequest;n.onprogress=function(e){if(e.lengthComputable){t(e.loaded/e.total)}};n.onload=function(){r(null)};n.onerror=function(e){r(e)};n.open("GET",e,true);n.send()}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(y.prototype,{get___:{value:w(n)},has___:{value:w(i)},set___:{value:w(s)},delete___:{value:w(a)}})};y.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function E(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof y)){b()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new y}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new y}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(y.prototype,{get___:{value:w(a)},has___:{value:w(o)},set___:{value:w(u)},delete___:{value:w(f)},permitHostObjects___:{value:w(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=y.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=y}})()},{}]},{},[2]); \ No newline at end of file +(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t,r){t||(t=function(){});r||(r=function(){});var n=new XMLHttpRequest;n.onprogress=function(e){if(e.lengthComputable){t(e.loaded/e.total)}};n.onload=function(){r(null)};n.onerror=function(e){r(e)};n.open("GET",e,true);n.send()}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(y.prototype,{get___:{value:w(n)},has___:{value:w(i)},set___:{value:w(s)},delete___:{value:w(a)}})};y.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function E(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof y)){b()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new y}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new y}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(y.prototype,{get___:{value:w(a)},has___:{value:w(o)},set___:{value:w(u)},delete___:{value:w(f)},permitHostObjects___:{value:w(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=y.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=y}})()},{}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index 5cc0a73..47e4950 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -163,7 +163,7 @@ // Wait the new image is loaded and send 'srcprogress' progress(newsrc, function (percent) { - var srcprogress = new CustomEvent('srcprogress', percent); + var srcprogress = new CustomEvent('srcprogress', {percent: percent}); this.el.dispatchEvent(srcprogress); }.bind(this), function (er) { if (er) return console.error(er); From 31652792116aa586394baefed9bd142672d9f16c Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Sun, 27 Dec 2015 19:21:06 +0100 Subject: [PATCH 24/26] simplifying --- build/srcset.js | 67 ++++++++++----------------------------------- build/srcset.min.js | 2 +- js/srcset.js | 67 ++++++++++----------------------------------- 3 files changed, 31 insertions(+), 105 deletions(-) diff --git a/build/srcset.js b/build/srcset.js index 3501122..a130902 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -170,27 +170,6 @@ var windowResizedAt = (new Date).getTime(); srcset.windowResizedAt = windowResizedAt; - // https://gist.github.com/abernier/6461914#load-with-progress - function progress(url, tick, cb) { - tick || (tick = function () {}); - cb || (cb = function () {}); - - var xhr = new XMLHttpRequest(); - xhr.onprogress = function (e) { - if (e.lengthComputable) { - tick(e.loaded / e.total); - } - }; - xhr.onload = function () { - cb(null); - }; - xhr.onerror = function (er) { - cb(er); - }; - xhr.open("GET", url, true); - xhr.send(); - } - // Picked from underscore.js function debounce(func, wait, immediate) { var timeout, args, context, timestamp, result; @@ -287,8 +266,8 @@ } } - var needUpdate = (!this.srcupdatedat || this.srcupdatedat < windowResizedAt || srcsetchanged); - if (!this.el.src || needUpdate || options.force) { + var needUpdate = (!this.srcupdatedat || this.srcupdatedat < windowResizedAt); + if (!this.el.src || needUpdate || srcsetchanged || options.force) { if (this.srcsetInfo) { var bestImageInfo = viewportInfo.getBestImage(this.srcsetInfo); @@ -300,39 +279,23 @@ //console.log('updating src', this.el, oldsrc, newsrc); - var eventdata = { - previous: oldsrc, - actual: newsrc, - bubbles: true - }; - - // - // 'srcchanging' event - // - - var srcchanging = new CustomEvent('srcchanging', eventdata); - this.el.dispatchEvent(srcchanging); - // // 'srcchanged' event // - var srcchanged = new CustomEvent('srcchanged', eventdata); - - // Wait the new image is loaded and send 'srcprogress' - progress(newsrc, function (percent) { - var srcprogress = new CustomEvent('srcprogress', {percent: percent}); - this.el.dispatchEvent(srcprogress); - }.bind(this), function (er) { - if (er) return console.error(er); - - this.el.src = newsrc; - - // Dispatch 'srcchanged' - setTimeout(function () { - this.el.dispatchEvent(srcchanged); - }.bind(this), 0); - }.bind(this)); + var srcchanged = new CustomEvent('srcchanged', { + detail: { + previous: oldsrc, + actual: newsrc + }, + bubbles: true + }); + + this.el.src = newsrc; + // Dispatch 'srcchanged' + setTimeout(function () { + this.el.dispatchEvent(srcchanged); + }.bind(this), 0); } // Remember when updated to compare with window's resizeAt timestamp diff --git a/build/srcset.min.js b/build/srcset.min.js index 30d67f5..bdbc1fe 100644 --- a/build/srcset.min.js +++ b/build/srcset.min.js @@ -1 +1 @@ -(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t,r){t||(t=function(){});r||(r=function(){});var n=new XMLHttpRequest;n.onprogress=function(e){if(e.lengthComputable){t(e.loaded/e.total)}};n.onload=function(){r(null)};n.onerror=function(e){r(e)};n.open("GET",e,true);n.send()}function f(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var c=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(y.prototype,{get___:{value:w(n)},has___:{value:w(i)},set___:{value:w(s)},delete___:{value:w(a)}})};y.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function E(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof y)){b()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new y}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new y}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(y.prototype,{get___:{value:w(a)},has___:{value:w(o)},set___:{value:w(u)},delete___:{value:w(f)},permitHostObjects___:{value:w(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=y.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=y}})()},{}]},{},[2]); \ No newline at end of file +(function e(t,r,n){function i(a,o){if(!r[a]){if(!t[a]){var u=typeof require=="function"&&require;if(!o&&u)return u(a,!0);if(s)return s(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var c=r[a]={exports:{}};t[a][0].call(c.exports,function(e){var r=t[a][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[a].exports}var s=typeof require=="function"&&require;for(var a=0;a0){var a=s[s.length-1];var o=s.substring(0,s.length-1);var u=parseInt(o,10);var f=parseFloat(o);if(o.match(e)&&a==="w"){n[a]=u}else if(o.match(e)&&a=="h"){n[a]=u}else if(!isNaN(f)&&a=="x"){n[a]=f}else{this.error='Invalid srcset descriptor found in "'+s+'".';this.isValid=false}}}return n};function n(e){this.src=e.src;this.w=e.w||Infinity;this.h=e.h||Infinity;this.x=e.x||1}this.SrcsetInfo=r;if(typeof t!=="undefined"&&t!==null){t.exports=this.SrcsetInfo}})(this)},{}],2:[function(e,t,r){(function(){var r=this.ViewportInfo||e("./viewport-info");var n=this.SrcsetInfo||e("./srcset-info");var i=e("weak-map");var s={};var a=new r;s.viewportInfo=a;a.compute();var o=(new Date).getTime();s.windowResizedAt=o;function u(e,t,r){var n,i,s,a,o;var u=function(){var f=(new Date).getTime()-a;if(f=0){n=setTimeout(u,t-f)}else{n=null;if(!r){o=e.apply(s,i);if(!n)s=i=null}}};return function(){s=this;i=arguments;a=(new Date).getTime();var f=r&&!n;if(!n)n=setTimeout(u,t);if(f){o=e.apply(s,i);s=i=null}return o}}var f=function(){var e=["WebKit","Moz","O","Ms",""];for(var t=0;tt.w});this._removeCandidatesIf(t,function(e){return function(t){return t.wt.h});this._removeCandidatesIf(t,function(e){return function(t){return t.ht.x});this._removeCandidatesIf(t,function(e){return function(t){return t.xs.w});var a=this._getBestCandidateIf(t,function(e,t){return e.hs.h});var o=this._getBestCandidateIf(t,function(e,t){return e.xo.x});return t[0]};n.prototype._getBestCandidateIf=function(e,t){var r=e[0];for(var n=0;n=0;r--){var n=e[r];if(t(n)){e.splice(r,1)}}return e};n.prototype.getBestImage2=function(e){var t=null;var r=e.imageCandidates;for(var n=0;n=0?t[s]:i}}function i(t){var n=_(t);if(n){return r in n}else{return e.indexOf(t)>=0}}function s(n,i){var s;var a=_(n);if(a){a[r]=i}else{s=e.indexOf(n);if(s>=0){t[s]=i}else{s=e.length;t[s]=i;e[s]=n}}return this}function a(n){var i=_(n);var s,a;if(i){return r in i&&delete i[r]}else{s=e.indexOf(n);if(s<0){return false}a=e.length-1;e[s]=void 0;t[s]=t[a];e[s]=e[a];e.length=a;t.length=a;return true}}return Object.create(m.prototype,{get___:{value:w(n)},has___:{value:w(i)},set___:{value:w(s)},delete___:{value:w(a)}})};m.prototype=Object.create(Object.prototype,{get:{value:function I(e,t){return this.get___(e,t)},writable:true,configurable:true},has:{value:function j(e){return this.has___(e)},writable:true,configurable:true},set:{value:function C(e,t){return this.set___(e,t)},writable:true,configurable:true},"delete":{value:function V(e){return this.delete___(e)},writable:true,configurable:true}});if(typeof n==="function"){(function(){if(r&&typeof Proxy!=="undefined"){Proxy=undefined}function i(){if(!(this instanceof m)){y()}var t=new n;var i=undefined;var s=false;function a(e,r){if(i){return t.has(e)?t.get(e):i.get___(e,r)}else{return t.get(e,r)}}function o(e){return t.has(e)||(i?i.has___(e):false)}var u;if(r){u=function(e,r){t.set(e,r);if(!t.has(e)){if(!i){i=new m}i.set(e,r)}return this}}else{u=function(e,r){if(s){try{t.set(e,r)}catch(n){if(!i){i=new m}i.set___(e,r)}}else{t.set(e,r)}return this}}function f(e){var r=!!t["delete"](e);if(i){return i.delete___(e)||r}return r}return Object.create(m.prototype,{get___:{value:w(a)},has___:{value:w(o)},set___:{value:w(u)},delete___:{value:w(f)},permitHostObjects___:{value:w(function(t){if(t===e){s=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}i.prototype=m.prototype;t.exports=i;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}t.exports=m}})()},{}]},{},[2]); \ No newline at end of file diff --git a/js/srcset.js b/js/srcset.js index 47e4950..b7bb33c 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -12,27 +12,6 @@ var windowResizedAt = (new Date).getTime(); srcset.windowResizedAt = windowResizedAt; - // https://gist.github.com/abernier/6461914#load-with-progress - function progress(url, tick, cb) { - tick || (tick = function () {}); - cb || (cb = function () {}); - - var xhr = new XMLHttpRequest(); - xhr.onprogress = function (e) { - if (e.lengthComputable) { - tick(e.loaded / e.total); - } - }; - xhr.onload = function () { - cb(null); - }; - xhr.onerror = function (er) { - cb(er); - }; - xhr.open("GET", url, true); - xhr.send(); - } - // Picked from underscore.js function debounce(func, wait, immediate) { var timeout, args, context, timestamp, result; @@ -129,8 +108,8 @@ } } - var needUpdate = (!this.srcupdatedat || this.srcupdatedat < windowResizedAt || srcsetchanged); - if (!this.el.src || needUpdate || options.force) { + var needUpdate = (!this.srcupdatedat || this.srcupdatedat < windowResizedAt); + if (!this.el.src || needUpdate || srcsetchanged || options.force) { if (this.srcsetInfo) { var bestImageInfo = viewportInfo.getBestImage(this.srcsetInfo); @@ -142,39 +121,23 @@ //console.log('updating src', this.el, oldsrc, newsrc); - var eventdata = { - previous: oldsrc, - actual: newsrc, - bubbles: true - }; - - // - // 'srcchanging' event - // - - var srcchanging = new CustomEvent('srcchanging', eventdata); - this.el.dispatchEvent(srcchanging); - // // 'srcchanged' event // - var srcchanged = new CustomEvent('srcchanged', eventdata); - - // Wait the new image is loaded and send 'srcprogress' - progress(newsrc, function (percent) { - var srcprogress = new CustomEvent('srcprogress', {percent: percent}); - this.el.dispatchEvent(srcprogress); - }.bind(this), function (er) { - if (er) return console.error(er); - - this.el.src = newsrc; - - // Dispatch 'srcchanged' - setTimeout(function () { - this.el.dispatchEvent(srcchanged); - }.bind(this), 0); - }.bind(this)); + var srcchanged = new CustomEvent('srcchanged', { + detail: { + previous: oldsrc, + actual: newsrc + }, + bubbles: true + }); + + this.el.src = newsrc; + // Dispatch 'srcchanged' + setTimeout(function () { + this.el.dispatchEvent(srcchanged); + }.bind(this), 0); } // Remember when updated to compare with window's resizeAt timestamp From 3b3102ed715712f2b6294ba061c11eb8e53050b2 Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Wed, 13 Apr 2016 11:41:09 +0200 Subject: [PATCH 25/26] Update srcset.js --- js/srcset.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/js/srcset.js b/js/srcset.js index b7bb33c..c64aeb7 100644 --- a/js/srcset.js +++ b/js/srcset.js @@ -1,3 +1,22 @@ +(function () { + // + // CustomEvent polyfill (https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill) + // + + if ( typeof window.CustomEvent === "function" ) return false; + + function CustomEvent ( event, params ) { + params = params || { bubbles: false, cancelable: false, detail: undefined }; + var evt = document.createEvent( 'CustomEvent' ); + evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail ); + return evt; + } + + CustomEvent.prototype = window.Event.prototype; + + window.CustomEvent = CustomEvent; +})(); + (function () { var ViewportInfo = this.ViewportInfo || require('./viewport-info'); var SrcsetInfo = this.SrcsetInfo || require('./srcset-info'); From 246e9a2e795e62042d7a573cd1760015a3ece03d Mon Sep 17 00:00:00 2001 From: Antoine BERNIER Date: Mon, 20 Mar 2017 16:31:22 +0100 Subject: [PATCH 26/26] doc --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index c5f791b..09411a7 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,26 @@ See [the specification][spec] for the reference algorithm. +## INSTALL + +with NPM: + +```sh +npm install https://github.com/abernier/srcset-polyfill/archive/patch-abernier-bunchofthings.tar.gz +``` + +or with a plain old ` +``` + +or with the minified version: + +```html + +``` + ## Usage Use the `data-srcset` attribute of `` elements. For example: