##// END OF EJS Templates
teach tree view about non-notebook files
MinRK -
Show More
@@ -7955,6 +7955,22 b' input.engine_num_input {'
7955 .notebook_icon:before.pull-right {
7955 .notebook_icon:before.pull-right {
7956 margin-left: .3em;
7956 margin-left: .3em;
7957 }
7957 }
7958 .file_icon:before {
7959 display: inline-block;
7960 font-family: FontAwesome;
7961 font-style: normal;
7962 font-weight: normal;
7963 line-height: 1;
7964 -webkit-font-smoothing: antialiased;
7965 -moz-osx-font-smoothing: grayscale;
7966 content: "\f016";
7967 }
7968 .file_icon:before.pull-left {
7969 margin-right: .3em;
7970 }
7971 .file_icon:before.pull-right {
7972 margin-left: .3em;
7973 }
7958 /*!
7974 /*!
7959 *
7975 *
7960 * IPython notebook
7976 * IPython notebook
@@ -161,11 +161,12 b' define(['
161 message = param.msg;
161 message = param.msg;
162 }
162 }
163 var item = null;
163 var item = null;
164 var content = data.content;
164 var model = null;
165 var len = content.length;
165 var list = data.content;
166 var len = list.length;
166 this.clear_list();
167 this.clear_list();
167 if (len === 0) {
168 if (len === 0) {
168 item = this.new_notebook_item(0);
169 item = this.new_item(0);
169 var span12 = item.children().first();
170 var span12 = item.children().first();
170 span12.empty();
171 span12.empty();
171 span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').text(message));
172 span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').text(message));
@@ -173,31 +174,24 b' define(['
173 var path = this.notebook_path;
174 var path = this.notebook_path;
174 var offset = 0;
175 var offset = 0;
175 if (path !== '') {
176 if (path !== '') {
176 item = this.new_notebook_item(0);
177 item = this.new_item(0);
177 this.add_dir(path, '..', item);
178 model = {
179 type: 'directory',
180 name: '..',
181 path: path,
182 };
183 this.add_link(model, item);
178 offset = 1;
184 offset = 1;
179 }
185 }
180 for (var i=0; i<len; i++) {
186 for (var i=0; i<len; i++) {
181 if (content[i].type === 'directory') {
187 model = list[i];
182 var name = content[i].name;
188 item = this.new_item(i+offset);
183 item = this.new_notebook_item(i+offset);
189 this.add_link(model, item);
184 this.add_dir(path, name, item);
185 } else {
186 var name = content[i].name;
187 item = this.new_notebook_item(i+offset);
188 this.add_link(path, name, item);
189 name = utils.url_path_join(path, name);
190 if(this.sessions[name] === undefined){
191 this.add_delete_button(item);
192 } else {
193 this.add_shutdown_button(item,this.sessions[name]);
194 }
195 }
196 }
190 }
197 };
191 };
198
192
199
193
200 NotebookList.prototype.new_notebook_item = function (index) {
194 NotebookList.prototype.new_item = function (index) {
201 var item = $('<div/>').addClass("list_item").addClass("row");
195 var item = $('<div/>').addClass("list_item").addClass("row");
202 // item.addClass('list_item ui-widget ui-widget-content ui-helper-clearfix');
196 // item.addClass('list_item ui-widget ui-widget-content ui-helper-clearfix');
203 // item.css('border-top-style','none');
197 // item.css('border-top-style','none');
@@ -220,47 +214,57 b' define(['
220 };
214 };
221
215
222
216
223 NotebookList.prototype.add_dir = function (path, name, item) {
217 NotebookList.icons = {
218 directory: 'folder_icon',
219 notebook: 'notebook_icon',
220 file: 'file_icon',
221 };
222
223 NotebookList.uri_prefixes = {
224 directory: 'tree',
225 notebook: 'notebooks',
226 file: 'files',
227 };
228
229
230 NotebookList.prototype.add_link = function (model, item) {
231 var path = model.path,
232 name = model.name;
224 item.data('name', name);
233 item.data('name', name);
225 item.data('path', path);
234 item.data('path', path);
226 item.find(".item_name").text(name);
235 item.find(".item_name").text(name);
227 item.find(".item_icon").addClass('folder_icon').addClass('icon-fixed-width');
236 var icon = NotebookList.icons[model.type];
237 var uri_prefix = NotebookList.uri_prefixes[model.type];
238 item.find(".item_icon").addClass(icon).addClass('icon-fixed-width');
228 item.find("a.item_link")
239 item.find("a.item_link")
229 .attr('href',
240 .attr('href',
230 utils.url_join_encode(
241 utils.url_join_encode(
231 this.base_url,
242 this.base_url,
232 "tree",
243 uri_prefix,
233 path,
244 path,
234 name
245 name
235 )
246 )
236 );
247 );
248 var path_name = utils.url_path_join(path, name);
249 if (model.type == 'file') {
250 this.add_delete_button(item);
251 } else if (model.type == 'notebook') {
252 if(this.sessions[path_name] === undefined){
253 this.add_delete_button(item);
254 } else {
255 this.add_shutdown_button(item, this.sessions[path_name]);
256 }
257 }
237 };
258 };
238
259
239
260
240 NotebookList.prototype.add_link = function (path, nbname, item) {
261 NotebookList.prototype.add_name_input = function (name, item) {
241 item.data('nbname', nbname);
262 item.data('name', name);
242 item.data('path', path);
243 item.find(".item_name").text(nbname);
244 item.find(".item_icon").addClass('notebook_icon').addClass('icon-fixed-width');
245 item.find("a.item_link")
246 .attr('href',
247 utils.url_join_encode(
248 this.base_url,
249 "notebooks",
250 path,
251 nbname
252 )
253 ).attr('target','_blank');
254 };
255
256
257 NotebookList.prototype.add_name_input = function (nbname, item) {
258 item.data('nbname', nbname);
259 item.find(".item_icon").addClass('notebook_icon').addClass('icon-fixed-width');
263 item.find(".item_icon").addClass('notebook_icon').addClass('icon-fixed-width');
260 item.find(".item_name").empty().append(
264 item.find(".item_name").empty().append(
261 $('<input/>')
265 $('<input/>')
262 .addClass("nbname_input")
266 .addClass("nbname_input")
263 .attr('value', utils.splitext(nbname)[0])
267 .attr('value', utils.splitext(name)[0])
264 .attr('size', '30')
268 .attr('size', '30')
265 .attr('type', 'text')
269 .attr('type', 'text')
266 );
270 );
@@ -308,10 +312,10 b' define(['
308 // We use the nbname and notebook_id from the parent notebook_item element's
312 // We use the nbname and notebook_id from the parent notebook_item element's
309 // data because the outer scopes values change as we iterate through the loop.
313 // data because the outer scopes values change as we iterate through the loop.
310 var parent_item = that.parents('div.list_item');
314 var parent_item = that.parents('div.list_item');
311 var nbname = parent_item.data('nbname');
315 var name = parent_item.data('name');
312 var message = 'Are you sure you want to permanently delete the notebook: ' + nbname + '?';
316 var message = 'Are you sure you want to permanently delete the file: ' + name + '?';
313 dialog.modal({
317 dialog.modal({
314 title : "Delete notebook",
318 title : "Delete file",
315 body : message,
319 body : message,
316 buttons : {
320 buttons : {
317 Delete : {
321 Delete : {
@@ -331,7 +335,7 b' define(['
331 notebooklist.base_url,
335 notebooklist.base_url,
332 'api/contents',
336 'api/contents',
333 notebooklist.notebook_path,
337 notebooklist.notebook_path,
334 nbname
338 name
335 );
339 );
336 $.ajax(url, settings);
340 $.ajax(url, settings);
337 }
341 }
@@ -442,7 +446,8 b' define(['
442 });
446 });
443 };
447 };
444
448
445 // Backwards compatability.
449
450 // Backwards compatability.
446 IPython.NotebookList = NotebookList;
451 IPython.NotebookList = NotebookList;
447
452
448 return {'NotebookList': NotebookList};
453 return {'NotebookList': NotebookList};
@@ -147,3 +147,7 b' input.engine_num_input {'
147 .notebook_icon:before {
147 .notebook_icon:before {
148 .icon(@fa-var-book)
148 .icon(@fa-var-book)
149 }
149 }
150
151 .file_icon:before {
152 .icon(@fa-var-file-o)
153 }
General Comments 0
You need to be logged in to leave comments. Login now