From 4d16145463c31f7f54da838f63cbdde7c9e5afc4 Mon Sep 17 00:00:00 2001 From: Frank Hellenkamp Date: Mon, 7 Oct 2013 15:06:43 +0200 Subject: [PATCH] removed unused dependency to jsuri --- Gruntfile.js | 1 - build/srcset.js | 474 ----------------------------------------- build/srcset.min.js | 2 +- js/libs/jsuri-1.1.1.js | 473 ---------------------------------------- 4 files changed, 1 insertion(+), 949 deletions(-) delete mode 100644 js/libs/jsuri-1.1.1.js diff --git a/Gruntfile.js b/Gruntfile.js index ee6e1a4..f9a04ed 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,7 +6,6 @@ module.exports = function(grunt) { concat: { dist: { src: [ - 'js/libs/*', 'js/srcset-info.js', 'js/viewport-info.js', 'js/main.js' diff --git a/build/srcset.js b/build/srcset.js index c716112..c63fe7c 100644 --- a/build/srcset.js +++ b/build/srcset.js @@ -1,477 +1,3 @@ -/*! - * 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) { var INT_REGEXP = /^[0-9]+$/; diff --git a/build/srcset.min.js b/build/srcset.min.js index 010fe61..7ffe4ca 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){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 i(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,r=0,s=[];""!==n;){for(;" "===n.charAt(0);)n=n.slice(1);if(r=n.indexOf(" "),-1!==r){if(t=n.slice(0,r),""===t)break;n=n.slice(r+1),r=n.indexOf(","),-1===r?(e=n,n=""):(e=n.slice(0,r),n=n.slice(r+1)),s.push({url:t,descriptors:e})}else s.push({url:n,descriptors:""}),n=""}for(var a=0,o=s.length;o>a;a++){var h=s[a],c=this._parseDescriptors(h.descriptors);this._addCandidate(new i({src:h.url,x:c.x,w:c.w,h:c.h}))}this.srcValue&&this._addCandidate(new i({src:this.srcValue}))},e.prototype._addCandidate=function(t){for(var e=0;this.imageCandidates.length>e;e++){var i=this.imageCandidates[e];if(i.x==t.x&&i.w==t.w&&i.h==t.h)return}this.imageCandidates.push(t)},e.prototype._parseDescriptors=function(t){for(var e=t.split(/\s/),i={},r=0;e.length>r;r++){var s=e[r];if(s.length>0){var a=s[s.length-1],o=s.substring(0,s.length-1),h=parseInt(o,10),c=parseFloat(o);o.match(n)&&"w"===a?i[a]=h:o.match(n)&&"h"==a?i[a]=h:isNaN(c)||"x"!=a?(this.error='Invalid srcset descriptor found in "'+s+'".',this.isValid=!1):i[a]=c}}return i},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),i=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 a=this._getBestCandidateIf(e,function(t,e){return t.xa.x}),e[0]},e.prototype._getBestCandidateIf=function(t,e){for(var i=t[0],n=0;t.length>n;n++){var r=t[n];e(r,i)&&(i=r)}return i},e.prototype._removeCandidatesIf=function(t,e){for(var i=t.length-1;i>=0;i--){var n=t[i];e(n)&&t.splice(i,1)}return t},e.prototype.getBestImage2=function(t){for(var e=null,i=t.imageCandidates,n=0;i.length>n;n++){var r=i[n],s=e?e.x:0;if(r.x>=s&&r.x<=this.x){if(null===e){e=r;continue}this.w<=r.w&&r.w<=e.w&&(e=r)}}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 i=document.querySelectorAll("img"),n=0;i.length>n;n++){var r=i[n],s=r.getAttribute("srcset");if(s){var a=new SrcsetInfo({src:r.src,srcset:s}),o=e.getBestImage(a);r.src=o.src,r.width||r.height||r.style.height||r.style.width||(r.style.webkitTransform="scale("+1/o.x+")",r.style.webkitTransformOrigin="0 0")}}}}var i=setInterval(function(){"complete"===document.readyState&&(e(),clearInterval(i))},10)}(window); \ No newline at end of file diff --git a/js/libs/jsuri-1.1.1.js b/js/libs/jsuri-1.1.1.js deleted file mode 100644 index c5ecee8..0000000 --- a/js/libs/jsuri-1.1.1.js +++ /dev/null @@ -1,473 +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 - */ - - -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;