Guest User

Untitled

a guest
May 26th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Load modernizr
  2. window.Modernizr=function(a,b,c){function A(){e.input=function(a){for(var b=0,c=a.length;b<c;b++)q[a[b]]=a[b]in k;return q}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,g,h,i=a.length;d<i;d++)k.setAttribute("type",g=a[d]),e=k.type!=="text",e&&(k.value=l,k.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(g)&&k.style.WebkitAppearance!==c?(f.appendChild(k),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(k,null).WebkitAppearance!=="textfield"&&k.offsetHeight!==0,f.removeChild(k)):/^(search|tel)$/.test(g)||(/^(url|email)$/.test(g)?e=k.checkValidity&&k.checkValidity()===!1:/^color$/.test(g)?(f.appendChild(k),f.offsetWidth,e=k.value!=l,f.removeChild(k)):e=k.value!=l)),p[a[d]]=!!e;return p}("search tel url email datetime date month week time datetime-local number range color".split(" "))}function z(a,b){return!!~(""+a).indexOf(b)}function y(a,b){return typeof a===b}function x(a,b){return w(prefixes.join(a+";")+(b||""))}function w(a){j.cssText=a}var d="2.0.6",e={},f=b.documentElement,g=b.head||b.getElementsByTagName("head")[0],h="modernizr",i=b.createElement(h),j=i.style,k=b.createElement("input"),l=":)",m=Object.prototype.toString,n="Webkit Moz O ms Khtml".split(" "),o={},p={},q={},r=[],s=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=y(e[d],"function"),y(e[d],c)||(e[d]=c),e.removeAttribute(d))),e=null;return f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),t,u={}.hasOwnProperty,v;!y(u,c)&&!y(u.call,c)?v=function(a,b){return u.call(a,b)}:v=function(a,b){return b in a&&y(a.constructor.prototype[b],c)};for(var B in o)v(o,B)&&(t=B.toLowerCase(),e[t]=o[B](),r.push((e[t]?"":"no-")+t));e.input||A(),w(""),i=k=null,e._version=d,e._domPrefixes=n,e.hasEvent=s;return e}(this,this.document);
  3.  
  4. // If placeholders are not supported
  5.         if(!Modernizr.input.placeholder)
  6.         {
  7.             // Loop through all inputs...
  8.             $("input").each(function()
  9.             {
  10.                 // ... with placeholders
  11.                 if($(this).val() == ""
  12.                 && $(this).attr("placeholder") != "")
  13.                 {
  14.                     // Put the placeholder as the value
  15.                     $(this).val($(this).attr("placeholder"));
  16.                    
  17.                     // Assign onFocus and onBlur events
  18.                     $(this).focus(function()
  19.                     {
  20.                         // If value is equal to the placeholder clear field
  21.                         if($(this).val() == $(this).attr("placeholder")) $(this).val("");
  22.                     });
  23.                        
  24.                     $(this).blur(function()
  25.                     {
  26.                         // If value is equal to the placeholder clear field
  27.                         if($(this).val() == "") $(this).val($(this).attr("placeholder"));
  28.                     });
  29.                        
  30.                 }
  31.             });
  32.         }
Add Comment
Please, Sign In to add comment