##// END OF EJS Templates
Animated arrow icon
Jonathan Frederic -
Show More
@@ -1,55 +1,85 b''
1 // Copyright (c) IPython Development Team.
1 // Copyright (c) IPython Development Team.
2 // Distributed under the terms of the Modified BSD License.
2 // Distributed under the terms of the Modified BSD License.
3
3
4 define([
4 define([
5 'base/js/namespace',
5 'base/js/namespace',
6 'jquery',
6 'jquery',
7 'base/js/utils',
7 'base/js/utils',
8 ], function(IPython, $, utils) {
8 ], function(IPython, $, utils) {
9 "use strict";
9 "use strict";
10
10
11 var SesssionList = function (options) {
11 var SesssionList = function (options) {
12 /**
12 /**
13 * Constructor
13 * Constructor
14 *
14 *
15 * Parameters:
15 * Parameters:
16 * options: dictionary
16 * options: dictionary
17 * Dictionary of keyword arguments.
17 * Dictionary of keyword arguments.
18 * events: $(Events) instance
18 * events: $(Events) instance
19 * base_url : string
19 * base_url : string
20 */
20 */
21 this.events = options.events;
21 this.events = options.events;
22 this.sessions = {};
22 this.sessions = {};
23 this.base_url = options.base_url || utils.get_body_data("baseUrl");
23 this.base_url = options.base_url || utils.get_body_data("baseUrl");
24
25 // Add collapse arrows.
26 $('#running .panel-group .panel .panel-heading a').each(function(index, el) {
27 var $link = $(el);
28 var $icon = $('<i />')
29 .addClass('fa fa-caret-down');
30 $link.append($icon);
31 $link.down = true;
32 $link.click(function () {
33 if ($link.down) {
34 $link.down = false;
35 // jQeury doesn't know how to animate rotations. Abuse
36 // jQueries animate function by using an unused css attribute
37 // to do the animation (borderSpacing).
38 $icon.animate({ borderSpacing: 90 }, {
39 step: function(now,fx) {
40 $icon.css('transform','rotate(-' + now + 'deg)');
41 }
42 }, 250);
43 } else {
44 $link.down = true;
45 // See comment above.
46 $icon.animate({ borderSpacing: 0 }, {
47 step: function(now,fx) {
48 $icon.css('transform','rotate(-' + now + 'deg)');
49 }
50 }, 250);
51 }
52 });
53 });
24 };
54 };
25
55
26 SesssionList.prototype.load_sessions = function(){
56 SesssionList.prototype.load_sessions = function(){
27 var that = this;
57 var that = this;
28 var settings = {
58 var settings = {
29 processData : false,
59 processData : false,
30 cache : false,
60 cache : false,
31 type : "GET",
61 type : "GET",
32 dataType : "json",
62 dataType : "json",
33 success : $.proxy(that.sessions_loaded, this),
63 success : $.proxy(that.sessions_loaded, this),
34 error : utils.log_ajax_error,
64 error : utils.log_ajax_error,
35 };
65 };
36 var url = utils.url_join_encode(this.base_url, 'api/sessions');
66 var url = utils.url_join_encode(this.base_url, 'api/sessions');
37 $.ajax(url, settings);
67 $.ajax(url, settings);
38 };
68 };
39
69
40 SesssionList.prototype.sessions_loaded = function(data){
70 SesssionList.prototype.sessions_loaded = function(data){
41 this.sessions = {};
71 this.sessions = {};
42 var len = data.length;
72 var len = data.length;
43 var nb_path;
73 var nb_path;
44 for (var i=0; i<len; i++) {
74 for (var i=0; i<len; i++) {
45 nb_path = data[i].notebook.path;
75 nb_path = data[i].notebook.path;
46 this.sessions[nb_path] = data[i].id;
76 this.sessions[nb_path] = data[i].id;
47 }
77 }
48 this.events.trigger('sessions_loaded.Dashboard', this.sessions);
78 this.events.trigger('sessions_loaded.Dashboard', this.sessions);
49 };
79 };
50
80
51 // Backwards compatability.
81 // Backwards compatability.
52 IPython.SesssionList = SesssionList;
82 IPython.SesssionList = SesssionList;
53
83
54 return {'SesssionList': SesssionList};
84 return {'SesssionList': SesssionList};
55 });
85 });
General Comments 0
You need to be logged in to leave comments. Login now