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