jupyter-js-filebrowser
Advanced tools
Comparing version 0.4.10 to 0.5.0
@@ -12,3 +12,3 @@ // Copyright (c) Jupyter Development Team. | ||
var phosphor_widget_1 = require('phosphor-widget'); | ||
var utils_1 = require('./utils'); | ||
var utils = require('./utils'); | ||
/** | ||
@@ -63,3 +63,3 @@ * The class name added to the button node. | ||
_this._model.newUntitled(type).catch(function (error) { | ||
return utils_1.showErrorMessage(_this, 'New File Error', error); | ||
return utils.showErrorMessage(_this, 'New File Error', error); | ||
}).then(function () { return _this._model.refresh(); }); | ||
@@ -101,3 +101,3 @@ }; | ||
} | ||
Promise.all(promises).then(function () { return _this._model.refresh(); }, function (err) { return utils_1.showErrorMessage(_this, 'Upload Error', err); }); | ||
Promise.all(promises).then(function () { return _this._model.refresh(); }, function (err) { return utils.showErrorMessage(_this, 'Upload Error', err); }); | ||
}; | ||
@@ -104,0 +104,0 @@ return FileButtons; |
@@ -12,3 +12,3 @@ // Copyright (c) Jupyter Development Team. | ||
var phosphor_widget_1 = require('phosphor-widget'); | ||
var utils_1 = require('./utils'); | ||
var utils = require('./utils'); | ||
/** | ||
@@ -123,3 +123,3 @@ * The class name added to the breadcrumb node. | ||
this._model.cd(BREAD_CRUMB_PATHS[index]).catch(function (error) { | ||
return utils_1.showErrorMessage(_this, 'Open Error', error); | ||
return utils.showErrorMessage(_this, 'Open Error', error); | ||
}); | ||
@@ -138,7 +138,7 @@ // Stop the event propagation. | ||
BreadCrumbs.prototype._evtDragEnter = function (event) { | ||
if (event.mimeData.hasData(utils_1.CONTENTS_MIME)) { | ||
var index = utils_1.hitTestNodes(this._crumbs, event.clientX, event.clientY); | ||
if (event.mimeData.hasData(utils.CONTENTS_MIME)) { | ||
var index = utils.hitTestNodes(this._crumbs, event.clientX, event.clientY); | ||
if (index !== -1) { | ||
if (index !== Private.Crumb.Current) { | ||
this._crumbs[index].classList.add(utils_1.DROP_TARGET_CLASS); | ||
this._crumbs[index].classList.add(utils.DROP_TARGET_CLASS); | ||
event.preventDefault(); | ||
@@ -156,6 +156,5 @@ event.stopPropagation(); | ||
event.stopPropagation(); | ||
var dropTargets = this.node.getElementsByClassName(utils_1.DROP_TARGET_CLASS); | ||
if (dropTargets.length) { | ||
dropTargets[0].classList.remove(utils_1.DROP_TARGET_CLASS); | ||
} | ||
var dropTarget = utils.findElement(this.node, utils.DROP_TARGET_CLASS); | ||
if (dropTarget) | ||
dropTarget.classList.remove(utils.DROP_TARGET_CLASS); | ||
}; | ||
@@ -169,9 +168,8 @@ /** | ||
event.dropAction = event.proposedAction; | ||
var dropTargets = this.node.getElementsByClassName(utils_1.DROP_TARGET_CLASS); | ||
if (dropTargets.length) { | ||
dropTargets[0].classList.remove(utils_1.DROP_TARGET_CLASS); | ||
} | ||
var index = utils_1.hitTestNodes(this._crumbs, event.clientX, event.clientY); | ||
var dropTarget = utils.findElement(this.node, utils.DROP_TARGET_CLASS); | ||
if (dropTarget) | ||
dropTarget.classList.remove(utils.DROP_TARGET_CLASS); | ||
var index = utils.hitTestNodes(this._crumbs, event.clientX, event.clientY); | ||
if (index !== -1) | ||
this._crumbs[index].classList.add(utils_1.DROP_TARGET_CLASS); | ||
this._crumbs[index].classList.add(utils.DROP_TARGET_CLASS); | ||
}; | ||
@@ -189,3 +187,3 @@ /** | ||
} | ||
if (!event.mimeData.hasData(utils_1.CONTENTS_MIME)) { | ||
if (!event.mimeData.hasData(utils.CONTENTS_MIME)) { | ||
return; | ||
@@ -196,4 +194,4 @@ } | ||
while (target && target.parentElement) { | ||
if (target.classList.contains(utils_1.DROP_TARGET_CLASS)) { | ||
target.classList.remove(utils_1.DROP_TARGET_CLASS); | ||
if (target.classList.contains(utils.DROP_TARGET_CLASS)) { | ||
target.classList.remove(utils.DROP_TARGET_CLASS); | ||
break; | ||
@@ -215,2 +213,5 @@ } | ||
promises.push(this._model.rename(original, newPath).catch(function (error) { | ||
if (error.xhr) { | ||
error.message = error.xhr.status + ": error.statusText"; | ||
} | ||
if (error.message.indexOf('409') !== -1) { | ||
@@ -225,3 +226,5 @@ var options = { | ||
return _this._model.delete(newPath).then(function () { | ||
return _this._model.rename(original, newPath); | ||
return _this._model.rename(original, newPath).then(function () { | ||
return _this._model.refresh(); | ||
}); | ||
}); | ||
@@ -233,3 +236,3 @@ } | ||
} | ||
Promise.all(promises).then(function () { return _this._model.refresh(); }, function (err) { return utils_1.showErrorMessage(_this, 'Move Error', err); }); | ||
Promise.all(promises).then(function () { return _this._model.refresh(); }, function (err) { return utils.showErrorMessage(_this, 'Move Error', err); }); | ||
}; | ||
@@ -236,0 +239,0 @@ return BreadCrumbs; |
@@ -115,2 +115,6 @@ import { IContentsModel } from 'jupyter-js-services'; | ||
/** | ||
* Handle the `'scroll'` event for the widget. | ||
*/ | ||
private _evtScroll(event); | ||
/** | ||
* Handle the `'mousedown'` event for the widget. | ||
@@ -182,3 +186,2 @@ */ | ||
private _prevPath; | ||
private _selectedNames; | ||
private _isCut; | ||
@@ -185,0 +188,0 @@ private _clipboard; |
@@ -11,6 +11,7 @@ // Copyright (c) Jupyter Development Team. | ||
var moment = require('moment'); | ||
var arrays = require('phosphor-arrays'); | ||
var phosphor_dragdrop_1 = require('phosphor-dragdrop'); | ||
var phosphor_signaling_1 = require('phosphor-signaling'); | ||
var phosphor_widget_1 = require('phosphor-widget'); | ||
var utils_1 = require('./utils'); | ||
var utils = require('./utils'); | ||
/** | ||
@@ -27,2 +28,14 @@ * The class name added to FileBrowser list area. | ||
*/ | ||
var HEADER_TEXT_CLASS = 'jp-DirListing-headerText'; | ||
/** | ||
* The class name added to FileBrowser list header items. | ||
*/ | ||
var HEADER_ITEM_CLASS = 'jp-DirListing-headerItem'; | ||
/** | ||
* The class name added to FileBrowser list header modified item. | ||
*/ | ||
var HEADER_ICON_CLASS = 'jp-DirListing-headerIcon'; | ||
/** | ||
* The class name added to FileBrowser list header file item. | ||
*/ | ||
var HEADER_FILE_CLASS = 'jp-DirListing-headerFile'; | ||
@@ -32,3 +45,3 @@ /** | ||
*/ | ||
var HEADER_TIME_CLASS = 'jp-DirListing-headerModified'; | ||
var HEADER_TIME_CLASS = 'jp-DirListing-headerTime'; | ||
/** | ||
@@ -99,2 +112,6 @@ * The class name added to the Filebrowser list area container. | ||
/** | ||
* The class name added for a decending sort. | ||
*/ | ||
var DESCENDING_CLASS = 'jp-mod-descending'; | ||
/** | ||
* The minimum duration for a rename select in ms. | ||
@@ -130,3 +147,2 @@ */ | ||
this._prevPath = ''; | ||
this._selectedNames = []; | ||
this._isCut = false; | ||
@@ -146,6 +162,5 @@ this._clipboard = []; | ||
var node = document.createElement('div'); | ||
var header = document.createElement('div'); | ||
var header = Private.createHeader(); | ||
var body = document.createElement('div'); | ||
var contents = document.createElement('ul'); | ||
header.className = LIST_HEADER_CLASS; | ||
body.className = LIST_CONTAINER_CLASS; | ||
@@ -156,10 +171,2 @@ contents.className = LIST_AREA_CLASS; | ||
body.appendChild(contents); | ||
var files = document.createElement('span'); | ||
var modified = document.createElement('span'); | ||
files.textContent = 'Files'; | ||
files.className = HEADER_FILE_CLASS; | ||
modified.textContent = 'Last Modified'; | ||
modified.className = HEADER_TIME_CLASS; | ||
header.appendChild(files); | ||
header.appendChild(modified); | ||
node.tabIndex = 1; | ||
@@ -278,3 +285,3 @@ return node; | ||
this.node.classList.remove(CLIPBOARD_CLASS); | ||
return Promise.all(promises).then(function () { return _this._model.refresh(); }, function (error) { return utils_1.showErrorMessage(_this, 'Paste Error', error); }); | ||
return Promise.all(promises).then(function () { return _this._model.refresh(); }, function (error) { return utils.showErrorMessage(_this, 'Paste Error', error); }); | ||
}; | ||
@@ -287,7 +294,8 @@ /** | ||
var promises = []; | ||
for (var _i = 0, _a = this._selectedNames; _i < _a.length; _i++) { | ||
var name_2 = _a[_i]; | ||
promises.push(this._model.delete(name_2)); | ||
for (var _i = 0, _a = this._model.selected; _i < _a.length; _i++) { | ||
var index = _a[_i]; | ||
var item = this._model.items[index]; | ||
promises.push(this._model.delete(item.name)); | ||
} | ||
return Promise.all(promises).then(function () { return _this._model.refresh(); }, function (error) { return utils_1.showErrorMessage(_this, 'Delete file', error); }); | ||
return Promise.all(promises).then(function () { return _this._model.refresh(); }, function (error) { return utils.showErrorMessage(_this, 'Delete file', error); }); | ||
}; | ||
@@ -307,3 +315,3 @@ /** | ||
} | ||
return Promise.all(promises).then(function () { return _this._model.refresh(); }, function (error) { return utils_1.showErrorMessage(_this, 'Duplicate file', error); }); | ||
return Promise.all(promises).then(function () { return _this._model.refresh(); }, function (error) { return utils.showErrorMessage(_this, 'Duplicate file', error); }); | ||
}; | ||
@@ -320,3 +328,3 @@ /** | ||
return this._model.download(item.path).catch(function (error) { | ||
return utils_1.showErrorMessage(_this, 'Download file', error); | ||
return utils.showErrorMessage(_this, 'Download file', error); | ||
}); | ||
@@ -340,3 +348,3 @@ } | ||
} | ||
return Promise.all(promises).then(function () { return _this._model.refresh(); }, function (error) { return utils_1.showErrorMessage(_this, 'Shutdown kernel', error); }); | ||
return Promise.all(promises).then(function () { return _this._model.refresh(); }, function (error) { return utils.showErrorMessage(_this, 'Shutdown kernel', error); }); | ||
}; | ||
@@ -349,3 +357,3 @@ /** | ||
var index = -1; | ||
if (this._selectedNames.length === 1 || keepExisting) { | ||
if (this._model.selected.length === 1 || keepExisting) { | ||
// Select the next item. | ||
@@ -356,3 +364,3 @@ index = this._model.selected[this._model.selected.length - 1] + 1; | ||
} | ||
else if (this._selectedNames.length === 0) { | ||
else if (this._model.selected.length === 0) { | ||
// Select the first item. | ||
@@ -380,3 +388,3 @@ index = 0; | ||
var index = -1; | ||
if (this._selectedNames.length === 1 || keepExisting) { | ||
if (this._model.selected.length === 1 || keepExisting) { | ||
// Select the previous item. | ||
@@ -387,3 +395,3 @@ index = this._model.selected[0] - 1; | ||
} | ||
else if (this._selectedNames.length === 0) { | ||
else if (this._model.selected.length === 0) { | ||
// Select the last item. | ||
@@ -435,2 +443,5 @@ index = this._items.length - 1; | ||
break; | ||
case 'scroll': | ||
this._evtScroll(event); | ||
break; | ||
case 'p-dragenter': | ||
@@ -456,2 +467,3 @@ this._evtDragEnter(event); | ||
var node = this.node; | ||
var list = utils.findElement(this.node, LIST_CONTAINER_CLASS); | ||
node.addEventListener('mousedown', this); | ||
@@ -461,2 +473,3 @@ node.addEventListener('keydown', this); | ||
node.addEventListener('dblclick', this); | ||
list.addEventListener('scroll', this); | ||
node.addEventListener('p-dragenter', this); | ||
@@ -473,2 +486,3 @@ node.addEventListener('p-dragleave', this); | ||
var node = this.node; | ||
var list = utils.findElement(this.node, LIST_CONTAINER_CLASS); | ||
node.removeEventListener('mousedown', this); | ||
@@ -478,2 +492,3 @@ node.removeEventListener('keydown', this); | ||
node.removeEventListener('dblclick', this); | ||
list.removeEventListener('scroll', this); | ||
node.removeEventListener('p-dragenter', this); | ||
@@ -493,3 +508,3 @@ node.removeEventListener('p-dragleave', this); | ||
var nodes = this._items; | ||
var content = this.node.getElementsByClassName(LIST_AREA_CLASS)[0]; | ||
var content = utils.findElement(this.node, LIST_AREA_CLASS); | ||
var subtype = this.constructor; | ||
@@ -507,2 +522,23 @@ // Remove any excess item nodes. | ||
} | ||
// Get the previously selected names. | ||
var prevSelected = this._items.map(function (item) { | ||
var el = utils.findElement(item, ITEM_TEXT_CLASS); | ||
if (item.classList.contains(SELECTED_CLASS)) { | ||
return el.textContent; | ||
} | ||
}); | ||
var sorter = utils.findElement(this.node, HEADER_FILE_CLASS); | ||
if (sorter.classList.contains(SELECTED_CLASS)) { | ||
} | ||
else { | ||
sorter = utils.findElement(this.node, HEADER_TIME_CLASS); | ||
items.sort(function (a, b) { | ||
var valA = new Date(a.last_modified).getTime(); | ||
var valB = new Date(b.last_modified).getTime(); | ||
return valB - valA; | ||
}); | ||
} | ||
if (sorter.classList.contains(DESCENDING_CLASS)) { | ||
items.reverse(); | ||
} | ||
// Update the node state to match the model contents. | ||
@@ -515,7 +551,7 @@ for (var i = 0, n = items.length; i < n; ++i) { | ||
if (this._model.path == this._prevPath) { | ||
var newNames = this._model.items.map(function (item) { return item.name; }); | ||
for (var _i = 0, _a = this._selectedNames; _i < _a.length; _i++) { | ||
var name_3 = _a[_i]; | ||
var index = newNames.indexOf(name_3); | ||
if (index !== 1) { | ||
for (var _i = 0, _a = this._items; _i < _a.length; _i++) { | ||
var row = _a[_i]; | ||
var text = utils.findElement(row, ITEM_TEXT_CLASS); | ||
var index = prevSelected.indexOf(text.textContent); | ||
if (index !== -1) { | ||
this._items[index].classList.add(SELECTED_CLASS); | ||
@@ -532,7 +568,7 @@ var path = '/' + this._model.items[index].path; | ||
// Handle notebook session statuses. | ||
var paths = this._model.items.map(function (item) { return item.path; }); | ||
var paths = items.map(function (item) { return item.path; }); | ||
for (var _b = 0, _c = this._model.sessionIds; _b < _c.length; _b++) { | ||
var sessionId = _c[_b]; | ||
var index = paths.indexOf(sessionId.notebook.path); | ||
var node = this._items[index].getElementsByClassName(NOTEBOOK_ICON_CLASS)[0]; | ||
var node = utils.findElement(this._items[index], NOTEBOOK_ICON_CLASS); | ||
node.classList.add(RUNNING_CLASS); | ||
@@ -553,4 +589,26 @@ node.title = sessionId.kernel.name; | ||
DirListing.prototype._evtClick = function (event) { | ||
var index = utils_1.hitTestNodes(this._items, event.clientX, event.clientY); | ||
var index = utils.hitTestNodes(this._items, event.clientX, event.clientY); | ||
if (index == -1) { | ||
var header = utils.findElement(this.node, LIST_HEADER_CLASS); | ||
index = utils.hitTestNodes(header.childNodes, event.clientX, event.clientY); | ||
if (index !== -1) { | ||
for (var i = 0; i < header.childNodes.length; i++) { | ||
var node = header.childNodes[i]; | ||
if (i === index) { | ||
if (node.classList.contains(SELECTED_CLASS)) { | ||
if (node.classList.contains(DESCENDING_CLASS)) { | ||
node.classList.remove(DESCENDING_CLASS); | ||
} | ||
else { | ||
node.classList.add(DESCENDING_CLASS); | ||
} | ||
} | ||
node.classList.add(SELECTED_CLASS); | ||
} | ||
else { | ||
node.classList.remove(SELECTED_CLASS); | ||
} | ||
} | ||
this.update(); | ||
} | ||
return; | ||
@@ -563,2 +621,10 @@ } | ||
/** | ||
* Handle the `'scroll'` event for the widget. | ||
*/ | ||
DirListing.prototype._evtScroll = function (event) { | ||
var list = utils.findElement(this.node, LIST_CONTAINER_CLASS); | ||
var header = utils.findElement(this.node, LIST_HEADER_CLASS); | ||
header.scrollLeft = list.scrollLeft; | ||
}; | ||
/** | ||
* Handle the `'mousedown'` event for the widget. | ||
@@ -578,3 +644,3 @@ */ | ||
} | ||
var index = utils_1.hitTestNodes(this._items, event.clientX, event.clientY); | ||
var index = utils.hitTestNodes(this._items, event.clientX, event.clientY); | ||
if (index == -1) { | ||
@@ -629,3 +695,2 @@ return; | ||
DirListing.prototype._evtKeydown = function (event) { | ||
console.log(event); | ||
switch (event.keyCode) { | ||
@@ -667,3 +732,3 @@ case 38: | ||
this._model.cd(item.name).catch(function (error) { | ||
return utils_1.showErrorMessage(_this, 'Change Directory Error', error); | ||
return utils.showErrorMessage(_this, 'Change Directory Error', error); | ||
}); | ||
@@ -683,8 +748,8 @@ } | ||
DirListing.prototype._evtDragEnter = function (event) { | ||
if (event.mimeData.hasData(utils_1.CONTENTS_MIME)) { | ||
var index = utils_1.hitTestNodes(this._items, event.clientX, event.clientY); | ||
if (event.mimeData.hasData(utils.CONTENTS_MIME)) { | ||
var index = utils.hitTestNodes(this._items, event.clientX, event.clientY); | ||
var target = this._items[index]; | ||
if (target.getElementsByClassName(FOLDER_ICON_CLASS).length && | ||
if (utils.findElement(target, FOLDER_ICON_CLASS) && | ||
!target.classList.contains(SELECTED_CLASS)) { | ||
target.classList.add(utils_1.DROP_TARGET_CLASS); | ||
target.classList.add(utils.DROP_TARGET_CLASS); | ||
event.preventDefault(); | ||
@@ -702,6 +767,5 @@ event.stopPropagation(); | ||
event.stopPropagation(); | ||
var dropTargets = this.node.getElementsByClassName(utils_1.DROP_TARGET_CLASS); | ||
if (dropTargets.length) { | ||
dropTargets[0].classList.remove(utils_1.DROP_TARGET_CLASS); | ||
} | ||
var dropTarget = utils.findElement(this.node, utils.DROP_TARGET_CLASS); | ||
if (dropTarget) | ||
dropTarget.classList.remove(utils.DROP_TARGET_CLASS); | ||
}; | ||
@@ -715,8 +779,7 @@ /** | ||
event.dropAction = event.proposedAction; | ||
var dropTargets = this.node.getElementsByClassName(utils_1.DROP_TARGET_CLASS); | ||
if (dropTargets.length) { | ||
dropTargets[0].classList.remove(utils_1.DROP_TARGET_CLASS); | ||
} | ||
var index = utils_1.hitTestNodes(this._items, event.clientX, event.clientY); | ||
this._items[index].classList.add(utils_1.DROP_TARGET_CLASS); | ||
var dropTarget = utils.findElement(this.node, utils.DROP_TARGET_CLASS); | ||
if (dropTarget) | ||
dropTarget.classList.remove(utils.DROP_TARGET_CLASS); | ||
var index = utils.hitTestNodes(this._items, event.clientX, event.clientY); | ||
this._items[index].classList.add(utils.DROP_TARGET_CLASS); | ||
}; | ||
@@ -734,3 +797,3 @@ /** | ||
} | ||
if (!event.mimeData.hasData(utils_1.CONTENTS_MIME)) { | ||
if (!event.mimeData.hasData(utils.CONTENTS_MIME)) { | ||
return; | ||
@@ -741,4 +804,4 @@ } | ||
while (target && target.parentElement) { | ||
if (target.classList.contains(utils_1.DROP_TARGET_CLASS)) { | ||
target.classList.remove(utils_1.DROP_TARGET_CLASS); | ||
if (target.classList.contains(utils.DROP_TARGET_CLASS)) { | ||
target.classList.remove(utils.DROP_TARGET_CLASS); | ||
break; | ||
@@ -774,3 +837,3 @@ } | ||
} | ||
Promise.all(promises).then(function () { return _this._model.refresh(); }, function (error) { return utils_1.showErrorMessage(_this, 'Move Error', error); }); | ||
Promise.all(promises).then(function () { return _this._model.refresh(); }, function (error) { return utils.showErrorMessage(_this, 'Move Error', error); }); | ||
}; | ||
@@ -792,3 +855,3 @@ /** | ||
if (selected.length > 1) { | ||
var text = dragImage.getElementsByClassName(ITEM_TEXT_CLASS)[0]; | ||
var text = utils.findElement(dragImage, ITEM_TEXT_CLASS); | ||
text.textContent = '(' + selected.length + ')'; | ||
@@ -803,3 +866,3 @@ } | ||
}); | ||
this._drag.mimeData.setData(utils_1.CONTENTS_MIME, null); | ||
this._drag.mimeData.setData(utils.CONTENTS_MIME, null); | ||
if (this._widgetFactory && selected.length == 1) { | ||
@@ -828,3 +891,3 @@ var item = this._model.items[selected[0]]; | ||
var nodes = this._items; | ||
var index = utils_1.hitTestNodes(this._items, event.clientX, event.clientY); | ||
var index = utils.hitTestNodes(this._items, event.clientX, event.clientY); | ||
var target = this._items[index]; | ||
@@ -880,8 +943,10 @@ for (var _i = 0; _i < nodes.length; _i++) { | ||
var selected = []; | ||
this._selectedNames = []; | ||
var items = this._model.items; | ||
for (var i = 0; i < this._items.length; i++) { | ||
if (this._items[i].classList.contains(SELECTED_CLASS)) { | ||
selected.push(i); | ||
this._selectedNames.push(items[i].name); | ||
var name = items[i].name; | ||
var index = arrays.findIndex(this._model.items, function (item) { | ||
return item.name === name; | ||
}); | ||
selected.push(index); | ||
} | ||
@@ -913,3 +978,6 @@ } | ||
var item = this._model.items[index]; | ||
var row = this._items[index]; | ||
var row = arrays.find(this._items, function (row) { | ||
var text = utils.findElement(row, ITEM_TEXT_CLASS); | ||
return text.textContent === item.name; | ||
}); | ||
if (item.type !== 'directory') { | ||
@@ -935,5 +1003,5 @@ if (isCut) | ||
var _this = this; | ||
var row = this.node.getElementsByClassName(SELECTED_CLASS)[0]; | ||
var fileCell = row.getElementsByClassName(ITEM_FILE_CLASS)[0]; | ||
var text = row.getElementsByClassName(ITEM_TEXT_CLASS)[0]; | ||
var row = utils.findElement(this.node, SELECTED_CLASS); | ||
var fileCell = utils.findElement(row, ITEM_FILE_CLASS); | ||
var text = utils.findElement(row, ITEM_TEXT_CLASS); | ||
var original = text.textContent; | ||
@@ -946,2 +1014,5 @@ return Private.doRename(fileCell, text, this._editNode).then(function (changed) { | ||
return _this._model.rename(original, newPath).catch(function (error) { | ||
if (error.xhr) { | ||
error.message = error.xhr.status + ": error.statusText"; | ||
} | ||
if (error.message.indexOf('409') !== -1 || | ||
@@ -954,6 +1025,8 @@ error.message.indexOf('already exists') !== -1) { | ||
}; | ||
jupyter_js_domutils_1.showDialog(options).then(function (button) { | ||
return jupyter_js_domutils_1.showDialog(options).then(function (button) { | ||
if (button.text === 'OK') { | ||
return _this._model.delete(newPath).then(function () { | ||
return _this._model.rename(original, newPath); | ||
return _this._model.rename(original, newPath).then(function () { | ||
_this._model.refresh(); | ||
}); | ||
}); | ||
@@ -967,3 +1040,3 @@ } | ||
}).catch(function (error) { | ||
utils_1.showErrorMessage(_this, 'Rename Error', error); | ||
utils.showErrorMessage(_this, 'Rename Error', error); | ||
return original; | ||
@@ -980,3 +1053,3 @@ }).then(function () { | ||
DirListing.prototype._selectItem = function (index, top, keepExisting) { | ||
// Add the selected class to current row, and remove from all others. | ||
// Add the selected class to selected row(s), and remove from all others. | ||
if (!keepExisting) { | ||
@@ -1159,3 +1232,3 @@ for (var _i = 0, _a = this._items; _i < _a.length; _i++) { | ||
/** | ||
* Check whether an element is scolled into view. | ||
* Check whether an element is scrolled into view. | ||
*/ | ||
@@ -1173,2 +1246,34 @@ function isScrolledIntoView(elem, container) { | ||
Private.isScrolledIntoView = isScrolledIntoView; | ||
/** | ||
* Create the header node. | ||
*/ | ||
function createHeader() { | ||
var files = document.createElement('div'); | ||
files.className = HEADER_FILE_CLASS; | ||
files.classList.add(HEADER_ITEM_CLASS); | ||
files.classList.add(SELECTED_CLASS); | ||
var fileText = document.createElement('span'); | ||
fileText.className = HEADER_TEXT_CLASS; | ||
fileText.textContent = 'Name'; | ||
var fileIcon = document.createElement('span'); | ||
fileIcon.className = "fa " + HEADER_ICON_CLASS; | ||
files.appendChild(fileText); | ||
files.appendChild(fileIcon); | ||
var modified = document.createElement('div'); | ||
modified.className = HEADER_TIME_CLASS; | ||
modified.classList.add(HEADER_ITEM_CLASS); | ||
var modText = document.createElement('span'); | ||
modText.className = HEADER_TEXT_CLASS; | ||
modText.textContent = 'Last Modified'; | ||
var modIcon = document.createElement('span'); | ||
modIcon.className = "fa " + HEADER_ICON_CLASS; | ||
modified.appendChild(modText); | ||
modified.appendChild(modIcon); | ||
var header = document.createElement('div'); | ||
header.className = LIST_HEADER_CLASS; | ||
header.appendChild(files); | ||
header.appendChild(modified); | ||
return header; | ||
} | ||
Private.createHeader = createHeader; | ||
})(Private || (Private = {})); |
@@ -21,2 +21,6 @@ import { Widget } from 'phosphor-widget'; | ||
*/ | ||
export declare function hitTestNodes(nodes: HTMLElement[], x: number, y: number): number; | ||
export declare function hitTestNodes(nodes: HTMLElement[] | NodeList, x: number, y: number): number; | ||
/** | ||
* Find the first element matching a class name. | ||
*/ | ||
export declare function findElement(parent: HTMLElement, className: string): HTMLElement; |
@@ -51,1 +51,10 @@ // Copyright (c) Jupyter Development Team. | ||
exports.hitTestNodes = hitTestNodes; | ||
/** | ||
* Find the first element matching a class name. | ||
*/ | ||
function findElement(parent, className) { | ||
var elements = parent.getElementsByClassName(className); | ||
if (elements.length) | ||
return elements[0]; | ||
} | ||
exports.findElement = findElement; |
{ | ||
"name": "jupyter-js-filebrowser", | ||
"version": "0.4.10", | ||
"version": "0.5.0", | ||
"description": "File browser widget for Jupyter", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
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
122310
3498
1
20