Advertisement
Guest User

jQuery.support HTML 5 plugin

a guest
Oct 15th, 2010
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // NB some code from diveintohtml5.org <http://diveintohtml5.org/>
  2.  
  3. (function($){
  4.     $.extend($.support, (function(){
  5.         var input = document.createElement('input'),
  6.             inputtypes = 'search number range color tel url email date month week time datetime datetime-local',
  7.             inputattrs = 'autocomplete autofocus list placeholder max min multiple pattern required step';
  8.        
  9.         return {
  10.             inputtypes: (function(){
  11.                 var types = inputtypes.split(' '),
  12.                     ret = {};
  13.                 for (i = 0, j = types.length; i < j; i++) {
  14.                     input.setAttribute('type', types[i]);
  15.                     ret[types[i]] = (input.type !== 'text');
  16.                 }
  17.                 return ret;
  18.             })(),
  19.            
  20.             input: (function(){
  21.                 var attrs = inputattrs.split(' '),
  22.                     ret = {};
  23.                    
  24.                 for (i = 0, j = attrs.length; i < j; i++) {
  25.                     ret[attrs[i]] = !!(attrs[i] in input);
  26.                 }
  27.                 return ret;
  28.             })()
  29.         };
  30.     })());
  31. })(jQuery);
  32.  
  33. /***************************************************
  34. ********************* MINIFIED *********************
  35. ***************************************************/
  36.  
  37. (function(d){d.extend(d.support,function(){var c=document.createElement("input");return{inputtypes:function(){var a="search number range color tel url email date month week time datetime datetime-local".split(" "),b={};i=0;for(j=a.length;i<j;i++){c.setAttribute("type",a[i]);b[a[i]]=c.type!=="text"}return b}(),input:function(){var a="autocomplete autofocus list placeholder max min multiple pattern required step".split(" "),b={};i=0;for(j=a.length;i<j;i++)b[a[i]]=!!(a[i]in c);return b}()}}())})(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement