jupyter-js-filebrowser
Advanced tools
Comparing version 0.4.9 to 0.4.10
@@ -82,7 +82,7 @@ import { IContentsModel } from 'jupyter-js-services'; | ||
*/ | ||
selectNext(): void; | ||
selectNext(keepExisting?: boolean): void; | ||
/** | ||
* Select previous item. | ||
*/ | ||
selectPrevious(): void; | ||
selectPrevious(keepExisting?: boolean): void; | ||
/** | ||
@@ -128,2 +128,6 @@ * Handle the DOM events for the directory listing. | ||
/** | ||
* Handle the `'keydown'` event for the widget. | ||
*/ | ||
private _evtKeydown(event); | ||
/** | ||
* Handle the `'dblclick'` event for the widget. | ||
@@ -171,3 +175,3 @@ */ | ||
*/ | ||
private _selectItem(index, top); | ||
private _selectItem(index, top, keepExisting); | ||
private _model; | ||
@@ -174,0 +178,0 @@ private _editNode; |
@@ -334,5 +334,6 @@ // Copyright (c) Jupyter Development Team. | ||
*/ | ||
DirListing.prototype.selectNext = function () { | ||
DirListing.prototype.selectNext = function (keepExisting) { | ||
if (keepExisting === void 0) { keepExisting = false; } | ||
var index = -1; | ||
if (this._selectedNames.length === 1) { | ||
if (this._selectedNames.length === 1 || keepExisting) { | ||
// Select the next item. | ||
@@ -353,6 +354,6 @@ index = this._model.selected[this._model.selected.length - 1] + 1; | ||
if (index === 0) { | ||
this._selectItem(index, true); | ||
this._selectItem(index, true, keepExisting); | ||
} | ||
else { | ||
this._selectItem(index, false); | ||
this._selectItem(index, false, keepExisting); | ||
} | ||
@@ -364,5 +365,6 @@ } | ||
*/ | ||
DirListing.prototype.selectPrevious = function () { | ||
DirListing.prototype.selectPrevious = function (keepExisting) { | ||
if (keepExisting === void 0) { keepExisting = false; } | ||
var index = -1; | ||
if (this._selectedNames.length === 1) { | ||
if (this._selectedNames.length === 1 || keepExisting) { | ||
// Select the previous item. | ||
@@ -383,6 +385,6 @@ index = this._model.selected[0] - 1; | ||
if (index === this._items.length - 1) { | ||
this._selectItem(index, false); | ||
this._selectItem(index, false, keepExisting); | ||
} | ||
else { | ||
this._selectItem(index, true); | ||
this._selectItem(index, true, keepExisting); | ||
} | ||
@@ -412,2 +414,5 @@ } | ||
break; | ||
case 'keydown': | ||
this._evtKeydown(event); | ||
break; | ||
case 'click': | ||
@@ -440,2 +445,3 @@ this._evtClick(event); | ||
node.addEventListener('mousedown', this); | ||
node.addEventListener('keydown', this); | ||
node.addEventListener('click', this); | ||
@@ -455,2 +461,3 @@ node.addEventListener('dblclick', this); | ||
node.removeEventListener('mousedown', this); | ||
node.removeEventListener('keydown', this); | ||
node.removeEventListener('click', this); | ||
@@ -598,2 +605,20 @@ node.removeEventListener('dblclick', this); | ||
/** | ||
* Handle the `'keydown'` event for the widget. | ||
*/ | ||
DirListing.prototype._evtKeydown = function (event) { | ||
console.log(event); | ||
switch (event.keyCode) { | ||
case 38: | ||
this.selectPrevious(event.shiftKey); | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
break; | ||
case 40: | ||
this.selectNext(event.shiftKey); | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
break; | ||
} | ||
}; | ||
/** | ||
* Handle the `'dblclick'` event for the widget. | ||
@@ -917,7 +942,9 @@ */ | ||
*/ | ||
DirListing.prototype._selectItem = function (index, top) { | ||
DirListing.prototype._selectItem = function (index, top, keepExisting) { | ||
// Add the selected class to current row, and remove from all others. | ||
for (var _i = 0, _a = this._items; _i < _a.length; _i++) { | ||
var node = _a[_i]; | ||
node.classList.remove(SELECTED_CLASS); | ||
if (!keepExisting) { | ||
for (var _i = 0, _a = this._items; _i < _a.length; _i++) { | ||
var node = _a[_i]; | ||
node.classList.remove(SELECTED_CLASS); | ||
} | ||
} | ||
@@ -924,0 +951,0 @@ this._items[index].classList.add(SELECTED_CLASS); |
{ | ||
"name": "jupyter-js-filebrowser", | ||
"version": "0.4.9", | ||
"version": "0.4.10", | ||
"description": "File browser widget for Jupyter", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120870
3477