vendor/assets/javascripts/webshims/shims/combos/31.js in webshims-rails-1.11.6.1 vs vendor/assets/javascripts/webshims/shims/combos/31.js in webshims-rails-1.12.0

- old
+ new

@@ -38,38 +38,10 @@ webshims.ready('DOM', switch$); $(switch$); webshims.ready('WINDOWLOAD', switch$); } -// (function(){ -// var hostNames = { -// 'afarkas.github.io': 1, -// localhost: 1, -// '127.0.0.1': 1 -// }; -// -// if( webshims.cfg.debug && (hostNames[location.hostname] || location.protocol == 'file:') ){ -// var list = $('<ul class="webshims-debug-list" />'); -// webshims.errorLog.push = function(message){ -// list.appendTo('body'); -// $('<li style="display: none;">'+ message +'</li>') -// .appendTo(list) -// .slideDown() -// .delay(3000) -// .slideUp(function(){ -// $(this).remove(); -// if(!$('li', list).length){ -// list.detach(); -// } -// }) -// ; -// }; -// $.each(webshims.errorLog, function(i, message){ -// webshims.errorLog.push(message); -// }); -// } -// })(); //shortcus var modules = webshims.modules; var listReg = /\s*,\s*/; @@ -507,38 +479,50 @@ obj[name] = prop; } }); }, getOptions: (function(){ + var normalName = /\-([a-z])/g; var regs = {}; + var nameRegs = {}; var regFn = function(f, upper){ return upper.toLowerCase(); }; - return function(elem, name, bases){ + var nameFn = function(f, dashed){ + return dashed.toUpperCase(); + }; + return function(elem, name, bases, stringAllowed){ + if(nameRegs[name]){ + name = nameRegs[name]; + } else { + nameRegs[name] = name.replace(normalName, nameFn); + name = nameRegs[name]; + } var data = elementData(elem, 'cfg'+name); var dataName; var cfg = {}; if(data){ return data; } data = $(elem).data(); - + if(data && typeof data[name] == 'string'){ + if(stringAllowed){ + return elementData(elem, 'cfg'+name, data[name]); + } + webshims.error('data-'+ name +' attribute has to be a valid JSON, was: '+ data[name]); + } if(!bases){ bases = [true, {}]; } else if(!Array.isArray(bases)){ bases = [true, {}, bases]; } else { bases.unshift(true, {}); } - if(data && data[name]){ - if(typeof data[name] == 'object'){ - bases.push(data[name]); - } else { - webshims.error('data-'+ name +' attribute has to be a valid JSON, was: '+ data[name]); - } + if(data && typeof data[name] == 'object'){ + bases.push(data[name]); } if(!regs[name]){ regs[name] = new RegExp('^'+ name +'([A-Z])'); } @@ -547,11 +531,10 @@ if(regs[name].test(dataName)){ cfg[dataName.replace(regs[name], regFn)] = data[dataName]; } } bases.push(cfg); - return elementData(elem, 'cfg'+name, $.extend.apply($, bases)); }; })(), //http://www.w3.org/TR/html5/common-dom-interfaces.html#reflect createPropDefault: createPropDefault, @@ -577,11 +560,11 @@ }, addShadowDom: (function(){ var resizeTimer; var lastHeight; var lastWidth; - + var $window = $(window); var docObserve = { init: false, runs: 0, test: function(){ var height = docObserve.getHeight(); @@ -597,29 +580,40 @@ } } else { docObserve.runs = 0; } }, - handler: function(e){ - clearTimeout(resizeTimer); - resizeTimer = setTimeout(function(){ - if(e.type == 'resize'){ - var width = $(window).width(); - var height = $(window).width(); - if(height == lastHeight && width == lastWidth){ - return; + handler: (function(){ + var trigger = function(){ + $(document).triggerHandler('updateshadowdom'); + }; + return function(e){ + clearTimeout(resizeTimer); + resizeTimer = setTimeout(function(){ + if(e.type == 'resize'){ + var width = $window.width(); + var height = $window.width(); + + if(height == lastHeight && width == lastWidth){ + return; + } + lastHeight = height; + lastWidth = width; + + docObserve.height = docObserve.getHeight(); + docObserve.width = docObserve.getWidth(); } - lastHeight = height; - lastWidth = width; + + if(window.requestAnimationFrame){ + requestAnimationFrame(trigger); + } else { + setTimeout(trigger, 0); + } - docObserve.height = docObserve.getHeight(); - docObserve.width = docObserve.getWidth(); - - } - $(document).triggerHandler('updateshadowdom'); - }, (e.type == 'resize') ? 50 : 9); - }, + }, (e.type == 'resize' && !window.requestAnimationFrame) ? 50 : 0); + }; + })(), _create: function(){ $.each({ Height: "getHeight", Width: "getWidth" }, function(name, type){ var body = document.body; var doc = document.documentElement; docObserve[type] = function(){ @@ -953,17 +947,21 @@ descs.set = descs; } webshims.defineNodeNamesProperty(elementNames, prop, { attr: { set: function(val){ - this.setAttribute(prop, val); + if(descs.useContentAttribute){ + webshims.contentAttr(this, prop, val); + } else { + this.setAttribute(prop, val); + } if(descs.set){ descs.set.call(this, true); } }, get: function(){ - var ret = this.getAttribute(prop); + var ret = (descs.useContentAttribute) ? webshims.contentAttr(this, prop) : this.getAttribute(prop); return (ret == null) ? undefined : prop; } }, removeAttr: { value: function(){ @@ -1016,26 +1014,29 @@ } delete loading[src]; }); } }; + var select = function(obj){ var oldLang = obj.__active; var selectLang = function(i, lang){ obj._isLoading = false; if(obj[lang] || obj.availableLangs.indexOf(lang) != -1){ if(obj[lang]){ obj.__active = obj[lang]; + obj.__activeName = lang; } else { load(obj.langSrc+lang, obj, curLang.join()); } return false; } }; $.each(curLang, selectLang); if(!obj.__active){ obj.__active = obj['']; + obj.__activeName = ''; } if(oldLang != obj.__active){ $(obj).trigger('change'); } }; @@ -1136,11 +1137,11 @@ addRole(footer, 'contentinfo'); } } }); -})(webshims.$, document); +})(webshims.$, document);; webshims.register('form-core', function($, webshims, window, document, undefined, options){ "use strict"; webshims.capturingEventPrevented = function(e){ if(!e._isPolyfilled){ @@ -1201,10 +1202,11 @@ }); return ret; }; var extendSels = function(){ + var matches, matchesOverride; var exp = $.expr[":"]; $.extend(exp, { "valid-element": function(elem){ return rElementsGroup.test(elem.nodeName || '') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem)); }, @@ -1225,11 +1227,19 @@ ['valid', 'invalid', 'required', 'optional'].forEach(function(name){ exp[name] = $.expr[":"][name+"-element"]; }); // sizzle/jQuery has a bug with :disabled/:enabled selectors - if(Modernizr.fieldsetdisabled && !$('<fieldset disabled=""><input /><fieldset>').find('input').is(':disabled')){ + if(Modernizr.fieldsetdisabled && !$('<fieldset disabled=""><input /><input /></fieldset>').find(':disabled').filter(':disabled').is(':disabled')){ + matches = $.find.matches; + matchesOverride = {':disabled': 1, ':enabled': 1}; + $.find.matches = function(expr, elements){ + if(matchesOverride[expr]){ + return matches.call(this, '*'+expr, elements); + } + return matches.apply(this, arguments); + }; $.extend(exp, { "enabled": function( elem ) { return elem.disabled === false && !$(elem).is('fieldset[disabled] *'); }, @@ -1329,11 +1339,11 @@ webshims.getContentValidationMessage = function(elem, validity, key){ if(webshims.errorbox && webshims.errorbox.initIvalContentMessage){ webshims.errorbox.initIvalContentMessage(elem); } - var message = (webshims.getOptions && webshims.errorbox ? webshims.getOptions(elem, 'errormessage') : $(elem).data('errormessage')) || elem.getAttribute('x-moz-errormessage') || ''; + var message = (webshims.getOptions && webshims.errorbox ? webshims.getOptions(elem, 'errormessage', false, true) : $(elem).data('errormessage')) || elem.getAttribute('x-moz-errormessage') || ''; if(key && message[key]){ message = message[key]; } else if(message) { validity = validity || $.prop(elem, 'validity') || {valid: 1}; if(validity.valid){ @@ -1380,13 +1390,11 @@ if('form' in e.target){ lazyLoad(); } }); webshims.ready('WINDOWLOAD', lazyLoad); - }); - -webshims.register('form-datalist', function($, webshims, window, document, undefined, options){ +;webshims.register('form-datalist', function($, webshims, window, document, undefined, options){ "use strict"; var doc = document; var lazyLoad = function(name){ if(!name || typeof name != 'string'){ name = 'DOM'; \ No newline at end of file