##// END OF EJS Templates
remove update_url occurences
Matthias BUSSONNIER -
Show More
@@ -1,68 +1,67
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // On document ready
9 // On document ready
10 //============================================================================
10 //============================================================================
11
11
12
12
13 $(document).ready(function () {
13 $(document).ready(function () {
14
14
15 IPython.init_mathjax();
15 IPython.init_mathjax();
16
16
17 IPython.read_only = $('body').data('readOnly') === 'True';
17 IPython.read_only = $('body').data('readOnly') === 'True';
18 $('div#main_app').addClass('border-box-sizing ui-widget');
18 $('div#main_app').addClass('border-box-sizing ui-widget');
19 $('div#notebook_panel').addClass('border-box-sizing ui-widget');
19 $('div#notebook_panel').addClass('border-box-sizing ui-widget');
20 // The header's bottom border is provided by the menu bar so we remove it.
20 // The header's bottom border is provided by the menu bar so we remove it.
21 $('div#header').css('border-bottom-style','none');
21 $('div#header').css('border-bottom-style','none');
22
22
23 IPython.page = new IPython.Page();
23 IPython.page = new IPython.Page();
24 IPython.markdown_converter = new Markdown.Converter();
24 IPython.markdown_converter = new Markdown.Converter();
25 IPython.layout_manager = new IPython.LayoutManager();
25 IPython.layout_manager = new IPython.LayoutManager();
26 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
26 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
27 IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
27 IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
28 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
28 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
29 IPython.notebook = new IPython.Notebook('div#notebook');
29 IPython.notebook = new IPython.Notebook('div#notebook');
30 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
30 IPython.save_widget = new IPython.SaveWidget('span#save_widget');
31 IPython.menubar = new IPython.MenuBar('#menubar')
31 IPython.menubar = new IPython.MenuBar('#menubar')
32 IPython.toolbar = new IPython.ToolBar('#toolbar')
32 IPython.toolbar = new IPython.ToolBar('#toolbar')
33 IPython.tooltip = new IPython.Tooltip()
33 IPython.tooltip = new IPython.Tooltip()
34 IPython.notification_widget = new IPython.NotificationWidget('#notification')
34 IPython.notification_widget = new IPython.NotificationWidget('#notification')
35
35
36 IPython.layout_manager.do_resize();
36 IPython.layout_manager.do_resize();
37
37
38 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
38 $('body').append('<div id="fonttest"><pre><span id="test1">x</span>'+
39 '<span id="test2" style="font-weight: bold;">x</span>'+
39 '<span id="test2" style="font-weight: bold;">x</span>'+
40 '<span id="test3" style="font-style: italic;">x</span></pre></div>')
40 '<span id="test3" style="font-style: italic;">x</span></pre></div>')
41 var nh = $('#test1').innerHeight();
41 var nh = $('#test1').innerHeight();
42 var bh = $('#test2').innerHeight();
42 var bh = $('#test2').innerHeight();
43 var ih = $('#test3').innerHeight();
43 var ih = $('#test3').innerHeight();
44 if(nh != bh || nh != ih) {
44 if(nh != bh || nh != ih) {
45 $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>');
45 $('head').append('<style>.CodeMirror span { vertical-align: bottom; }</style>');
46 }
46 }
47 $('#fonttest').remove();
47 $('#fonttest').remove();
48
48
49 if(IPython.read_only){
49 if(IPython.read_only){
50 // hide various elements from read-only view
50 // hide various elements from read-only view
51 $('div#pager').remove();
51 $('div#pager').remove();
52 $('div#pager_splitter').remove();
52 $('div#pager_splitter').remove();
53
53
54 // set the notebook name field as not modifiable
54 // set the notebook name field as not modifiable
55 $('#notebook_name').attr('disabled','disabled')
55 $('#notebook_name').attr('disabled','disabled')
56 }
56 }
57
57
58 IPython.page.show();
58 IPython.page.show();
59
59
60 IPython.layout_manager.do_resize();
60 IPython.layout_manager.do_resize();
61 $([IPython.events]).on('notebook_loaded.Notebook', function () {
61 $([IPython.events]).on('notebook_loaded.Notebook', function () {
62 IPython.layout_manager.do_resize();
62 IPython.layout_manager.do_resize();
63 IPython.save_widget.update_url();
64 })
63 })
65 IPython.notebook.load_notebook($('body').data('notebookId'));
64 IPython.notebook.load_notebook($('body').data('notebookId'));
66
65
67 });
66 });
68
67
@@ -1,148 +1,139
1 //----------------------------------------------------------------------------
1 //----------------------------------------------------------------------------
2 // Copyright (C) 2008-2011 The IPython Development Team
2 // Copyright (C) 2008-2011 The IPython Development Team
3 //
3 //
4 // Distributed under the terms of the BSD License. The full license is in
4 // Distributed under the terms of the BSD License. The full license is in
5 // the file COPYING, distributed as part of this software.
5 // the file COPYING, distributed as part of this software.
6 //----------------------------------------------------------------------------
6 //----------------------------------------------------------------------------
7
7
8 //============================================================================
8 //============================================================================
9 // SaveWidget
9 // SaveWidget
10 //============================================================================
10 //============================================================================
11
11
12 var IPython = (function (IPython) {
12 var IPython = (function (IPython) {
13
13
14 var utils = IPython.utils;
14 var utils = IPython.utils;
15
15
16 var SaveWidget = function (selector) {
16 var SaveWidget = function (selector) {
17 this.selector = selector;
17 this.selector = selector;
18 if (this.selector !== undefined) {
18 if (this.selector !== undefined) {
19 this.element = $(selector);
19 this.element = $(selector);
20 this.style();
20 this.style();
21 this.bind_events();
21 this.bind_events();
22 }
22 }
23 };
23 };
24
24
25
25
26 SaveWidget.prototype.style = function () {
26 SaveWidget.prototype.style = function () {
27 this.element.find('span#save_widget').addClass('ui-widget');
27 this.element.find('span#save_widget').addClass('ui-widget');
28 this.element.find('span#notebook_name').addClass('ui-widget ui-widget-content');
28 this.element.find('span#notebook_name').addClass('ui-widget ui-widget-content');
29 this.element.find('span#save_status').addClass('ui-widget ui-widget-content')
29 this.element.find('span#save_status').addClass('ui-widget ui-widget-content')
30 .css({border: 'none', 'margin-left': '20px'});
30 .css({border: 'none', 'margin-left': '20px'});
31 };
31 };
32
32
33
33
34 SaveWidget.prototype.bind_events = function () {
34 SaveWidget.prototype.bind_events = function () {
35 var that = this;
35 var that = this;
36 this.element.find('span#notebook_name').click(function () {
36 this.element.find('span#notebook_name').click(function () {
37 that.rename_notebook();
37 that.rename_notebook();
38 });
38 });
39 this.element.find('span#notebook_name').hover(function () {
39 this.element.find('span#notebook_name').hover(function () {
40 $(this).addClass("ui-state-hover");
40 $(this).addClass("ui-state-hover");
41 }, function () {
41 }, function () {
42 $(this).removeClass("ui-state-hover");
42 $(this).removeClass("ui-state-hover");
43 });
43 });
44 $([IPython.events]).on('notebook_loaded.Notebook', function () {
44 $([IPython.events]).on('notebook_loaded.Notebook', function () {
45 that.set_last_saved();
45 that.set_last_saved();
46 that.update_notebook_name();
46 that.update_notebook_name();
47 that.update_document_title();
47 that.update_document_title();
48 });
48 });
49 $([IPython.events]).on('notebook_saved.Notebook', function () {
49 $([IPython.events]).on('notebook_saved.Notebook', function () {
50 that.set_last_saved();
50 that.set_last_saved();
51 that.update_notebook_name();
51 that.update_notebook_name();
52 that.update_document_title();
52 that.update_document_title();
53 });
53 });
54 $([IPython.events]).on('notebook_save_failed.Notebook', function () {
54 $([IPython.events]).on('notebook_save_failed.Notebook', function () {
55 that.set_save_status('Last Save Failed!');
55 that.set_save_status('Last Save Failed!');
56 });
56 });
57 };
57 };
58
58
59
59
60 SaveWidget.prototype.rename_notebook = function () {
60 SaveWidget.prototype.rename_notebook = function () {
61 var that = this;
61 var that = this;
62 var dialog = $('<div/>');
62 var dialog = $('<div/>');
63 dialog.append(
63 dialog.append(
64 $('<h3/>').html('Enter a new notebook name:')
64 $('<h3/>').html('Enter a new notebook name:')
65 .css({'margin-bottom': '10px'})
65 .css({'margin-bottom': '10px'})
66 );
66 );
67 dialog.append(
67 dialog.append(
68 $('<input/>').attr('type','text').attr('size','25')
68 $('<input/>').attr('type','text').attr('size','25')
69 .addClass('ui-widget ui-widget-content')
69 .addClass('ui-widget ui-widget-content')
70 .attr('value',IPython.notebook.get_notebook_name())
70 .attr('value',IPython.notebook.get_notebook_name())
71 );
71 );
72 // $(document).append(dialog);
72 // $(document).append(dialog);
73 dialog.dialog({
73 dialog.dialog({
74 resizable: false,
74 resizable: false,
75 modal: true,
75 modal: true,
76 title: "Rename Notebook",
76 title: "Rename Notebook",
77 closeText: "",
77 closeText: "",
78 close: function(event, ui) {$(this).dialog('destroy').remove();},
78 close: function(event, ui) {$(this).dialog('destroy').remove();},
79 buttons : {
79 buttons : {
80 "OK": function () {
80 "OK": function () {
81 var new_name = $(this).find('input').attr('value');
81 var new_name = $(this).find('input').attr('value');
82 if (!IPython.notebook.test_notebook_name(new_name)) {
82 if (!IPython.notebook.test_notebook_name(new_name)) {
83 $(this).find('h3').html(
83 $(this).find('h3').html(
84 "Invalid notebook name. Notebook names must "+
84 "Invalid notebook name. Notebook names must "+
85 "have 1 or more characters and can contain any characters " +
85 "have 1 or more characters and can contain any characters " +
86 "except :/\\. Please enter a new notebook name:"
86 "except :/\\. Please enter a new notebook name:"
87 );
87 );
88 } else {
88 } else {
89 IPython.notebook.set_notebook_name(new_name);
89 IPython.notebook.set_notebook_name(new_name);
90 IPython.notebook.save_notebook();
90 IPython.notebook.save_notebook();
91 $(this).dialog('close');
91 $(this).dialog('close');
92 }
92 }
93 },
93 },
94 "Cancel": function () {
94 "Cancel": function () {
95 $(this).dialog('close');
95 $(this).dialog('close');
96 }
96 }
97 },
97 },
98 open : function (event, ui) {
98 open : function (event, ui) {
99 var that = $(this);
99 var that = $(this);
100 // Upon ENTER, click the OK button.
100 // Upon ENTER, click the OK button.
101 that.find('input[type="text"]').keydown(function (event, ui) {
101 that.find('input[type="text"]').keydown(function (event, ui) {
102 if (event.which === utils.keycodes.ENTER) {
102 if (event.which === utils.keycodes.ENTER) {
103 that.parent().find('button').first().click();
103 that.parent().find('button').first().click();
104 }
104 }
105 });
105 });
106 }
106 }
107 });
107 });
108 }
108 }
109
109
110
110
111 SaveWidget.prototype.update_notebook_name = function () {
111 SaveWidget.prototype.update_notebook_name = function () {
112 var nbname = IPython.notebook.get_notebook_name();
112 var nbname = IPython.notebook.get_notebook_name();
113 this.element.find('span#notebook_name').html(nbname);
113 this.element.find('span#notebook_name').html(nbname);
114 };
114 };
115
115
116
116
117 SaveWidget.prototype.update_document_title = function () {
117 SaveWidget.prototype.update_document_title = function () {
118 var nbname = IPython.notebook.get_notebook_name();
118 var nbname = IPython.notebook.get_notebook_name();
119 document.title = nbname;
119 document.title = nbname;
120 };
120 };
121
121
122
122
123 SaveWidget.prototype.update_url = function () {
124 var notebook_id = IPython.notebook.get_notebook_id();
125 if (notebook_id !== null) {
126 var new_url = $('body').data('baseProjectUrl') + notebook_id;
127 window.history.replaceState({}, '', new_url);
128 };
129 };
130
131
132 SaveWidget.prototype.set_save_status = function (msg) {
123 SaveWidget.prototype.set_save_status = function (msg) {
133 this.element.find('span#save_status').html(msg);
124 this.element.find('span#save_status').html(msg);
134 }
125 }
135
126
136
127
137 SaveWidget.prototype.set_last_saved = function () {
128 SaveWidget.prototype.set_last_saved = function () {
138 var d = new Date();
129 var d = new Date();
139 this.set_save_status('Last saved: '+d.format('mmm dd h:MM TT'));
130 this.set_save_status('Last saved: '+d.format('mmm dd h:MM TT'));
140 };
131 };
141
132
142
133
143 IPython.SaveWidget = SaveWidget;
134 IPython.SaveWidget = SaveWidget;
144
135
145 return IPython;
136 return IPython;
146
137
147 }(IPython));
138 }(IPython));
148
139
General Comments 0
You need to be logged in to leave comments. Login now