webshims-rails 1.10.3 → 1.10.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +8 -8
  2. data/lib/webshims-rails/version.rb +2 -2
  3. data/vendor/assets/javascripts/webshims/polyfiller.js +96 -73
  4. data/vendor/assets/javascripts/webshims/shims/color-picker.js +2415 -0
  5. data/vendor/assets/javascripts/webshims/shims/combos/1.js +248 -745
  6. data/vendor/assets/javascripts/webshims/shims/combos/10.js +771 -1206
  7. data/vendor/assets/javascripts/webshims/shims/combos/11.js +679 -1201
  8. data/vendor/assets/javascripts/webshims/shims/combos/12.js +46 -65
  9. data/vendor/assets/javascripts/webshims/shims/combos/13.js +45 -64
  10. data/vendor/assets/javascripts/webshims/shims/combos/14.js +94 -7
  11. data/vendor/assets/javascripts/webshims/shims/combos/15.js +557 -1189
  12. data/vendor/assets/javascripts/webshims/shims/combos/16.js +598 -1249
  13. data/vendor/assets/javascripts/webshims/shims/combos/17.js +697 -1208
  14. data/vendor/assets/javascripts/webshims/shims/combos/18.js +697 -1208
  15. data/vendor/assets/javascripts/webshims/shims/combos/19.js +145 -78
  16. data/vendor/assets/javascripts/webshims/shims/combos/2.js +472 -1280
  17. data/vendor/assets/javascripts/webshims/shims/combos/20.js +144 -77
  18. data/vendor/assets/javascripts/webshims/shims/combos/21.js +14 -15
  19. data/vendor/assets/javascripts/webshims/shims/combos/22.js +2 -2
  20. data/vendor/assets/javascripts/webshims/shims/combos/23.js +45 -64
  21. data/vendor/assets/javascripts/webshims/shims/combos/24.js +848 -0
  22. data/vendor/assets/javascripts/webshims/shims/combos/25.js +4373 -0
  23. data/vendor/assets/javascripts/webshims/shims/combos/26.js +1516 -0
  24. data/vendor/assets/javascripts/webshims/shims/combos/27.js +884 -0
  25. data/vendor/assets/javascripts/webshims/shims/combos/28.js +2067 -0
  26. data/vendor/assets/javascripts/webshims/shims/combos/29.js +1156 -0
  27. data/vendor/assets/javascripts/webshims/shims/combos/3.js +313 -700
  28. data/vendor/assets/javascripts/webshims/shims/combos/30.js +1868 -0
  29. data/vendor/assets/javascripts/webshims/shims/combos/31.js +1663 -0
  30. data/vendor/assets/javascripts/webshims/shims/combos/4.js +111 -20
  31. data/vendor/assets/javascripts/webshims/shims/combos/5.js +747 -1321
  32. data/vendor/assets/javascripts/webshims/shims/combos/6.js +837 -1809
  33. data/vendor/assets/javascripts/webshims/shims/combos/7.js +435 -1239
  34. data/vendor/assets/javascripts/webshims/shims/combos/8.js +360 -766
  35. data/vendor/assets/javascripts/webshims/shims/combos/9.js +843 -1676
  36. data/vendor/assets/javascripts/webshims/shims/details.js +1 -1
  37. data/vendor/assets/javascripts/webshims/shims/dom-extend.js +90 -3
  38. data/vendor/assets/javascripts/webshims/shims/filereader.js +386 -0
  39. data/vendor/assets/javascripts/webshims/shims/form-core.js +201 -680
  40. data/vendor/assets/javascripts/webshims/shims/form-datalist-lazy.js +418 -0
  41. data/vendor/assets/javascripts/webshims/shims/form-datalist.js +69 -467
  42. data/vendor/assets/javascripts/webshims/shims/form-message.js +21 -17
  43. data/vendor/assets/javascripts/webshims/shims/form-native-extend.js +19 -82
  44. data/vendor/assets/javascripts/webshims/shims/form-number-date-api.js +17 -6
  45. data/vendor/assets/javascripts/webshims/shims/form-number-date-ui.js +570 -1185
  46. data/vendor/assets/javascripts/webshims/shims/form-shim-extend.js +181 -28
  47. data/vendor/assets/javascripts/webshims/shims/form-validation.js +599 -0
  48. data/vendor/assets/javascripts/webshims/{extras/custom-validity.js → shims/form-validators.js} +33 -38
  49. data/vendor/assets/javascripts/webshims/shims/forms-picker.js +865 -0
  50. data/vendor/assets/javascripts/webshims/shims/geolocation.js +2 -2
  51. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-de.txt +37 -34
  52. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-en.txt +88 -48
  53. data/vendor/assets/javascripts/webshims/shims/i18n/formcfg-lt.js +74 -0
  54. data/vendor/assets/javascripts/webshims/shims/jpicker/ChangeLog.txt +121 -0
  55. data/vendor/assets/javascripts/webshims/shims/jpicker/ReadMe.txt +47 -0
  56. data/vendor/assets/javascripts/webshims/shims/jpicker/images/AlphaBar.png +0 -0
  57. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Bars.png +0 -0
  58. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Maps.png +0 -0
  59. data/vendor/assets/javascripts/webshims/shims/jpicker/images/NoColor.png +0 -0
  60. data/vendor/assets/javascripts/webshims/shims/jpicker/images/Thumbs.db +0 -0
  61. data/vendor/assets/javascripts/webshims/shims/jpicker/images/bar-opacity.png +0 -0
  62. data/vendor/assets/javascripts/webshims/shims/jpicker/images/map-opacity.png +0 -0
  63. data/vendor/assets/javascripts/webshims/shims/jpicker/images/mappoint.gif +0 -0
  64. data/vendor/assets/javascripts/webshims/shims/jpicker/images/picker.gif +0 -0
  65. data/vendor/assets/javascripts/webshims/shims/jpicker/images/preview-opacity.png +0 -0
  66. data/vendor/assets/javascripts/webshims/shims/jpicker/images/rangearrows.gif +0 -0
  67. data/vendor/assets/javascripts/webshims/shims/jpicker/jpicker.css +257 -0
  68. data/vendor/assets/javascripts/webshims/shims/json-storage.js +4 -4
  69. data/vendor/assets/javascripts/webshims/shims/mediaelement-core.js +44 -63
  70. data/vendor/assets/javascripts/webshims/shims/mediaelement-jaris.js +10 -11
  71. data/vendor/assets/javascripts/webshims/shims/mediaelement-native-fix.js +2 -1
  72. data/vendor/assets/javascripts/webshims/shims/mediaelement-yt.js +5 -3
  73. data/vendor/assets/javascripts/webshims/shims/range-ui.js +110 -17
  74. data/vendor/assets/javascripts/webshims/shims/styles/forms.png +0 -0
  75. data/vendor/assets/javascripts/webshims/shims/styles/range-track.png +0 -0
  76. data/vendor/assets/javascripts/webshims/shims/styles/scss/shim.scss +104 -21
  77. data/vendor/assets/javascripts/webshims/shims/styles/shim.css +90 -16
  78. data/vendor/assets/javascripts/webshims/shims/styles/vertical-range.png +0 -0
  79. data/vendor/assets/javascripts/webshims/shims/swf/filereader.swf +0 -0
  80. data/vendor/assets/javascripts/webshims/shims/swfmini.js +1 -1
  81. data/vendor/assets/javascripts/webshims/shims/track-ui.js +35 -3
  82. data/vendor/assets/javascripts/webshims/shims/track.js +1 -1
  83. metadata +33 -3
@@ -8,7 +8,7 @@ var swfmini = function() {
8
8
 
9
9
  var UNDEF = "undefined",
10
10
  OBJECT = "object",
11
- webshims = jQuery.webshims,
11
+ webshims = jQuery.webshims || window.webshims,
12
12
  SHOCKWAVE_FLASH = "Shockwave Flash",
13
13
  SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
14
14
  FLASH_MIME_TYPE = "application/x-shockwave-flash",
@@ -497,10 +497,10 @@ var swfmini = function() {
497
497
  }();
498
498
 
499
499
  //DOM-Extension helper
500
- jQuery.webshims.register('dom-extend', function($, webshims, window, document, undefined){
500
+ webshims.register('dom-extend', function($, webshims, window, document, undefined){
501
501
  "use strict";
502
502
 
503
- webshims.assumeARIA = Modernizr.localstorage || Modernizr.video || Modernizr.boxsizing;
503
+ webshims.assumeARIA = $.support.getSetAttribute || Modernizr.canvas || Modernizr.video || Modernizr.boxsizing;
504
504
 
505
505
  if($('<input type="email" />').attr('type') == 'text' || $('<form />').attr('novalidate') === "" || ('required' in $('<input />')[0].attributes)){
506
506
  webshims.error("IE browser modes are busted in IE10. Please test your HTML/CSS/JS with a real IE version or at least IETester or similiar tools");
@@ -509,6 +509,57 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
509
509
  if(!$.parseHTML){
510
510
  webshims.error("Webshims needs jQuery 1.8+ to work properly. Please update your jQuery version or downgrade webshims.");
511
511
  }
512
+ if (!webshims.cfg.no$Switch) {
513
+ var switch$ = function(){
514
+ if (window.jQuery && (!window.$ || window.jQuery == window.$) && !window.jQuery.webshims) {
515
+ webshims.error("jQuery was included more than once. Make sure to include it only once! Webshims and other Plugins might not work properly.");
516
+ if (window.$) {
517
+ window.$ = webshims.$;
518
+ }
519
+ window.jQuery = webshims.$;
520
+ }
521
+ if(webshims.M != Modernizr){
522
+ webshims.error("Modernizr was included more than once. Make sure to include it only once! Webshims and other scripts might not work properly.");
523
+ for(var i in Modernizr){
524
+ if(!(i in webshims.M)){
525
+ webshims.M[i] = Modernizr[i];
526
+ }
527
+ }
528
+ Modernizr = webshims.M;
529
+ }
530
+ };
531
+ switch$();
532
+ setTimeout(switch$, 90);
533
+ $(switch$);
534
+ }
535
+ // (function(){
536
+ // var hostNames = {
537
+ // 'afarkas.github.io': 1,
538
+ // localhost: 1,
539
+ // '127.0.0.1': 1
540
+ // };
541
+ //
542
+ // if( webshims.debug && (hostNames[location.hostname] || location.protocol == 'file:') ){
543
+ // var list = $('<ul class="webshims-debug-list" />');
544
+ // webshims.errorLog.push = function(message){
545
+ // list.appendTo('body');
546
+ // $('<li style="display: none;">'+ message +'</li>')
547
+ // .appendTo(list)
548
+ // .slideDown()
549
+ // .delay(3000)
550
+ // .slideUp(function(){
551
+ // $(this).remove();
552
+ // if(!$('li', list).length){
553
+ // list.detach();
554
+ // }
555
+ // })
556
+ // ;
557
+ // };
558
+ // $.each(webshims.errorLog, function(i, message){
559
+ // webshims.errorLog.push(message);
560
+ // });
561
+ // }
562
+ // })();
512
563
 
513
564
  //shortcus
514
565
  var modules = webshims.modules;
@@ -526,6 +577,24 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
526
577
  return (_argless) ? oldVal.call($(elem)) : oldVal.call($(elem), val);
527
578
  };
528
579
 
580
+ //jquery mobile and jquery ui
581
+ if(!$.widget){
582
+ (function(){
583
+ var _cleanData = $.cleanData;
584
+ $.cleanData = function( elems ) {
585
+ if(!$.widget){
586
+ for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
587
+ try {
588
+ $( elem ).triggerHandler( "remove" );
589
+ // http://bugs.jquery.com/ticket/8235
590
+ } catch( e ) {}
591
+ }
592
+ }
593
+ _cleanData( elems );
594
+ };
595
+ })();
596
+ }
597
+
529
598
 
530
599
  $.fn.val = function(val){
531
600
  var elem = this[0];
@@ -559,6 +628,18 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
559
628
  return this.on(evt, fn).each(fn);
560
629
  };
561
630
 
631
+ $.fn.onWSOff = function(evt, fn, trigger, evtDel){
632
+ if(!evtDel){
633
+ evtDel = document;
634
+ }
635
+ $(evtDel)[trigger ? 'onTrigger' : 'on'](evt, fn);
636
+ this.on('remove', function(e){
637
+ if(!e.originalEvent){
638
+ $(evtDel).off(evt, fn);
639
+ }
640
+ });
641
+ };
642
+
562
643
  var dataID = '_webshimsLib'+ (Math.round(Math.random() * 1000));
563
644
  var elementData = function(elem, key, val){
564
645
  elem = elem.jquery ? elem[0] : elem;
@@ -920,7 +1001,7 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
920
1001
  implement: function(elem, type){
921
1002
  var data = elementData(elem, 'implemented') || elementData(elem, 'implemented', {});
922
1003
  if(data[type]){
923
- webshims.info(type +' already implemented for element #'+elem.id);
1004
+ webshims.warn(type +' already implemented for element #'+elem.id);
924
1005
  return false;
925
1006
  }
926
1007
  data[type] = true;
@@ -1064,6 +1145,12 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
1064
1145
  shadowFocusElementData = $.data(opts.shadowFocusElement, dataID) || $.data(opts.shadowFocusElement, dataID, shadowFocusElementData);
1065
1146
  }
1066
1147
 
1148
+ $(nativeElem).on('remove', function(e){
1149
+ if (!e.originalEvent) {
1150
+ $(shadowElem).remove();
1151
+ }
1152
+ });
1153
+
1067
1154
  nativeData.hasShadow = shadowElem;
1068
1155
  shadowFocusElementData.nativeElement = shadowData.nativeElement = nativeElem;
1069
1156
  shadowFocusElementData.shadowData = shadowData.shadowData = nativeData.shadowData = {
@@ -1539,32 +1626,9 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
1539
1626
 
1540
1627
  })(jQuery, document);
1541
1628
 
1542
- //additional tests for partial implementation of forms features
1543
- (function($){
1629
+ webshims.register('form-core', function($, webshims, window, document, undefined, options){
1544
1630
  "use strict";
1545
- var isWebkit = 'webkitURL' in window;
1546
- var Modernizr = window.Modernizr;
1547
- var webshims = $.webshims;
1548
- var bugs = webshims.bugs;
1549
- var form = $('<form action="#" style="width: 1px; height: 1px; overflow: hidden;"><select name="b" required="" /><input required="" name="a" /></form>');
1550
- var testRequiredFind = function(){
1551
- if(form[0].querySelector){
1552
- try {
1553
- bugs.findRequired = !(form[0].querySelector('select:required'));
1554
- } catch(er){
1555
- bugs.findRequired = false;
1556
- }
1557
- }
1558
- };
1559
- var inputElem = $('input', form).eq(0);
1560
- var onDomextend = function(fn){
1561
- webshims.loader.loadList(['dom-extend']);
1562
- webshims.ready('dom-extend', fn);
1563
- };
1564
-
1565
- bugs.findRequired = false;
1566
- bugs.validationMessage = false;
1567
-
1631
+
1568
1632
  webshims.capturingEventPrevented = function(e){
1569
1633
  if(!e._isPolyfilled){
1570
1634
  var isDefaultPrevented = e.isDefaultPrevented;
@@ -1583,195 +1647,258 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
1583
1647
  }
1584
1648
  };
1585
1649
 
1586
- if(!Modernizr.formvalidation || bugs.bustedValidity){
1587
- testRequiredFind();
1588
- } else {
1650
+ if(Modernizr.formvalidation && !webshims.bugs.bustedValidity){
1589
1651
  //create delegatable events
1590
1652
  webshims.capturingEvents(['invalid'], true);
1591
-
1592
- if(window.opera || window.testGoodWithFix){
1593
-
1594
- form.appendTo('head');
1595
-
1596
- testRequiredFind();
1597
- bugs.validationMessage = !(inputElem.prop('validationMessage'));
1653
+ }
1654
+
1655
+ var isValid = function(elem){
1656
+ return ($.prop(elem, 'validity') || {valid: 1}).valid;
1657
+ };
1658
+ var lazyLoad = function(){
1659
+ var toLoad = ['form-validation'];
1660
+ if(options.lazyCustomMessages){
1661
+ options.customMessages = true;
1662
+ toLoad.push('form-message');
1663
+ }
1664
+ if(options.addValidators){
1665
+ toLoad.push('form-validators');
1666
+ }
1667
+ webshims.reTest(toLoad);
1668
+ $(document).off('.lazyloadvalidation');
1669
+ };
1670
+ /*
1671
+ * Selectors for all browsers
1672
+ */
1673
+ var hasInvalid = function(elem){
1674
+ var ret = false;
1675
+ $(elem).jProp('elements').each(function(){
1676
+ ret = $(this).is(':invalid');
1677
+ if(ret){
1678
+ return false;
1679
+ }
1680
+ });
1681
+ return ret;
1682
+ };
1683
+ var rElementsGroup = /^(?:form)$/i;///^(?:form|fieldset)$/i
1684
+ $.extend($.expr[":"], {
1685
+ "valid-element": function(elem){
1686
+ return rElementsGroup.test(elem.nodeName || '') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem));
1687
+ },
1688
+ "invalid-element": function(elem){
1689
+ return rElementsGroup.test(elem.nodeName || '') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
1690
+ },
1691
+ "required-element": function(elem){
1692
+ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
1693
+ },
1694
+ "user-error": function(elem){
1695
+ return ($.prop(elem, 'willValidate') && $(elem).hasClass('user-error'));
1696
+ },
1697
+ "optional-element": function(elem){
1698
+ return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
1699
+ }
1700
+ });
1701
+
1702
+ ['valid', 'invalid', 'required', 'optional'].forEach(function(name){
1703
+ $.expr[":"][name] = $.expr.filters[name+"-element"];
1704
+ });
1705
+
1706
+
1707
+ $.expr[":"].focus = function( elem ) {
1708
+ try {
1709
+ var doc = elem.ownerDocument;
1710
+ return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus());
1711
+ } catch(e){}
1712
+ return false;
1713
+ };
1714
+
1715
+ webshims.triggerInlineForm = function(elem, event){
1716
+ $(elem).trigger(event);
1717
+ };
1718
+
1719
+ var lazyLoadProxy = function(obj, fn, args){
1720
+ lazyLoad();
1721
+ webshims.ready('form-validation', function(){
1722
+ obj[fn].apply(obj, args);
1723
+ });
1724
+ };
1725
+
1726
+
1727
+ webshims.wsPopover = {
1728
+ id: 0,
1729
+ _create: function(){
1730
+ this.options = $.extend({}, webshims.cfg.wspopover, this.options);
1731
+ this.id = webshims.wsPopover.id++;
1732
+ this.eventns = '.wsoverlay' + this.id;
1733
+ this.timers = {};
1734
+ this.element = $('<div class="ws-popover" tabindex="-1"><div class="ws-po-outerbox"><div class="ws-po-arrow"><div class="ws-po-arrowbox" /></div><div class="ws-po-box" /></div></div>');
1735
+ this.contentElement = $('.ws-po-box', this.element);
1736
+ this.lastElement = $([]);
1737
+ this.bindElement();
1598
1738
 
1599
- webshims.reTest(['form-native-extend', 'form-message']);
1739
+ this.element.data('wspopover', this);
1600
1740
 
1601
- form.remove();
1602
-
1603
- $(function(){
1604
- onDomextend(function(){
1605
-
1606
- //Opera shows native validation bubbles in case of input.checkValidity()
1607
- // Opera 11.6/12 hasn't fixed this issue right, it's buggy
1608
- var preventDefault = function(e){
1609
- e.preventDefault();
1610
- };
1611
-
1612
- ['form', 'input', 'textarea', 'select'].forEach(function(name){
1613
- var desc = webshims.defineNodeNameProperty(name, 'checkValidity', {
1614
- prop: {
1615
- value: function(){
1616
- if (!webshims.fromSubmit) {
1617
- $(this).on('invalid.checkvalidity', preventDefault);
1618
- }
1619
-
1620
- webshims.fromCheckValidity = true;
1621
- var ret = desc.prop._supvalue.apply(this, arguments);
1622
- if (!webshims.fromSubmit) {
1623
- $(this).unbind('invalid.checkvalidity', preventDefault);
1624
- }
1625
- webshims.fromCheckValidity = false;
1626
- return ret;
1627
- }
1628
- }
1629
- });
1630
- });
1631
-
1632
- });
1741
+ },
1742
+ options: {},
1743
+ content: function(html){
1744
+ this.contentElement.html(html);
1745
+ },
1746
+ bindElement: function(){
1747
+ var that = this;
1748
+ var stopBlur = function(){
1749
+ that.stopBlur = false;
1750
+ };
1751
+ this.preventBlur = function(e){
1752
+ that.stopBlur = true;
1753
+ clearTimeout(that.timers.stopBlur);
1754
+ that.timers.stopBlur = setTimeout(stopBlur, 9);
1755
+ };
1756
+ this.element.on({
1757
+ 'mousedown': this.preventBlur
1633
1758
  });
1759
+ },
1760
+ show: function(){
1761
+ lazyLoadProxy(this, 'show', arguments);
1634
1762
  }
1635
-
1636
- if(isWebkit && !webshims.bugs.bustedValidity){
1637
- (function(){
1638
- var elems = /^(?:textarea|input)$/i;
1639
- var form = false;
1640
-
1641
- document.addEventListener('contextmenu', function(e){
1642
- if(elems.test( e.target.nodeName || '') && (form = e.target.form)){
1643
- setTimeout(function(){
1644
- form = false;
1645
- }, 1);
1646
- }
1647
- }, false);
1648
-
1649
- $(window).on('invalid', function(e){
1650
- if(e.originalEvent && form && form == e.target.form){
1651
- e.wrongWebkitInvalid = true;
1652
- e.stopImmediatePropagation();
1653
- }
1654
- });
1655
-
1656
- })();
1763
+ };
1764
+
1765
+ /* some extra validation UI */
1766
+ webshims.validityAlert = {
1767
+ showFor: function(){
1768
+ lazyLoadProxy(this, 'showFor', arguments);
1657
1769
  }
1658
- }
1659
-
1660
- $.webshims.register('form-core', function($, webshims, window, document, undefined, options){
1770
+ };
1661
1771
 
1662
- var checkTypes = {checkbox: 1, radio: 1};
1663
- var emptyJ = $([]);
1664
- var bugs = webshims.bugs;
1665
- var getGroupElements = function(elem){
1666
- elem = $(elem);
1667
- var name;
1668
- var form;
1669
- var ret = emptyJ;
1670
- if(elem[0].type == 'radio'){
1671
- form = elem.prop('form');
1672
- name = elem[0].name;
1673
- if(!name){
1674
- ret = elem;
1675
- } else if(form){
1676
- ret = $(form[name]);
1677
- } else {
1678
- ret = $(document.getElementsByName(name)).filter(function(){
1679
- return !$.prop(this, 'form');
1680
- });
1681
- }
1682
- ret = ret.filter('[type="radio"]');
1683
- }
1684
- return ret;
1685
- };
1772
+
1773
+ /* extension, but also used to fix native implementation workaround/bugfixes */
1774
+ (function(){
1775
+ var firstEvent,
1776
+ invalids = [],
1777
+ stopSubmitTimer,
1778
+ form
1779
+ ;
1686
1780
 
1687
- var getContentValidationMessage = webshims.getContentValidationMessage = function(elem, validity, key){
1688
- var message = $(elem).data('errormessage') || elem.getAttribute('x-moz-errormessage') || '';
1689
- if(key && message[key]){
1690
- message = message[key];
1691
- }
1692
- if(typeof message == 'object'){
1693
- validity = validity || $.prop(elem, 'validity') || {valid: 1};
1694
- if(!validity.valid){
1695
- $.each(validity, function(name, prop){
1696
- if(prop && name != 'valid' && message[name]){
1697
- message = message[name];
1698
- return false;
1699
- }
1700
- });
1701
- }
1702
- }
1781
+ $(document).on('invalid', function(e){
1782
+ if(e.wrongWebkitInvalid){return;}
1783
+ var jElm = $(e.target);
1784
+
1703
1785
 
1704
- if(typeof message == 'object'){
1705
- message = message.defaultMessage;
1786
+ if(!firstEvent){
1787
+ //trigger firstinvalid
1788
+ firstEvent = $.Event('firstinvalid');
1789
+ firstEvent.isInvalidUIPrevented = e.isDefaultPrevented;
1790
+ var firstSystemInvalid = $.Event('firstinvalidsystem');
1791
+ $(document).triggerHandler(firstSystemInvalid, {element: e.target, form: e.target.form, isInvalidUIPrevented: e.isDefaultPrevented});
1792
+ jElm.trigger(firstEvent);
1706
1793
  }
1707
- return message || '';
1708
- };
1794
+
1795
+ //if firstinvalid was prevented all invalids will be also prevented
1796
+ if( firstEvent && firstEvent.isDefaultPrevented() ){
1797
+ e.preventDefault();
1798
+ }
1799
+ invalids.push(e.target);
1800
+ e.extraData = 'fix';
1801
+ clearTimeout(stopSubmitTimer);
1802
+ stopSubmitTimer = setTimeout(function(){
1803
+ var lastEvent = {type: 'lastinvalid', cancelable: false, invalidlist: $(invalids)};
1804
+ //reset firstinvalid
1805
+ firstEvent = false;
1806
+ invalids = [];
1807
+ $(e.target).trigger(lastEvent, lastEvent);
1808
+ }, 9);
1809
+ jElm = null;
1810
+ });
1811
+ })();
1812
+
1813
+
1814
+ webshims.getContentValidationMessage = function(elem, validity, key){
1815
+ var message = $(elem).data('errormessage') || elem.getAttribute('x-moz-errormessage') || '';
1816
+ if(key && message[key]){
1817
+ message = message[key];
1818
+ }
1819
+ if(typeof message == 'object'){
1820
+ validity = validity || $.prop(elem, 'validity') || {valid: 1};
1821
+ if(!validity.valid){
1822
+ $.each(validity, function(name, prop){
1823
+ if(prop && name != 'valid' && message[name]){
1824
+ message = message[name];
1825
+ return false;
1826
+ }
1827
+ });
1828
+ }
1829
+ }
1709
1830
 
1710
- /*
1711
- * Selectors for all browsers
1712
- */
1713
- var rangeTypes = {number: 1, range: 1, date: 1/*, time: 1, 'datetime-local': 1, datetime: 1, month: 1, week: 1*/};
1714
- var hasInvalid = function(elem){
1715
- var ret = false;
1716
- $($.prop(elem, 'elements')).each(function(){
1717
- ret = $(this).is(':invalid');
1718
- if(ret){
1719
- return false;
1720
- }
1721
- });
1722
- return ret;
1723
- };
1724
- $.extend($.expr[":"], {
1725
- "valid-element": function(elem){
1726
- return $.nodeName(elem, 'form') ? !hasInvalid(elem) :!!($.prop(elem, 'willValidate') && isValid(elem));
1727
- },
1728
- "invalid-element": function(elem){
1729
- return $.nodeName(elem, 'form') ? hasInvalid(elem) : !!($.prop(elem, 'willValidate') && !isValid(elem));
1730
- },
1731
- "required-element": function(elem){
1732
- return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required'));
1733
- },
1734
- "user-error": function(elem){
1735
- return ($.prop(elem, 'willValidate') && $(elem).hasClass('user-error'));
1736
- },
1737
- "optional-element": function(elem){
1738
- return !!($.prop(elem, 'willValidate') && $.prop(elem, 'required') === false);
1739
- },
1740
- "in-range": function(elem){
1741
- if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1742
- return false;
1743
- }
1744
- var val = $.prop(elem, 'validity');
1745
- return !!(val && !val.rangeOverflow && !val.rangeUnderflow);
1746
- },
1747
- "out-of-range": function(elem){
1748
- if(!rangeTypes[$.prop(elem, 'type')] || !$.prop(elem, 'willValidate')){
1749
- return false;
1750
- }
1751
- var val = $.prop(elem, 'validity');
1752
- return !!(val && (val.rangeOverflow || val.rangeUnderflow));
1831
+ if(typeof message == 'object'){
1832
+ message = message.defaultMessage;
1833
+ }
1834
+ return message || '';
1835
+ };
1836
+
1837
+ $.fn.getErrorMessage = function(key){
1838
+ var message = '';
1839
+ var elem = this[0];
1840
+ if(elem){
1841
+ message = webshims.getContentValidationMessage(elem, false, key) || $.prop(elem, 'customValidationMessage') || $.prop(elem, 'validationMessage');
1842
+ }
1843
+ return message;
1844
+ };
1845
+
1846
+
1847
+ webshims.ready('forms', function(){
1848
+ $(document).on('focusin.lazyloadvalidation', function(e){
1849
+ if('form' in e.target && $(e.target).is(':invalid')){
1850
+ lazyLoad();
1753
1851
  }
1754
-
1755
1852
  });
1756
-
1757
- ['valid', 'invalid', 'required', 'optional'].forEach(function(name){
1758
- $.expr[":"][name] = $.expr.filters[name+"-element"];
1853
+ });
1854
+ webshims.ready('WINDOWLOAD', lazyLoad);
1855
+ if(options.overrideMessages){
1856
+ options.customMessages = true;
1857
+ webshims.reTest('form-message');
1858
+ webshims.error('overrideMessages is deprecated. use customMessages instead.');
1859
+ }
1860
+ if(options.replaceValidationUI){
1861
+ webshims.ready('DOM forms', function(){
1862
+ $(document).on('firstinvalid', function(e){
1863
+ if(!e.isInvalidUIPrevented()){
1864
+ e.preventDefault();
1865
+ webshims.validityAlert.showFor( e.target );
1866
+ }
1867
+ });
1759
1868
  });
1760
-
1761
-
1762
- $.expr[":"].focus = function( elem ) {
1763
- try {
1764
- var doc = elem.ownerDocument;
1765
- return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus());
1766
- } catch(e){}
1767
- return false;
1768
- };
1769
-
1770
-
1771
- var customEvents = $.event.customEvent || {};
1772
- var isValid = function(elem){
1773
- return ($.prop(elem, 'validity') || {valid: 1}).valid;
1774
- };
1869
+ }
1870
+ });
1871
+
1872
+
1873
+ if(!Modernizr.formvalidation || webshims.bugs.bustedValidity){
1874
+ webshims.register('form-shim-extend', function($, webshims, window, document, undefined, options){
1875
+ "use strict";
1876
+ webshims.inputTypes = webshims.inputTypes || {};
1877
+ //some helper-functions
1878
+ var cfg = webshims.cfg.forms;
1879
+ var bugs = webshims.bugs;
1880
+ var isSubmit;
1881
+
1882
+ var isNumber = function(string){
1883
+ return (typeof string == 'number' || (string && string == string * 1));
1884
+ },
1885
+ typeModels = webshims.inputTypes,
1886
+ checkTypes = {
1887
+ radio: 1,
1888
+ checkbox: 1
1889
+ },
1890
+ getType = function(elem){
1891
+ return (elem.getAttribute('type') || elem.type || '').toLowerCase();
1892
+ }
1893
+ ;
1894
+
1895
+ (function(){
1896
+ if('querySelector' in document){
1897
+ try {
1898
+ bugs.findRequired = !($('<form action="#" style="width: 1px; height: 1px; overflow: hidden;"><select name="b" required="" /></form>')[0].querySelector('select:required'));
1899
+ } catch(er){
1900
+ bugs.findRequired = false;
1901
+ }
1775
1902
 
1776
1903
  if (bugs.bustedValidity || bugs.findRequired) {
1777
1904
  (function(){
@@ -1807,480 +1934,8 @@ jQuery.webshims.register('dom-extend', function($, webshims, window, document, u
1807
1934
 
1808
1935
  })();
1809
1936
  }
1810
-
1811
- //ToDo needs testing
1812
- var oldAttr = $.prop;
1813
- var changeVals = {selectedIndex: 1, value: 1, checked: 1, disabled: 1, readonly: 1};
1814
- $.prop = function(elem, name, val){
1815
- var ret = oldAttr.apply(this, arguments);
1816
- if(elem && 'form' in elem && changeVals[name] && val !== undefined && $(elem).hasClass(invalidClass)){
1817
- if(isValid(elem)){
1818
- $(elem).getShadowElement().removeClass(invalidClass);
1819
- if(name == 'checked' && val) {
1820
- getGroupElements(elem).not(elem).removeClass(invalidClass).removeAttr('aria-invalid');
1821
- }
1822
- }
1823
- }
1824
- return ret;
1825
- };
1826
-
1827
- var returnValidityCause = function(validity, elem){
1828
- var ret;
1829
- $.each(validity, function(name, value){
1830
- if(value){
1831
- ret = (name == 'customError') ? $.prop(elem, 'validationMessage') : name;
1832
- return false;
1833
- }
1834
- });
1835
- return ret;
1836
- };
1837
-
1838
- var isInGroup = function(name){
1839
- var ret;
1840
- try {
1841
- ret = document.activeElement.name === name;
1842
- } catch(e){}
1843
- return ret;
1844
- };
1845
- /* form-ui-invalid/form-ui-valid are deprecated. use user-error/user-success instead */
1846
- var invalidClass = 'user-error';
1847
- var validClass = 'user-success';
1848
- var stopChangeTypes = {
1849
- time: 1,
1850
- date: 1,
1851
- month: 1,
1852
- datetime: 1,
1853
- week: 1,
1854
- 'datetime-local': 1
1855
- };
1856
- var switchValidityClass = function(e){
1857
- var elem, timer;
1858
- if(!e.target){return;}
1859
- elem = $(e.target).getNativeElement()[0];
1860
- if(elem.type == 'submit' || !$.prop(elem, 'willValidate')){return;}
1861
- timer = $.data(elem, 'webshimsswitchvalidityclass');
1862
- var switchClass = function(){
1863
- if(e.type == 'focusout' && elem.type == 'radio' && isInGroup(elem.name)){return;}
1864
- var validity = $.prop(elem, 'validity');
1865
- var shadowElem = $(elem).getShadowElement();
1866
- var addClass, removeClass, trigger, generaltrigger, validityCause;
1867
-
1868
- if(isWebkit && e.type == 'change' && !bugs.bustedValidity && stopChangeTypes[shadowElem.prop('type')] && shadowElem.is(':focus')){return;}
1869
-
1870
- $(elem).trigger('refreshCustomValidityRules');
1871
-
1872
- if(validity.valid){
1873
- if(!shadowElem.hasClass(validClass)){
1874
- addClass = validClass;
1875
- removeClass = invalidClass;
1876
- generaltrigger = 'changedvaliditystate';
1877
- trigger = 'changedvalid';
1878
- if(checkTypes[elem.type] && elem.checked){
1879
- getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass).removeAttr('aria-invalid');
1880
- }
1881
- $.removeData(elem, 'webshimsinvalidcause');
1882
- }
1883
- } else {
1884
- validityCause = returnValidityCause(validity, elem);
1885
- if($.data(elem, 'webshimsinvalidcause') != validityCause){
1886
- $.data(elem, 'webshimsinvalidcause', validityCause);
1887
- generaltrigger = 'changedvaliditystate';
1888
- }
1889
- if(!shadowElem.hasClass(invalidClass)){
1890
- addClass = invalidClass;
1891
- removeClass = validClass;
1892
- if (checkTypes[elem.type] && !elem.checked) {
1893
- getGroupElements(elem).not(elem).removeClass(removeClass).addClass(addClass);
1894
- }
1895
- trigger = 'changedinvalid';
1896
- }
1897
- }
1898
-
1899
- if(addClass){
1900
- shadowElem.addClass(addClass).removeClass(removeClass);
1901
- //jQuery 1.6.1 IE9 bug (doubble trigger bug)
1902
- setTimeout(function(){
1903
- $(elem).trigger(trigger);
1904
- }, 0);
1905
- }
1906
- if(generaltrigger){
1907
- setTimeout(function(){
1908
- $(elem).trigger(generaltrigger);
1909
- }, 0);
1910
- }
1911
-
1912
- $.removeData(elem, 'webshimsswitchvalidityclass');
1913
- };
1914
-
1915
- if(timer){
1916
- clearTimeout(timer);
1917
- }
1918
- if(e.type == 'refreshvalidityui'){
1919
- switchClass();
1920
- } else {
1921
- $.data(elem, 'webshimsswitchvalidityclass', setTimeout(switchClass, 9));
1922
- }
1923
- };
1924
-
1925
- $(document).on(options.validityUIEvents || 'focusout change refreshvalidityui', switchValidityClass);
1926
- customEvents.changedvaliditystate = true;
1927
- customEvents.refreshCustomValidityRules = true;
1928
- customEvents.changedvalid = true;
1929
- customEvents.changedinvalid = true;
1930
- customEvents.refreshvalidityui = true;
1931
-
1932
-
1933
- webshims.triggerInlineForm = function(elem, event){
1934
- $(elem).trigger(event);
1935
- };
1936
-
1937
- webshims.modules["form-core"].getGroupElements = getGroupElements;
1938
-
1939
-
1940
- var setRoot = function(){
1941
- webshims.scrollRoot = (isWebkit || document.compatMode == 'BackCompat') ?
1942
- $(document.body) :
1943
- $(document.documentElement)
1944
- ;
1945
- };
1946
- var minWidth = (Modernizr.boxSizing || Modernizr['display-table'] || $.support.getSetAttribute) ?
1947
- 'minWidth' :
1948
- 'width'
1949
- ;
1950
- setRoot();
1951
- webshims.ready('DOM', setRoot);
1952
-
1953
- webshims.getRelOffset = function(posElem, relElem){
1954
- posElem = $(posElem);
1955
- var offset = $(relElem).offset();
1956
- var bodyOffset;
1957
- $.swap($(posElem)[0], {visibility: 'hidden', display: 'inline-block', left: 0, top: 0}, function(){
1958
- bodyOffset = posElem.offset();
1959
- });
1960
- offset.top -= bodyOffset.top;
1961
- offset.left -= bodyOffset.left;
1962
- return offset;
1963
- };
1964
-
1965
- webshims.wsPopover = {
1966
- _create: function(){
1967
- this.options = $.extend({}, webshims.cfg.wspopover, this.options);
1968
- this.id = webshims.wsPopover.id++;
1969
- this.eventns = '.wsoverlay'+this.id;
1970
- this.timers = {};
1971
- this.element = $('<div class="ws-popover" tabindex="-1"><div class="ws-po-outerbox"><div class="ws-po-arrow"><div class="ws-po-arrowbox" /></div><div class="ws-po-box" /></div></div>');
1972
- this.contentElement = $('.ws-po-box', this.element);
1973
- this.lastElement = $([]);
1974
- this.bindElement();
1975
-
1976
- this.element.data('wspopover', this);
1977
-
1978
- },
1979
- options: {},
1980
- content: function(html){
1981
- this.contentElement.html(html);
1982
- },
1983
- bindElement: function(){
1984
- var that = this;
1985
- var stopBlur = function(){
1986
- that.stopBlur = false;
1987
- };
1988
- this.preventBlur = function(e){
1989
- that.stopBlur = true;
1990
- clearTimeout(that.timers.stopBlur);
1991
- that.timers.stopBlur = setTimeout(stopBlur, 9);
1992
- };
1993
- this.element.on({
1994
- 'mousedown': this.preventBlur
1995
- });
1996
- },
1997
-
1998
- isInElement: function(container, contained){
1999
- return container == contained || $.contains(container, contained);
2000
- },
2001
- show: function(element){
2002
- var e = $.Event('wspopoverbeforeshow');
2003
- this.element.trigger(e);
2004
- if(e.isDefaultPrevented() || this.isVisible){return;}
2005
- this.isVisible = true;
2006
- element = $(element || this.options.prepareFor).getNativeElement() ;
2007
-
2008
- var that = this;
2009
- var visual = $(element).getShadowElement();
2010
-
2011
- this.clear();
2012
- this.element.removeClass('ws-po-visible').css('display', 'none');
2013
-
2014
- this.prepareFor(element, visual);
2015
-
2016
- this.position(visual);
2017
- that.timers.show = setTimeout(function(){
2018
- that.element.css('display', '');
2019
- that.timers.show = setTimeout(function(){
2020
- that.element.addClass('ws-po-visible').trigger('wspopovershow');
2021
- }, 9);
2022
- }, 9);
2023
- $(document).on('focusin'+this.eventns+' mousedown'+this.eventns, function(e){
2024
- if(that.options.hideOnBlur && !that.stopBlur && !that.isInElement(that.lastElement[0] || document.body, e.target) && !that.isInElement(element[0] || document.body, e.target) && !that.isInElement(that.element[0], e.target)){
2025
- that.hide();
2026
- }
2027
- });
2028
- $(window).on('resize'+this.eventns + ' pospopover'+this.eventns, function(){
2029
- clearTimeout(that.timers.repos);
2030
- that.timers.repos = setTimeout(function(){
2031
- that.position(visual);
2032
- }, 900);
2033
- });
2034
- },
2035
- prepareFor: function(element, visual){
2036
- var onBlur;
2037
- var opts = $.extend({}, this.options, $(element.prop('form') || []).data('wspopover') || {}, element.data('wspopover'));
2038
- var that = this;
2039
- var css = {};
2040
- this.lastElement = $(element).getShadowFocusElement();
2041
- if(opts.appendTo == 'element'){
2042
- this.element.insertAfter(element);
2043
- } else {
2044
- this.element.appendTo(opts.appendTo);
2045
- }
2046
-
2047
- this.element.attr({
2048
- 'data-class': element.prop('className'),
2049
- 'data-id': element.prop('id')
2050
- });
2051
-
2052
- css[minWidth] = opts.constrainWidth ? visual.outerWidth() : '';
2053
-
2054
- this.element.css(css);
2055
-
2056
- if(opts.hideOnBlur){
2057
- onBlur = function(e){
2058
- if(that.stopBlur){
2059
- e.stopImmediatePropagation();
2060
- } else {
2061
- that.hide();
2062
- }
2063
- };
2064
-
2065
- that.timers.bindBlur = setTimeout(function(){
2066
- that.lastElement.off(that.eventns).on('focusout'+that.eventns + ' blur'+that.eventns, onBlur);
2067
- that.lastElement.getNativeElement().off(that.eventns);
2068
- }, 10);
2069
-
2070
-
2071
- }
2072
-
2073
- if(!this.prepared){
2074
-
2075
- if($.fn.bgIframe){
2076
- this.element.bgIframe();
2077
- }
2078
- }
2079
- this.prepared = true;
2080
- },
2081
- clear: function(){
2082
- $(window).off(this.eventns);
2083
- $(document).off(this.eventns);
2084
-
2085
- this.stopBlur = false;
2086
- $.each(this.timers, function(timerName, val){
2087
- clearTimeout(val);
2088
- });
2089
- },
2090
- hide: function(){
2091
- var e = $.Event('wspopoverbeforehide');
2092
- this.element.trigger(e);
2093
- if(e.isDefaultPrevented() || !this.isVisible){return;}
2094
- this.isVisible = false;
2095
- var that = this;
2096
- var forceHide = function(){
2097
- that.element.css('display', 'none').attr({'data-id': '', 'data-class': '', 'hidden': 'hidden'});
2098
- clearTimeout(that.timers.forcehide);
2099
- };
2100
- this.clear();
2101
- this.element.removeClass('ws-po-visible').trigger('wspopoverhide');
2102
- $(window).on('resize'+this.eventns, forceHide);
2103
- that.timers.forcehide = setTimeout(forceHide, 999);
2104
- },
2105
- position: function(element){
2106
- var offset = webshims.getRelOffset(this.element.css({marginTop: 0, marginLeft: 0, marginRight: 0, marginBottom: 0}).removeAttr('hidden'), element);
2107
- offset.top += element.outerHeight();
2108
- this.element.css({marginTop: '', marginLeft: '', marginRight: '', marginBottom: ''}).css(offset);
2109
- }
2110
- };
2111
-
2112
- webshims.wsPopover.id = 0;
2113
-
2114
- /* some extra validation UI */
2115
- webshims.validityAlert = (function(){
2116
-
2117
-
2118
- var focusTimer = false;
2119
-
2120
- var api = webshims.objectCreate(webshims.wsPopover, {}, options.messagePopover);
2121
- var boundHide = api.hide.bind(api);
2122
-
2123
- api.element.addClass('validity-alert').attr({role: 'alert'});
2124
- $.extend(api, {
2125
- hideDelay: 5000,
2126
- showFor: function(elem, message, noFocusElem, noBubble){
2127
-
2128
- elem = $(elem).getNativeElement();
2129
- this.clear();
2130
- this.hide();
2131
- if(!noBubble){
2132
- this.getMessage(elem, message);
2133
-
2134
- this.show(elem);
2135
- if(this.hideDelay){
2136
- this.timers.delayedHide = setTimeout(boundHide, this.hideDelay);
2137
- }
2138
-
2139
- }
2140
-
2141
- if(!noFocusElem){
2142
- this.setFocus(elem);
2143
- }
2144
- },
2145
- setFocus: function(element){
2146
- var focusElem = $(element).getShadowFocusElement();
2147
- var scrollTop = webshims.scrollRoot.scrollTop();
2148
- var elemTop = focusElem.offset().top - 30;
2149
- var smooth;
2150
-
2151
- if(scrollTop > elemTop){
2152
- webshims.scrollRoot.animate(
2153
- {scrollTop: elemTop - 5},
2154
- {
2155
- queue: false,
2156
- duration: Math.max( Math.min( 600, (scrollTop - elemTop) * 1.5 ), 80 )
2157
- }
2158
- );
2159
- smooth = true;
2160
- }
2161
- try {
2162
- focusElem[0].focus();
2163
- } catch(e){}
2164
- if(smooth){
2165
- webshims.scrollRoot.scrollTop(scrollTop);
2166
- setTimeout(function(){
2167
- webshims.scrollRoot.scrollTop(scrollTop);
2168
- }, 0);
2169
- }
2170
-
2171
- $(window).triggerHandler('pospopover'+this.eventns);
2172
- },
2173
- getMessage: function(elem, message){
2174
- if (!message) {
2175
- message = getContentValidationMessage(elem[0]) || elem.prop('customValidationMessage') || elem.prop('validationMessage');
2176
- }
2177
- if (message) {
2178
- api.contentElement.text(message);
2179
- } else {
2180
- this.hide();
2181
- }
2182
- }
2183
- });
2184
-
2185
-
2186
- return api;
2187
- })();
2188
-
2189
-
2190
- /* extension, but also used to fix native implementation workaround/bugfixes */
2191
- (function(){
2192
- var firstEvent,
2193
- invalids = [],
2194
- stopSubmitTimer,
2195
- form
2196
- ;
2197
-
2198
- $(document).on('invalid', function(e){
2199
- if(e.wrongWebkitInvalid){return;}
2200
- var jElm = $(e.target);
2201
- var shadowElem = jElm.getShadowElement();
2202
- if(!shadowElem.hasClass(invalidClass)){
2203
- shadowElem.addClass(invalidClass).removeClass(validClass);
2204
- setTimeout(function(){
2205
- $(e.target).trigger('changedinvalid').trigger('changedvaliditystate');
2206
- }, 0);
2207
- }
2208
-
2209
- if(!firstEvent){
2210
- //trigger firstinvalid
2211
- firstEvent = $.Event('firstinvalid');
2212
- firstEvent.isInvalidUIPrevented = e.isDefaultPrevented;
2213
- var firstSystemInvalid = $.Event('firstinvalidsystem');
2214
- $(document).triggerHandler(firstSystemInvalid, {element: e.target, form: e.target.form, isInvalidUIPrevented: e.isDefaultPrevented});
2215
- jElm.trigger(firstEvent);
2216
- }
2217
-
2218
- //if firstinvalid was prevented all invalids will be also prevented
2219
- if( firstEvent && firstEvent.isDefaultPrevented() ){
2220
- e.preventDefault();
2221
- }
2222
- invalids.push(e.target);
2223
- e.extraData = 'fix';
2224
- clearTimeout(stopSubmitTimer);
2225
- stopSubmitTimer = setTimeout(function(){
2226
- var lastEvent = {type: 'lastinvalid', cancelable: false, invalidlist: $(invalids)};
2227
- //reset firstinvalid
2228
- firstEvent = false;
2229
- invalids = [];
2230
- $(e.target).trigger(lastEvent, lastEvent);
2231
- }, 9);
2232
- jElm = null;
2233
- shadowElem = null;
2234
- });
2235
- })();
2236
-
2237
- $.fn.getErrorMessage = function(){
2238
- var message = '';
2239
- var elem = this[0];
2240
- if(elem){
2241
- message = getContentValidationMessage(elem) || $.prop(elem, 'customValidationMessage') || $.prop(elem, 'validationMessage');
2242
- }
2243
- return message;
2244
- };
2245
-
2246
- if(options.replaceValidationUI){
2247
- if(options.overrideMessages && (options.customMessages || options.customMessages == null)){
2248
- options.customMessages = true;
2249
- options.overrideMessages = false;
2250
- webshims.info("set overrideMessages to false. Use customMessages instead");
2251
- }
2252
- webshims.ready('DOM forms', function(){
2253
- $(document).on('firstinvalid', function(e){
2254
- if(!e.isInvalidUIPrevented()){
2255
- e.preventDefault();
2256
- $.webshims.validityAlert.showFor( e.target );
2257
- }
2258
- });
2259
- });
2260
- }
2261
- });
2262
-
2263
- })(jQuery);
2264
- if(!Modernizr.formvalidation || jQuery.webshims.bugs.bustedValidity){
2265
- jQuery.webshims.register('form-shim-extend', function($, webshims, window, document){
2266
- "use strict";
2267
- webshims.inputTypes = webshims.inputTypes || {};
2268
- //some helper-functions
2269
- var cfg = webshims.cfg.forms;
2270
- var isSubmit;
2271
-
2272
- var isNumber = function(string){
2273
- return (typeof string == 'number' || (string && string == string * 1));
2274
- },
2275
- typeModels = webshims.inputTypes,
2276
- checkTypes = {
2277
- radio: 1,
2278
- checkbox: 1
2279
- },
2280
- getType = function(elem){
2281
- return (elem.getAttribute('type') || elem.type || '').toLowerCase();
2282
1937
  }
2283
- ;
1938
+ })();
2284
1939
 
2285
1940
  //API to add new input types
2286
1941
  webshims.addInputType = function(type, obj){
@@ -2309,7 +1964,29 @@ var isPlaceholderOptionSelected = function(select){
2309
1964
  }
2310
1965
  return false;
2311
1966
  };
2312
-
1967
+ var modules = webshims.modules;
1968
+ var emptyJ = $([]);
1969
+ var getGroupElements = function(elem){
1970
+ elem = $(elem);
1971
+ var name;
1972
+ var form;
1973
+ var ret = emptyJ;
1974
+ if(elem[0].type == 'radio'){
1975
+ form = elem.prop('form');
1976
+ name = elem[0].name;
1977
+ if(!name){
1978
+ ret = elem;
1979
+ } else if(form){
1980
+ ret = $(form[name]);
1981
+ } else {
1982
+ ret = $(document.getElementsByName(name)).filter(function(){
1983
+ return !$.prop(this, 'form');
1984
+ });
1985
+ }
1986
+ ret = ret.filter('[type="radio"]');
1987
+ }
1988
+ return ret;
1989
+ };
2313
1990
  var validityRules = {
2314
1991
  valueMissing: function(input, val, cache){
2315
1992
  if(!input.prop('required')){return false;}
@@ -2320,7 +1997,7 @@ var validityRules = {
2320
1997
  if(cache.nodeName == 'select'){
2321
1998
  ret = (!val && (input[0].selectedIndex < 0 || isPlaceholderOptionSelected(input[0]) ));
2322
1999
  } else if(checkTypes[cache.type]){
2323
- ret = (cache.type == 'checkbox') ? !input.is(':checked') : !webshims.modules["form-core"].getGroupElements(input).filter(':checked')[0];
2000
+ ret = (cache.type == 'checkbox') ? !input.is(':checked') : !getGroupElements(input).filter(':checked')[0];
2324
2001
  } else {
2325
2002
  ret = !(val);
2326
2003
  }
@@ -3115,6 +2792,52 @@ webshims.addReady(function(context, contextElem){
3115
2792
 
3116
2793
  });
3117
2794
 
2795
+ if(!Modernizr.input.list){
2796
+ webshims.defineNodeNameProperty('datalist', 'options', {
2797
+ prop: {
2798
+ writeable: false,
2799
+ get: function(){
2800
+ var elem = this;
2801
+ var select = $('select', elem);
2802
+ var options;
2803
+ if(select[0]){
2804
+ options = select[0].options;
2805
+ } else {
2806
+ options = $('option', elem).get();
2807
+ if(options.length){
2808
+ webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
2809
+ }
2810
+ }
2811
+ return options;
2812
+ }
2813
+ }
2814
+ });
2815
+
2816
+ webshims.ready('form-datalist', function(){
2817
+ webshims.defineNodeNameProperties('input', {
2818
+ list: {
2819
+ attr: {
2820
+ get: function(){
2821
+ var val = webshims.contentAttr(this, 'list');
2822
+ return (val == null) ? undefined : val;
2823
+ },
2824
+ set: function(value){
2825
+ var elem = this;
2826
+ webshims.contentAttr(elem, 'list', value);
2827
+ webshims.objectCreate(options.shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
2828
+ $(elem).triggerHandler('listdatalistchange');
2829
+ }
2830
+ },
2831
+ initAttr: true,
2832
+ reflect: true,
2833
+ propType: 'element',
2834
+ propNodeName: 'datalist'
2835
+ }
2836
+ });
2837
+ });
2838
+
2839
+ }
2840
+
3118
2841
  if(!Modernizr.formattribute || !Modernizr.fieldsetdisabled){
3119
2842
  (function(){
3120
2843
  (function(prop, undefined){
@@ -3366,7 +3089,9 @@ if(!Modernizr.formattribute || !Modernizr.fieldsetdisabled){
3366
3089
  value: function(){
3367
3090
  this.removeAttribute(name);
3368
3091
  if(removeProp){
3369
- delete this.value;
3092
+ try {
3093
+ delete this.value;
3094
+ } catch(er){}
3370
3095
  }
3371
3096
  updateProgress.isInChange = name;
3372
3097
  updateProgress(this);
@@ -3465,7 +3190,7 @@ try {
3465
3190
  webshims.onNodeNamesPropertyModify('input', 'checked', function(value, boolVal){
3466
3191
  var type = this.type;
3467
3192
  if(type == 'radio' && boolVal){
3468
- webshims.modules["form-core"].getGroupElements(this).each(checkChange);
3193
+ getGroupElements(this).each(checkChange);
3469
3194
  } else if(checkInputs[type]) {
3470
3195
  $(this).each(checkChange);
3471
3196
  }
@@ -3475,7 +3200,7 @@ try {
3475
3200
 
3476
3201
  if(checkInputs[e.target.type]){
3477
3202
  if(e.target.type == 'radio'){
3478
- webshims.modules["form-core"].getGroupElements(e.target).each(checkChange);
3203
+ getGroupElements(e.target).each(checkChange);
3479
3204
  } else {
3480
3205
  $(e.target)[$.prop(e.target, 'checked') ? 'addClass' : 'removeClass']('prop-checked');
3481
3206
  }
@@ -3493,7 +3218,7 @@ try {
3493
3218
  prop = 'checked';
3494
3219
  } else if(this.nodeName.toLowerCase() == 'option'){
3495
3220
  prop = 'selected';
3496
- }
3221
+ }
3497
3222
  if(prop){
3498
3223
  $(this)[$.prop(this, prop) ? 'addClass' : 'removeClass']('prop-checked');
3499
3224
  }
@@ -3505,13 +3230,41 @@ try {
3505
3230
  }
3506
3231
 
3507
3232
  (function(){
3233
+ var bustedPlaceholder;
3508
3234
  Modernizr.textareaPlaceholder = !!('placeholder' in $('<textarea />')[0]);
3509
- if(Modernizr.input.placeholder && Modernizr.textareaPlaceholder){return;}
3235
+ if(Modernizr.input.placeholder && options.overridePlaceholder){
3236
+ bustedPlaceholder = true;
3237
+ }
3238
+ if(Modernizr.input.placeholder && Modernizr.textareaPlaceholder && !bustedPlaceholder){
3239
+ (function(){
3240
+ var ua = navigator.userAgent;
3241
+
3242
+ if(ua.indexOf('Mobile') != -1 && ua.indexOf('Safari') != -1){
3243
+ $(window).on('orientationchange', (function(){
3244
+ var timer;
3245
+ var retVal = function(i, value){
3246
+ return value;
3247
+ };
3248
+
3249
+ var set = function(){
3250
+ $('input[placeholder], textarea[placeholder]').attr('placeholder', retVal);
3251
+ };
3252
+ return function(e){
3253
+ clearTimeout(timer);
3254
+ timer = setTimeout(set, 9);
3255
+ };
3256
+ })());
3257
+ }
3258
+ })();
3259
+
3260
+ //abort
3261
+ return;
3262
+ }
3510
3263
 
3511
3264
  var isOver = (webshims.cfg.forms.placeholderType == 'over');
3512
3265
  var isResponsive = (webshims.cfg.forms.responsivePlaceholder);
3513
3266
  var polyfillElements = ['textarea'];
3514
- if(!Modernizr.input.placeholder){
3267
+ if(!Modernizr.input.placeholder || bustedPlaceholder){
3515
3268
  polyfillElements.push('input');
3516
3269
  }
3517
3270
 
@@ -3648,7 +3401,7 @@ try {
3648
3401
  }
3649
3402
  ;
3650
3403
 
3651
- if(webshims.modules["form-number-date-ui"].loaded){
3404
+ if(modules["form-number-date-ui"].loaded){
3652
3405
  delete allowedPlaceholder.number;
3653
3406
  }
3654
3407
 
@@ -3666,11 +3419,11 @@ try {
3666
3419
  });
3667
3420
 
3668
3421
  if((form = $.prop(elem, 'form'))){
3669
- $(form).on('reset.placeholder', function(e){
3422
+ $(elem).onWSOff('reset.placeholder', function(e){
3670
3423
  setTimeout(function(){
3671
3424
  changePlaceholderVisibility(elem, false, false, data, e.type );
3672
3425
  }, 0);
3673
- });
3426
+ }, false, form);
3674
3427
  }
3675
3428
 
3676
3429
  if(elem.type == 'password' || isOver){
@@ -3709,8 +3462,8 @@ try {
3709
3462
  data.text.css('padding'+ side, size);
3710
3463
  });
3711
3464
 
3712
- $(document)
3713
- .onTrigger('updateshadowdom', function(){
3465
+ $(elem)
3466
+ .onWSOff('updateshadowdom', function(){
3714
3467
  var height, width;
3715
3468
  if((width = elem.offsetWidth) || (height = elem.offsetHeight)){
3716
3469
  data.text
@@ -3721,27 +3474,25 @@ try {
3721
3474
  .css($(elem).position())
3722
3475
  ;
3723
3476
  }
3724
- })
3477
+ }, true)
3725
3478
  ;
3726
3479
 
3727
3480
  } else {
3728
3481
  var reset = function(e){
3729
3482
  if($(elem).hasClass('placeholder-visible')){
3730
3483
  hidePlaceholder(elem, data, '');
3731
- if(e && e.type == 'submit'){
3732
- setTimeout(function(){
3733
- if(e.isDefaultPrevented()){
3734
- changePlaceholderVisibility(elem, false, false, data );
3735
- }
3736
- }, 9);
3737
- }
3484
+ setTimeout(function(){
3485
+ if(!e || e.type != 'submit' || e.isDefaultPrevented()){
3486
+ changePlaceholderVisibility(elem, false, false, data );
3487
+ }
3488
+ }, 9);
3738
3489
  }
3739
3490
  };
3740
3491
 
3741
- $(window).on('beforeunload', reset);
3492
+ $(elem).onWSOff('beforeunload', reset, false, window);
3742
3493
  data.box = $(elem);
3743
3494
  if(form){
3744
- $(form).submit(reset);
3495
+ $(elem).onWSOff('submit', reset, false, form);
3745
3496
  }
3746
3497
  }
3747
3498
 
@@ -3774,11 +3525,20 @@ try {
3774
3525
  attr: {
3775
3526
  set: function(val){
3776
3527
  var elem = this;
3777
- webshims.contentAttr(elem, 'placeholder', val);
3528
+ if(bustedPlaceholder){
3529
+ webshims.data(elem, 'bustedPlaceholder', val);
3530
+ elem.placeholder = '';
3531
+ } else {
3532
+ webshims.contentAttr(elem, 'placeholder', val);
3533
+ }
3778
3534
  pHolder.update(elem, val);
3779
3535
  },
3780
3536
  get: function(){
3781
- return webshims.contentAttr(this, 'placeholder');
3537
+ var placeholder;
3538
+ if(bustedPlaceholder){
3539
+ placeholder = webshims.data(this, 'bustedPlaceholder');
3540
+ }
3541
+ return placeholder || webshims.contentAttr(this, 'placeholder');
3782
3542
  }
3783
3543
  },
3784
3544
  reflect: true,
@@ -3795,7 +3555,9 @@ try {
3795
3555
  set: function(val){
3796
3556
  var elem = this;
3797
3557
  var placeholder;
3798
-
3558
+ if(bustedPlaceholder){
3559
+ placeholder = webshims.data(elem, 'bustedPlaceholder');
3560
+ }
3799
3561
  if(!placeholder){
3800
3562
  placeholder = webshims.contentAttr(elem, 'placeholder');
3801
3563
  }
@@ -3965,11 +3727,15 @@ try {
3965
3727
  }); //webshims.ready end
3966
3728
  }//end formvalidation
3967
3729
 
3968
- jQuery.webshims.register('form-message', function($, webshims, window, document, undefined, options){
3730
+ webshims.register('form-message', function($, webshims, window, document, undefined, options){
3969
3731
  "use strict";
3732
+ if(options.overrideMessages){
3733
+ options.customMessages = true;
3734
+ webshims.error('overrideMessages is deprecated. use customMessages instead.');
3735
+ }
3970
3736
  var validityMessages = webshims.validityMessages;
3971
3737
 
3972
- var implementProperties = (options.overrideMessages || options.customMessages) ? ['customValidationMessage'] : [];
3738
+ var implementProperties = options.customMessages ? ['customValidationMessage'] : [];
3973
3739
 
3974
3740
  validityMessages.en = $.extend(true, {
3975
3741
  typeMismatch: {
@@ -4000,17 +3766,17 @@ jQuery.webshims.register('form-message', function($, webshims, window, document,
4000
3766
 
4001
3767
  if(typeof validityMessages['en'].valueMissing == 'object'){
4002
3768
  ['select', 'radio'].forEach(function(type){
4003
- validityMessages.en.valueMissing[type] = 'Please select an option.';
3769
+ validityMessages.en.valueMissing[type] = validityMessages.en.valueMissing[type] || 'Please select an option.';
4004
3770
  });
4005
3771
  }
4006
3772
  if(typeof validityMessages.en.rangeUnderflow == 'object'){
4007
3773
  ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
4008
- validityMessages.en.rangeUnderflow[type] = 'Value must be at or after {%min}.';
3774
+ validityMessages.en.rangeUnderflow[type] = validityMessages.en.rangeUnderflow[type] || 'Value must be at or after {%min}.';
4009
3775
  });
4010
3776
  }
4011
3777
  if(typeof validityMessages.en.rangeOverflow == 'object'){
4012
3778
  ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
4013
- validityMessages.en.rangeOverflow[type] = 'Value must be at or before {%max}.';
3779
+ validityMessages.en.rangeOverflow[type] = validityMessages.en.rangeOverflow[type] || 'Value must be at or before {%max}.';
4014
3780
  });
4015
3781
  }
4016
3782
 
@@ -4046,17 +3812,17 @@ jQuery.webshims.register('form-message', function($, webshims, window, document,
4046
3812
 
4047
3813
  if(typeof validityMessages.de.valueMissing == 'object'){
4048
3814
  ['select', 'radio'].forEach(function(type){
4049
- validityMessages.de.valueMissing[type] = 'Bitte wählen Sie eine Option aus.';
3815
+ validityMessages.de.valueMissing[type] = validityMessages.de.valueMissing[type] || 'Bitte wählen Sie eine Option aus.';
4050
3816
  });
4051
3817
  }
4052
3818
  if(typeof validityMessages.de.rangeUnderflow == 'object'){
4053
3819
  ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
4054
- validityMessages.de.rangeUnderflow[type] = '{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.';
3820
+ validityMessages.de.rangeUnderflow[type] = validityMessages.de.rangeUnderflow[type] || '{%value} ist zu früh. {%min} ist die früheste Zeit, die Sie benutzen können.';
4055
3821
  });
4056
3822
  }
4057
3823
  if(typeof validityMessages.de.rangeOverflow == 'object'){
4058
3824
  ['date', 'time', 'datetime-local', 'month'].forEach(function(type){
4059
- validityMessages.de.rangeOverflow[type] = '{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.';
3825
+ validityMessages.de.rangeOverflow[type] = validityMessages.de.rangeOverflow[type] || '{%value} ist zu spät. {%max} ist die späteste Zeit, die Sie benutzen können.';
4060
3826
  });
4061
3827
  }
4062
3828
 
@@ -4074,12 +3840,12 @@ jQuery.webshims.register('form-message', function($, webshims, window, document,
4074
3840
  };
4075
3841
 
4076
3842
  webshims.createValidationMessage = function(elem, name){
4077
- var spinner;
3843
+ var widget;
4078
3844
  var message = getMessageFromObj(currentValidationMessage[name], elem);
4079
-
3845
+ var type = $.prop(elem, 'type');
4080
3846
  if(!message){
4081
- message = getMessageFromObj(validityMessages[''][name], elem) || 'invalid value';
4082
- webshims.info('could not find errormessage for: '+ name +' / '+ $.prop(elem, 'type') +'. in language: '+$.webshims.activeLang());
3847
+ message = getMessageFromObj(validityMessages[''][name], elem) || $.prop(elem, 'validationMessage');
3848
+ webshims.info('could not find errormessage for: '+ name +' / '+ type +'. in language: '+$.webshims.activeLang());
4083
3849
  }
4084
3850
  if(message){
4085
3851
  ['value', 'min', 'max', 'title', 'maxlength', 'label'].forEach(function(attr){
@@ -4089,11 +3855,11 @@ jQuery.webshims.register('form-message', function($, webshims, window, document,
4089
3855
  webshims.error('no title for patternMismatch provided. Always add a title attribute.');
4090
3856
  }
4091
3857
  if(valueVals[attr]){
4092
- if(!spinner){
4093
- spinner = $(elem).getShadowElement().data('wsspinner');
3858
+ if(!widget){
3859
+ widget = $(elem).getShadowElement().data('wsWidget'+type);
4094
3860
  }
4095
- if(spinner && spinner.formatValue){
4096
- val = spinner.formatValue(val, false);
3861
+ if(widget && widget.formatValue){
3862
+ val = widget.formatValue(val, false);
4097
3863
  }
4098
3864
  }
4099
3865
  message = message.replace('{%'+ attr +'}', val);
@@ -4108,7 +3874,7 @@ jQuery.webshims.register('form-message', function($, webshims, window, document,
4108
3874
  };
4109
3875
 
4110
3876
 
4111
- if(webshims.bugs.validationMessage || !Modernizr.formvalidation || webshims.bugs.bustedValidity){
3877
+ if(!Modernizr.formvalidation || webshims.bugs.bustedValidity){
4112
3878
  implementProperties.push('validationMessage');
4113
3879
  }
4114
3880
 
@@ -4166,9 +3932,37 @@ jQuery.webshims.register('form-message', function($, webshims, window, document,
4166
3932
 
4167
3933
  });
4168
3934
  });
4169
- jQuery.webshims.register('form-datalist', function($, webshims, window, document, undefined, options){
3935
+ webshims.register('form-datalist', function($, webshims, window, document, undefined, options){
4170
3936
  "use strict";
4171
- var doc = document;
3937
+ var doc = document;
3938
+ var lazyLoad = function(name){
3939
+ if(!name || typeof name != 'string'){
3940
+ name = 'DOM';
3941
+ }
3942
+ if(!lazyLoad[name+'Loaded']){
3943
+ lazyLoad[name+'Loaded'] = true;
3944
+ webshims.ready(name, function(){
3945
+ webshims.loader.loadList(['form-datalist-lazy']);
3946
+ });
3947
+ }
3948
+ };
3949
+ var noDatalistSupport = {
3950
+ submit: 1,
3951
+ button: 1,
3952
+ reset: 1,
3953
+ hidden: 1,
3954
+
3955
+ range: 1,
3956
+ date: 1,
3957
+ month: 1
3958
+ };
3959
+ if(webshims.modules["form-number-date-ui"].loaded){
3960
+ $.extend(noDatalistSupport, {
3961
+ number: 1,
3962
+ time: 1
3963
+ });
3964
+ }
3965
+
4172
3966
 
4173
3967
  /*
4174
3968
  * implement propType "element" currently only used for list-attribute (will be moved to dom-extend, if needed)
@@ -4204,28 +3998,6 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4204
3998
  var initializeDatalist = function(){
4205
3999
 
4206
4000
 
4207
- if(!listSupport){
4208
- webshims.defineNodeNameProperty('datalist', 'options', {
4209
- prop: {
4210
- writeable: false,
4211
- get: function(){
4212
- var elem = this;
4213
- var select = $('select', elem);
4214
- var options;
4215
- if(select[0]){
4216
- options = select[0].options;
4217
- } else {
4218
- options = $('option', elem).get();
4219
- if(options.length){
4220
- webshims.warn('you should wrap your option-elements for a datalist in a select element to support IE and other old browsers.');
4221
- }
4222
- }
4223
- return options;
4224
- }
4225
- }
4226
- });
4227
- }
4228
-
4229
4001
  var inputListProto = {
4230
4002
  //override autocomplete
4231
4003
  autocomplete: {
@@ -4285,27 +4057,8 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4285
4057
  };
4286
4058
  }
4287
4059
 
4288
- if(!listSupport){
4289
-
4290
- inputListProto['list'] = {
4291
- attr: {
4292
- get: function(){
4293
- var val = webshims.contentAttr(this, 'list');
4294
- return (val == null) ? undefined : val;
4295
- },
4296
- set: function(value){
4297
- var elem = this;
4298
- webshims.contentAttr(elem, 'list', value);
4299
- webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
4300
- $(elem).triggerHandler('listdatalistchange');
4301
- }
4302
- },
4303
- initAttr: true,
4304
- reflect: true,
4305
- propType: 'element',
4306
- propNodeName: 'datalist'
4307
- };
4308
- } else {
4060
+
4061
+ if(listSupport){
4309
4062
  //options only return options, if option-elements are rooted: but this makes this part of HTML5 less backwards compatible
4310
4063
  if(!($('<datalist><select><option></option></select></datalist>').prop('options') || []).length ){
4311
4064
  webshims.defineNodeNameProperty('datalist', 'options', {
@@ -4325,13 +4078,15 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4325
4078
  }
4326
4079
  });
4327
4080
  }
4328
- inputListProto['list'] = {
4081
+ inputListProto.list = {
4329
4082
  attr: {
4330
4083
  get: function(){
4331
4084
  var val = webshims.contentAttr(this, 'list');
4332
4085
  if(val != null){
4333
4086
  $.data(this, 'datalistListAttr', val);
4334
- this.removeAttribute('list');
4087
+ if(!noDatalistSupport[$.prop(this, 'type')] && !noDatalistSupport[$.attr(this, 'type')]){
4088
+ this.removeAttribute('list');
4089
+ }
4335
4090
  } else {
4336
4091
  val = $.data(this, 'datalistListAttr');
4337
4092
  }
@@ -4341,7 +4096,15 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4341
4096
  set: function(value){
4342
4097
  var elem = this;
4343
4098
  $.data(elem, 'datalistListAttr', value);
4344
- webshims.objectCreate(shadowListProto, undefined, {input: elem, id: value, datalist: $.prop(elem, 'list')});
4099
+ if (!noDatalistSupport[$.prop(this, 'type')] && !noDatalistSupport[$.attr(this, 'type')]) {
4100
+ webshims.objectCreate(shadowListProto, undefined, {
4101
+ input: elem,
4102
+ id: value,
4103
+ datalist: $.prop(elem, 'list')
4104
+ });
4105
+ } else {
4106
+ elem.setAttribute('list', value);
4107
+ }
4345
4108
  $(elem).triggerHandler('listdatalistchange');
4346
4109
  }
4347
4110
  },
@@ -4361,62 +4124,14 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4361
4124
  .each(function(){
4362
4125
  $(this).triggerHandler('updateDatalist');
4363
4126
  })
4364
-
4365
4127
  ;
4366
-
4367
4128
  });
4368
-
4369
-
4370
4129
  };
4371
4130
 
4372
4131
 
4373
4132
  /*
4374
4133
  * ShadowList
4375
4134
  */
4376
- var listidIndex = 0;
4377
- var noDatalistSupport = {
4378
- submit: 1,
4379
- button: 1,
4380
- reset: 1,
4381
- hidden: 1,
4382
-
4383
- range: 1,
4384
- date: 1,
4385
- month: 1
4386
- };
4387
- if(webshims.modules["form-number-date-ui"].loaded){
4388
- $.extend(noDatalistSupport, {
4389
- number: 1,
4390
- time: 1
4391
- });
4392
- }
4393
-
4394
- var globStoredOptions = {};
4395
- var getStoredOptions = function(name){
4396
- if(!name){return [];}
4397
- if(globStoredOptions[name]){
4398
- return globStoredOptions[name];
4399
- }
4400
- var data;
4401
- try {
4402
- data = JSON.parse(localStorage.getItem('storedDatalistOptions'+name));
4403
- } catch(e){}
4404
- globStoredOptions[name] = data || [];
4405
- return data || [];
4406
- };
4407
- var storeOptions = function(name, val){
4408
- if(!name){return;}
4409
- val = val || [];
4410
- try {
4411
- localStorage.setItem( 'storedDatalistOptions'+name, JSON.stringify(val) );
4412
- } catch(e){}
4413
- };
4414
-
4415
- var getText = function(elem){
4416
- return (elem.textContent || elem.innerText || $.text([ elem ]) || '');
4417
- };
4418
- var lReg = /</g;
4419
- var gReg = />/g;
4420
4135
 
4421
4136
  var shadowListProto = {
4422
4137
  _create: function(opts){
@@ -4424,6 +4139,7 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4424
4139
  if(noDatalistSupport[$.prop(opts.input, 'type')] || noDatalistSupport[$.attr(opts.input, 'type')]){return;}
4425
4140
  var datalist = opts.datalist;
4426
4141
  var data = $.data(opts.input, 'datalistWidget');
4142
+ var that = this;
4427
4143
  if(datalist && data && data.datalist !== datalist){
4428
4144
  data.datalist = datalist;
4429
4145
  data.id = opts.id;
@@ -4444,9 +4160,8 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4444
4160
  } else if(data && data.datalist === datalist){
4445
4161
  return;
4446
4162
  }
4447
- listidIndex++;
4448
- var that = this;
4449
- this.hideList = $.proxy(that, 'hideList');
4163
+
4164
+
4450
4165
 
4451
4166
  this.datalist = datalist;
4452
4167
  this.id = opts.id;
@@ -4454,121 +4169,21 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4454
4169
  this._autocomplete = $.attr(opts.input, 'autocomplete');
4455
4170
  $.data(opts.input, 'datalistWidget', this);
4456
4171
 
4457
- this.popover = webshims.objectCreate(webshims.wsPopover, {}, options.datalistPopover);
4458
- this.shadowList = this.popover.element.addClass('datalist-polyfill');
4459
-
4460
-
4461
- this.index = -1;
4462
- this.input = opts.input;
4463
- this.arrayOptions = [];
4464
-
4465
- this.shadowList
4466
- .delegate('li', 'mouseenter.datalistWidget mousedown.datalistWidget click.datalistWidget', function(e){
4467
- var items = $('li:not(.hidden-item)', that.shadowList);
4468
- var select = (e.type == 'mousedown' || e.type == 'click');
4469
- that.markItem(items.index(e.currentTarget), select, items);
4470
- if(e.type == 'click'){
4471
- that.hideList();
4472
- if(formsCFG.customDatalist){
4473
- $(opts.input).getNativeElement().trigger('datalistselect');
4474
- }
4475
- }
4476
- return (e.type != 'mousedown');
4477
- })
4478
- ;
4479
-
4480
- opts.input.setAttribute('autocomplete', 'off');
4481
-
4482
- $(opts.input)
4483
- .attr({
4484
- //role: 'combobox',
4485
- 'aria-haspopup': 'true'
4486
- })
4487
- .on({
4488
- 'input.datalistWidget': function(){
4489
- if(!that.triggeredByDatalist){
4490
- that.changedValue = false;
4491
- that.showHideOptions();
4492
- }
4493
- },
4494
- 'keydown.datalistWidget': function(e){
4495
- var keyCode = e.keyCode;
4496
- var activeItem;
4497
- var items;
4498
- if(keyCode == 40 && !that.showList()){
4499
- that.markItem(that.index + 1, true);
4500
- return false;
4501
- }
4502
-
4503
- if(!that.popover.isVisible){return;}
4504
-
4505
-
4506
- if(keyCode == 38){
4507
- that.markItem(that.index - 1, true);
4508
- return false;
4509
- }
4510
- if(!e.shiftKey && (keyCode == 33 || keyCode == 36)){
4511
- that.markItem(0, true);
4512
- return false;
4513
- }
4514
- if(!e.shiftKey && (keyCode == 34 || keyCode == 35)){
4515
- items = $('li:not(.hidden-item)', that.shadowList);
4516
- that.markItem(items.length - 1, true, items);
4517
- return false;
4518
- }
4519
- if(keyCode == 13 || keyCode == 27){
4520
- if (keyCode == 13){
4521
- activeItem = $('li.active-item:not(.hidden-item)', that.shadowList);
4522
- that.changeValue( $('li.active-item:not(.hidden-item)', that.shadowList) );
4523
- }
4524
- that.hideList();
4525
- if(formsCFG.customDatalist && activeItem && activeItem[0]){
4526
- $(opts.input).getNativeElement().trigger('datalistselect');
4527
- }
4528
- return false;
4529
- }
4530
- },
4531
- 'focus.datalistWidget': function(){
4532
- if($(this).hasClass('list-focus')){
4533
- that.showList();
4534
- }
4535
- },
4536
- 'mousedown.datalistWidget': function(){
4537
- if($(this).is(':focus')){
4538
- that.showList();
4539
- }
4540
- }
4541
- })
4542
- ;
4543
-
4544
-
4545
- $(this.datalist)
4546
- .off('updateDatalist.datalistWidget')
4547
- .on('updateDatalist.datalistWidget', $.proxy(this, '_resetListCached'))
4548
- ;
4549
-
4550
- this._resetListCached();
4172
+ lazyLoad('WINDOWLOAD');
4551
4173
 
4552
- if(opts.input.form && (opts.input.name || opts.input.id)){
4553
- $(opts.input.form).on('submit.datalistWidget'+opts.input.id, function(){
4554
- if(!$(opts.input).hasClass('no-datalist-cache') && that._autocomplete != 'off'){
4555
- var val = $.prop(opts.input, 'value');
4556
- var name = (opts.input.name || opts.input.id) + $.prop(opts.input, 'type');
4557
- if(!that.storedOptions){
4558
- that.storedOptions = getStoredOptions( name );
4559
- }
4560
- if(val && that.storedOptions.indexOf(val) == -1){
4561
- that.storedOptions.push(val);
4562
- storeOptions(name, that.storedOptions );
4563
- }
4174
+ if(webshims.isReady('form-datalist-lazy')){
4175
+ this._lazyCreate(opts);
4176
+ } else {
4177
+ $(opts.input).one('focus', lazyLoad);
4178
+ webshims.ready('form-datalist-lazy', function(){
4179
+ if(!that._destroyed){
4180
+ that._lazyCreate(opts);
4564
4181
  }
4565
4182
  });
4566
4183
  }
4567
- $(window).on('unload.datalist'+this.id+' beforeunload.datalist'+this.id, function(){
4568
- that.destroy();
4569
- });
4570
4184
  },
4571
- destroy: function(){
4185
+ destroy: function(e){
4186
+ var input;
4572
4187
  var autocomplete = $.attr(this.input, 'autocomplete');
4573
4188
  $(this.input)
4574
4189
  .off('.datalistWidget')
@@ -4586,268 +4201,21 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4586
4201
  } else {
4587
4202
  $(this.input).attr('autocomplete', autocomplete);
4588
4203
  }
4589
- },
4590
- _resetListCached: function(e){
4591
- var that = this;
4592
- var forceShow;
4593
- this.needsUpdate = true;
4594
- this.lastUpdatedValue = false;
4595
- this.lastUnfoundValue = '';
4596
-
4597
- if(!this.updateTimer){
4598
- if(window.QUnit || (forceShow = ($(that.input).is(':focus') && ($(that.input).hasClass('list-focus') || $.prop(that.input, 'value'))) )){
4599
- that.updateListOptions(forceShow);
4600
- } else {
4601
- webshims.ready('WINDOWLOAD', function(){
4602
- that.updateTimer = setTimeout(function(){
4603
- that.updateListOptions();
4604
- that = null;
4605
- listidIndex = 1;
4606
- }, 200 + (100 * listidIndex));
4607
- });
4608
- }
4609
- }
4610
- },
4611
- updateListOptions: function(_forceShow){
4612
- this.needsUpdate = false;
4613
- clearTimeout(this.updateTimer);
4614
- this.updateTimer = false;
4615
-
4616
- this.searchStart = formsCFG.customDatalist && $(this.input).hasClass('search-start');
4617
- this.addMarkElement = options.addMark || $(this.input).hasClass('mark-option-text');
4618
-
4619
- var list = [];
4620
-
4621
- var values = [];
4622
- var allOptions = [];
4623
- var rElem, rItem, rOptions, rI, rLen, item, value;
4624
- for(rOptions = $.prop(this.datalist, 'options'), rI = 0, rLen = rOptions.length; rI < rLen; rI++){
4625
- rElem = rOptions[rI];
4626
- if(!rElem.disabled && (value = $(rElem).val())){
4627
- rItem = {
4628
- value: value.replace(lReg, '&lt;').replace(gReg, '&gt;'),
4629
- label: $.trim($.attr(rElem, 'label') || getText(rElem)).replace(lReg, '&lt;').replace(gReg, '&gt;'),
4630
- className: rElem.className || ''
4631
- };
4632
-
4633
- if(rItem.label){
4634
- rItem.className += ' has-option-label';
4635
- }
4636
- values.push(rItem.value);
4637
- allOptions.push(rItem);
4638
- }
4639
- }
4640
-
4641
- if(!this.storedOptions){
4642
- this.storedOptions = ($(this.input).hasClass('no-datalist-cache') || this._autocomplete == 'off') ? [] : getStoredOptions((this.input.name || this.input.id) + $.prop(this.input, 'type'));
4643
- }
4644
-
4645
- this.storedOptions.forEach(function(val, i){
4646
- if(values.indexOf(val) == -1){
4647
- allOptions.push({value: val, label: '', className: 'stored-suggest', style: ''});
4648
- }
4649
- });
4650
-
4651
- for(rI = 0, rLen = allOptions.length; rI < rLen; rI++){
4652
- item = allOptions[rI];
4653
- list[rI] = '<li class="'+ item.className +'" tabindex="-1" role="listitem">'+ this.getOptionContent(item) +'</li>';
4654
- }
4655
-
4656
- this.arrayOptions = allOptions;
4657
- this.popover.contentElement.html('<div class="datalist-box"><ul role="list">'+ list.join("\n") +'</ul></div>');
4658
-
4659
-
4660
- if(_forceShow || this.popover.isVisible){
4661
- this.showHideOptions();
4662
- }
4663
- },
4664
- getOptionContent: function(item){
4665
- var content = '';
4666
- if(options.getOptionContent){
4667
- content = options.apply(this, arguments) || '';
4668
- } else {
4669
- content = '<span class="option-value">'+ item.value +'</span>';
4670
- if(item.label){
4671
- content += ' <span class="option-label">'+ item.label +'</span>';
4672
- }
4673
- }
4674
- return content;
4675
- },
4676
- showHideOptions: function(_fromShowList){
4677
- var value = $.prop(this.input, 'value').toLowerCase();
4678
-
4679
- //first check prevent infinite loop, second creates simple lazy optimization
4680
- if(value === this.lastUpdatedValue){
4681
- return;
4682
- }
4683
- if(this.lastUnfoundValue && value.indexOf(this.lastUnfoundValue) === 0){
4684
- this.hideList();
4685
- return;
4686
- }
4687
-
4688
-
4689
- this.lastUpdatedValue = value;
4690
- var found = false;
4691
- var startSearch = this.searchStart;
4692
- var lis = $('li', this.shadowList);
4693
- var that = this;
4694
- if(value){
4695
-
4696
- this.arrayOptions.forEach(function(item, i){
4697
- var search, searchIndex, foundName;
4698
- if(!('lowerValue' in item)){
4699
- item.lowerValue = item.value.toLowerCase();
4700
- if(item.label && item.label != item.value ){
4701
- item.lowerLabel = item.label.toLowerCase();
4702
- }
4703
- }
4704
-
4705
- if(value != item.lowerValue && item.lowerLabel != value){
4706
- searchIndex = item.lowerValue.indexOf(value);
4707
- search = startSearch ? !searchIndex : searchIndex !== -1;
4708
- if(search){
4709
- foundName = 'value';
4710
- } else if(item.lowerLabel){
4711
- searchIndex = item.lowerLabel.indexOf(value);
4712
- search = startSearch ? !searchIndex : searchIndex !== -1;
4713
- foundName = 'label';
4714
- }
4715
- }
4716
-
4717
- if(search){
4718
- that.addMark($(lis[i]).removeClass('hidden-item'), item, foundName, searchIndex, value.length);
4719
- found = true;
4720
- } else {
4721
- $(lis[i]).addClass('hidden-item');
4722
- }
4723
- });
4724
- } else if(lis.length) {
4725
- this.removeMark(lis.removeClass('hidden-item'));
4726
- found = true;
4727
- }
4728
-
4729
- this.hasViewableData = found;
4730
- if(!_fromShowList && found){
4731
- this.showList();
4732
- }
4733
-
4734
- if(!found){
4735
- this.lastUnfoundValue = value;
4736
- this.hideList();
4737
- } else {
4738
- this.lastUnfoundValue = false;
4739
- }
4740
- },
4741
- otherType: {
4742
- value: 'label',
4743
- label: 'value'
4744
- },
4745
- addMark: function(elem, item, prop, start, length){
4746
- if(this.addMarkElement){
4747
- var text = item[prop].substr(start, length);
4748
- text = item[prop].replace(text ,'<mark>'+ text +'</mark>');
4749
- $('.option-'+ this.otherType[prop] +' > mark', elem).each(this._replaceMark);
4750
- $('.option-'+prop, elem).html(text);
4751
-
4752
- }
4753
- },
4754
- _replaceMark: function(){
4755
- var content = $(this).html();
4756
- $(this).replaceWith(content);
4757
- },
4758
- removeMark: function(lis){
4759
- if(this.addMarkElement){
4760
- $('mark', lis).each(this._replaceMark);
4761
- }
4762
- },
4763
- showList: function(){
4764
- if(this.popover.isVisible){return false;}
4765
- if(this.needsUpdate){
4766
- this.updateListOptions();
4767
- }
4768
- this.showHideOptions(true);
4769
- if(!this.hasViewableData){return false;}
4770
- var that = this;
4771
-
4772
- that.shadowList.find('li.active-item').removeClass('active-item');
4773
- that.popover.show(this.input);
4774
-
4775
-
4776
- return true;
4777
- },
4778
- hideList: function(){
4779
- if(!this.popover.isVisible){return false;}
4780
- var that = this;
4781
-
4782
-
4783
- this.popover.hide();
4784
- that.shadowList.removeClass('datalist-visible list-item-active');
4785
- that.index = -1;
4786
- if(that.changedValue){
4787
- that.triggeredByDatalist = true;
4788
- $(that.input).trigger('input').trigger('change');
4789
- that.changedValue = false;
4790
- that.triggeredByDatalist = false;
4791
- }
4792
-
4793
- return true;
4794
- },
4795
- scrollIntoView: function(elem){
4796
- var ul = $('ul', this.shadowList);
4797
- var div = $('div.datalist-box', this.shadowList);
4798
- var elemPos = elem.position();
4799
- var containerHeight;
4800
- elemPos.top -= (parseInt(ul.css('paddingTop'), 10) || 0) + (parseInt(ul.css('marginTop'), 10) || 0) + (parseInt(ul.css('borderTopWidth'), 10) || 0);
4801
- if(elemPos.top < 0){
4802
- div.scrollTop( div.scrollTop() + elemPos.top - 2);
4803
- return;
4804
- }
4805
- elemPos.top += elem.outerHeight();
4806
- containerHeight = div.height();
4807
- if(elemPos.top > containerHeight){
4808
- div.scrollTop( div.scrollTop() + (elemPos.top - containerHeight) + 2);
4809
- }
4810
- },
4811
- changeValue: function(activeItem){
4812
- if(!activeItem[0]){return;}
4813
- var spinner;
4814
- var newValue = $('span.option-value', activeItem).text();
4815
- var oldValue = $.prop(this.input, 'value');
4816
- if(newValue != oldValue){
4817
-
4818
- $(this.input)
4819
- .prop('value', newValue)
4820
- .triggerHandler('updateInput')
4821
- ;
4822
- this.changedValue = true;
4823
- if((spinner = $.data(this.input, 'wsspinner')) && spinner.setInput){
4824
- spinner.setInput(newValue);
4825
- }
4826
- }
4827
- },
4828
- markItem: function(index, doValue, items){
4829
- var activeItem;
4830
- var goesUp;
4831
-
4832
- items = items || $('li:not(.hidden-item)', this.shadowList);
4833
- if(!items.length){return;}
4834
- if(index < 0){
4835
- index = items.length - 1;
4836
- } else if(index >= items.length){
4837
- index = 0;
4838
- }
4839
- items.removeClass('active-item');
4840
- this.shadowList.addClass('list-item-active');
4841
- activeItem = items.filter(':eq('+ index +')').addClass('active-item');
4842
-
4843
- if(doValue){
4844
- this.changeValue(activeItem);
4845
- this.scrollIntoView(activeItem);
4204
+ if(e && e.type == 'beforeunload'){
4205
+ input = this.input;
4206
+ setTimeout(function(){
4207
+ $.attr(input, 'list', $.attr(input, 'list'));
4208
+ }, 9);
4846
4209
  }
4847
- this.index = index;
4210
+ this._destroyed = true;
4848
4211
  }
4849
4212
  };
4850
4213
 
4214
+ webshims.loader.addModule('form-datalist-lazy', {
4215
+ noAutoCallback: true,
4216
+ options: $.extend(options, {shadowListProto: shadowListProto})
4217
+ });
4218
+
4851
4219
  //init datalist update
4852
4220
  initializeDatalist();
4853
4221
  })();
@@ -4858,7 +4226,7 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4858
4226
  var hasNative = Modernizr.audio && Modernizr.video;
4859
4227
  var supportsLoop = false;
4860
4228
  var bugs = webshims.bugs;
4861
-
4229
+ var swfType = 'mediaelement-jaris';
4862
4230
  var loadSwf = function(){
4863
4231
  webshims.ready(swfType, function(){
4864
4232
  if(!webshims.mediaelement.createSWF){
@@ -4868,7 +4236,7 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4868
4236
  });
4869
4237
  };
4870
4238
  var options = webshims.cfg.mediaelement;
4871
- var swfType = 'mediaelement-jaris';
4239
+ var hasFullTrackSupport;
4872
4240
  var hasSwf;
4873
4241
  if(!options){
4874
4242
  webshims.error("mediaelement wasn't implemented but loaded");
@@ -4881,14 +4249,11 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4881
4249
 
4882
4250
  webshims.capturingEvents(['play', 'playing', 'waiting', 'paused', 'ended', 'durationchange', 'loadedmetadata', 'canplay', 'volumechange']);
4883
4251
 
4884
- if(!Modernizr.videoBuffered){
4252
+ if(!Modernizr.videoBuffered ){
4885
4253
  webshims.addPolyfill('mediaelement-native-fix', {
4886
- f: 'mediaelement',
4887
- test: Modernizr.videoBuffered,
4888
4254
  d: ['dom-support']
4889
4255
  });
4890
-
4891
- webshims.reTest('mediaelement-native-fix');
4256
+ webshims.loader.loadList(['mediaelement-native-fix']);
4892
4257
  }
4893
4258
  }
4894
4259
 
@@ -4899,9 +4264,9 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4899
4264
  };
4900
4265
  var switchOptions = function(e){
4901
4266
  var media;
4902
- var parent = e.target.parentNode;
4267
+ var parent;
4903
4268
  if(!options.preferFlash &&
4904
- ($(e.target).is('audio, video') || (parent && $('source:last', parent)[0] == e.target)) &&
4269
+ ($(e.target).is('audio, video') || ((parent = e.target.parentNode) && $('source:last', parent)[0] == e.target)) &&
4905
4270
  (media = $(e.target).closest('audio, video')) && !noSwitch[media.prop('error')]
4906
4271
  ){
4907
4272
  $(function(){
@@ -4915,7 +4280,7 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4915
4280
  $('audio, video').each(function(){
4916
4281
  webshims.mediaelement.selectSource(this);
4917
4282
  });
4918
- webshims.info("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src+" Mediaerror: "+ media.prop('error'));
4283
+ webshims.error("switching mediaelements option to 'preferFlash', due to an error with native player: "+e.target.src+" Mediaerror: "+ media.prop('error'));
4919
4284
  }
4920
4285
  }, 9);
4921
4286
  });
@@ -4950,43 +4315,9 @@ jQuery.webshims.register('form-datalist', function($, webshims, window, document
4950
4315
  bugs.track = true;
4951
4316
  }
4952
4317
  }
4953
-
4954
- var trackOptions = webshims.cfg.track;
4955
- var trackListener = function(e){
4956
- $(e.target).filter('track').each(changeApi);
4957
- };
4958
- var changeApi = function(){
4959
- if(bugs.track || (!trackOptions.override && $.prop(this, 'readyState') == 3)){
4960
- trackOptions.override = true;
4961
- webshims.reTest('track');
4962
- document.removeEventListener('error', trackListener, true);
4963
- if(this && $.nodeName(this, 'track')){
4964
- webshims.error("track support was overwritten. Please check your vtt including your vtt mime-type");
4965
- } else {
4966
- webshims.info("track support was overwritten. due to bad browser support");
4967
- }
4968
- return false;
4969
- }
4970
- };
4971
- var detectTrackError = function(){
4972
- document.addEventListener('error', trackListener, true);
4973
-
4974
- if(bugs.track){
4975
- changeApi();
4976
- } else {
4977
- $('track').each(changeApi);
4978
- }
4979
- };
4980
- if(!trackOptions.override){
4981
- if(webshims.isReady('track')){
4982
- detectTrackError();
4983
- } else {
4984
- $(detectTrackError);
4985
- }
4986
- }
4987
4318
  })();
4988
-
4989
4319
  }
4320
+ hasFullTrackSupport = Modernizr.track && !bugs.track;
4990
4321
 
4991
4322
  webshims.register('mediaelement-core', function($, webshims, window, document, undefined){
4992
4323
  hasSwf = swfmini.hasFlashPlayerVersion('9.0.115');
@@ -5071,7 +4402,8 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
5071
4402
  var loadTrackUi = function(){
5072
4403
  if(loadTrackUi.loaded){return;}
5073
4404
  loadTrackUi.loaded = true;
5074
- $(function(){
4405
+ webshims.ready('WINDOWLOAD', function(){
4406
+ loadThird();
5075
4407
  webshims.loader.loadList(['track-ui']);
5076
4408
  });
5077
4409
  };
@@ -5244,27 +4576,40 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
5244
4576
  }
5245
4577
  return ret;
5246
4578
  };
5247
-
4579
+ var emptyType = (/^\s*application\/octet\-stream\s*$/i);
4580
+ var getRemoveEmptyType = function(){
4581
+ var ret = emptyType.test($.attr(this, 'type') || '');
4582
+ if(ret){
4583
+ $(this).removeAttr('type');
4584
+ }
4585
+ return ret;
4586
+ };
5248
4587
  mediaelement.setError = function(elem, message){
5249
- if(!message){
5250
- message = "can't play sources";
4588
+ if($('source', elem).filter(getRemoveEmptyType).length){
4589
+ webshims.error('"application/octet-stream" is a useless mimetype for audio/video. Please change this attribute.');
4590
+ try {
4591
+ $(elem).mediaLoad();
4592
+ } catch(er){}
4593
+ } else {
4594
+ if(!message){
4595
+ message = "can't play sources";
4596
+ }
4597
+ $(elem).pause().data('mediaerror', message);
4598
+ webshims.error('mediaelementError: '+ message);
4599
+ setTimeout(function(){
4600
+ if($(elem).data('mediaerror')){
4601
+ $(elem).trigger('mediaerror');
4602
+ }
4603
+ }, 1);
5251
4604
  }
5252
4605
 
5253
- $(elem).pause().data('mediaerror', message);
5254
- webshims.error('mediaelementError: '+ message);
5255
- setTimeout(function(){
5256
- if($(elem).data('mediaerror')){
5257
- $(elem).trigger('mediaerror');
5258
- }
5259
- }, 1);
4606
+
5260
4607
  };
5261
4608
 
5262
4609
  var handleThird = (function(){
5263
4610
  var requested;
5264
4611
  return function( mediaElem, ret, data ){
5265
- if(!requested){
5266
- loadTrackUi();
5267
- }
4612
+
5268
4613
  webshims.ready(hasSwf ? swfType : 'mediaelement-yt', function(){
5269
4614
  if(mediaelement.createSWF){
5270
4615
  mediaelement.createSWF( mediaElem, ret, data );
@@ -5409,6 +4754,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
5409
4754
  var buffered = getBufferedString();
5410
4755
  if(buffered != lastBuffered){
5411
4756
  lastBuffered = buffered;
4757
+ webshims.info('needed to trigger progress manually');
5412
4758
  $(elem).triggerHandler('progress');
5413
4759
  }
5414
4760
  };
@@ -5460,11 +4806,14 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
5460
4806
  $('video, audio', context)
5461
4807
  .add(insertedElement.filter('video, audio'))
5462
4808
  .each(function(){
5463
- if(!mediaelement.canNativePlaySrces(this) || (!loadTrackUi.loaded && $('track', this).length)){
4809
+ if(!mediaelement.canNativePlaySrces(this)){
5464
4810
  loadThird();
5465
4811
  handleMedia = true;
5466
4812
  return false;
5467
4813
  }
4814
+ if((!hasFullTrackSupport || webshims.modules.track.options.override) && !loadTrackUi.loaded && $('track', this).length){
4815
+ loadTrackUi();
4816
+ }
5468
4817
  })
5469
4818
  ;
5470
4819
  }
@@ -5472,7 +4821,7 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
5472
4821
  }
5473
4822
  };
5474
4823
 
5475
- if(Modernizr.track && !bugs.track){
4824
+ if(hasFullTrackSupport){
5476
4825
  webshims.defineProperty(TextTrack.prototype, 'shimActiveCues', {
5477
4826
  get: function(){
5478
4827
  return this._shimActiveCues || this.activeCues;
@@ -5487,6 +4836,6 @@ webshims.register('mediaelement-core', function($, webshims, window, document, u
5487
4836
  } else {
5488
4837
  webshims.ready(swfType, initMediaElements);
5489
4838
  }
5490
- webshims.ready('WINDOWLOAD mediaelement', loadTrackUi);
4839
+ webshims.ready('track', loadTrackUi);
5491
4840
  });
5492
- })(jQuery, Modernizr, jQuery.webshims);
4841
+ })(jQuery, Modernizr, webshims);