Changeset - fcd0768aa12d
[Not reviewed]
default
0 1 0
ethanzonca - 15 years ago 2010-07-10 01:16:24

Added nicer defaulttext implementation. jQuery doesn't support .live blur though, so it won't work for new sections. Workaround?
1 file changed with 28 insertions and 5 deletions:
input.php
28
5
0 comments (0 inline, 0 general)
input.php
Show inline comments
 
@@ -8,24 +8,30 @@ include_once 'class.class.php';
 
include_once 'class.section.php';
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html>
 
<head>
 
	<title>Scheduler</title>
 
<style type="text/css">
 
	body {
 
		width: 80%;
 
		margin:auto;
 
		font-family: sans-serif;
 
	}
 
	.defaultText { 
 
		width: 300px; }
 
	.defaultTextActive { 
 
		color: #a1a1a1; 
 
		font-style: italic; 
 
	}
 
	#savedBox {
 
		width: 15em;
 
		padding: 1em;
 
		border: 1px solid #000;
 
		float:right;
 
		background: #DDD;
 
		font-size: .8em;
 
	}
 
	#header {
 
		text-align: left;
 
		background: rgb(220,220,220); /* IE fallback */
 
		background: rgba(200,200,200, .3);  
 
@@ -181,25 +187,25 @@ include_once 'class.section.php';
 
			<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][2]" value="1" /></td>\
 
			<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][3]" value="1" /></td>\
 
			<td><input type="checkbox" class="daysRequired" name="postData[' + cnum + '][' + snum + '][days][4]" value="1" /></td>';
 
	
 
		return result;
 
	}
 

	
 
	//--------------------------------------------------
 
	// Adds a new class to the input.
 
	//--------------------------------------------------
 
	function addRow(){
 
		sectionsOfClass[classNum] = 0; // This is class 0, initialize at 0
 
		jQuery('#jsrows').append('<tr title="' + classNum + '" class="class class' + classNum + '"><td><input type="text" class="required" name="postData[' + classNum + '][name]" /></td>' + getCommonInputs(classNum) + '<td><div class="addSection"><input type="button" value="Add section" /></div></td><td><div class="deleteClass"><input type="button" value="Delete" /></div></td></tr>');
 
		jQuery('#jsrows').append('<tr title="' + classNum + '" class="class class' + classNum + '"><td><input type="text" class="required defText" title="Class Name" name="postData[' + classNum + '][name]" /></td>' + getCommonInputs(classNum) + '<td><div class="addSection"><input type="button" value="Add section" /></div></td><td><div class="deleteClass"><input type="button" value="Delete" /></div></td></tr>');
 
		classNum++;
 
	};
 
	
 
	addRow(); // Add initial row
 

	
 
	//--------------------------------------------------
 
	// Adds a new class when the add class button is 
 
	// clicked.
 
	//--------------------------------------------------
 
	jQuery('#classage').click(function() {
 
		addRow();
 
	});
 
@@ -225,27 +231,44 @@ include_once 'class.section.php';
 
	jQuery('.addSection').live('click', function() {
 
		sectionsOfClass[jQuery(this).parent().parent().attr("title")]++; // Increases sectionsOfClass[classNum]
 
		jQuery(this).parent().parent().after('<tr class="section class' + jQuery(this).parent().parent().attr("title") + '"><td class="none"></td>' + getCommonInputs(jQuery(this).parent().parent().attr("title")) + '<td></td><td><div class="deleteSection"><input type="button" value="Delete" /></div></td></tr>');
 
	});
 

	
 
	//--------------------------------------------------
 
	// Resets the form
 
	//--------------------------------------------------
 
	jQuery('#reset').click(function() {
 
		jQuery('#scheduleForm').resetForm();
 
    });
 

	
 
	jQuery('#scheduleName').hover(function() {
 
		jQuery(this).val('');
 
	});
 
	//--------------------------------------------------
 
	// Default text stuff
 
	//--------------------------------------------------
 
    jQuery(".defText").focus(function(srcc)
 
    {
 
        if (jQuery(this).val() == jQuery(this)[0].title)
 
        {
 
            jQuery(this).removeClass("defaultTextActive");
 
            jQuery(this).val("");
 
        }
 
    });
 
    jQuery(".defText").blur(function()
 
    {
 
        if (jQuery(this).val() == "")
 
        {
 
            jQuery(this).addClass("defaultTextActive");
 
            jQuery(this).val($(this)[0].title);
 
        }
 
    });
 
    jQuery(".defText").blur();    
 

	
 
});
 

	
 
</script>
 

	
 
</head>
 
<body>
 

	
 
<div id="header">
 
	<h1>
 
		<em>
 
			SlatePermutate
 
@@ -265,25 +288,25 @@ if(isset($_SESSION['saved']) && count($_
 
		echo "<a href=\"process.php?savedkey=$key\">#" . ($key + 1) . " - " . $sch->getName() . "</a> <em><a href=\"process.php?delsaved=$key\"><img src=\"images/close.png\" style=\"border:0;\" /></a></em><br />";
 
	}
 
	echo '</div>';
 
}
 
?>
 

	
 
	</p>
 

	
 
<form method="post" action="process.php" id="scheduleForm">
 

	
 
<table id="jsrows">
 
	<tr>
 
		<td colspan="11" style="padding-bottom:2em;"><input id="scheduleName" type="text" class="required" value="Schedule Name" name="postData[name]" />
 
		<td colspan="11" style="padding-bottom:2em;"><input id="scheduleName" class="defText" type="text" class="required" title="Schedule Name" name="postData[name]" />
 
			<em>(For example: Fall <?php echo Date("Y"); ?>)</em>
 
		</td>
 
	</tr>
 

	
 
<!-- Header -->
 
	<tr>
 
		<td>Class</td>
 
		<td class="center">Letter</td>
 
		<td class="center">Start Time</td>
 
		<td class="center">End Time</td>
 
		<td class="center">M</td>
 
		<td class="center">Tu</td>
0 comments (0 inline, 0 general)