vendor/assets/javascripts/webshims/shims/combos/15.js in webshims-rails-1.10.11 vs vendor/assets/javascripts/webshims/shims/combos/15.js in webshims-rails-1.11.1
- old
+ new
@@ -11,14 +11,10 @@
if(!$.parseHTML){
webshims.error("Webshims needs jQuery 1.8+ to work properly. Please update your jQuery version or downgrade webshims.");
}
- if(webshims.cfg.extendNative === undefined){
- webshims.warn("extendNative configuration was set to false by default with this release. In case you rely on it set it to 'true' otherwise to 'false'. See http://bit.ly/16OOTQO");
- }
-
if (!webshims.cfg.no$Switch) {
var switch$ = function(){
if (window.jQuery && (!window.$ || window.jQuery == window.$) && !window.jQuery.webshims) {
webshims.error("jQuery was included more than once. Make sure to include it only once or try the $.noConflict(extreme) feature! Webshims and other Plugins might not work properly. Or set webshims.cfg.no$Switch to 'true'.");
if (window.$) {
@@ -1295,66 +1291,16 @@
return message;
};
$(document).on('focusin.lazyloadvalidation', function(e){
- if('form' in e.target && $(e.target).is(':invalid')){
+ if('form' in e.target && (e.target.list || $(e.target).is(':invalid'))){
lazyLoad();
}
});
webshims.ready('WINDOWLOAD', lazyLoad);
- if(options.replaceValidationUI){
- webshims.ready('DOM forms', function(){
- $(document).on('firstinvalid', function(e){
- if(!e.isInvalidUIPrevented()){
- e.preventDefault();
- webshims.validityAlert.showFor( e.target );
- }
- });
- });
- }
-
- /* extension, but also used to fix native implementation workaround/bugfixes */
- (function(){
- var firstEvent,
- invalids = [],
- stopSubmitTimer,
- form
- ;
-
- $(document).on('invalid', function(e){
- if(e.wrongWebkitInvalid){return;}
- var jElm = $(e.target);
-
-
- if(!firstEvent){
- //trigger firstinvalid
- firstEvent = $.Event('firstinvalid');
- firstEvent.isInvalidUIPrevented = e.isDefaultPrevented;
- var firstSystemInvalid = $.Event('firstinvalidsystem');
- $(document).triggerHandler(firstSystemInvalid, {element: e.target, form: e.target.form, isInvalidUIPrevented: e.isDefaultPrevented});
- jElm.trigger(firstEvent);
- }
-
- //if firstinvalid was prevented all invalids will be also prevented
- if( firstEvent && firstEvent.isDefaultPrevented() ){
- e.preventDefault();
- }
- invalids.push(e.target);
- e.extraData = 'fix';
- clearTimeout(stopSubmitTimer);
- stopSubmitTimer = setTimeout(function(){
- var lastEvent = {type: 'lastinvalid', cancelable: false, invalidlist: $(invalids)};
- //reset firstinvalid
- firstEvent = false;
- invalids = [];
- $(e.target).trigger(lastEvent, lastEvent);
- }, 9);
- jElm = null;
- });
- })();
});
if(!Modernizr.formvalidation || webshims.bugs.bustedValidity){
webshims.register('form-shim-extend', function($, webshims, window, document, undefined, options){
"use strict";
@@ -2686,10 +2632,11 @@
}
var isOver = (webshims.cfg.forms.placeholderType == 'over');
var isResponsive = (webshims.cfg.forms.responsivePlaceholder);
var polyfillElements = ['textarea'];
+ var debug = webshims.debug !== false;
if(!Modernizr.input.placeholder || bustedPlaceholder){
polyfillElements.push('input');
}
var setSelection = function(elem){
@@ -2776,30 +2723,33 @@
changePlaceholderVisibility = function(elem, value, placeholderTxt, data, type){
if(!data){
data = $.data(elem, 'placeHolder');
if(!data){return;}
}
+ var isVisible = $(elem).hasClass('placeholder-visible');
+ if(placeholderTxt === false){
+ placeholderTxt = $.attr(elem, 'placeholder') || '';
+ }
+
$(elem).unbind('.placeholderremove');
if(value === false){
value = $.prop(elem, 'value');
}
if(!value && (type == 'focus' || (!type && $(elem).is(':focus')))){
- if(elem.type == 'password' || isOver || $(elem).hasClass('placeholder-visible')){
+ if(elem.type == 'password' || isOver || isVisible){
hidePlaceholder(elem, data, '', true);
}
return;
}
if(value){
hidePlaceholder(elem, data, value);
return;
}
- if(placeholderTxt === false){
- placeholderTxt = $.attr(elem, 'placeholder') || '';
- }
+
if(placeholderTxt && !value){
showPlaceholder(elem, data, placeholderTxt);
} else {
hidePlaceholder(elem, data, value);
}
@@ -2903,9 +2853,10 @@
} else {
var reset = function(e){
if($(elem).hasClass('placeholder-visible')){
hidePlaceholder(elem, data, '');
+
setTimeout(function(){
if(!e || e.type != 'submit' || e.isDefaultPrevented()){
changePlaceholderVisibility(elem, false, false, data );
}
}, 9);
\ No newline at end of file