##// END OF EJS Templates
fix upload button selection by class...
Matthias BUSSONNIER -
Show More
@@ -1,82 +1,82 b''
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.page = new IPython.Page();
15 IPython.page = new IPython.Page();
16
16
17 $('div#tabs').tabs();
17 $('div#tabs').tabs();
18 $('div#tabs').on('tabsselect', function (event, ui) {
18 $('div#tabs').on('tabsselect', function (event, ui) {
19 var new_url = $('body').data('baseProjectUrl') + '#' + ui.panel.id;
19 var new_url = $('body').data('baseProjectUrl') + '#' + ui.panel.id;
20 window.history.replaceState({}, '', new_url);
20 window.history.replaceState({}, '', new_url);
21 });
21 });
22 $('div#main_app').addClass('border-box-sizing ui-widget');
22 $('div#main_app').addClass('border-box-sizing ui-widget');
23 $('div#notebooks_toolbar').addClass('ui-widget ui-helper-clearfix');
23 $('div#notebooks_toolbar').addClass('ui-widget ui-helper-clearfix');
24 $('#new_notebook').button().click(function (e) {
24 $('#new_notebook').button().click(function (e) {
25 window.open($('body').data('baseProjectUrl')+'new');
25 window.open($('body').data('baseProjectUrl')+'new');
26 });
26 });
27
27
28 IPython.read_only = $('body').data('readOnly') === 'True';
28 IPython.read_only = $('body').data('readOnly') === 'True';
29 IPython.notebook_list = new IPython.NotebookList('div#notebook_list');
29 IPython.notebook_list = new IPython.NotebookList('div#notebook_list');
30 IPython.cluster_list = new IPython.ClusterList('div#cluster_list');
30 IPython.cluster_list = new IPython.ClusterList('div#cluster_list');
31 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
31 IPython.login_widget = new IPython.LoginWidget('span#login_widget');
32
32
33 var interval_id=0;
33 var interval_id=0;
34 // auto refresh every xx secondes, no need to be fast,
34 // auto refresh every xx secondes, no need to be fast,
35 // update is done at least when page get focus
35 // update is done at least when page get focus
36 var time_refresh = 60; // in sec
36 var time_refresh = 60; // in sec
37
37
38 var enable_autorefresh = function(){
38 var enable_autorefresh = function(){
39 //refresh immediately , then start interval
39 //refresh immediately , then start interval
40 if($('upload_button').length == 0)
40 if($('.upload_button').length == 0)
41 {
41 {
42 IPython.notebook_list.load_list();
42 IPython.notebook_list.load_list();
43 IPython.cluster_list.load_list();
43 IPython.cluster_list.load_list();
44 }
44 }
45 if (!interval_id){
45 if (!interval_id){
46 interval_id = setInterval(function(){
46 interval_id = setInterval(function(){
47 if($('upload_button').length == 0)
47 if($('.upload_button').length == 0)
48 {
48 {
49 IPython.notebook_list.load_list();
49 IPython.notebook_list.load_list();
50 IPython.cluster_list.load_list();
50 IPython.cluster_list.load_list();
51 }
51 }
52 }, time_refresh*1000);
52 }, time_refresh*1000);
53 }
53 }
54 }
54 }
55
55
56 var disable_autorefresh = function(){
56 var disable_autorefresh = function(){
57 clearInterval(interval_id);
57 clearInterval(interval_id);
58 interval_id = 0;
58 interval_id = 0;
59 }
59 }
60
60
61 // stop autorefresh when page lose focus
61 // stop autorefresh when page lose focus
62 $(window).blur(function() {
62 $(window).blur(function() {
63 disable_autorefresh();
63 disable_autorefresh();
64 })
64 })
65
65
66 //re-enable when page get focus back
66 //re-enable when page get focus back
67 $(window).focus(function() {
67 $(window).focus(function() {
68 enable_autorefresh();
68 enable_autorefresh();
69 });
69 });
70
70
71 // finally start it, it will refresh immediately
71 // finally start it, it will refresh immediately
72 enable_autorefresh();
72 enable_autorefresh();
73
73
74 IPython.page.show();
74 IPython.page.show();
75
75
76 // bound the upload method to the on change of the file select list
76 // bound the upload method to the on change of the file select list
77 $("#alternate_upload").change(function (event){
77 $("#alternate_upload").change(function (event){
78 IPython.notebook_list.handelFilesUpload(event,'form');
78 IPython.notebook_list.handelFilesUpload(event,'form');
79 });
79 });
80
80
81 });
81 });
82
82
General Comments 0
You need to be logged in to leave comments. Login now