rbbt-rest 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/config.ru +3 -0
- data/lib/rbbt/rest/client.rb +9 -10
- data/lib/rbbt/rest/common/cache.rb +32 -7
- data/lib/rbbt/rest/common/forms.rb +33 -0
- data/lib/rbbt/rest/common/locate.rb +4 -0
- data/lib/rbbt/rest/common/misc.rb +24 -0
- data/lib/rbbt/rest/common/render.rb +26 -9
- data/lib/rbbt/rest/common/resources.rb +1 -1
- data/lib/rbbt/rest/common/table.rb +87 -26
- data/lib/rbbt/rest/common/users.rb +5 -1
- data/lib/rbbt/rest/entity.rb +300 -95
- data/lib/rbbt/rest/entity/action_controller.rb +6 -1
- data/lib/rbbt/rest/entity/entity_list_card.rb +1 -1
- data/lib/rbbt/rest/entity/entity_map_card.rb +15 -0
- data/lib/rbbt/rest/entity/favourites.rb +57 -1
- data/lib/rbbt/rest/entity/finder.rb +1 -1
- data/lib/rbbt/rest/entity/helpers.rb +40 -7
- data/lib/rbbt/rest/entity/list.rb +8 -0
- data/lib/rbbt/rest/entity/locate.rb +114 -0
- data/lib/rbbt/rest/entity/map.rb +99 -0
- data/lib/rbbt/rest/entity/render.rb +25 -0
- data/lib/rbbt/rest/entity/rest.rb +33 -4
- data/lib/rbbt/rest/main.rb +27 -4
- data/lib/rbbt/rest/workflow.rb +7 -1
- data/lib/rbbt/rest/workflow/jobs.rb +21 -1
- data/share/views/compass/app.sass +17 -9
- data/share/views/compass/entity_card.sass +16 -3
- data/share/views/compass/favourites.sass +44 -2
- data/share/views/compass/form.sass +11 -0
- data/share/views/compass/list_container.sass +1 -1
- data/share/views/compass/reveal.sass +31 -0
- data/share/views/compass/style.sass +29 -1
- data/share/views/compass/style_mixins.sass +18 -6
- data/share/views/compass/table.sass +19 -3
- data/share/views/compass/topbar.sass +8 -2
- data/share/views/entity_map/Default.haml +5 -0
- data/share/views/entity_partials/action_card.haml +2 -0
- data/share/views/entity_partials/action_controller.haml +8 -1
- data/share/views/entity_partials/entity_list_card.haml +8 -6
- data/share/views/entity_partials/entity_map_card.haml +63 -0
- data/share/views/entity_partials/list_container.haml +3 -2
- data/share/views/error.haml +14 -10
- data/share/views/help.haml +34 -0
- data/share/views/help/entity.haml +193 -0
- data/share/views/help/workflow.haml +77 -0
- data/share/views/job_result/tsv.haml +3 -2
- data/share/views/layout.haml +33 -3
- data/share/views/layout/favourites.haml +14 -4
- data/share/views/layout/header.haml +4 -0
- data/share/views/partials/form.haml +3 -1
- data/share/views/partials/table.haml +16 -52
- data/share/views/partials/table/column.haml +10 -0
- data/share/views/partials/table/files.haml +4 -0
- data/share/views/partials/table/filters.haml +11 -0
- data/share/views/partials/table/page.haml +37 -0
- data/share/views/public/favicon.gif +0 -0
- data/share/views/public/js/_ajax_replace.js +76 -4
- data/share/views/public/js/_fix_tablesorter_science.js +13 -0
- data/share/views/public/js/actions.js +8 -2
- data/share/views/public/js/base.js +12 -1
- data/share/views/public/js/entities.js +39 -7
- data/share/views/public/js/favourites.js +308 -77
- data/share/views/public/js/helpers.js +9 -5
- data/share/views/public/js/lists.js +12 -12
- data/share/views/public/js/maps.js +17 -0
- data/share/views/public/js/reveal.js +48 -0
- data/share/views/public/js/tables.js +110 -51
- data/share/views/public/js/workflow.js +4 -16
- data/share/views/public/plugins/underscore/js/underscore.js +1227 -0
- data/share/views/tasks.haml +12 -1
- data/share/views/wait.haml +7 -0
- metadata +17 -2
@@ -23,3 +23,16 @@ $.tablesorter.addParser({
|
|
23
23
|
type: 'text'
|
24
24
|
});
|
25
25
|
|
26
|
+
$.tablesorter.addParser({
|
27
|
+
// set a unique id
|
28
|
+
id: 'percentage',
|
29
|
+
is: function(s) {
|
30
|
+
return /\d+\s*%/.test(s);
|
31
|
+
},
|
32
|
+
format: function(s) {
|
33
|
+
var num = $.tablesorter.formatFloat(s);
|
34
|
+
return num;
|
35
|
+
},
|
36
|
+
type: 'numeric'
|
37
|
+
});
|
38
|
+
|
@@ -10,8 +10,13 @@ function load_action(link){
|
|
10
10
|
if (jqXHR.status == 202){
|
11
11
|
action_controller.removeClass('active');
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
var response = $(jqXHR.responseText)
|
14
|
+
var stat = response.find('span.status').html()
|
15
|
+
var message = response.find('ul.step_messages li:first').html()
|
16
|
+
if (undefined === message){
|
17
|
+
action_div.html("<span class='loading'>Loading [" + stat + "] ...</span>");
|
18
|
+
}else{
|
19
|
+
action_div.html("<span class='loading'>Loading [" + stat + ": " + message + "] ...</span>");
|
15
20
|
}
|
16
21
|
}else{
|
17
22
|
action_controller.addClass('active');
|
@@ -92,6 +97,7 @@ function setup_action(){
|
|
92
97
|
|
93
98
|
var body = $('body');
|
94
99
|
|
100
|
+
body.on('click', '.action_controller > ul.actions li > a.entity_map_action', activate_action)
|
95
101
|
body.on('click', '.action_controller > ul.actions li > a.entity_list_action', activate_action)
|
96
102
|
body.on('click', '.action_controller > ul.actions li > a.entity_action', activate_action)
|
97
103
|
body.on('click', '.action_controller > ul.actions > li.select > a', show_actions)
|
@@ -34,6 +34,7 @@ function setup_page_reload(){
|
|
34
34
|
var body = $('body');
|
35
35
|
body.on('click', 'a#reload_page', function(){
|
36
36
|
var url = window.location.toString();
|
37
|
+
url = url.replace(/#$/, '');
|
37
38
|
|
38
39
|
url = remove_parameter(url, '_update');
|
39
40
|
url = add_parameters(url, '_update=reload');
|
@@ -47,9 +48,11 @@ function setup_page_reload(){
|
|
47
48
|
}
|
48
49
|
|
49
50
|
function setup_fragments(){
|
51
|
+
|
50
52
|
register_dom_update(('a.fragment'), function(link){
|
51
53
|
link.each(function(){replace_link($(this))});
|
52
54
|
})
|
55
|
+
|
53
56
|
register_dom_update(('a.modal_fragment'), function(link){
|
54
57
|
link.click(function(){
|
55
58
|
var modal = $('#modal1')
|
@@ -66,6 +69,13 @@ function deactivate_off_links(){
|
|
66
69
|
body.on('click', 'a.off', function(){return false})
|
67
70
|
}
|
68
71
|
|
72
|
+
$('body').on('click', 'a#permalink', function(){
|
73
|
+
var url = window.location.toString()
|
74
|
+
url = add_parameter(url, '_permalink', 'true')
|
75
|
+
window.location = url
|
76
|
+
return false
|
77
|
+
})
|
78
|
+
|
69
79
|
function setup_finder(){
|
70
80
|
//register_dom_update("#header li.search input", function(elem){
|
71
81
|
// elem.autocomplete({
|
@@ -92,14 +102,15 @@ function fit_content(){
|
|
92
102
|
function update_rbbt(){
|
93
103
|
update_dom();
|
94
104
|
start_defferred();
|
105
|
+
apply_highlights();
|
95
106
|
}
|
96
107
|
|
97
108
|
function setup_rbbt(){
|
98
109
|
setup_fragments();
|
99
110
|
setup_action();
|
100
111
|
setup_page_reload();
|
101
|
-
setup_favourites();
|
102
112
|
deactivate_off_links();
|
113
|
+
update_favourite_entities_star();
|
103
114
|
setup_finder();
|
104
115
|
setup_offcanvas();
|
105
116
|
setup_list_management();
|
@@ -5,6 +5,7 @@ function page_type(path){
|
|
5
5
|
|
6
6
|
if (path.match(/^\/entity\//)){ return "entity"; }
|
7
7
|
if (path.match(/^\/entity_action\//)){ return "entity_action"; }
|
8
|
+
if (path.match(/^\/entity_map\//)){ return "entity_map"; }
|
8
9
|
if (path.match(/^\/entity_list\//)){ return "entity_list"; }
|
9
10
|
if (path.match(/^\/entity_list_action\//)){ return "entity_list_action"; }
|
10
11
|
return undefined;
|
@@ -24,7 +25,7 @@ function page_entity(path){
|
|
24
25
|
function page_entity_list(path){
|
25
26
|
if (undefined === path){ path = window.location.pathname; }
|
26
27
|
|
27
|
-
switch(page_type()){
|
28
|
+
switch(page_type(path)){
|
28
29
|
case "entity_list":
|
29
30
|
return restore_element(path.split("/")[3]);
|
30
31
|
default:
|
@@ -32,28 +33,50 @@ function page_entity_list(path){
|
|
32
33
|
}
|
33
34
|
}
|
34
35
|
|
36
|
+
function page_entity_map(path){
|
37
|
+
if (undefined === path){ path = window.location.pathname; }
|
38
|
+
|
39
|
+
switch(page_type(path)){
|
40
|
+
case "entity_map":
|
41
|
+
return restore_element(path.split("/")[4]);
|
42
|
+
default:
|
43
|
+
return undefined
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
function page_entity_map_column(path){
|
48
|
+
if (undefined === path){ path = window.location.pathname; }
|
49
|
+
|
50
|
+
switch(page_type(path)){
|
51
|
+
case "entity_map":
|
52
|
+
return restore_element(path.split("/")[3]);
|
53
|
+
default:
|
54
|
+
return undefined
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
35
58
|
function page_entity_type(path){
|
36
59
|
if (undefined === path){ path = window.location.pathname; }
|
37
60
|
var entity_type;
|
38
61
|
|
39
|
-
switch(page_type()){
|
62
|
+
switch(page_type(path)){
|
40
63
|
case "entity":
|
41
64
|
case "entity_list":
|
42
65
|
case "entity_action":
|
43
66
|
case "entity_list_action":
|
67
|
+
case "entity_map":
|
44
68
|
return restore_element(path.split("/")[2]);
|
45
69
|
break;
|
46
70
|
}
|
47
71
|
return undefined;
|
48
72
|
}
|
49
73
|
|
50
|
-
function page_entity_base_type(){
|
51
|
-
return page_entity_type().split(":")[0]
|
74
|
+
function page_entity_base_type(path){
|
75
|
+
return page_entity_type(path).split(":")[0]
|
52
76
|
}
|
53
77
|
|
54
|
-
|
55
|
-
|
56
|
-
return page_entity_type().split(":")[1]
|
78
|
+
function page_entity_format(path){
|
79
|
+
return page_entity_type(path).split(":")[1]
|
57
80
|
}
|
58
81
|
|
59
82
|
function page_entity_info(params){
|
@@ -72,4 +95,13 @@ function list_link(type, id){
|
|
72
95
|
return a
|
73
96
|
}
|
74
97
|
|
98
|
+
function map_link(type, column, id){
|
99
|
+
var a = $('<a>' + id +'</a>');
|
100
|
+
var url = "/entity_map/" + clean_element(type) + "/" + clean_element(column) + "/" + clean_element(id)
|
101
|
+
var base_type = type.split(":")[0]
|
102
|
+
|
103
|
+
a.addClass('entity_map').addClass(type).addClass(base_type).attr('href', url).attr('title', id)
|
104
|
+
return a
|
105
|
+
}
|
106
|
+
|
75
107
|
|
@@ -1,91 +1,144 @@
|
|
1
|
-
|
1
|
+
// HELPERS
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
function get_favourite_entities(){
|
4
|
+
//return JSON.parse($.ajax({url: '/favourite_entities', async: false, cache: false}).responseText)
|
5
|
+
return JSON.parse(get_ajax({url: '/favourite_entities', async: false, cache: false}))
|
6
|
+
}
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
var entity_type = page_entity_type();
|
12
|
-
var entity_info = page_entity_info();
|
8
|
+
function get_favourite_entity_lists(){
|
9
|
+
//return JSON.parse($.ajax({url: '/favourite_entity_lists', async: false, cache: false}).responseText)
|
10
|
+
return JSON.parse(get_ajax({url: '/favourite_entity_lists', async: false, cache: false}))
|
11
|
+
}
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
}
|
19
|
-
var url = method + clean_element(entity_type) + "/" + entity;
|
13
|
+
function get_favourite_entity_maps(){
|
14
|
+
//return JSON.parse($.ajax({url: '/favourite_entity_maps', async: false, cache: false}).responseText)
|
15
|
+
return JSON.parse(get_ajax({url: '/favourite_entity_maps', async: false, cache: false}))
|
16
|
+
}
|
20
17
|
|
21
|
-
|
18
|
+
function toggle_favourite(link){
|
19
|
+
var link = $(link);
|
20
|
+
var path;
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
if (link.parents('.reveal-modal').length == 0){
|
23
|
+
path = undefined;
|
24
|
+
}else{
|
25
|
+
path = link.closest('.reveal-modal').find('.embedded').first().attr('target-href');
|
26
|
+
}
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
var type = page_type(path);
|
29
|
+
switch(type){
|
30
|
+
case "entity":
|
31
|
+
var entity = page_entity(path);
|
32
|
+
var entity_type = page_entity_type(path);
|
33
|
+
var entity_info = page_entity_info(path);
|
34
34
|
|
35
|
-
|
35
|
+
if (link.hasClass('active')){
|
36
|
+
method = "/remove_favourite_entity/";
|
37
|
+
}else{
|
38
|
+
method = "/add_favourite_entity/";
|
39
|
+
}
|
40
|
+
var url = method + clean_element(entity_type) + "/" + entity;
|
36
41
|
|
37
|
-
|
38
|
-
}
|
39
|
-
})
|
40
|
-
})
|
42
|
+
$.ajax({url: url, type: 'POST', data: entity_info, success: function (){ update_favourite_entities() }})
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
return false
|
45
|
+
case "entity_list":
|
46
|
+
var entity_list = page_entity_list(path);
|
47
|
+
var entity_type = page_entity_type(path);
|
44
48
|
|
45
|
-
|
46
|
-
|
47
|
-
}
|
49
|
+
if (link.hasClass('active')){
|
50
|
+
method = "/remove_favourite_entity_list/";
|
51
|
+
}else{
|
52
|
+
method = "/add_favourite_entity_list/";
|
53
|
+
}
|
54
|
+
var url = method + clean_element(entity_type) + "/" + clean_element(entity_list);
|
48
55
|
|
49
|
-
function
|
50
|
-
|
56
|
+
$.ajax({url: url, type: 'POST', success: function (){ update_favourite_entity_lists() }})
|
57
|
+
|
58
|
+
return false
|
59
|
+
case "entity_map":
|
60
|
+
var entity_map = page_entity_map(path);
|
61
|
+
var entity_type = page_entity_type(path);
|
62
|
+
var entity_column = page_entity_map_column(path);
|
63
|
+
|
64
|
+
if (link.hasClass('active')){
|
65
|
+
method = "/remove_favourite_entity_map/";
|
66
|
+
}else{
|
67
|
+
method = "/add_favourite_entity_map/";
|
68
|
+
}
|
69
|
+
var url = method + clean_element(entity_type) + "/" + clean_element(entity_column) + "/" + clean_element(entity_map);
|
70
|
+
|
71
|
+
$.ajax({url: url, type: 'POST', success: function (){ update_favourite_entity_maps() }})
|
72
|
+
}
|
51
73
|
}
|
52
74
|
|
53
|
-
|
75
|
+
// TOGGLE START
|
76
|
+
|
77
|
+
$('body').on('click', 'a#toggle_favourite, .reveal-modal a.toggle_favourite',function(link){
|
78
|
+
var link = $(this)
|
79
|
+
toggle_favourite(link)
|
80
|
+
update_favourite_entities_star(undefined, link);
|
81
|
+
return false
|
82
|
+
})
|
83
|
+
|
54
84
|
|
55
|
-
|
85
|
+
function update_favourite_entities_star(favourites, link){
|
86
|
+
if (undefined === link){link = $('a#toggle_favourite')}
|
87
|
+
|
88
|
+
var path
|
89
|
+
if (link.parents('.reveal-modal').length == 0){
|
90
|
+
path = undefined;
|
91
|
+
}else{
|
92
|
+
path = link.closest('.reveal-modal').find('.embedded').first().attr('target-href');
|
93
|
+
}
|
94
|
+
|
95
|
+
var type = page_type(path);
|
56
96
|
switch(type){
|
57
97
|
case "entity":
|
98
|
+
if (undefined === favourites){ favourites = get_favourite_entities(path); }
|
58
99
|
|
59
|
-
|
60
|
-
|
61
|
-
var entity = page_entity();
|
62
|
-
var type = page_entity_base_type();
|
100
|
+
var entity = page_entity(path);
|
101
|
+
var type = page_entity_base_type(path);
|
63
102
|
|
64
103
|
if ((favourites[type] != undefined) && (favourites[type][entity] != undefined)){
|
65
|
-
|
104
|
+
link.addClass('active').removeClass('inactive');
|
66
105
|
}else{
|
67
|
-
|
106
|
+
link.removeClass('active').addClass('inactive');
|
68
107
|
}
|
69
|
-
|
70
108
|
break
|
71
|
-
case "entity_list":
|
72
109
|
|
73
|
-
|
110
|
+
case "entity_list":
|
111
|
+
if (undefined === favourites){ favourites = get_favourite_entity_lists(path); }
|
74
112
|
|
75
|
-
var entity_list = page_entity_list();
|
76
|
-
var type = page_entity_base_type();
|
113
|
+
var entity_list = page_entity_list(path);
|
114
|
+
var type = page_entity_base_type(path);
|
77
115
|
|
78
116
|
if ((favourites[type] != undefined) && ($.inArray(entity_list, favourites[type]) != -1 )){
|
79
|
-
|
117
|
+
link.addClass('active').removeClass('inactive');
|
80
118
|
}else{
|
81
|
-
|
119
|
+
link.removeClass('active').addClass('inactive');
|
82
120
|
}
|
121
|
+
break
|
83
122
|
|
123
|
+
case "entity_map":
|
124
|
+
if (undefined === favourites){ favourites = get_favourite_entity_maps(path); }
|
125
|
+
|
126
|
+
var entity_list = page_entity_map(path);
|
127
|
+
var type = page_entity_base_type(path);
|
128
|
+
var column = page_entity_map_column(path);
|
129
|
+
|
130
|
+
if ((favourites[type] != undefined) && (favourites[type][column] != undefined) && ($.inArray(entity_list, favourites[type][column]) != -1 )){
|
131
|
+
link.addClass('active').removeClass('inactive');
|
132
|
+
}else{
|
133
|
+
link.removeClass('active').addClass('inactive');
|
134
|
+
}
|
84
135
|
|
85
136
|
break
|
86
137
|
}
|
87
138
|
}
|
88
139
|
|
140
|
+
//{{{{ FAVOURITE MENUS
|
141
|
+
|
89
142
|
function favourite_type_ul(entities){
|
90
143
|
var type_ul = $('<ul>')
|
91
144
|
for (var entity in entities){
|
@@ -110,6 +163,18 @@ function favourite_list_type_ul(type, lists){
|
|
110
163
|
return type_ul
|
111
164
|
}
|
112
165
|
|
166
|
+
function favourite_map_type_ul(type, column, maps){
|
167
|
+
var type_ul = $('<ul>')
|
168
|
+
for (var map in maps){
|
169
|
+
var map = maps[map];
|
170
|
+
var link = map_link(type, column, map)
|
171
|
+
var entity_li = $('<li>');
|
172
|
+
entity_li.html(link);
|
173
|
+
type_ul.append(entity_li);
|
174
|
+
}
|
175
|
+
return type_ul
|
176
|
+
}
|
177
|
+
|
113
178
|
function update_favourite_entities(favourites){
|
114
179
|
if (undefined === favourites){ favourites = get_favourite_entities(); }
|
115
180
|
|
@@ -119,15 +184,15 @@ function update_favourite_entities(favourites){
|
|
119
184
|
|
120
185
|
for (var type in favourites){
|
121
186
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
187
|
+
var title_li = $('<li class="title back js-generated rbbt-generated"><h5><a href="#">' + type + '</a></h5></li>');
|
188
|
+
var entities = favourites[type];
|
189
|
+
var type_ul = favourite_type_ul(entities);
|
190
|
+
type_ul.addClass("dropdown").prepend(title_li);
|
126
191
|
|
127
|
-
|
128
|
-
|
192
|
+
var type_li = $('<li class="has-dropdown">')
|
193
|
+
type_li.append($('<a href="#">' + type + '</a>')).append(type_ul);
|
129
194
|
|
130
|
-
|
195
|
+
favourites_ul.append(type_li);
|
131
196
|
}
|
132
197
|
|
133
198
|
var current_favourites = $('li#top-favourites ul.favourite_entities')
|
@@ -143,28 +208,56 @@ function update_favourite_entity_lists(favourites){
|
|
143
208
|
favourites_ul.append(title_li);
|
144
209
|
|
145
210
|
for (var type in favourites){
|
211
|
+
var title_li = $('<li class="title back js-generated rbbt-generated"><h5><a href="#">' + type + '</a></h5></li>');
|
212
|
+
var lists = favourites[type];
|
213
|
+
var type_ul = favourite_list_type_ul(type, lists);
|
214
|
+
|
215
|
+
type_ul.addClass("dropdown").prepend(title_li);
|
216
|
+
|
217
|
+
var type_li = $('<li class="has-dropdown">')
|
218
|
+
type_li.append($('<a href="#">' + type + '</a>')).append(type_ul);
|
219
|
+
|
220
|
+
favourites_ul.append(type_li);
|
221
|
+
}
|
222
|
+
|
223
|
+
var current_favourites = $('li#top-favourite_lists ul.favourite_entity_lists')
|
224
|
+
current_favourites.replaceWith(favourites_ul);
|
225
|
+
update_favourite_entities_star(favourites);
|
226
|
+
update_list_selects(favourites);
|
227
|
+
}
|
146
228
|
|
147
|
-
|
148
|
-
|
149
|
-
|
229
|
+
function update_favourite_entity_maps(favourites){
|
230
|
+
if (undefined === favourites){ favourites = get_favourite_entity_maps(); }
|
231
|
+
|
232
|
+
var favourites_ul = $('<ul class="dropdown favourite_entity_maps" >');
|
233
|
+
var title_li = $('<li class="title back js-generated rbbt-generated"><h5><a href="#">Favourite Entities Lists</a></h5></li>');
|
234
|
+
favourites_ul.append(title_li);
|
235
|
+
|
236
|
+
for (var type in favourites){
|
237
|
+
for (var column in favourites[type]){
|
238
|
+
var title_li = $('<li class="title back js-generated rbbt-generated"><h5><a href="#">' + type + ' - ' + column + '</a></h5></li>');
|
239
|
+
var lists = favourites[type][column];
|
240
|
+
var type_ul = favourite_map_type_ul(type, column, lists);
|
150
241
|
|
151
242
|
type_ul.addClass("dropdown").prepend(title_li);
|
152
243
|
|
153
244
|
var type_li = $('<li class="has-dropdown">')
|
154
|
-
type_li.append($('<a href="#">' + type + '</a>')).append(type_ul);
|
245
|
+
type_li.append($('<a href="#">' + type + ' - ' + column + '</a>')).append(type_ul);
|
155
246
|
|
156
247
|
favourites_ul.append(type_li);
|
248
|
+
}
|
249
|
+
|
157
250
|
}
|
158
251
|
|
159
|
-
var current_favourites = $('li#top-
|
252
|
+
var current_favourites = $('li#top-favourite_maps ul.favourite_entity_maps')
|
160
253
|
current_favourites.replaceWith(favourites_ul);
|
161
254
|
update_favourite_entities_star(favourites);
|
162
|
-
|
255
|
+
update_map_selects(favourites);
|
163
256
|
}
|
164
257
|
|
165
|
-
|
166
|
-
select.find('option[class*=automatic_load]').remove();
|
258
|
+
//{{{{ LIST SELECTS
|
167
259
|
|
260
|
+
function update_list_select(select, type, lists){
|
168
261
|
if (select.attr('attr-allow-empty') == 'true'){
|
169
262
|
var option = $('<option value="none" class="loaded">none</option>')
|
170
263
|
select.append(option);
|
@@ -180,31 +273,169 @@ function update_select(select, lists){
|
|
180
273
|
var option = null;
|
181
274
|
var name = elems
|
182
275
|
if (selected == null || name != selected){
|
183
|
-
option = $('<option class="automatic_load" value="' + name + '">' + name + '</option>');
|
276
|
+
option = $('<option attr-entity_type="' + type + '" class="automatic_load" value="' + name + '">' + name + '</option>');
|
184
277
|
}else{
|
185
|
-
option = $('<option class="automatic_load" selected=selected value="' + name + '">' + name + '</option>');
|
278
|
+
option = $('<option attr-entity_type="' + type + '" class="automatic_load" selected=selected value="' + name + '">' + name + '</option>');
|
186
279
|
}
|
187
280
|
select.append(option);
|
188
281
|
return true
|
189
282
|
})
|
190
|
-
|
191
283
|
}
|
192
284
|
|
193
|
-
function
|
285
|
+
function update_list_selects(favourites){
|
194
286
|
if (undefined === favourites){ favourites = get_favourite_entity_lists(); }
|
195
287
|
|
288
|
+
$('select.favourite_lists').find('option.automatic_load').remove()
|
289
|
+
|
196
290
|
$.each(favourites, function(type, lists){
|
197
291
|
$('select.favourite_lists[type=' + type + ']').each(function(){
|
198
292
|
var select = $(this);
|
199
|
-
|
293
|
+
update_list_select(select, type, lists);
|
294
|
+
})
|
295
|
+
$('select.favourite_lists[type=All]').each(function(){
|
296
|
+
var select = $(this);
|
297
|
+
select.append($('<option class="automatic_load" disabled>'+ type +'</option>'));
|
298
|
+
update_list_select(select, type, lists);
|
200
299
|
})
|
201
300
|
});
|
301
|
+
|
202
302
|
}
|
203
303
|
|
204
304
|
register_dom_update('select.favourite_lists', function(select){
|
305
|
+
$.each(select, function(){
|
306
|
+
var select = $(this);
|
205
307
|
var type = select.attr('type');
|
206
|
-
|
207
|
-
if (
|
208
|
-
|
308
|
+
console.log(type)
|
309
|
+
if (type == 'All'){
|
310
|
+
update_list_selects();
|
311
|
+
}else{
|
312
|
+
var lists = get_favourite_entity_lists()[type];
|
313
|
+
if (undefined !== lists){
|
314
|
+
update_list_select(select, type, lists);
|
315
|
+
}
|
316
|
+
}
|
317
|
+
})
|
318
|
+
})
|
319
|
+
|
320
|
+
//{{{{ MAP SELECTS
|
321
|
+
|
322
|
+
function update_map_select(select, type, map_lists){
|
323
|
+
if (select.attr('attr-allow-empty') == 'true'){
|
324
|
+
var option = $('<option value="none" class="loaded">none</option>')
|
325
|
+
select.append(option);
|
326
|
+
}
|
327
|
+
|
328
|
+
var selected = null;
|
329
|
+
|
330
|
+
if (select.attr('attr-selected') != undefined ){
|
331
|
+
selected = select.attr('attr-selected');
|
332
|
+
}
|
333
|
+
|
334
|
+
for (column in map_lists){
|
335
|
+
var maps = map_lists[column]
|
336
|
+
if (undefined === select.attr('column') || select.attr('column') == column){
|
337
|
+
$.each(maps, function(name, elems){
|
338
|
+
var option = null;
|
339
|
+
var name = elems
|
340
|
+
if (selected == null || name != selected){
|
341
|
+
option = $('<option class="automatic_load" attr-entity_type="' + type + '" attr-column="'+ column + '" value="' + name + '">' + name + '</option>');
|
342
|
+
}else{
|
343
|
+
option = $('<option class="automatic_load" attr-entity_type="' + type + '" attr-column="'+ column + '" selected=selected value="' + name + '">' + name + '</option>');
|
344
|
+
}
|
345
|
+
select.append(option);
|
346
|
+
return true
|
347
|
+
})
|
348
|
+
}
|
349
|
+
}
|
350
|
+
}
|
351
|
+
|
352
|
+
function update_map_selects(favourites){
|
353
|
+
if (undefined === favourites){ favourites = get_favourite_entity_maps(); }
|
354
|
+
|
355
|
+
$('select.favourite_maps').find('option.automatic_load').remove()
|
356
|
+
|
357
|
+
$.each(favourites, function(type, maps){
|
358
|
+
$('select.favourite_maps[type=' + type + ']').each(function(){
|
359
|
+
var select = $(this);
|
360
|
+
update_map_select(select, type, maps);
|
361
|
+
})
|
362
|
+
$('select.favourite_maps[type=All]').each(function(){
|
363
|
+
var select = $(this);
|
364
|
+
select.append($('<option class="automatic_load" disabled>'+ type +'</option>'));
|
365
|
+
update_map_select(select, type, maps);
|
366
|
+
})
|
367
|
+
|
368
|
+
});
|
369
|
+
}
|
370
|
+
|
371
|
+
register_dom_update('select.favourite_maps', function(select){
|
372
|
+
var type = select.attr('type');
|
373
|
+
if (type == "All"){
|
374
|
+
update_map_selects();
|
375
|
+
}else{
|
376
|
+
var map_lists = get_favourite_entity_maps()[type];
|
377
|
+
if (undefined !== map_lists){
|
378
|
+
update_map_select(select, type, map_lists);
|
379
|
+
}
|
380
|
+
}
|
381
|
+
})
|
382
|
+
|
383
|
+
// HIGHLIGHT
|
384
|
+
|
385
|
+
if (undefined === localStorage["highlights"]){
|
386
|
+
localStorage["highlights"] = '{}'
|
387
|
+
}
|
388
|
+
|
389
|
+
register_dom_update('ul.favourite_entity_lists > li > ul.dropdown > li > a:not(.highlight)', function(list_link){
|
390
|
+
list_link.before($('<a class="highlight"><i class="foundicon-flag"/></a>'))
|
391
|
+
})
|
392
|
+
|
393
|
+
function add_highlight(type, list){
|
394
|
+
highlights = JSON.parse(localStorage["highlights"])
|
395
|
+
if (undefined === highlights[type]){
|
396
|
+
highlights[type] = [];
|
397
|
+
}
|
398
|
+
highlights[type].push(list)
|
399
|
+
highlights[type] = $.unique(highlights[type]);
|
400
|
+
localStorage["highlights"] = JSON.stringify(highlights)
|
401
|
+
}
|
402
|
+
|
403
|
+
function remove_highlight(type, list){
|
404
|
+
highlights = JSON.parse(localStorage["highlights"])
|
405
|
+
if (undefined === highlights[type]){ return }
|
406
|
+
highlights[type] = remove_from_array(highlights[type], list)
|
407
|
+
$('ul.favourite_entity_lists li[entity_type=' + type + '] ul li a[href*="' + list + '"]').parent().find('a.highlight').removeClass('active')
|
408
|
+
localStorage["highlights"] = JSON.stringify(highlights)
|
409
|
+
}
|
410
|
+
|
411
|
+
function apply_highlights(){
|
412
|
+
$('a.entity').removeClass('highlighted')
|
413
|
+
highlights = JSON.parse(localStorage["highlights"])
|
414
|
+
var entities = []
|
415
|
+
for (type in highlights){
|
416
|
+
for (i in highlights[type]){
|
417
|
+
var list = highlights[type][i]
|
418
|
+
var entities = list_entities(type, list)
|
419
|
+
$('ul.favourite_entity_lists li[entity_type=' + type + '] ul li a[href*="' + list + '"]').parent().find('a.highlight').addClass('active')
|
420
|
+
var type_entities = $('a.entity.' + type)
|
421
|
+
for (j in entities){
|
422
|
+
var entity_id = entities[j];
|
423
|
+
type_entities.filter('[attr-entity_id=' + entity_id + ']').addClass('highlighted')
|
424
|
+
}
|
425
|
+
}
|
426
|
+
}
|
427
|
+
}
|
428
|
+
|
429
|
+
$('body').on('click', 'ul.favourite_entity_lists a.highlight', function(){
|
430
|
+
var link = $(this)
|
431
|
+
var list_link = link.parent().children().last()
|
432
|
+
var list = list_link.attr('href').split("/")[3]
|
433
|
+
var type = link.closest('li.type').find('a').html()
|
434
|
+
highlights = JSON.parse(localStorage["highlights"])
|
435
|
+
if (undefined === highlights[type] || ! $.inArray(highlights[type], list)){
|
436
|
+
add_highlight(type, list)
|
437
|
+
}else{
|
438
|
+
remove_highlight(type, list)
|
209
439
|
}
|
440
|
+
apply_highlights()
|
210
441
|
})
|