Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Deprecated code in October into (event.key) #4489

Merged
merged 8 commits into from Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/backend/assets/js/october.flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
}

Flyout.prototype.onDocumentKeydown = function(ev) {
if (ev.which == 27) {
if (ev.key === 'Escape') {
this.hide();
}
}
Expand Down
34 changes: 13 additions & 21 deletions modules/backend/formwidgets/richeditor/assets/js/plugins/figures.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,28 +85,24 @@
}

function _handleUiBlocksKeydown(ev) {
if (ev.which == 40 || ev.which == 38 || ev.which == 8 || ev.which == 46) {
if (ev.key === 'ArrowDown' || ev.key === 'ArrowUp' || ev.key === 'Backspace' || ev.key === 'Delete') {
var $block = $(editor.selection.element())
if ($block.is('br')) {
$block = $block.parent()
}

if (!!$block.length) {
switch (ev.which) {
case 38:
// Up arrow
switch (ev.key) {
case 'ArrowUp':
_handleUiBlockCaretIn($block.prev())
break
case 40:
// Down arrow
case 'ArrowDown':
_handleUiBlockCaretIn($block.next())
break
case 46:
// Delete key
case 'Delete':
_handleUiBlockCaretClearEmpty($block.next(), $block)
break
case 8:
// Backspace key
case 'Backspace':
_handleUiBlockCaretClearEmpty($block.prev(), $block)
break
}
Expand All @@ -133,27 +129,23 @@
}

function _uiBlockKeyDown(ev, block) {
if (ev.which == 40 || ev.which == 38 || ev.which == 13 || ev.which == 8 || ev.which == 46) {
switch (ev.which) {
case 40:
// Down arrow
if (ev.key === 'ArrowDown' || ev.key === 'ArrowUp' || ev.key === 'Enter' || ev.key === 'Backspace' || ev.key === 'Delete') {
switch (ev.key) {
case 'ArrowDown':
_focusUiBlockOrText($(block).next(), true)
break
case 38:
// Up arrow
case 'ArrowUp':
_focusUiBlockOrText($(block).prev(), false)
break
case 13:
// Enter key
case 'Enter':
var $paragraph = $('<p><br/></p>')
$paragraph.insertAfter(block)
editor.selection.setAfter(block)
editor.selection.restore()
editor.undo.saveStep()
break
case 8:
case 46:
// Delete / Backspace key
case 'Backspace':
case 'Delete':
var $nextFocus = $(block).next(),
gotoStart = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,13 @@ MediaManager.prototype.onSortingChanged=function(ev){var $target=$(ev.target),da
if($target.data('sort')=='by'){data.sortBy=$target.val();}else if($target.data('sort')=='direction'){data.sortDirection=$target.val()}
this.execNavigationRequest('onSetSorting',data)}
MediaManager.prototype.onKeyDown=function(ev){var eventHandled=false
switch(ev.which){case 13:var items=this.getSelectedItems(true,true)
switch(ev.key){case 'Enter':var items=this.getSelectedItems(true,true)
if(items.length>0)
this.navigateToItem($(items[0]))
eventHandled=true
break;case 39:case 40:this.selectRelative(true,ev.shiftKey)
break;case 'ArrowRight':case 'ArrowDown':this.selectRelative(true,ev.shiftKey)
eventHandled=true
break;case 37:case 38:this.selectRelative(false,ev.shiftKey)
break;case 'ArrowLeft':case 'ArrowUp':this.selectRelative(false,ev.shiftKey)
eventHandled=true
break;}
if(eventHandled){ev.preventDefault()
Expand Down
14 changes: 8 additions & 6 deletions modules/backend/widgets/mediamanager/assets/js/mediamanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@
var item = items[i],
path = item.getAttribute('data-path')


if (item.getAttribute('data-item-type') == 'folder')
data.folders.push(path)
else
Expand Down Expand Up @@ -1250,21 +1251,22 @@
MediaManager.prototype.onKeyDown = function(ev) {
var eventHandled = false

switch (ev.which) {
case 13:

switch (ev.key) {
case 'Enter':
var items = this.getSelectedItems(true, true)
if (items.length > 0)
this.navigateToItem($(items[0]))

eventHandled = true
break;
case 39:
case 40:
case 'ArrowRight':
case 'ArrowDown':
this.selectRelative(true, ev.shiftKey)
eventHandled = true
break;
case 37:
case 38:
case 'ArrowLeft':
case 'ArrowUp':
this.selectRelative(false, ev.shiftKey)
eventHandled = true
break;
Expand Down
32 changes: 16 additions & 16 deletions modules/backend/widgets/table/assets/js/build-min.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ var target=this.getEventTarget(ev,'TD')
if(!target){this.unfocusTable();return;}
if(target.tagName!='TD'){this.unfocusTable();return;}
this.focusCell(target,true)}
Table.prototype.onKeydown=function(ev){if(ev.keyCode==65&&ev.altKey&&this.options.adding){if(!ev.shiftKey){this.addRecord('below')}
Table.prototype.onKeydown=function(ev){if((ev.key==='a'||ev.key==='A')&&ev.altKey&&this.options.adding){if(!ev.shiftKey){this.addRecord('below')}
else{this.addRecord('above')}
this.stopEvent(ev)
return}
if(ev.keyCode==68&&ev.altKey&&this.options.deleting){this.deleteRecord()
if((ev.key==='d'||ev.key==='D')&&ev.altKey&&this.options.deleting){this.deleteRecord()
this.stopEvent(ev)
return}
for(var i=0,len=this.options.columns.length;i<len;i++){var column=this.options.columns[i].key
Expand Down Expand Up @@ -527,15 +527,15 @@ if(focusRow)
this.focusCell(focusRow,cellIndex)
else
this.focusCell('top',cellIndex)}}
Navigation.prototype.onKeydown=function(ev){if(ev.keyCode==40)
Navigation.prototype.onKeydown=function(ev){if(ev.key==='ArrowDown')
return this.navigateDown(ev)
else if(ev.keyCode==38)
else if(ev.key==='ArrowUp')
return this.navigateUp(ev)
else if(ev.keyCode==37)
else if(ev.key==='ArrowLeft')
return this.navigateLeft(ev)
if(ev.keyCode==39)
if(ev.key==='ArrowRight')
return this.navigateRight(ev)
if(ev.keyCode==9)
if(ev.key==='Tab')
return this.navigateNext(ev)}
Navigation.prototype.onClick=function(ev){var target=this.tableObj.getEventTarget(ev,'A')
if(!target||!$(target).hasClass('pagination-link'))
Expand Down Expand Up @@ -570,7 +570,7 @@ Search.prototype.searchEnabled=function(){return this.tableObj.options.searching
Search.prototype.performSearch=function(query,onSuccess){var isDirty=this.activeQuery!=query
this.activeQuery=query
if(isDirty){this.tableObj.updateDataTable(onSuccess)}}
Search.prototype.onKeydown=function(ev){if(ev.keyCode==9){this.onClick(ev)
Search.prototype.onKeydown=function(ev){if(ev.key==='Tab'){this.onClick(ev)
return}
if(!this.isActive){return}
var self=this
Expand Down Expand Up @@ -765,7 +765,7 @@ checkbox.setAttribute('tabindex','0')
if(value&&value!=0&&value!="false"){checkbox.setAttribute('class','checked')}
cellContentContainer.appendChild(checkbox)}
CheckboxProcessor.prototype.onFocus=function(cellElement,isClick){cellElement.querySelector('div[data-checkbox-element]').focus()}
CheckboxProcessor.prototype.onKeyDown=function(ev){if(ev.keyCode==32)
CheckboxProcessor.prototype.onKeyDown=function(ev){if(ev.key==='(Space character)'||ev.key==='Spacebar'||ev.key===' ')
this.onClick(ev)}
CheckboxProcessor.prototype.onClick=function(ev){var target=this.tableObj.getEventTarget(ev,'DIV')
if(target.getAttribute('data-checkbox-element')){var container=this.getCheckboxContainerNode(target)
Expand Down Expand Up @@ -887,20 +887,20 @@ if(target.tagName=='LI'){target.focus();this.updateCellFromFocusedItem()
this.hideDropdown()}}
DropdownProcessor.prototype.onItemKeyDown=function(ev){if(!this.itemListElement)
return
if(ev.keyCode==40||ev.keyCode==38)
if(ev.key==='ArrowDown'||ev.key==='ArrowUp')
{var focused=this.findFocusedItem(),newFocusedItem=focused.nextElementSibling
if(ev.keyCode==38)
if(ev.key==='ArrowUp')
newFocusedItem=focused.previousElementSibling
if(newFocusedItem){newFocusedItem.focus()}
return}
if(ev.keyCode==13||ev.keyCode==32){this.updateCellFromFocusedItem()
if(ev.key==='Enter'||ev.key==='(Space character)'||ev.key==='Spacebar'||ev.key===' '){this.updateCellFromFocusedItem()
this.hideDropdown()
return}
if(ev.keyCode==9){this.updateCellFromFocusedItem()
if(ev.key==='Tab'){this.updateCellFromFocusedItem()
this.tableObj.navigation.navigateNext(ev)
this.tableObj.stopEvent(ev)
return}
if(ev.keyCode==27){this.hideDropdown()
if(ev.key==='Escape'){this.hideDropdown()
return}
this.searchByTextInput(ev,true);}
DropdownProcessor.prototype.onItemMouseMove=function(ev){if(!this.itemListElement)
Expand All @@ -909,9 +909,9 @@ var target=this.tableObj.getEventTarget(ev)
if(target.tagName=='LI'){target.focus();}}
DropdownProcessor.prototype.onKeyDown=function(ev){if(!this.itemListElement)
return
if(ev.keyCode==32&&!this.searching){this.showDropdown()}else if(ev.keyCode==40||ev.keyCode==38){var selected=this.findSelectedItem(),newSelectedItem;if(!selected){if(ev.keyCode==38){return false}
if((ev.key==='(Space character)'||ev.key==='Spacebar'||ev.key===' ')&&!this.searching){this.showDropdown()}else if(ev.key==='ArrowDown'||ev.key==='ArrowUp'){var selected=this.findSelectedItem(),newSelectedItem;if(!selected){if(ev.key=='ArrowUp'){return false}
newSelectedItem=this.itemListElement.querySelector('ul li:first-child')}else{newSelectedItem=selected.nextElementSibling
if(ev.keyCode==38)
if(ev.key==='ArrowUp')
newSelectedItem=selected.previousElementSibling}
if(newSelectedItem){this.setSelectedItem(newSelectedItem);}
return false}else{this.searchByTextInput(ev);}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,17 @@
// The navigation object uses the table's keydown handler
// and doesn't register own handler.

if (ev.keyCode == 40)
if (ev.key === 'ArrowDown')
return this.navigateDown(ev)
else if (ev.keyCode == 38)
else if (ev.key === 'ArrowUp')
return this.navigateUp(ev)
else if (ev.keyCode == 37)
else if (ev.key === 'ArrowLeft')
return this.navigateLeft(ev)

if (ev.keyCode == 39)
if (ev.key === 'ArrowRight')
return this.navigateRight(ev)

if (ev.keyCode == 9)
if (ev.key === 'Tab')
return this.navigateNext(ev)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
// and doesn't register own handler.

// Tab pressed
if (ev.keyCode == 9) {
if (ev.key === 'Tab') {
this.onClick(ev)
return
}
Expand Down
4 changes: 2 additions & 2 deletions modules/backend/widgets/table/assets/js/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@
}

Table.prototype.onKeydown = function(ev) {
if (ev.keyCode == 65 && ev.altKey && this.options.adding) {
if ((ev.key === 'a' || ev.key === 'A') && ev.altKey && this.options.adding) {
if (!ev.shiftKey) {
// alt+a - add record below
this.addRecord('below')
Expand All @@ -770,7 +770,7 @@
return
}

if (ev.keyCode == 68 && ev.altKey && this.options.deleting) {
if ((ev.key === 'd' || ev.key === 'D') && ev.altKey && this.options.deleting) {
// alt+d - delete record
this.deleteRecord()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
* for all processors.
*/
CheckboxProcessor.prototype.onKeyDown = function(ev) {
if (ev.keyCode == 32)
if (ev.key === '(Space character)' || ev.key === 'Spacebar' || ev.key === ' ')
this.onClick(ev)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@
if (!this.itemListElement)
return

if (ev.keyCode == 40 || ev.keyCode == 38)
if (ev.key === 'ArrowDown' || ev.key === 'ArrowUp')
{
// Up or down keys - find previous/next list item and select it
var focused = this.findFocusedItem(),
newFocusedItem = focused.nextElementSibling

if (ev.keyCode == 38)
if (ev.key === 'ArrowUp')
newFocusedItem = focused.previousElementSibling

if (newFocusedItem) {
Expand All @@ -334,22 +334,22 @@
return
}

if (ev.keyCode == 13 || ev.keyCode == 32) {
if (ev.key === 'Enter' || ev.key === '(Space character)' || ev.key === 'Spacebar' || ev.key === ' ') {
// Return or space keys - update the selected value and hide the editor
this.updateCellFromFocusedItem()
this.hideDropdown()
return
}

if (ev.keyCode == 9) {
if (ev.key === 'Tab') {
// Tab - update the selected value and pass control to the table navigation
this.updateCellFromFocusedItem()
this.tableObj.navigation.navigateNext(ev)
this.tableObj.stopEvent(ev)
return
}

if (ev.keyCode == 27) {
if (ev.key === 'Escape') {
// Esc - hide the drop-down
this.hideDropdown()
return
Expand Down Expand Up @@ -380,22 +380,22 @@
if (!this.itemListElement)
return

if (ev.keyCode == 32 && !this.searching) { // Spacebar
if ((ev.key === '(Space character)' || ev.key === 'Spacebar' || ev.key === ' ') && !this.searching) { // Spacebar
this.showDropdown()
} else if (ev.keyCode == 40 || ev.keyCode == 38) { // Up and down arrow keys
} else if (ev.key === 'ArrowDown' || ev.key === 'ArrowUp') { // Up and down arrow keys
var selected = this.findSelectedItem(),
newSelectedItem;

if (!selected) {
if (ev.keyCode == 38) {
if (ev.key === 'ArrowUp') {
// Only show an initial item when the down array key is pressed
return false
}
newSelectedItem = this.itemListElement.querySelector('ul li:first-child')
} else {
newSelectedItem = selected.nextElementSibling

if (ev.keyCode == 38)
if (ev.key === 'ArrowUp')
newSelectedItem = selected.previousElementSibling
}

Expand Down
2 changes: 1 addition & 1 deletion modules/system/assets/js/framework-min.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ $(document).on('click','a[data-request], button[data-request], input[type=button
$(this).request()
if($(this).is('[type=submit]'))
return false})
$(document).on('keydown','input[type=text][data-request], input[type=submit][data-request], input[type=password][data-request]',function documentOnKeydown(e){if(e.keyCode==13){if(this.dataTrackInputTimer!==undefined)
$(document).on('keydown','input[type=text][data-request], input[type=submit][data-request], input[type=password][data-request]',function documentOnKeydown(e){if(e.key==='Enter'){if(this.dataTrackInputTimer!==undefined)
window.clearTimeout(this.dataTrackInputTimer)
$(this).request()
return false}})
Expand Down
2 changes: 1 addition & 1 deletion modules/system/assets/js/framework.combined-min.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ $(document).on('click','a[data-request], button[data-request], input[type=button
$(this).request()
if($(this).is('[type=submit]'))
return false})
$(document).on('keydown','input[type=text][data-request], input[type=submit][data-request], input[type=password][data-request]',function documentOnKeydown(e){if(e.keyCode==13){if(this.dataTrackInputTimer!==undefined)
$(document).on('keydown','input[type=text][data-request], input[type=submit][data-request], input[type=password][data-request]',function documentOnKeydown(e){if(e.key==='Enter'){if(this.dataTrackInputTimer!==undefined)
window.clearTimeout(this.dataTrackInputTimer)
$(this).request()
return false}})
Expand Down
2 changes: 1 addition & 1 deletion modules/system/assets/js/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ if (window.jQuery.request !== undefined) {
})

$(document).on('keydown', 'input[type=text][data-request], input[type=submit][data-request], input[type=password][data-request]', function documentOnKeydown(e) {
if (e.keyCode == 13) {
if (e.key === 'Enter') {
if (this.dataTrackInputTimer !== undefined)
window.clearTimeout(this.dataTrackInputTimer)

Expand Down
Loading