Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Update jquery-watermark.js #1

Open
wants to merge 7 commits into from

2 participants

@coolj

$.fn.watermark = function (params) {
//default values
var settings = $.extend({
'waterAttr' : 'data-water',
'waterCss': { color: 'Gray' },
'activeCss': { color: 'Black' },
'class': 'watermarked',
}, params);

$(this).parents('form').submit(function()
{
    $(this).find('['+settings.waterAttr+']').each(function() {
        if (($(this).val() == $(this).attr(settings.waterAttr)) || (jQuery.trim($(this).val()).length == 0)) {
            $(this).val("");
            $(this).css(settings.activeCss);
            $(this).removeClass(settings.class);
        }
    });
    return true;    
});
//loop
$(this).each(function () {
    if ($(this).val().length == 0) {
        $(this).css(settings.waterCss);
        $(this).addClass(settings.class);
        $(this).val($(this).attr(settings.waterAttr));
    }
    $(this).unbind("focus").focus(function () {
        if (($(this).val() == $(this).attr(settings.waterAttr)) || (jQuery.trim($(this).val()).length == 0)) {
            $(this).val("");
            $(this).css(settings.activeCss);
            $(this).removeClass(settings.class);
        }
    }).blur(function () {
        if (jQuery.trim($(this).val()).length == 0) {
            $(this).val($(this).attr(settings.waterAttr));
            $(this).css(settings.waterCss);
            $(this).addClass(settings.class);
        }
    });
});

}

coolj added some commits
@coolj coolj Update jquery-watermark.js
var settings = $.extend({
    	'waterAttr' : 'data-water',
        'class':	'watermarked',
});  


$(this).parents('form').submit(function()
	{
		$(this).find('['+settings.waterAttr+']').each(function() {
			if (($(this).val() == $(this).attr(settings.waterAttr)) || (jQuery.trim($(this).val()).length == 0)) {
                $(this).val("");
                $(this).css(settings.activeCss);
				$(this).removeClass(settings.class);
            }
        });
		return true;	
	});
9cf54c2
@coolj coolj Update jquery-watermark.js 43a5667
@coolj coolj Update jquery-watermark.js b2dd5a5
@coolj coolj Update jquery-watermark.js 2424091
@coolj coolj Update README.md ecf8eb7
@coolj coolj Update README.md 7244407
@coolj coolj Update README.md 69057d5
@sagivo
Owner

@coolj - please provide explanation for this pull request. what did you want to change and why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 5, 2012
  1. @coolj

    Update jquery-watermark.js

    coolj authored
    var settings = $.extend({
        	'waterAttr' : 'data-water',
            'class':	'watermarked',
    });  
    
    
    $(this).parents('form').submit(function()
    	{
    		$(this).find('['+settings.waterAttr+']').each(function() {
    			if (($(this).val() == $(this).attr(settings.waterAttr)) || (jQuery.trim($(this).val()).length == 0)) {
                    $(this).val("");
                    $(this).css(settings.activeCss);
    				$(this).removeClass(settings.class);
                }
            });
    		return true;	
    	});
  2. @coolj

    Update jquery-watermark.js

    coolj authored
  3. @coolj

    Update jquery-watermark.js

    coolj authored
  4. @coolj

    Update jquery-watermark.js

    coolj authored
  5. @coolj

    Update README.md

    coolj authored
  6. @coolj

    Update README.md

    coolj authored
  7. @coolj

    Update README.md

    coolj authored
This page is out of date. Refresh to see the latest.
Showing with 27 additions and 9 deletions.
  1. +5 −3 README.md
  2. +22 −6 jquery-watermark.js
View
8 README.md
@@ -20,12 +20,14 @@ Download `jquery-watermark.min.js` script and include it in your page:
Define your params (if you want):
- var params = { activeCss: { 'color': 'Black', 'background-color': 'Blue', 'font-size': '20px' }, waterCss: {color: 'Gray'}};
+ var params = { waterAttr: 'data-water',class: 'waterMark',activeCss: { 'color': 'Black', 'background-color': 'Blue', 'font-size': '20px' }, waterCss: {color: 'Gray'}};
The defaults are:
'waterCss': { color: 'Gray' },
- 'activeCss': { color: 'Black' }
+ 'activeCss': { color: 'Black' },
+ 'waterAttr': 'data-water',
+ 'activeCss': 'watermarked'
From within your code call to the `watermark()` function on your selector (in this case i used input fields).
@@ -37,7 +39,7 @@ Go and have another beer.
Contribution
------------
-- Sagiv Ofek
+- Sagiv Ofek ( Patch1 - Yanislav Dimitrov )
License
-------
View
28 jquery-watermark.js
@@ -1,27 +1,43 @@
-/*! jQuery-water v1.0 created by: Sagiv Ofek */
+/*! jQuery-water v1.01 created by: Yanislav Dimitrov */
$.fn.watermark = function (params) {
//default values
var settings = $.extend({
+ 'waterAttr' : 'data-water',
'waterCss': { color: 'Gray' },
- 'activeCss': { color: 'Black' }
+ 'activeCss': { color: 'Black' },
+ 'class': 'watermarked',
}, params);
+ $(this).parents('form').submit(function()
+ {
+ $(this).find('['+settings.waterAttr+']').each(function() {
+ if (($(this).val() == $(this).attr(settings.waterAttr)) || (jQuery.trim($(this).val()).length == 0)) {
+ $(this).val("");
+ $(this).css(settings.activeCss);
+ $(this).removeClass(settings.class);
+ }
+ });
+ return true;
+ });
//loop
$(this).each(function () {
if ($(this).val().length == 0) {
$(this).css(settings.waterCss);
- $(this).val($(this).attr("data-water"));
+ $(this).addClass(settings.class);
+ $(this).val($(this).attr(settings.waterAttr));
}
$(this).unbind("focus").focus(function () {
- if (($(this).val() == $(this).attr("data-water")) || (jQuery.trim($(this).val()).length == 0)) {
+ if (($(this).val() == $(this).attr(settings.waterAttr)) || (jQuery.trim($(this).val()).length == 0)) {
$(this).val("");
$(this).css(settings.activeCss);
+ $(this).removeClass(settings.class);
}
}).blur(function () {
if (jQuery.trim($(this).val()).length == 0) {
- $(this).val($(this).attr("data-water"));
+ $(this).val($(this).attr(settings.waterAttr));
$(this).css(settings.waterCss);
+ $(this).addClass(settings.class);
}
});
});
-}
+}
Something went wrong with that request. Please try again.