vendor/assets/javascripts/webshims/shims/combos/30.js in webshims-rails-1.13.0 vs vendor/assets/javascripts/webshims/shims/combos/30.js in webshims-rails-1.14.1
- old
+ new
@@ -177,12 +177,12 @@
$(evtDel).off(evt, fn);
}
});
return this;
};
-
- var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
+ var idCount = 0;
+ var dataID = '_webshims'+ (Math.round(Math.random() * 1000));
var elementData = function(elem, key, val){
elem = elem.jquery ? elem[0] : elem;
if(!elem){return val || {};}
var data = $.data(elem, dataID);
if(val !== undefined){
@@ -209,10 +209,39 @@
}
});
return this.pushStack(elems);
};
});
+
+ function clone(elem, dataAndEvents, uniqueIds){
+ var cloned = $.clone( elem, dataAndEvents, false );
+ $(cloned.querySelectorAll('.'+webshims.shadowClass)).detach();
+ if(uniqueIds){
+ idCount++;
+ $(cloned.querySelectorAll('[id]')).prop('id', function(i, id){
+ return id +idCount;
+ });
+ } else {
+ $(cloned.querySelectorAll('audio[id^="ID-"], video[id^="ID-"], label[id^="ID-"]')).removeAttr('id');
+ }
+ return cloned;
+ }
+
+ $.fn.clonePolyfill = function(dataAndEvents, uniqueIds){
+ dataAndEvents = dataAndEvents || false;
+ return this
+ .map(function() {
+ var cloned = clone( this, dataAndEvents, uniqueIds );
+ setTimeout(function(){
+ if($.contains(document.body, cloned)){
+ $(cloned).updatePolyfill();
+ }
+ });
+ return cloned;
+ })
+ ;
+ };
//add support for $('video').trigger('play') in case extendNative is set to false
if(!webshims.cfg.extendNative && !webshims.cfg.noTriggerOverride){
(function(oldTrigger){
$.event.trigger = function(event, data, elem, onlyHandlers){
@@ -520,10 +549,11 @@
elem.eq(0).prop('id', id);
}
return id;
};
})(),
+ shadowClass: 'wsshadow-'+(Date.now()),
implement: function(elem, type){
var data = elementData(elem, 'implemented') || elementData(elem, 'implemented', {});
if(data[type]){
webshims.warn(type +' already implemented for element #'+elem.id);
return false;
@@ -1331,10 +1361,12 @@
var poCFG = webshims.cfg.wspopover;
addModule('form-validation', $.extend({d: ['form-message']}, formExtras));
addModule('form-validators', $.extend({}, formExtras));
+
+
if($.expr.filters){
extendSels();
} else {
webshims.ready('sizzle', extendSels);
@@ -1452,16 +1484,25 @@
return message;
};
$.event.special.valuevalidation = {
setup: function(){
+ webshims.error('valuevalidation was renamed to validatevalue!');
+ }
+ };
+
+
+ $.event.special.validatevalue = {
+ setup: function(){
var data = $(this).data() || $.data(this, {});
- if(!('valuevalidation' in data)){
- data.valuevalidation = true;
+ if(!('validatevalue' in data)){
+ data.validatevalue = true;
}
}
};
+
+
$(document).on('focusin.lazyloadvalidation', function(e){
if('form' in e.target){
lazyLoad();
}
@@ -1470,10 +1511,30 @@
webshims.ready('WINDOWLOAD', lazyLoad);
if(modules['form-number-date-ui'].loaded && !options.customMessages && (modules['form-number-date-api'].test() || (Modernizr.inputtypes.range && Modernizr.inputtypes.color))){
webshims.isReady('form-number-date-ui', true);
}
+
+ webshims.ready('DOM', function(){
+ if(document.querySelector('.ws-custom-file')){
+ webshims.reTest(['form-validation']);
+ }
+ });
+
+ $(function(){
+ var fileReaderReady = ('FileReader' in window && 'FormData' in window);
+ if(!fileReaderReady){
+ webshims.addReady(function(context){
+ if(!fileReaderReady && !modules.filereader.loaded && !modules.moxie.loaded){
+ if(context.querySelector('input.ws-filereader')){
+ webshims.reTest(['filereader', 'moxie']);
+ fileReaderReady = true;
+ }
+ }
+ });
+ }
+ });
});
;webshims.register('form-message', function($, webshims, window, document, undefined, options){
"use strict";
if(options.lazyCustomMessages){
options.customMessages = true;
@@ -1689,10 +1750,10 @@
}
if(message && message.indexOf('{%') != -1){
['value', 'min', 'max', 'maxlength', 'minlength', 'label'].forEach(function(attr){
if(message.indexOf('{%'+attr) === -1){return;}
- var val = ((attr == 'label') ? $.trim($('label[for="'+ elem.id +'"]', elem.form).text()).replace(/\*$|:$/, '') : $.prop(elem, attr)) || '';
+ var val = ((attr == 'label') ? $.trim($('label[for="'+ elem.id +'"]', elem.form).text()).replace(/\*$|:$/, '') : $.prop(elem, attr) || $.attr(elem, attr) || '') || '';
val = ''+val;
val = toLocale(val, elem, attr);