diff options
| -rw-r--r-- | TODO | 21 | ||||
| -rw-r--r-- | better-scrumdo.js | 124 | 
2 files changed, 88 insertions, 57 deletions
| @@ -1,6 +1,27 @@  TODO  ==== +# 2013.02.28: +- '<' and '>' keys to move a story from one column to another +v Disable keyboard shortcuts when an input field is focused  +  (all except for esc) +- esc should exit out of tasks drop-down +- change $(document).on('keydown') to something other than document, unless  +  the key binding really needs it +> Create mechanism to select stories on board using arrow keys +- 'p' to point the story +- 'L' to open a new tab with the iteration in list view +- If you press numbers and then Enter in a short enough amount of time, the  +  story corresponding to the numbers you typed in gets selected +- Documentation +- Apple-Enter to update a story from within the story edit modal +- 'c' to comment on story in the story list (or at least something to  +  permalink to the story in the story list) +- keyboard command to add a new story +/ Create a KeyboardCommands/KeyboardShortcuts class to manage abstraction of  +  setting up shortcuts, separate shortcuts into related groups, and handle  +  activation and deactivation of groups of shortcuts +  # 2013.02.26:  - '<' and '>' keys to move a story from one column to another  - Disable keyboard shortcuts when an input field is focused  diff --git a/better-scrumdo.js b/better-scrumdo.js index ce4196c..3f0a789 100644 --- a/better-scrumdo.js +++ b/better-scrumdo.js @@ -207,6 +207,7 @@ $(function() {  			if (this.current) {  				this.open_edit_modal();  				this.wait_for_edit_modal_to_load(function() { +					KeyCommandManager.toggle_keyboard_events_on_input_focus();  					$('textarea#id_summary').focus();  				});  			} @@ -241,6 +242,7 @@ $(function() {  				// Focus task summary field  				that = this;  				setTimeout(function() { +					KeyCommandManager.toggle_keyboard_events_on_input_focus();  					that.current.find('.tasks_area input[name="summary"]').focus();  				}, 500);  			} @@ -320,6 +322,70 @@ var KeyCodes = {  }; +var cKeyCommandManager = function() { +	var self = this; +	 +	this.toggle_keyboard_events_on_input_focus = function() { +		$('input[type="text"], textarea') +			.off('focus', this.disable_keyboard_shortcuts) +			.off('blur', this.enable_keyboard_shortcuts); +			 +		$('input[type="text"], textarea') +			.on('focus', this.disable_keyboard_shortcuts) +			.on('blur', this.enable_keyboard_shortcuts); +	}; +	 +	this.bind_keyboard_commands = function(e) { +		var key = (e.which || e.keyCode); +		 +		// console.log(e); +		 +		var responds_to = []; +		// for (var k in KeyCodes){} +		 +		switch (key) { +			case KeyCodes.i: +				Story.edit(); +				break; +			case KeyCodes.a: +				Story.assign(); +				break; +			case KeyCodes.p: +				Story.point(); +				break; +			case KeyCodes.t: +				Story.tasks(); +				break; +			case KeyCodes.b: +				Story.toggle_project_panel(); +				break; +			case KeyCodes.esc: +				Story.close_edit_modal(); +				break; +			case KeyCodes.l: +				if (e.shiftKey) { +					Story.list_view(); +				} +				break; +		} +	}; +	 +	this.disable_keyboard_shortcuts = function() { +		console.log('KEYBOARD COMMANDS DISABLED'); +		$(document).off('keydown', self.bind_keyboard_commands); +	}; +	 +	this.enable_keyboard_shortcuts = function() { +		console.log('KEYBOARD COMMANDS ENABLED'); +		$(document).on('keydown', self.bind_keyboard_commands); +	}; +	 +	 +	return this; +}; +var KeyCommandManager = new cKeyCommandManager(); + +  // Set the current story  $(function() {  	var $story_el = $('.scrum_board_story_block'); @@ -362,63 +428,7 @@ $(function() {  				break;  		}  	}); -}); - - -// Story actions - keyboard shortcuts -$(function() { -	// Disable keyboard shortcuts when an input element is focused -	$('input[type="text"], textarea').on('focus', function() { -		// Disable -		disable_keyboard_shortcuts(); -	}).on('blur', function() { -		// Enable -		enable_keyboard_shortcuts(); -	}); -	 -	var bind_keyboard_commands = function(e) { -		var key = (e.which || e.keyCode); -	 -		// console.log(e); -		var responds_to = []; -		// for (var k in KeyCodes){} -		switch (key) { -			case KeyCodes.i: -				Story.edit(); -				break; -			case KeyCodes.a: -				Story.assign(); -				break; -			case KeyCodes.p: -				Story.point(); -				break; -			case KeyCodes.t: -				Story.tasks(); -				break; -			case KeyCodes.b: -				Story.toggle_project_panel(); -				break; -			case KeyCodes.esc: -				Story.close_edit_modal(); -				break; -			case KeyCodes.l: -				if (e.shiftKey) { -					Story.list_view(); -				} -				break; -		} -	}; -	 -	var disable_keyboard_shortcuts = function() { -		console.log('DISABLED'); -		$(document).off('keydown', bind_keyboard_commands); -	}; -	 -	var enable_keyboard_shortcuts = function() { -		console.log('ENABLED'); -		$(document).on('keydown', bind_keyboard_commands); -	}; -	enable_keyboard_shortcuts(); +	KeyCommandManager.enable_keyboard_shortcuts();  }); | 
