project/static/jquery/jquery.watermarkinput.js
author Madhusudan.C.S <madhusudancs@gmail.com>
Tue, 13 Jul 2010 17:00:55 +0530
changeset 106 7ebd3a7e8ccf
parent 94 e86755df35da
permissions -rw-r--r--
Revert all leading /2009 from URL Patters since this is now handled in Apache on server.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
94
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     1
/*
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     2
 * Copyright (c) 2007 Josh Bush (digitalbush.com)
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     3
 * 
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     4
 * Permission is hereby granted, free of charge, to any person
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     5
 * obtaining a copy of this software and associated documentation
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     6
 * files (the "Software"), to deal in the Software without
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     7
 * restriction, including without limitation the rights to use,
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
     9
 * copies of the Software, and to permit persons to whom the
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    10
 * Software is furnished to do so, subject to the following
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    11
 * conditions:
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    12
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    13
 * The above copyright notice and this permission notice shall be
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    14
 * included in all copies or substantial portions of the Software.
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    15
 * 
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    23
 * OTHER DEALINGS IN THE SOFTWARE. 
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    24
 */
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    25
 
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    26
/*
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    27
 * Version: Beta 1
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    28
 * Release: 2007-06-01
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    29
 */ 
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    30
(function($) {
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    31
	var map=new Array();
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    32
	$.Watermark = {
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    33
		ShowAll:function(){
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    34
			for (var i=0;i<map.length;i++){
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    35
				if(map[i].obj.val()==""){
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    36
					map[i].obj.val(map[i].text);					
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    37
					map[i].obj.css("color",map[i].WatermarkColor);
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    38
				}else{
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    39
				    map[i].obj.css("color",map[i].DefaultColor);
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    40
				}
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    41
			}
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    42
		},
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    43
		HideAll:function(){
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    44
			for (var i=0;i<map.length;i++){
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    45
				if(map[i].obj.val()==map[i].text)
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    46
					map[i].obj.val("");					
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    47
			}
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    48
		}
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    49
	};
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    50
	
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    51
	$.fn.Watermark = function(text,color) {
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    52
		if(!color)
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    53
			color="#cccccc";
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    54
		return this.each(
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    55
			function(){		
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    56
				var input=$(this);
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    57
				var defaultColor=input.css("color");
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    58
				map[map.length]={text:text,obj:input,DefaultColor:defaultColor,WatermarkColor:color};
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    59
				function clearMessage(){
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    60
					if(input.val()==text)
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    61
						input.val("");
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    62
					input.css("color",defaultColor);
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    63
				}
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    64
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    65
				function insertMessage(){
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    66
					if(input.val().length==0 || input.val()==text){
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    67
						input.val(text);
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    68
						input.css("color",color);	
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    69
					}else
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    70
						input.css("color",defaultColor);				
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    71
				}
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    72
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    73
				input.focus(clearMessage);
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    74
				input.blur(insertMessage);								
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    75
				input.change(insertMessage);
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    76
				
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    77
				insertMessage();
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    78
			}
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    79
		);
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    80
	};
e86755df35da Add admin interface and views for proceedings. Booklet is also setup to generate paper.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff changeset
    81
})(jQuery);