Skip to content
Browse files

add jqplaceholder for IE

  • Loading branch information...
1 parent b801afa commit 3c764eb4f98dec77606761ff0bf39188e914f773 Chris Moore committed
View
1 build/index.html
@@ -1055,6 +1055,7 @@
<!-- Enable Scrolling -->
<script src="js/libs/jquery.scrollTo-1.4.2.js"></script>
<script src="js/libs/jquery.localscroll.js"></script>
+ <script src="js/libs/jquery.placeholder.min.js"></script>
<script type="text/javascript" src="http://use.typekit.com/ipz4mdt.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
View
11 build/js/libs/jquery.placeholder.min.js
@@ -0,0 +1,11 @@
+/*
+* Placeholder plugin for jQuery
+* ---
+* Copyright 2010, Daniel Stocks (http://webcloud.se)
+* Released under the MIT, BSD, and GPL Licenses.
+*/
+
+(function(b){function d(a){this.input=a;a.attr("type")=="password"&&this.handlePassword();b(a[0].form).submit(function(){if(a.hasClass("placeholder")&&a[0].value==a.attr("placeholder"))a[0].value=""})}d.prototype={show:function(a){if(this.input[0].value===""||a&&this.valueIsPlaceholder()){if(this.isPassword)try{this.input[0].setAttribute("type","text")}catch(b){this.input.before(this.fakePassword.show()).hide()}this.input.addClass("placeholder");this.input[0].value=this.input.attr("placeholder")}},
+hide:function(){if(this.valueIsPlaceholder()&&this.input.hasClass("placeholder")&&(this.input.removeClass("placeholder"),this.input[0].value="",this.isPassword)){try{this.input[0].setAttribute("type","password")}catch(a){}this.input.show();this.input[0].focus()}},valueIsPlaceholder:function(){return this.input[0].value==this.input.attr("placeholder")},handlePassword:function(){var a=this.input;a.attr("realType","password");this.isPassword=!0;if(b.browser.msie&&a[0].outerHTML){var c=b(a[0].outerHTML.replace(/type=(['"])?password\1/gi,
+"type=$1text$1"));this.fakePassword=c.val(a.attr("placeholder")).addClass("placeholder").focus(function(){a.trigger("focus");b(this).hide()});b(a[0].form).submit(function(){c.remove();a.show()})}}};var e=!!("placeholder"in document.createElement("input"));b.fn.placeholder=function(){return e?this:this.each(function(){var a=b(this),c=new d(a);c.show(!0);a.focus(function(){c.hide()});a.blur(function(){c.show(!1)});b.browser.msie&&(b(window).load(function(){a.val()&&a.removeClass("placeholder");c.show(!0)}),
+a.focus(function(){if(this.value==""){var a=this.createTextRange();a.collapse(!0);a.moveStart("character",0);a.select()}}))})}})(jQuery);
View
1 build/js/script.js
@@ -13,6 +13,7 @@ $(window).bind('scroll', function(){
});
$(document).ready(function(){
$("#message a").hide();
+ $('input[placeholder], textarea[placeholder]').placeholder();
});
View
1 source/index.html
@@ -1055,6 +1055,7 @@
<!-- Enable Scrolling -->
<script src="js/libs/jquery.scrollTo-1.4.2.js"></script>
<script src="js/libs/jquery.localscroll.js"></script>
+ <script src="js/libs/jquery.placeholder.min.js"></script>
<script type="text/javascript" src="http://use.typekit.com/ipz4mdt.js"></script>
<script type="text/javascript">try{Typekit.load();}catch(e){}</script>
View
11 source/js/libs/jquery.placeholder.min.js
@@ -0,0 +1,11 @@
+/*
+* Placeholder plugin for jQuery
+* ---
+* Copyright 2010, Daniel Stocks (http://webcloud.se)
+* Released under the MIT, BSD, and GPL Licenses.
+*/
+
+(function(b){function d(a){this.input=a;a.attr("type")=="password"&&this.handlePassword();b(a[0].form).submit(function(){if(a.hasClass("placeholder")&&a[0].value==a.attr("placeholder"))a[0].value=""})}d.prototype={show:function(a){if(this.input[0].value===""||a&&this.valueIsPlaceholder()){if(this.isPassword)try{this.input[0].setAttribute("type","text")}catch(b){this.input.before(this.fakePassword.show()).hide()}this.input.addClass("placeholder");this.input[0].value=this.input.attr("placeholder")}},
+hide:function(){if(this.valueIsPlaceholder()&&this.input.hasClass("placeholder")&&(this.input.removeClass("placeholder"),this.input[0].value="",this.isPassword)){try{this.input[0].setAttribute("type","password")}catch(a){}this.input.show();this.input[0].focus()}},valueIsPlaceholder:function(){return this.input[0].value==this.input.attr("placeholder")},handlePassword:function(){var a=this.input;a.attr("realType","password");this.isPassword=!0;if(b.browser.msie&&a[0].outerHTML){var c=b(a[0].outerHTML.replace(/type=(['"])?password\1/gi,
+"type=$1text$1"));this.fakePassword=c.val(a.attr("placeholder")).addClass("placeholder").focus(function(){a.trigger("focus");b(this).hide()});b(a[0].form).submit(function(){c.remove();a.show()})}}};var e=!!("placeholder"in document.createElement("input"));b.fn.placeholder=function(){return e?this:this.each(function(){var a=b(this),c=new d(a);c.show(!0);a.focus(function(){c.hide()});a.blur(function(){c.show(!1)});b.browser.msie&&(b(window).load(function(){a.val()&&a.removeClass("placeholder");c.show(!0)}),
+a.focus(function(){if(this.value==""){var a=this.createTextRange();a.collapse(!0);a.moveStart("character",0);a.select()}}))})}})(jQuery);
View
1 source/js/script.js
@@ -13,6 +13,7 @@ $(window).bind('scroll', function(){
});
$(document).ready(function(){
$("#message a").hide();
+ $('input[placeholder], textarea[placeholder]').placeholder();
});

0 comments on commit 3c764eb

Please sign in to comment.
Something went wrong with that request. Please try again.