Mise à jour de webshims

This commit is contained in:
echarp 2014-07-20 02:43:13 +02:00
parent a1e70d9a29
commit c1148aefeb
66 changed files with 1474 additions and 1867 deletions

View File

@ -290,7 +290,7 @@ GEM
warden (1.2.3)
rack (>= 1.0)
webrick (1.3.1)
webshims-rails (1.14.4)
webshims-rails (1.14.5)
rails (> 3.1.0)
PLATFORMS

View File

@ -104,6 +104,11 @@
var getAutoEnhance = function(prop){
return !webCFG.enhanceAuto && prop == 'auto' ? false : prop;
};
var featureAlias = {
matchmedia: 'matchMedia',
xhr2: 'filereader',
promise: 'es6'
};
clearInterval(webshims.timer);
support.advancedObjectProperties = support.objectAccessor = support.ES5 = !!('create' in Object && 'seal' in Object);
@ -121,7 +126,7 @@
}
$.extend(webshims, {
version: '1.14.4',
version: '1.14.5',
cfg: {
enhanceAuto: window.Audio && (!window.matchMedia || matchMedia('(min-device-width: 721px)').matches),
@ -244,12 +249,9 @@
}
$.each(features, function(i, feature){
if(feature == 'xhr2'){
feature = 'filereader';
}
if(feature == 'promise'){
feature = 'es6';
}
feature = featureAlias[feature] || feature;
if(!webshimsFeatures[feature]){
WSDEBUG && webshims.error("could not find webshims-feature (aborted): "+ feature);
isReady(feature, true);
@ -1010,7 +1012,7 @@
support.inputtypes = inputtypes;
$.each(['number', 'range', 'date', 'datetime-local', 'month', 'color'], function(i, type){
$.each(['range', 'date', 'datetime-local', 'month', 'color', 'number'], function(i, type){
input.setAttribute('type', type);
inputtypes[type] = (input.type == type && (input.value = '(') && input.value != '(');
});
@ -1026,7 +1028,7 @@
try {
if(fieldset.querySelector(':invalid')){
fieldset.disabled = true;
tmp = !fieldset.querySelector(':invalid');
tmp = !fieldset.querySelector(':invalid') && fieldset.querySelector(':disabled');
}
} catch(er){}
support.fieldsetdisabled = !!tmp;
@ -1035,15 +1037,39 @@
if(support[formvalidation]){
bustedWidgetUi = !support.fieldsetdisabled || !support.fieldsetelements || !('value' in progress) || !('value' in output);
replaceBustedUI = bustedWidgetUi && (/Android/i).test(navigator.userAgent);
bugs.bustedValidity = bustedValidity = window.opera || bugs.bustedValidity || bustedWidgetUi || !support.datalist;
} else {
bugs.bustedValidity = false;
bustedValidity = window.opera || bugs.bustedValidity || bustedWidgetUi || !support.datalist;
if(!bustedValidity && inputtypes.number){
bustedValidity = true;
try {
input.type = 'number';
input.value = '';
input.stepUp();
bustedValidity = input.value != '1';
} catch(e){}
}
}
bugs.bustedValidity = bustedValidity;
formExtend = support[formvalidation] && !bustedValidity ? 'form-native-extend' : fShim;
initialFormTest = $.noop;
return false;
};
var typeTest = function(o){
var ret = true;
if(!o._types){
o._types = o.types.split(' ');
}
$.each(o._types, function(i, name){
if((name in inputtypes) && !inputtypes[name]){
ret = false;
return false;
}
});
return ret;
};
webshims.validationMessages = webshims.validityMessages = {
@ -1129,19 +1155,13 @@
types: 'date time range number'
},
test: function(){
var ret = true;
var o = this.options;
if(!o._types){
o._types = o.types.split(' ');
}
initialFormTest();
$.each(o._types, function(i, name){
if((name in inputtypes) && !inputtypes[name]){
ret = false;
return false;
}
});
var ret = !bustedValidity;
if(ret){
ret = typeTest(this.options);
}
return ret;
},
methodNames: ['stepUp', 'stepDown'],
@ -1169,7 +1189,7 @@
if(!o.replaceUI && replaceBustedUI){
o.replaceUI = true;
}
return !o.replaceUI && modules[fNuAPI].test();
return !o.replaceUI && typeTest(o);
},
d: ['forms', DOMSUPPORT, fNuAPI, 'range-ui'],
options: {
@ -1177,7 +1197,6 @@
calculateWidth: true,
animate: true
}
// ,replaceUI: false
},
c: [6, 5, 9, 10, 17, 11]
});

View File

@ -250,6 +250,9 @@ webshims.isReady('swfmini', true);
};
var lazyLoad = function(){
var toLoad = ['form-validation'];
$(document).off('.lazyloadvalidation');
if(options.lazyCustomMessages){
options.customMessages = true;
toLoad.push('form-message');
@ -264,7 +267,6 @@ webshims.isReady('swfmini', true);
toLoad.push('form-validators');
}
webshims.reTest(toLoad);
$(document).off('.lazyloadvalidation');
};
/*
* Selectors for all browsers
@ -321,11 +323,11 @@ webshims.isReady('swfmini', true);
};
$.extend(exp, {
"enabled": function( elem ) {
return elem.disabled === false && !$(elem).is('fieldset[disabled] *');
return 'disabled' in elem && elem.disabled === false && !$.find.matchesSelector(elem, 'fieldset[disabled] *');
},
"disabled": function( elem ) {
return elem.disabled === true || ('disabled' in elem && $(elem).is('fieldset[disabled] *'));
return elem.disabled === true || ('disabled' in elem && $.find.matchesSelector(elem, 'fieldset[disabled] *'));
}
});
}
@ -504,8 +506,7 @@ webshims.isReady('swfmini', true);
};
$(document).on('focusin.lazyloadvalidation', function(e){
$(document).on('focusin.lazyloadvalidation mousedown.lazyloadvalidation touchstart.lazyloadvalidation', function(e){
if('form' in e.target){
lazyLoad();
}
@ -536,6 +537,14 @@ webshims.isReady('swfmini', true);
});
}
});
if(options.addValidators && options.fastValidators){
webshims.reTest(['form-validators', 'form-validation']);
}
if(document.readyState == 'complete'){
webshims.isReady('WINDOWLOAD', true);
}
});
;(function(webshims){
"use strict";
@ -1070,6 +1079,10 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
webshims.ready(swfType, initMediaElements);
}
webshims.ready('track', loadTrackUi);
if(document.readyState == 'complete'){
webshims.isReady('WINDOWLOAD', true);
}
});
})(webshims);

View File

@ -549,8 +549,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
webshims.warn(type +' already implemented for element #'+elem.id);
return false;
}
data[type] = true;
return true;
return !$(elem).hasClass('ws-nopolyfill');
},
extendUNDEFProp: function(obj, props){
$.each(props, function(name, prop){
@ -2015,9 +2016,11 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
$(element).attr({'aria-labelledby': labels.map(getId).get().join(' ')});
if(!noFocus){
labels.on('click', function(e){
element.getShadowFocusElement().focus();
e.preventDefault();
return false;
if(!e.isDefaultPrevented()){
element.getShadowFocusElement().focus();
e.preventDefault();
return false;
}
});
}
};
@ -3675,7 +3678,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
});
});
}
if(opts.calculateWidth){
sizeInput(data.shim);
} else {
@ -3705,28 +3708,28 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
}
var replace = {};
if(options.replaceUI){
if( $.isPlainObject(options.replaceUI) ){
$.extend(replace, options.replaceUI);
} else {
$.extend(replace, {
'range': 1,
'number': 1,
'time': 1,
'month': 1,
'date': 1,
'color': 1,
'datetime-local': 1
});
}
$.each($.extend(replace, $.isPlainObject(options.replaceUI) ? options.replaceUI : {
'range': 1,
'number': 1,
'time': 1,
'month': 1,
'date': 1,
'color': 1,
'datetime-local': 1
}), function(name, val){
if(supportInputTypes[name] && val == 'auto'){
replace[name] = webshims._getAutoEnhance(val);
}
});
}
if(supportInputTypes.number && navigator.userAgent.indexOf('Touch') == -1 && ((/MSIE 1[0|1]\.\d/.test(navigator.userAgent)) || (/Trident\/7\.0/.test(navigator.userAgent)))){
replace.number = 1;
}
if(!supportInputTypes.range || replace.range){
if(replace.range !== false && (!supportInputTypes.range || replace.range)){
extendType('range', {
_create: function(opts, set){
var data = $('<span />').insertAfter(opts.orig).rangeUI(opts).data('rangeUi');
@ -3737,12 +3740,13 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
['number', 'time', 'month', 'date', 'color', 'datetime-local'].forEach(function(name){
if(!supportInputTypes[name] || replace[name]){
if(replace[name] !== false && (!supportInputTypes[name] || replace[name])){
extendType(name, {
_create: function(opts, set){
if(opts.monthSelect || opts.daySelect || opts.yearSelect){
opts.splitInput = true;
}
if(opts.splitInput && !splitInputs[name]){
webshims.warn('splitInput not supported for '+ name);
opts.splitInput = false;

View File

@ -803,9 +803,11 @@
$(element).attr({'aria-labelledby': labels.map(getId).get().join(' ')});
if(!noFocus){
labels.on('click', function(e){
element.getShadowFocusElement().focus();
e.preventDefault();
return false;
if(!e.isDefaultPrevented()){
element.getShadowFocusElement().focus();
e.preventDefault();
return false;
}
});
}
};
@ -2463,7 +2465,7 @@
});
});
}
if(opts.calculateWidth){
sizeInput(data.shim);
} else {
@ -2493,28 +2495,28 @@
}
var replace = {};
if(options.replaceUI){
if( $.isPlainObject(options.replaceUI) ){
$.extend(replace, options.replaceUI);
} else {
$.extend(replace, {
'range': 1,
'number': 1,
'time': 1,
'month': 1,
'date': 1,
'color': 1,
'datetime-local': 1
});
}
$.each($.extend(replace, $.isPlainObject(options.replaceUI) ? options.replaceUI : {
'range': 1,
'number': 1,
'time': 1,
'month': 1,
'date': 1,
'color': 1,
'datetime-local': 1
}), function(name, val){
if(supportInputTypes[name] && val == 'auto'){
replace[name] = webshims._getAutoEnhance(val);
}
});
}
if(supportInputTypes.number && navigator.userAgent.indexOf('Touch') == -1 && ((/MSIE 1[0|1]\.\d/.test(navigator.userAgent)) || (/Trident\/7\.0/.test(navigator.userAgent)))){
replace.number = 1;
}
if(!supportInputTypes.range || replace.range){
if(replace.range !== false && (!supportInputTypes.range || replace.range)){
extendType('range', {
_create: function(opts, set){
var data = $('<span />').insertAfter(opts.orig).rangeUI(opts).data('rangeUi');
@ -2525,12 +2527,13 @@
['number', 'time', 'month', 'date', 'color', 'datetime-local'].forEach(function(name){
if(!supportInputTypes[name] || replace[name]){
if(replace[name] !== false && (!supportInputTypes[name] || replace[name])){
extendType(name, {
_create: function(opts, set){
if(opts.monthSelect || opts.daySelect || opts.yearSelect){
opts.splitInput = true;
}
if(opts.splitInput && !splitInputs[name]){
webshims.warn('splitInput not supported for '+ name);
opts.splitInput = false;

View File

@ -754,6 +754,10 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
webshims.ready(swfType, initMediaElements);
}
webshims.ready('track', loadTrackUi);
if(document.readyState == 'complete'){
webshims.isReady('WINDOWLOAD', true);
}
});
})(webshims);

View File

@ -531,6 +531,10 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
webshims.ready(swfType, initMediaElements);
}
webshims.ready('track', loadTrackUi);
if(document.readyState == 'complete'){
webshims.isReady('WINDOWLOAD', true);
}
});
})(webshims);

View File

@ -553,7 +553,6 @@ webshims.register('form-native-extend', function($, webshims, window, doc, undef
}
var nan = parseInt('NaN', 10),
doc = document,
typeModels = webshims.inputTypes,
isNumber = function(string){
return (typeof string == 'number' || (string && string == string * 1));

View File

@ -549,8 +549,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
webshims.warn(type +' already implemented for element #'+elem.id);
return false;
}
data[type] = true;
return true;
return !$(elem).hasClass('ws-nopolyfill');
},
extendUNDEFProp: function(obj, props){
$.each(props, function(name, prop){
@ -1239,6 +1240,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
var lazyLoad = function(){
var toLoad = ['form-validation'];
$(document).off('.lazyloadvalidation');
if(options.lazyCustomMessages){
options.customMessages = true;
toLoad.push('form-message');
@ -1253,7 +1257,6 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
toLoad.push('form-validators');
}
webshims.reTest(toLoad);
$(document).off('.lazyloadvalidation');
};
/*
* Selectors for all browsers
@ -1310,11 +1313,11 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
$.extend(exp, {
"enabled": function( elem ) {
return elem.disabled === false && !$(elem).is('fieldset[disabled] *');
return 'disabled' in elem && elem.disabled === false && !$.find.matchesSelector(elem, 'fieldset[disabled] *');
},
"disabled": function( elem ) {
return elem.disabled === true || ('disabled' in elem && $(elem).is('fieldset[disabled] *'));
return elem.disabled === true || ('disabled' in elem && $.find.matchesSelector(elem, 'fieldset[disabled] *'));
}
});
}
@ -1493,8 +1496,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
$(document).on('focusin.lazyloadvalidation', function(e){
$(document).on('focusin.lazyloadvalidation mousedown.lazyloadvalidation touchstart.lazyloadvalidation', function(e){
if('form' in e.target){
lazyLoad();
}
@ -1525,6 +1527,14 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
});
}
});
if(options.addValidators && options.fastValidators){
webshims.reTest(['form-validators', 'form-validation']);
}
if(document.readyState == 'complete'){
webshims.isReady('WINDOWLOAD', true);
}
});
;webshims.register('form-shim-extend', function($, webshims, window, document, undefined, options){
"use strict";
@ -1920,7 +1930,7 @@ var rsubmittable = /^(?:select|textarea|input)/i;
;
return function(){
var elem = $(this).getNativeElement()[0];
return !!(!elem.readOnly && !types[elem.type] && !$(elem).is(':disabled') );
return !!(!elem.readOnly && !types[elem.type] && !$.find.matchesSelector(elem, ':disabled') );
};
})()
},

View File

@ -772,8 +772,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
webshims.warn(type +' already implemented for element #'+elem.id);
return false;
}
data[type] = true;
return true;
return !$(elem).hasClass('ws-nopolyfill');
},
extendUNDEFProp: function(obj, props){
$.each(props, function(name, prop){
@ -1462,6 +1463,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
var lazyLoad = function(){
var toLoad = ['form-validation'];
$(document).off('.lazyloadvalidation');
if(options.lazyCustomMessages){
options.customMessages = true;
toLoad.push('form-message');
@ -1476,7 +1480,6 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
toLoad.push('form-validators');
}
webshims.reTest(toLoad);
$(document).off('.lazyloadvalidation');
};
/*
* Selectors for all browsers
@ -1533,11 +1536,11 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
$.extend(exp, {
"enabled": function( elem ) {
return elem.disabled === false && !$(elem).is('fieldset[disabled] *');
return 'disabled' in elem && elem.disabled === false && !$.find.matchesSelector(elem, 'fieldset[disabled] *');
},
"disabled": function( elem ) {
return elem.disabled === true || ('disabled' in elem && $(elem).is('fieldset[disabled] *'));
return elem.disabled === true || ('disabled' in elem && $.find.matchesSelector(elem, 'fieldset[disabled] *'));
}
});
}
@ -1716,8 +1719,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
$(document).on('focusin.lazyloadvalidation', function(e){
$(document).on('focusin.lazyloadvalidation mousedown.lazyloadvalidation touchstart.lazyloadvalidation', function(e){
if('form' in e.target){
lazyLoad();
}
@ -1748,6 +1750,14 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
});
}
});
if(options.addValidators && options.fastValidators){
webshims.reTest(['form-validators', 'form-validation']);
}
if(document.readyState == 'complete'){
webshims.isReady('WINDOWLOAD', true);
}
});
;webshims.register('form-shim-extend', function($, webshims, window, document, undefined, options){
"use strict";
@ -2143,7 +2153,7 @@ var rsubmittable = /^(?:select|textarea|input)/i;
;
return function(){
var elem = $(this).getNativeElement()[0];
return !!(!elem.readOnly && !types[elem.type] && !$(elem).is(':disabled') );
return !!(!elem.readOnly && !types[elem.type] && !$.find.matchesSelector(elem, ':disabled') );
};
})()
},
@ -3698,6 +3708,10 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
webshims.ready(swfType, initMediaElements);
}
webshims.ready('track', loadTrackUi);
if(document.readyState == 'complete'){
webshims.isReady('WINDOWLOAD', true);
}
});
})(webshims);

View File

@ -30,7 +30,6 @@ webshims.register('form-number-date-api', function($, webshims, window, document
}
var nan = parseInt('NaN', 10),
doc = document,
typeModels = webshims.inputTypes,
isNumber = function(string){
return (typeof string == 'number' || (string && string == string * 1));
@ -1420,9 +1419,11 @@ webshims.register('form-number-date-api', function($, webshims, window, document
$(element).attr({'aria-labelledby': labels.map(getId).get().join(' ')});
if(!noFocus){
labels.on('click', function(e){
element.getShadowFocusElement().focus();
e.preventDefault();
return false;
if(!e.isDefaultPrevented()){
element.getShadowFocusElement().focus();
e.preventDefault();
return false;
}
});
}
};
@ -3080,7 +3081,7 @@ webshims.register('form-number-date-api', function($, webshims, window, document
});
});
}
if(opts.calculateWidth){
sizeInput(data.shim);
} else {
@ -3110,28 +3111,28 @@ webshims.register('form-number-date-api', function($, webshims, window, document
}
var replace = {};
if(options.replaceUI){
if( $.isPlainObject(options.replaceUI) ){
$.extend(replace, options.replaceUI);
} else {
$.extend(replace, {
'range': 1,
'number': 1,
'time': 1,
'month': 1,
'date': 1,
'color': 1,
'datetime-local': 1
});
}
$.each($.extend(replace, $.isPlainObject(options.replaceUI) ? options.replaceUI : {
'range': 1,
'number': 1,
'time': 1,
'month': 1,
'date': 1,
'color': 1,
'datetime-local': 1
}), function(name, val){
if(supportInputTypes[name] && val == 'auto'){
replace[name] = webshims._getAutoEnhance(val);
}
});
}
if(supportInputTypes.number && navigator.userAgent.indexOf('Touch') == -1 && ((/MSIE 1[0|1]\.\d/.test(navigator.userAgent)) || (/Trident\/7\.0/.test(navigator.userAgent)))){
replace.number = 1;
}
if(!supportInputTypes.range || replace.range){
if(replace.range !== false && (!supportInputTypes.range || replace.range)){
extendType('range', {
_create: function(opts, set){
var data = $('<span />').insertAfter(opts.orig).rangeUI(opts).data('rangeUi');
@ -3142,12 +3143,13 @@ webshims.register('form-number-date-api', function($, webshims, window, document
['number', 'time', 'month', 'date', 'color', 'datetime-local'].forEach(function(name){
if(!supportInputTypes[name] || replace[name]){
if(replace[name] !== false && (!supportInputTypes[name] || replace[name])){
extendType(name, {
_create: function(opts, set){
if(opts.monthSelect || opts.daySelect || opts.yearSelect){
opts.splitInput = true;
}
if(opts.splitInput && !splitInputs[name]){
webshims.warn('splitInput not supported for '+ name);
opts.splitInput = false;

View File

@ -10,23 +10,65 @@
webshim.isReady('picture', true);
setTimeout(function(){
webshim.ready('matchMedia', function(){
if(window.picturefill){
var sel = 'picture, img[srcset]';
webshim.addReady(function(context){
if(context.querySelector(sel)){
window.picturefill();
}
});
}
});
if(window.picturefill){
var sel = 'picture, img[srcset]';
webshim.addReady(function(context){
if(context.querySelector(sel)){
window.picturefill();
}
});
}
});
})();
/*! Picturefill - v2.1.0-beta - 2014-06-03
/*! Picturefill - v2.1.0-beta - 2014-07-15
* http://scottjehl.github.io/picturefill
* Copyright (c) 2014 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT */
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */
window.matchMedia || (window.matchMedia = function() {
"use strict";
// For browsers that support matchMedium api such as IE 9 and webkit
var styleMedia = (window.styleMedia || window.media);
// For those that don't support matchMedium
if (!styleMedia) {
var style = document.createElement('style'),
script = document.getElementsByTagName('script')[0],
info = null;
style.type = 'text/css';
style.id = 'matchmediajs-test';
script.parentNode.insertBefore(style, script);
// 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers
info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle;
styleMedia = {
matchMedium: function(media) {
var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }';
// 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers
if (style.styleSheet) {
style.styleSheet.cssText = text;
} else {
style.textContent = text;
}
// Test if media query is true or false
return info.width === '1px';
}
};
}
return function(media) {
return {
matches: styleMedia.matchMedium(media || 'all'),
media: media || 'all'
};
};
}());
/*! Picturefill - Responsive Images that work today.
* Author: Scott Jehl, Filament Group, 2012 ( new proposal implemented by Shawn Jansepar )
* License: MIT/GPLv2
@ -38,6 +80,7 @@
// If picture is supported, well, that's awesome. Let's get outta here...
if ( w.HTMLPictureElement ) {
w.picturefill = function() { };
return;
}
@ -51,7 +94,8 @@
pf.ns = "picturefill";
// srcset support test
pf.srcsetSupported = new w.Image().srcset !== undefined;
pf.srcsetSupported = "srcset" in doc.createElement( "img" );
pf.sizesSupported = w.HTMLImageElement.sizes;
// just a string trim workaround
pf.trim = function( str ) {
@ -82,8 +126,8 @@
* http://dev.w3.org/csswg/css-values-3/#length-value
*/
pf.getWidthFromLength = function( length ) {
// If no length was specified, or it is 0, default to `100vw` (per the spec).
length = length && parseFloat( length ) > 0 ? length : "100vw";
// If no length was specified, or it is 0 or negative, default to `100vw` (per the spec).
length = length && ( parseFloat( length ) > 0 || length.indexOf( "calc(" ) > -1 ) ? length : "100vw";
/**
* If length is specified in `vw` units, use `%` instead since the div were measuring
@ -101,7 +145,12 @@
// Positioning styles help prevent padding/margin/width on `html` from throwing calculations off.
pf.lengthEl.style.cssText = "position: absolute; left: 0; width: " + length + ";";
// Using offsetWidth to get width from CSS
if ( pf.lengthEl.offsetWidth <= 0 ) {
// Something has gone wrong. `calc()` is in use and unsupported, most likely. Default to `100vw` (`100%`, for broader support.):
pf.lengthEl.style.cssText = "width: 100%;";
}
return pf.lengthEl.offsetWidth;
};
@ -263,38 +312,32 @@
return candidates;
};
pf.parseDescriptor = function( descriptor, sizes ) {
pf.parseDescriptor = function( descriptor, sizesattr ) {
// 11. Descriptor parser: Let candidates be an initially empty source set. The order of entries in the list
// is the order in which entries are added to the list.
var sizeDescriptor = descriptor && descriptor.replace(/(^\s+|\s+$)/g, ""),
widthInCssPixels = sizes ? pf.findWidthFromSourceSize( sizes ) : "100%",
var sizes = sizesattr || "100vw",
sizeDescriptor = descriptor && descriptor.replace(/(^\s+|\s+$)/g, ""),
widthInCssPixels = pf.findWidthFromSourceSize( sizes ),
resCandidate;
if ( sizeDescriptor ) {
var splitDescriptor = sizeDescriptor.split(" ");
for (var i = splitDescriptor.length + 1; i >= 0; i--) {
if ( splitDescriptor[ i ] !== undefined ) {
var curr = splitDescriptor[ i ],
lastchar = curr && curr.slice( curr.length - 1 );
var curr = splitDescriptor[ i ],
lastchar = curr && curr.slice( curr.length - 1 );
if ( lastchar === "w" || lastchar === "x" ) {
resCandidate = curr;
}
if ( sizes && resCandidate ) {
// get the dpr by taking the length / width in css pixels
resCandidate = parseFloat( ( parseInt( curr, 10 ) / widthInCssPixels ) );
} else {
// get the dpr by grabbing the value of Nx
var res = curr && parseFloat( curr, 10 );
resCandidate = res && !isNaN( res ) && lastchar === "x" || lastchar === "w" ? res : 1;
if ( ( lastchar === "h" || lastchar === "w" ) && !pf.sizesSupported ) {
resCandidate = parseFloat( ( parseInt( curr, 10 ) / widthInCssPixels ) );
} else if ( lastchar === "x" ) {
var res = curr && parseFloat( curr, 10 );
resCandidate = res && !isNaN( res ) ? res : 1;
}
}
}
} else {
resCandidate = 1;
}
return resCandidate;
return resCandidate || 1;
};
/**
@ -372,7 +415,7 @@
}
}
if ( !pf.endsWith( picImg.src, bestCandidate.url ) ) {
if ( bestCandidate && !pf.endsWith( picImg.src, bestCandidate.url ) ) {
picImg.src = bestCandidate.url;
// currentSrc attribute and property to match
// http://picture.responsiveimages.org/#the-img-element
@ -405,32 +448,26 @@
};
/*
* Find all picture elements and,
* in browsers that don't natively support srcset, find all img elements
* with srcset attrs that don't have picture parents
* Find all `img` elements, and add them to the candidate list if they have
* a `picture` parent, a `sizes` attribute in basic `srcset` supporting browsers,
* a `srcset` attribute at all, and they havent been evaluated already.
*/
pf.getAllElements = function() {
var pictures = doc.getElementsByTagName( "picture" ),
elems = [],
var elems = [],
imgs = doc.getElementsByTagName( "img" );
for ( var h = 0, len = pictures.length + imgs.length; h < len; h++ ) {
if ( h < pictures.length ) {
elems[ h ] = pictures[ h ];
} else {
var currImg = imgs[ h - pictures.length ];
for ( var h = 0, len = imgs.length; h < len; h++ ) {
var currImg = imgs[ h ];
if ( currImg.parentNode.nodeName.toUpperCase() !== "PICTURE" &&
( ( pf.srcsetSupported && currImg.getAttribute( "sizes" ) ) ||
currImg.getAttribute( "srcset" ) !== null ) ) {
elems.push( currImg );
}
if ( currImg.parentNode.nodeName.toUpperCase() === "PICTURE" ||
( currImg.getAttribute( "srcset" ) !== null ) || currImg[ pf.ns ] && currImg[ pf.ns ].srcset !== null ) {
elems.push( currImg );
}
}
return elems;
};
pf.getMatch = function( picture ) {
pf.getMatch = function( img, picture ) {
var sources = picture.childNodes,
match;
@ -443,9 +480,9 @@
continue;
}
// Hitting an `img` element stops the search for `sources`.
// Hitting the `img` element that started everything stops the search for `sources`.
// If no previous `source` matches, the `img` itself is evaluated later.
if ( source.nodeName.toUpperCase() === "IMG" ) {
if ( source === img ) {
return match;
}
@ -477,24 +514,22 @@
return match;
};
function picturefill( options ) {
function picturefill( opt ) {
var elements,
element,
elemType,
parent,
firstMatch,
candidates,
picImg;
options = options || {};
options = opt || {};
elements = options.elements || pf.getAllElements();
// Loop through all elements
for ( var i = 0, plen = elements.length; i < plen; i++ ) {
element = elements[ i ];
elemType = element.nodeName.toUpperCase();
parent = element.parentNode;
firstMatch = undefined;
candidates = undefined;
picImg = undefined;
// expando for caching data on the img
if ( !element[ pf.ns ] ) {
@ -508,16 +543,16 @@
continue;
}
// if element is a picture element
if ( elemType === "PICTURE" ) {
// if `img` is in a `picture` element
if ( parent.nodeName.toUpperCase() === "PICTURE" ) {
// IE9 video workaround
pf.removeVideoShim( element );
pf.removeVideoShim( parent );
// return the first match which might undefined
// returns false if there is a pending source
// TODO the return type here is brutal, cleanup
firstMatch = pf.getMatch( element );
firstMatch = pf.getMatch( element, parent );
// if any sources are pending in this picture due to async type test(s)
// remove the evaluated attr and skip for now ( the pending test will
@ -525,43 +560,32 @@
if ( firstMatch === false ) {
continue;
}
// Find any existing img element in the picture element
picImg = element.getElementsByTagName( "img" )[ 0 ];
} else {
// if it's an img element
firstMatch = undefined;
picImg = element;
}
if ( picImg ) {
// expando for caching data on the img
if ( !picImg[ pf.ns ] ) {
picImg[ pf.ns ] = {};
}
// Cache and remove `srcset` if present and were going to be doing `sizes`/`picture` polyfilling to it.
if ( picImg.srcset && ( elemType === "PICTURE" || picImg.getAttribute( "sizes" ) ) ) {
pf.dodgeSrcset( picImg );
}
if ( firstMatch ) {
candidates = pf.processSourceSet( firstMatch );
pf.applyBestCandidate( candidates, picImg );
} else {
// No sources matched, so were down to processing the inner `img` as a source.
candidates = pf.processSourceSet( picImg );
if ( picImg.srcset === undefined || picImg[ pf.ns ].srcset ) {
// Either `srcset` is completely unsupported, or we need to polyfill `sizes` functionality.
pf.applyBestCandidate( candidates, picImg );
} // Else, resolution-only `srcset` is supported natively.
}
// set evaluated to true to avoid unnecessary reparsing
element[ pf.ns ].evaluated = true;
// Cache and remove `srcset` if present and were going to be doing `picture`/`srcset`/`sizes` polyfilling to it.
if ( parent.nodeName.toUpperCase() === "PICTURE" ||
( element.srcset && !pf.srcsetSupported ) ||
( !pf.sizesSupported && ( element.srcset && element.srcset.indexOf("w") > -1 ) ) ) {
pf.dodgeSrcset( element );
}
if ( firstMatch ) {
candidates = pf.processSourceSet( firstMatch );
pf.applyBestCandidate( candidates, element );
} else {
// No sources matched, so were down to processing the inner `img` as a source.
candidates = pf.processSourceSet( element );
if ( element.srcset === undefined || element[ pf.ns ].srcset ) {
// Either `srcset` is completely unsupported, or we need to polyfill `sizes` functionality.
pf.applyBestCandidate( candidates, element );
} // Else, resolution-only `srcset` is supported natively.
}
// set evaluated to true to avoid unnecessary reparsing
element[ pf.ns ].evaluated = true;
}
}
@ -596,7 +620,7 @@
}
}
webshim.ready('matchMedia', runPicturefill);
runPicturefill();
/* expose methods for testing */
picturefill._ = pf;
@ -615,6 +639,7 @@
} )( this, this.document );
;/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */
window.matchMedia || (window.matchMedia = function() {

View File

@ -772,8 +772,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
webshims.warn(type +' already implemented for element #'+elem.id);
return false;
}
data[type] = true;
return true;
return !$(elem).hasClass('ws-nopolyfill');
},
extendUNDEFProp: function(obj, props){
$.each(props, function(name, prop){
@ -1462,6 +1463,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
var lazyLoad = function(){
var toLoad = ['form-validation'];
$(document).off('.lazyloadvalidation');
if(options.lazyCustomMessages){
options.customMessages = true;
toLoad.push('form-message');
@ -1476,7 +1480,6 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
toLoad.push('form-validators');
}
webshims.reTest(toLoad);
$(document).off('.lazyloadvalidation');
};
/*
* Selectors for all browsers
@ -1533,11 +1536,11 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
$.extend(exp, {
"enabled": function( elem ) {
return elem.disabled === false && !$(elem).is('fieldset[disabled] *');
return 'disabled' in elem && elem.disabled === false && !$.find.matchesSelector(elem, 'fieldset[disabled] *');
},
"disabled": function( elem ) {
return elem.disabled === true || ('disabled' in elem && $(elem).is('fieldset[disabled] *'));
return elem.disabled === true || ('disabled' in elem && $.find.matchesSelector(elem, 'fieldset[disabled] *'));
}
});
}
@ -1716,8 +1719,7 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
};
$(document).on('focusin.lazyloadvalidation', function(e){
$(document).on('focusin.lazyloadvalidation mousedown.lazyloadvalidation touchstart.lazyloadvalidation', function(e){
if('form' in e.target){
lazyLoad();
}
@ -1748,6 +1750,14 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
});
}
});
if(options.addValidators && options.fastValidators){
webshims.reTest(['form-validators', 'form-validation']);
}
if(document.readyState == 'complete'){
webshims.isReady('WINDOWLOAD', true);
}
});
;webshims.register('form-datalist', function($, webshims, window, document, undefined, options){
"use strict";
@ -2579,6 +2589,10 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
webshims.ready(swfType, initMediaElements);
}
webshims.ready('track', loadTrackUi);
if(document.readyState == 'complete'){
webshims.isReady('WINDOWLOAD', true);
}
});
})(webshims);

View File

@ -462,6 +462,7 @@
var onEvent = {
onPlayPause: function(jaris, data, override){
var playing, type;
var idled = data.paused || data.ended;
if(override == null){
try {
playing = data.api.api_get("isPlaying");
@ -469,7 +470,7 @@
} else {
playing = override;
}
if(playing == data.paused){
if(playing == idled || playing == null){
data.paused = !playing;
type = data.paused ? 'pause' : 'play';
@ -1546,11 +1547,11 @@
var media, error, parent;
if(
($(e.target).is('audio, video') || ((parent = e.target.parentNode) && $('source', parent).last()[0] == e.target)) &&
(media = $(e.target).closest('audio, video')) && !media.is('.nonnative-api-active')
(media = $(e.target).closest('audio, video')) && !media.hasClass('nonnative-api-active')
){
error = media.prop('error');
setTimeout(function(){
if(!media.is('.nonnative-api-active')){
if(!media.hasClass('nonnative-api-active')){
if(error && switchErrors[error.code]){
options.preferFlash = true;
document.removeEventListener('error', switchOptions, true);

View File

@ -754,6 +754,10 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
webshims.ready(swfType, initMediaElements);
}
webshims.ready('track', loadTrackUi);
if(document.readyState == 'complete'){
webshims.isReady('WINDOWLOAD', true);
}
});
})(webshims);

View File

@ -549,8 +549,9 @@ webshims.register('dom-extend', function($, webshims, window, document, undefine
webshims.warn(type +' already implemented for element #'+elem.id);
return false;
}
data[type] = true;
return true;
return !$(elem).hasClass('ws-nopolyfill');
},
extendUNDEFProp: function(obj, props){
$.each(props, function(name, prop){