Ver código fonte

Fix for https://github.com/eddiemachado/bones/issues/47

polyvisual 14 anos atrás
pai
commit
b95dc8cea2
1 arquivos alterados com 35 adições e 1 exclusões
  1. 35 1
      library/js/scripts.js

+ 35 - 1
library/js/scripts.js

@@ -34,4 +34,38 @@ $(document).ready(function() {
 	// add all your scripts here
 
  
-}); /* end of as page load scripts */
+}); /* end of as page load scripts */
+
+// HTML5 Fallbacks for older browsers
+$(function() {
+    // check placeholder browser support
+    if (!Modernizr.input.placeholder) {
+        // set placeholder values
+        $(this).find('[placeholder]').each(function() {
+            $(this).val( $(this).attr('placeholder') );
+        });
+ 
+        // focus and blur of placeholders
+        $('[placeholder]').focus(function() {
+            if ($(this).val() == $(this).attr('placeholder')) {
+                $(this).val('');
+                $(this).removeClass('placeholder');
+            }
+        }).blur(function() {
+            if ($(this).val() == '' || $(this).val() == $(this).attr('placeholder')) {
+                $(this).val($(this).attr('placeholder'));
+                $(this).addClass('placeholder');
+            }
+        });
+ 
+        // remove placeholders on submit
+        $('[placeholder]').closest('form').submit(function() {
+            $(this).find('[placeholder]').each(function() {
+                if ($(this).val() == $(this).attr('placeholder')) {
+                    $(this).val('');
+                }
+            });
+        });
+    }
+});
+