##// END OF EJS Templates
Improved notebook renaming....
Brian Granger -
Show More
@@ -18,23 +18,25 b' body {'
18 }
18 }
19
19
20 span#save_widget {
20 span#save_widget {
21 padding: 2px 0px;
21 padding: 5px;
22 margin: 0px 0px 0px 300px;
22 margin: 0px 0px 0px 300px;
23 display:inline-block;
23 display:inline-block;
24 }
24 }
25
25
26 span#notebook_name {
27 height: 1em;
28 line-height: 1em;
29 padding: 3px;
30 border: none;
31 font-size: 146.5%;
32 }
33
26 span#quick_help_area {
34 span#quick_help_area {
27 position: static;
35 position: static;
28 padding: 5px 0px;
36 padding: 5px 0px;
29 margin: 0px 0px 0px 0px;
37 margin: 0px 0px 0px 0px;
30 }
38 }
31
39
32 input#notebook_name {
33 height: 1em;
34 line-height: 1em;
35 padding: 5px;
36 }
37
38 span#kernel_status {
40 span#kernel_status {
39 position: absolute;
41 position: absolute;
40 padding: 8px 5px 5px 5px;
42 padding: 8px 5px 5px 5px;
@@ -245,7 +247,7 b' div.text_cell_render {'
245 .ansigrey {color: grey;}
247 .ansigrey {color: grey;}
246 .ansibold {font-weight: bold;}
248 .ansibold {font-weight: bold;}
247
249
248 .completions , .tooltip{
250 .completions , .tooltip {
249 position: absolute;
251 position: absolute;
250 z-index: 10;
252 z-index: 10;
251 overflow: auto;
253 overflow: auto;
@@ -52,6 +52,9 b' var IPython = (function (IPython) {'
52 this.element.find('#open_notebook').click(function () {
52 this.element.find('#open_notebook').click(function () {
53 window.open($('body').data('baseProjectUrl'));
53 window.open($('body').data('baseProjectUrl'));
54 });
54 });
55 this.element.find('#rename_notebook').click(function () {
56 IPython.save_widget.rename_notebook();
57 });
55 this.element.find('#save_notebook').click(function () {
58 this.element.find('#save_notebook').click(function () {
56 IPython.save_widget.save_notebook();
59 IPython.save_widget.save_notebook();
57 });
60 });
@@ -26,20 +26,20 b' var IPython = (function (IPython) {'
26
26
27
27
28 SaveWidget.prototype.style = function () {
28 SaveWidget.prototype.style = function () {
29 this.element.find('input#notebook_name').addClass('ui-widget ui-widget-content');
29 this.element.find('span#save_widget').addClass('ui-widget');
30 this.element.find('input#notebook_name').attr('tabindex','1');
30 this.element.find('span#notebook_name').addClass('ui-widget ui-widget-content');
31 this.element.find('button#save_notebook').button();
32 this.element.find('button#save_notebook').attr('title', 'Save the Notebook');
33 };
31 };
34
32
35
33
36 SaveWidget.prototype.bind_events = function () {
34 SaveWidget.prototype.bind_events = function () {
37 var that = this;
35 var that = this;
38 this.element.find('button#save_notebook').click(function () {
36 this.element.find('span#notebook_name').click(function () {
39 that.save_notebook();
37 that.rename_notebook();
40 });
38 });
41 this.element.find('input#notebook_name').keyup(function () {
39 this.element.find('span#notebook_name').hover(function () {
42 that.is_renaming();
40 $(this).addClass("ui-state-hover");
41 }, function () {
42 $(this).removeClass("ui-state-hover");
43 });
43 });
44 };
44 };
45
45
@@ -49,28 +49,59 b' var IPython = (function (IPython) {'
49 };
49 };
50
50
51
51
52 SaveWidget.prototype.rename_notebook = function () {
53 var that = this;
54 var dialog = $('<div/>');
55 dialog.append(
56 $('<h3/>').html('Enter a new notebook name:')
57 .css({'margin-bottom': '10px'})
58 );
59 dialog.append(
60 $('<input/>').attr('type','text')
61 .attr('value',this.get_notebook_name()).wijtextbox()
62 );
63 $(document).append(dialog);
64 dialog.dialog({
65 resizable: false,
66 modal: true,
67 title: "Rename Notebook",
68 closeText: "",
69 buttons : {
70 "OK": function () {
71 var new_name = $(this).find('input').attr('value');
72 if (!that.test_notebook_name(new_name)) {
73 $(this).find('h3').html(
74 "Invalid notebook name. " +
75 "Notebook names can contain any characters " +
76 "except / and \\. Please enter a new notebook name:"
77 );
78 } else {
79 that.set_notebook_name(new_name);
80 that.save_notebook();
81 $(this).dialog('close');
82 }
83 },
84 "Cancel": function () {
85 $(this).dialog('close');
86 }
87 }
88 });
89 }
90
91
52 SaveWidget.prototype.notebook_saved = function () {
92 SaveWidget.prototype.notebook_saved = function () {
53 this.set_document_title();
93 this.set_document_title();
54 this.last_saved_name = this.get_notebook_name();
94 this.last_saved_name = this.get_notebook_name();
55 };
95 };
56
96
57
97
58 SaveWidget.prototype.is_renaming = function () {
59 if (this.get_notebook_name() !== this.last_saved_name) {
60 this.status_rename();
61 } else {
62 this.status_save();
63 };
64 };
65
66
67 SaveWidget.prototype.get_notebook_name = function () {
98 SaveWidget.prototype.get_notebook_name = function () {
68 return this.element.find('input#notebook_name').attr('value');
99 return this.element.find('span#notebook_name').html();
69 };
100 };
70
101
71
102
72 SaveWidget.prototype.set_notebook_name = function (nbname) {
103 SaveWidget.prototype.set_notebook_name = function (nbname) {
73 this.element.find('input#notebook_name').attr('value',nbname);
104 this.element.find('span#notebook_name').html(nbname);
74 this.set_document_title();
105 this.set_document_title();
75 this.last_saved_name = nbname;
106 this.last_saved_name = nbname;
76 };
107 };
@@ -95,18 +126,10 b' var IPython = (function (IPython) {'
95 };
126 };
96
127
97
128
98 SaveWidget.prototype.test_notebook_name = function () {
129 SaveWidget.prototype.test_notebook_name = function (nbname) {
99 var nbname = this.get_notebook_name();
100 if (this.notebook_name_blacklist_re.test(nbname) == false) {
130 if (this.notebook_name_blacklist_re.test(nbname) == false) {
101 return true;
131 return true;
102 } else {
132 } else {
103 var bad_name = $('<div/>');
104 bad_name.html(
105 "The notebook name you entered (" +
106 nbname +
107 ") is not valid. Notebook names can contain any characters except / and \\."
108 );
109 bad_name.dialog({title: 'Invalid name', modal: true});
110 return false;
133 return false;
111 };
134 };
112 };
135 };
@@ -118,26 +141,18 b' var IPython = (function (IPython) {'
118
141
119
142
120 SaveWidget.prototype.status_save = function () {
143 SaveWidget.prototype.status_save = function () {
121 this.element.find('button#save_notebook').button('option', 'label', '<u>S</u>ave');
122 this.element.find('button#save_notebook').button('enable');
123 };
144 };
124
145
125
146
126 SaveWidget.prototype.status_saving = function () {
147 SaveWidget.prototype.status_saving = function () {
127 this.element.find('button#save_notebook').button('option', 'label', 'Saving');
128 this.element.find('button#save_notebook').button('disable');
129 };
148 };
130
149
131
150
132 SaveWidget.prototype.status_loading = function () {
151 SaveWidget.prototype.status_loading = function () {
133 this.element.find('button#save_notebook').button('option', 'label', 'Loading');
152 };
134 this.element.find('button#save_notebook').button('disable');
135 };
136
153
137
154
138 SaveWidget.prototype.status_rename = function () {
155 SaveWidget.prototype.status_rename = function () {
139 this.element.find('button#save_notebook').button('option', 'label', 'Rename');
140 this.element.find('button#save_notebook').button('enable');
141 };
156 };
142
157
143
158
@@ -45,8 +45,7 b''
45 <div id="header">
45 <div id="header">
46 <span id="ipython_notebook"><h1><a href='..' alt='dashboard'><img src='/static/ipynblogo.png' alt='IPython Notebook'/></a></h1></span>
46 <span id="ipython_notebook"><h1><a href='..' alt='dashboard'><img src='/static/ipynblogo.png' alt='IPython Notebook'/></a></h1></span>
47 <span id="save_widget">
47 <span id="save_widget">
48 <input type="text" id="notebook_name" size="20"></textarea>
48 <span id="notebook_name"></span>
49 <button id="save_notebook"><u>S</u>ave</button>
50 </span>
49 </span>
51
50
52 <span id="login_widget">
51 <span id="login_widget">
@@ -67,8 +66,9 b''
67 <li><a href="#">File</a>
66 <li><a href="#">File</a>
68 <ul>
67 <ul>
69 <li id="new_notebook"><span class="wijmo-wijmenu-text">New</span></li>
68 <li id="new_notebook"><span class="wijmo-wijmenu-text">New</span></li>
70 <li id="open_notebook"><span class="wijmo-wijmenu-text">Open</span></li>
69 <li id="open_notebook"><span class="wijmo-wijmenu-text">Open...</span></li>
71 <li></li>
70 <li></li>
71 <li id="rename_notebook"><span class="wijmo-wijmenu-text">Rename...</span></li>
72 <li id="save_notebook">
72 <li id="save_notebook">
73 <div>
73 <div>
74 <span class="wijmo-wijmenu-text">Save</span>
74 <span class="wijmo-wijmenu-text">Save</span>
General Comments 0
You need to be logged in to leave comments. Login now