UNPKG

1.57 kBJavaScriptView Raw
1/**
2* this is only needed in the Polyfill demos to distinguish the difference between native placeholders and the polyfill
3*/
4if(window.location.search && window.location.search == '?demo'){
5 window.demo = true;
6 document.documentElement.className += ' demo';
7}
8
9(function($) {
10 var mode = window.demo ? 'OFF' : 'ON',
11 link = window.demo ? '?' : '?demo',
12 msg = '';
13 if('placeholder' in $('<input>')[0]){ // don't run the polyfill when the browser has native support
14 msg = '<strong class="alert">YOUR CURRENT BROWSER HAS NATIVE SUPPORT! ';
15 if(window.placeHolderConfig && window.placeHolderConfig.forceApply){
16 msg += "THE POLYFILL WOULD'T NOT RUN BUT IT'S FORCED IN THIS EXAMPLE!";
17 }else{
18 msg += 'THE POLYFILL WILL NOT RUN!';
19 }
20 msg += '</strong>';
21 }else{
22 msg = '<strong>Your current Browser does not have native support so the Polyfill will work its magic :-)</strong>';
23 }
24 $('#browserlist').after(msg);
25 $('#nav strong').after(' [<a title="in demo mode the placeholders rendered by the Polyfill will be red instead of their normal gray" class="demotoggle" href="'+link+'">toggle demo '+mode+'</a>]');
26
27
28
29 $('#updatetestbutton').click(function(){
30 var currentPlaceholer = $('#updatetest').attr('placeholder');
31 alert(currentPlaceholer);
32 if(currentPlaceholer == 'whatever'){
33 $('#updatetest').attr('placeholder','e.g. 42');
34 }else{
35 $('#updatetest').attr('placeholder','whatever');
36 }
37 });
38})(jQuery);
\No newline at end of file