Changeset - 476a47d2ea81
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 15 years ago 2011-03-24 21:00:53
ohnobinki@ohnopublishing.net
Play around with the <enter>->noop code. Still not ideal, will have to look into autocomplete plugin hacking and making the class title .blur() upon <enter>.
1 file changed with 28 insertions and 21 deletions:
0 comments (0 inline, 0 general)
scripts/scheduleInput.js
Show inline comments
 
@@ -271,27 +271,6 @@ function add_class_n(course_id, title)
 

	
 
		var class_elem = jQuery('.className' + classNum);
 

	
 

	
 
		/*
 
		 * Don't let the user accidentally submit the form by
 
		 * pressing <ENTER>. Instead, select the first
 
		 * autocomplete result if possible.
 
		 */
 
		class_elem.bind('keyup keydown', function(e)
 
				  {
 
				      /* <ENTER> is 13 */
 
				      if (e.which == 13)
 
					  {
 
					      /*
 
					       * The user has pressed enter before selecting an autocomplete entry, which means the
 
					       * form will be submitted without his expecting it to be. We yet need code
 
					       * to figure out what the first autocomplete result is :-/.
 
					       */
 
					      return false;
 
					  }
 
				      return true;
 
				  });
 

	
 
		class_elem.autocomplete({ source: 'auto.php' });
 
		class_elem.bind('autocompleteselect', {class_num: classNum, class_elem: class_elem},
 
			function(event, ui)
 
@@ -435,6 +414,28 @@ function course_free_check(course_i)
 

	
 
/**
 
 * \brief
 
 *   A function to prevent accidental form submission.
 
 *
 
 * To be bound to keyup and keydown events for objects which may
 
 * accidentally be used to cause form submission.
 
 */
 
function slate_permutate_nullify_enter(e)
 
{
 
    /* <ENTER> is 13 */
 
    if (e.which == 13)
 
    {
 
	/*
 
	 * The user has pressed enter before selecting an autocomplete entry, which means the
 
	 * form will be submitted without his expecting it to be. We yet need code
 
	 * to figure out what the first autocomplete result is :-/.
 
	 */
 
	return false;
 
    }
 
    return true;
 
}
 

	
 
/**
 
 * \brief
 
 *   Render a slate_permutate-encoded time-of-day.
 
 *
 
 * \param time_str
 
@@ -581,6 +582,12 @@ jQuery(document).ready(function() {
 
        jQuery('.course-title-entry').live('click', function() {
 
          jQuery(this).toggleClass('inPlace');
 
        });
 
    /*
 
     * Prevent accidental form submission for className and course
 
     * title entry text fields.
 
     */
 
    jQuery('.course-title-entry').live('keyup keydown', slate_permutate_nullify_enter);
 
    jQuery('.className').live('keyup keydown', slate_permutate_nullify_enter);
 
        jQuery('.course-title-entry').live('blur', function() {
 
          jQuery(this).addClass('inPlace');
 
        });
0 comments (0 inline, 0 general)