Changeset - 8ff4814831af
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 15 years ago 2011-03-21 00:12:27
ohnobinki@ohnopublishing.net
Remove validation plugin which will allow us to now finally upgrade to jquery-1.5.
2 files changed with 4 insertions and 97 deletions:
0 comments (0 inline, 0 general)
input.php
Show inline comments
 
@@ -15,25 +15,25 @@
 
 * GNU Affero General Public License for more details.
 
 *
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with SlatePermutate.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
include_once 'inc' . DIRECTORY_SEPARATOR . 'class.schedule.php';
 
include_once 'inc' . DIRECTORY_SEPARATOR . 'class.course.inc';
 
include_once 'inc' . DIRECTORY_SEPARATOR . 'class.section.php';
 
include_once 'inc' . DIRECTORY_SEPARATOR . 'class.page.php';
 
require_once('inc' . DIRECTORY_SEPARATOR . 'schedule_store.inc');
 

	
 
$scripts = array('jQuery', 'jQueryUI', 'jValidate','qTip','schedInput');
 
$scripts = array('jQuery', 'jQueryUI', 'qTip','schedInput');
 
$inputPage = page::page_create('Scheduler', $scripts, FALSE);
 

	
 
$schedule_store = FALSE;
 
$sch = FALSE;
 
$school = $inputPage->get_school();
 

	
 
$parent_schedule_id = NULL;
 
if (isset($_REQUEST['s']))
 
  {
 
    $schedule_store = schedule_store_init();
 
    $parent_schedule_id = (int)$_REQUEST['s'];
 
    $sch = schedule_store_retrieve($schedule_store, $parent_schedule_id);
scripts/scheduleInput.js
Show inline comments
 
@@ -35,126 +35,38 @@ var sectionsOfClass = new Array();
 
 * \brief
 
 *   Help to generate a unique section identifier for each section
 
 *   added to a given course.
 
 *
 
 * Necessary to support PHP-style post array thingies, like
 
 * classes[0][1][$x] would be all of the data for course_i=0,
 
 * section_i=1, variable $x (ex. day of week, start time, end time,
 
 * teacher). We can't have two sections for a given course using the
 
 * same section_i because those values would override eachother.
 
 */
 
var last_section_i = 0;
 

	
 
/*
 
/**
 
 * \brief
 
 *   The course number which contains nothing.
 
 *
 
 * To avoid having a user need to click the ``Add course'' button, we
 
 * keep a course added at the end of the list of courses. If this
 
 * variable is -1, it indicates that no such free course exists. If it
 
 * is zero or greater, that number is the class which is the free one.
 
 */
 
var slate_permutate_course_free = -1;
 

	
 
    //--------------------------------------------------
 
    // Validation Functions
 
    //--------------------------------------------------      
 

	
 
	//--------------------------------------------------
 
	// Default Error Message
 
	//--------------------------------------------------
 
	jQuery.each(jQuery.validator.messages, function(i) {
 
		jQuery.validator.messages[i] = "<p class=\"error\">Please fill the field</p>";
 
	});
 

	
 
	//--------------------------------------------------
 
	// Time Selection Validation
 
	//--------------------------------------------------
 
	jQuery.validator.addMethod( 
 
		"selectNone", 
 
		function(value, element) { 
 
			if (element.value == "none") { 
 
				return false; 
 
			} 
 
			else return true; 
 
		}, 
 
		"<p class=\"error\">Please select a time</p>"); 
 
	
 
	//--------------------------------------------------
 
	// Days of Week validation
 
	//--------------------------------------------------
 
	jQuery.validator.addMethod( 
 
		"daysRequired", 
 
		function(value, element) { 
 
			var checkedCount = 0;
 
			jQuery(element).parent().parent().children().children('.daysRequired:checked').each( function() {
 
				checkedCount++;
 
			});
 
			if (checkedCount === 0) { 
 
				return false; 
 
			} 
 
			else return true; 
 
		}, 
 
		"<p class=\"error\">Select a day!</p>"); 
 

	
 
/**
 
 * Class name validation: only require a class name if it has at least
 
 * one section. Backend throws out empty classes and it's more
 
 * convenient if we can let the user have one extra, empty class. This
 
 * is because we automatically add a new class each time we do an
 
 * autofill to make the life of the user easier and less confusing.
 
/*
 
 * General Input Functions
 
 */
 
jQuery.validator.addMethod('classRequired',
 
			   function(value, element)
 
			   {
 
			       if (value.length)
 
				   return true;
 

	
 
			       var css_classes = jQuery(element).attr('class');
 
			       var cnum_pos = css_classes.indexOf('className');
 
			       var cnum = css_classes.substr(cnum_pos + 'className'.length, css_classes.indexOf(' ', cnum_pos) - cnum_pos - 'className'.length) * 1;
 
			       if (cnum < 0 || cnum > classNum)
 
				   alert('JS error: ' + cnum + ' is an invalid class number.');
 

	
 
			       /*
 
				* ignore the class with no
 
				* sections. This only works when the
 
				* class was added and the user _never_
 
				* clicked the Add Section button. Once
 
				* the user clicks that button, he has
 
				* to delete the class because of how
 
				* our numbering works.
 
				*/
 
			       if (!course_has_sections(cnum))
 
				   return true;
 

	
 
			       return false;
 
			   },
 
			   '<p class="error">Enter Class Name.</p>');
 

	
 
	//--------------------------------------------------
 
	// Add validation rules
 
	//--------------------------------------------------
 
	jQuery.validator.addClassRules("selectRequired", {
 
		selectNone: true
 
	});
 
	jQuery.validator.addClassRules("daysRequired", {
 
		daysRequired: true
 
	});
 
jQuery.validator.addClassRules('classRequired', { classRequired: true });
 

	
 

	
 
    //--------------------------------------------------
 
    // General Input Functions
 
    //--------------------------------------------------
 

	
 
/**
 
 * \brief
 
 * Returns the common inputs for each new section.
 
 */
 
function genSectionHtml(cnum)
 
{
 
    genSectionHtml_n(cnum, '', '', '', '', '', '', '');
 
}
 

	
 
/* @TODO: This should select & set items based on args, if the args != '' */
 
function genSectionHtml_n(cnum, name, synonym, stime, etime, days, prof, location, type)
 
@@ -515,29 +427,24 @@ function prettyTime(time_str)
 
	hour_str = '0' + hour_str;
 
    */
 

	
 
    return hour_str + ':' + time_str.substr(2) + ' ' + m + 'm';
 
}
 

	
 
//--------------------------------------------------
 
// Items bound to pageload/events
 
//--------------------------------------------------
 
jQuery(document).ready(function() {
 

	
 
	//--------------------------------------------------
 
	// Validates the form (pre-submission check)
 
	//--------------------------------------------------
 
	jQuery('#scheduleForm').validate({ debug: false });
 

	
 
	//--------------------------------------------------
 
	// Bind the class-adding method
 
	//--------------------------------------------------
 
	jQuery('#addclass').click(function() {
 
		var classNum = add_class();
 
		// add_section(classNum); // enable eventually
 
	});
 

	
 
	//--------------------------------------------------
 
	// Deletes the selected class from input
 
	//--------------------------------------------------
 
	jQuery('.deleteClass').live('click', function() {
 
		if(confirm('Delete class and all sections of this class?')) {
0 comments (0 inline, 0 general)