forked from jquery/jquery-ui
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Grid Editing: Add cursor cell navigation to grid. Also includes some …
…cleanup and bugfix in grid and datasource-local
- Loading branch information
1 parent
4f09739
commit 258c960
Showing
7 changed files
with
121 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,7 +51,6 @@ function meta( input ) { | |
} | ||
output.push(field); | ||
} | ||
console.log(input, output) | ||
return output; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Grid Navigator | ||
* | ||
* Depends on: | ||
* widget | ||
*/ | ||
(function( $ ) { | ||
|
||
$.widget( "ui.navigator", { | ||
_create: function() { | ||
this.active = $(); | ||
this.element.attr( "tabIndex", 0 ); | ||
this._bind({ | ||
focusin: "activate", | ||
focusout: "deactivate", | ||
keydown: "move", | ||
keyup: "enter", | ||
click: "select" | ||
}); | ||
}, | ||
select: function( event ) { | ||
var target = $( event.target ).closest( "td" ); | ||
if (target.length) { | ||
this.deactivate(); | ||
this.active = target; | ||
this.activate(); | ||
} | ||
}, | ||
activate: function() { | ||
if ( !this.active.length || !this.active.parents("body").length ) { | ||
this.active = this.element.find("td:first"); | ||
} | ||
this.active.addClass("navigator-active"); | ||
}, | ||
deactivate: function() { | ||
this.active.removeClass("navigator-active"); | ||
}, | ||
move: function( event ) { | ||
switch ( event.keyCode ) { | ||
case $.ui.keyCode.RIGHT: | ||
this.right(); break; | ||
case $.ui.keyCode.LEFT: | ||
this.left(); break; | ||
case $.ui.keyCode.UP: | ||
this.up(); break; | ||
case $.ui.keyCode.DOWN: | ||
this.down(); break; | ||
} | ||
}, | ||
enter: function( event ) { | ||
switch ( event.keyCode ) { | ||
case $.ui.keyCode.ENTER: | ||
this.click(); break; | ||
} | ||
}, | ||
right: function() { | ||
var next = this.active.next(); | ||
if (next.length) { | ||
this.deactivate(); | ||
this.active = next; | ||
this.activate(); | ||
} | ||
}, | ||
left: function() { | ||
var next = this.active.prev(); | ||
if (next.length) { | ||
this.deactivate(); | ||
this.active = next; | ||
this.activate(); | ||
} | ||
}, | ||
up: function() { | ||
var index = this.active[ 0 ].cellIndex; | ||
var next = this.active.parent().prev().children( "td" ).eq( index ); | ||
if (next.length) { | ||
this.deactivate(); | ||
this.active = next; | ||
this.activate(); | ||
} | ||
}, | ||
down: function() { | ||
var index = this.active[ 0 ].cellIndex; | ||
var next = this.active.parent().next().children( "td" ).eq( index ); | ||
if (next.length) { | ||
this.deactivate(); | ||
this.active = next; | ||
this.activate(); | ||
} | ||
}, | ||
click: function() { | ||
this.active.trigger("click"); | ||
} | ||
}); | ||
|
||
})( jQuery ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters