rbbt-rest 1.1.5 → 1.2.0

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.
Files changed (127) hide show
  1. checksums.yaml +8 -8
  2. data/lib/rbbt/rest/common/cache.rb +33 -14
  3. data/lib/rbbt/rest/common/locate.rb +8 -6
  4. data/lib/rbbt/rest/common/misc.rb +4 -0
  5. data/lib/rbbt/rest/common/render.rb +14 -4
  6. data/lib/rbbt/rest/common/resources.rb +1 -1
  7. data/lib/rbbt/rest/common/table.rb +37 -7
  8. data/lib/rbbt/rest/entity.rb +5 -3
  9. data/lib/rbbt/rest/entity/favourites.rb +4 -1
  10. data/lib/rbbt/rest/entity/helpers.rb +12 -0
  11. data/lib/rbbt/rest/entity/rest.rb +6 -2
  12. data/lib/rbbt/rest/helpers.rb +7 -0
  13. data/lib/rbbt/rest/knowledge_base.rb +338 -0
  14. data/lib/rbbt/rest/knowledge_base/helpers.rb +57 -0
  15. data/lib/rbbt/rest/main.rb +16 -3
  16. data/share/views/compass/_rbbt.sass +11 -0
  17. data/share/views/compass/actions.sass +48 -24
  18. data/share/views/compass/app.sass +72 -50
  19. data/share/views/compass/colors.sass +3 -229
  20. data/share/views/compass/entity_card.sass +44 -108
  21. data/share/views/compass/favourites.sass +17 -72
  22. data/share/views/compass/finder.sass +30 -0
  23. data/share/views/compass/foundation.sass +79 -0
  24. data/share/views/compass/functions.sass +27 -0
  25. data/share/views/compass/help.sass +3 -0
  26. data/share/views/compass/layout.sass +132 -0
  27. data/share/views/compass/rbbt/form.sass +84 -0
  28. data/share/views/compass/rbbt/fragment.sass +7 -0
  29. data/share/views/compass/rbbt/menu.sass +189 -0
  30. data/share/views/compass/rbbt/reveal.sass +46 -0
  31. data/share/views/compass/rbbt/table.sass +169 -0
  32. data/share/views/compass/skeleton.sass +2 -0
  33. data/share/views/compass/skeleton/_dependencies.sass +151 -0
  34. data/share/views/compass/skeleton/_functions.sass +4 -0
  35. data/share/views/compass/skeleton/_mixins.sass +25 -0
  36. data/share/views/compass/skeleton/_vars.sass +72 -0
  37. data/share/views/compass/skeleton/base.sass +333 -0
  38. data/share/views/compass/skeleton/layout.sass +51 -0
  39. data/share/views/compass/skeleton/skeleton.sass +105 -0
  40. data/share/views/compass/solarized.sass +56 -0
  41. data/share/views/compass/style.sass +2 -116
  42. data/share/views/compass/theme.sass +57 -44
  43. data/share/views/compass/top_menu.sass +121 -0
  44. data/share/views/compass/user.sass +7 -0
  45. data/share/views/compass/variables.sass +7 -0
  46. data/share/views/compass/workflow.sass +6 -14
  47. data/share/views/entity_partials/action_controller.haml +7 -4
  48. data/share/views/entity_partials/entity_card.haml +10 -5
  49. data/share/views/entity_partials/entity_list.haml +4 -7
  50. data/share/views/entity_partials/entity_list_card.haml +10 -3
  51. data/share/views/entity_partials/entity_map_card.haml +2 -2
  52. data/share/views/entity_partials/list_container.haml +31 -26
  53. data/share/views/error.haml +5 -7
  54. data/share/views/help.haml +75 -31
  55. data/share/views/help/entity.haml +191 -193
  56. data/share/views/help/workflow.haml +59 -63
  57. data/share/views/job_result.haml +23 -26
  58. data/share/views/layout.haml +41 -61
  59. data/share/views/layout/top_menu.haml +19 -0
  60. data/share/views/layout/top_menu/favourites.haml +45 -0
  61. data/share/views/layout/top_menu/finder.haml +4 -0
  62. data/share/views/layout/top_menu/user.haml +15 -0
  63. data/share/views/public/js/_ajax_replace.js +17 -5
  64. data/share/views/public/js/_ellipsis.js +7 -9
  65. data/share/views/public/js/app.js +50 -2
  66. data/share/views/public/js/foundation/foundation.abide.js +194 -0
  67. data/share/views/public/js/foundation/foundation.alerts.js +52 -0
  68. data/share/views/public/js/foundation/foundation.clearing.js +516 -0
  69. data/share/views/public/js/foundation/foundation.cookie.js +74 -0
  70. data/share/views/public/js/foundation/foundation.dropdown.js +177 -0
  71. data/share/views/public/js/foundation/foundation.forms.js +533 -0
  72. data/share/views/public/js/foundation/foundation.interchange.js +280 -0
  73. data/share/views/public/js/foundation/foundation.joyride.js +850 -0
  74. data/share/views/public/js/foundation/foundation.js +440 -0
  75. data/share/views/public/js/foundation/foundation.magellan.js +135 -0
  76. data/share/views/public/js/foundation/foundation.orbit.js +412 -0
  77. data/share/views/public/js/foundation/foundation.placeholder.js +179 -0
  78. data/share/views/public/js/foundation/foundation.reveal.js +330 -0
  79. data/share/views/public/js/foundation/foundation.section.js +400 -0
  80. data/share/views/public/js/foundation/foundation.tooltips.js +208 -0
  81. data/share/views/public/js/foundation/foundation.topbar.js +300 -0
  82. data/share/views/public/js/foundation/index.js +18 -0
  83. data/share/views/public/js/helpers.js +33 -2
  84. data/share/views/public/js/jquery-ui.js +313 -0
  85. data/share/views/public/js/rbbt/actions.js +264 -0
  86. data/share/views/public/js/{_dom_update.js → rbbt/dom_update.js} +0 -0
  87. data/share/views/public/js/rbbt/favourites.js +425 -0
  88. data/share/views/public/js/rbbt/fragment.js +13 -0
  89. data/share/views/public/js/rbbt/hide.js +60 -0
  90. data/share/views/public/js/rbbt/list.js +117 -0
  91. data/share/views/public/js/{maps.js → rbbt/map.js} +3 -2
  92. data/share/views/public/js/rbbt/menu.js +22 -0
  93. data/share/views/public/js/rbbt/modal.js +96 -0
  94. data/share/views/public/js/{entities.js → rbbt/page_type.js} +12 -9
  95. data/share/views/public/js/rbbt/reveal.js +19 -0
  96. data/share/views/public/js/rbbt/table.js +283 -0
  97. data/share/views/public/js/{workflow.js → rbbt/workflow.js} +0 -0
  98. data/share/views/tasks.haml +14 -15
  99. data/share/views/wait.haml +11 -12
  100. metadata +62 -33
  101. data/share/views/compass/_foundation_setup.sass +0 -74
  102. data/share/views/compass/dom.sass +0 -32
  103. data/share/views/compass/footer.sass +0 -4
  104. data/share/views/compass/form.sass +0 -41
  105. data/share/views/compass/fragment.sass +0 -8
  106. data/share/views/compass/list_container.sass +0 -34
  107. data/share/views/compass/lists.sass +0 -33
  108. data/share/views/compass/offcanvas.sass +0 -66
  109. data/share/views/compass/responsive_table.sass +0 -80
  110. data/share/views/compass/reveal.sass +0 -31
  111. data/share/views/compass/style_mixins.sass +0 -42
  112. data/share/views/compass/table.sass +0 -63
  113. data/share/views/compass/tabs.sass +0 -81
  114. data/share/views/compass/topbar.sass +0 -25
  115. data/share/views/compass/web-fonts.sass +0 -77
  116. data/share/views/layout/favourites.haml +0 -46
  117. data/share/views/layout/header.haml +0 -44
  118. data/share/views/public/js/_fix_tablesorter_science.js +0 -38
  119. data/share/views/public/js/_foundation.js +0 -42
  120. data/share/views/public/js/actions.js +0 -108
  121. data/share/views/public/js/base.js +0 -121
  122. data/share/views/public/js/favourites.js +0 -441
  123. data/share/views/public/js/lists.js +0 -117
  124. data/share/views/public/js/offcanvas.js +0 -35
  125. data/share/views/public/js/reveal.js +0 -48
  126. data/share/views/public/js/tables.js +0 -314
  127. data/share/views/public/js/tabs.js +0 -7
@@ -1,46 +0,0 @@
1
-
2
- %li#top-favourites.has-dropdown
3
- %a(href="#") Fav. Entities
4
-
5
- %ul.favourite_entities.dropdown
6
- - favourite_entities.each do |type, entities|
7
- %li.type.has-dropdown(entity_type=type)
8
- %a(href="#")= type
9
- %ul.dropdown
10
- - entities.each do |entity|
11
- %li
12
- = entity.link
13
-
14
- %li#top-favourite_lists.has-dropdown
15
- %a(href="#") Fav. Entity Lists
16
-
17
- %ul.favourite_entity_lists.dropdown
18
- - favourite_entity_lists.each do |type, lists|
19
- %li.type.has-dropdown(entity_type=type)
20
- %a(href="#")= type
21
- %ul.dropdown
22
- - lists.each do |list_id|
23
- %li
24
- %a(href="#{Entity::REST.entity_list_url(list_id, type)}")= list_id
25
-
26
- %li#top-favourite_maps.has-dropdown
27
- %a(href="#") Fav. Entity Maps
28
-
29
- %ul.favourite_entity_maps.dropdown
30
- - favourite_entity_maps.each do |type, columns|
31
- - columns.each do |column, maps|
32
- %li.type.has-dropdown(entity_type=type entity_column=column)
33
- %a(href="#")= [type, column] * " - "
34
- %ul.dropdown
35
- - maps.each do |map_id|
36
- %li
37
- %a(href="#{Entity::REST.entity_map_url(map_id, type, column)}")= map_id
38
-
39
-
40
- %li#top-favourite_lists.has-dropdown
41
- %a(href="#") New Entity List
42
- %ul.new_entity_list.dropdown
43
- - Entity::REST::REST_ENTITIES.each do |mod|
44
- %li
45
- %a.new_list(href="#" data-reveal-id='modal1')= mod.to_s
46
-
@@ -1,44 +0,0 @@
1
- %nav.top-bar
2
-
3
- %ul.title-area
4
- %li.name
5
- %h1
6
- %a(href="/")= $title || "Genome Scout"
7
-
8
- %li.toggle-topbar.menu-icon
9
- %a(href="#")
10
- %span
11
- Menu
12
-
13
- %section.top-bar-section
14
-
15
- %ul.left
16
- %li
17
- %a#reload_page(href="#")
18
- %i.general.foundicon-refresh.hide-for-small
19
- %span.show-for-small
20
- Reload page
21
-
22
- %ul.left
23
- - if user and self.respond_to? :favourite_entities
24
- %li#top-add-favourite
25
- %a#toggle_favourite.inactive
26
- %i.general.foundicon-star.hide-for-small
27
- %span.add.show-for-small
28
- Add to Favourites
29
- %span.remove.show-for-small
30
- Remove from Favourites
31
-
32
- = partial_render('layout/favourites')
33
-
34
- %ul.right
35
- - if settings.respond_to? :finder and not settings.finder.nil?
36
- %li.search.has-form
37
- %form.collapse(action='/find' method="POST")
38
- %input(type="text" name="term")
39
- %button.secondary.radius.button(type="submit") Search
40
-
41
- %li
42
- %a(href="/help") Help
43
- %li.ajax_counter
44
- %a#ajax_processes 0
@@ -1,38 +0,0 @@
1
- $.tablesorter.addParser({
2
- // set a unique id
3
- id: 'scinot',
4
- is: function(s) {
5
- return /^\s*[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?\s*$/.test(s);
6
- },
7
- format: function(s) {
8
- return $.tablesorter.formatFloat(s);
9
- },
10
- type: 'numeric'
11
- });
12
-
13
- $.tablesorter.addParser({
14
- // set a unique id
15
- id: 'anchor_text',
16
- is: function(s) {
17
- return /<\/a>/.test(s);
18
- },
19
- format: function(s) {
20
- var text = $(s).find('a').text();
21
- return text;
22
- },
23
- type: 'text'
24
- });
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
-
@@ -1,42 +0,0 @@
1
- ;(function ($, window, undefined) {
2
- 'use strict';
3
-
4
- var $doc = $(document),
5
- Modernizr = window.Modernizr;
6
-
7
- $(document).ready(function() {
8
- $.fn.foundationAlerts ? $doc.foundationAlerts() : null;
9
- $.fn.foundationButtons ? $doc.foundationButtons() : null;
10
- $.fn.foundationAccordion ? $doc.foundationAccordion() : null;
11
- $.fn.foundationNavigation ? $doc.foundationNavigation() : null;
12
- $.fn.foundationTopBar ? $doc.foundationTopBar() : null;
13
- //$.fn.foundationCustomForms ? $doc.foundationCustomForms() : null;
14
- $.fn.foundationMediaQueryViewer ? $doc.foundationMediaQueryViewer() : null;
15
- $.fn.foundationTabs ? $doc.foundationTabs({callback : $.foundation.customForms.appendCustomMarkup}) : null;
16
- $.fn.foundationTooltips ? $doc.foundationTooltips() : null;
17
- $.fn.foundationMagellan ? $doc.foundationMagellan() : null;
18
- $.fn.foundationClearing ? $doc.foundationClearing() : null;
19
-
20
- $.fn.placeholder ? $('input, textarea').placeholder() : null;
21
- });
22
-
23
- // UNCOMMENT THE LINE YOU WANT BELOW IF YOU WANT IE8 SUPPORT AND ARE USING .block-grids
24
- // $('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'both'});
25
- // $('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'both'});
26
- // $('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'both'});
27
- // $('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'both'});
28
-
29
- // Hide address bar on mobile devices (except if #hash present, so we don't mess up deep linking).
30
- if (Modernizr.touch && !window.location.hash) {
31
- $(window).load(function () {
32
- setTimeout(function () {
33
- // At load, if user hasn't scrolled more than 20px or so...
34
- if( $(window).scrollTop() < 20 ) {
35
- window.scrollTo(0, 1);
36
- }
37
- }, 0);
38
- });
39
- }
40
-
41
- })(Foundation.zj, this);
42
-
@@ -1,108 +0,0 @@
1
- function load_action(link){
2
- var action_list_item = link.parent('li');
3
- var action_list = action_list_item.parent('ul');
4
- var action_controller = action_list.parents('.action_controller').first();
5
- var action_div = action_controller.next('.action_loader');
6
- var href = link.attr('href')
7
-
8
- setup_action_controls = function(jqXHR, textStatus){
9
- var action_div = action_controller.next('.action_loader');
10
- if (jqXHR.status == 202){
11
- action_controller.removeClass('active');
12
-
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>");
20
- }
21
- }else{
22
- action_controller.addClass('active');
23
- action_controller.find('ul.controls > li.reload').addClass('active');
24
- }
25
-
26
- var action_div = action_controller.next('.action_loader').first();
27
- if (action_div.find('> .action_card > .action_parameters').length > 0){
28
- action_controller.find('ul.controls > li.parameters').addClass('active');
29
- }else{
30
- action_controller.find('ul.controls > li.parameters').removeClass('active');
31
- }
32
- }
33
-
34
- if( ! action_div.hasClass('reloading') ) {
35
- action_div.removeClass('active');
36
- action_controller.find('ul.controls > li.reload').removeClass('active');
37
- action_controller.find('ul.controls > li.parameters').removeClass('active');
38
- action_list.find('li').removeClass('active');
39
- action_list_item.addClass('active');
40
- replace_object(action_div, href, true, setup_action_controls);
41
-
42
- return false
43
- }
44
- }
45
-
46
- function display_parameters(){
47
- var link = $(this);
48
- var action_controller = link.parents('.action_controller').first()
49
- var action_loader = action_controller.next('.action_loader').first();
50
- var action_parameters = action_loader.find('.action_parameters').first();
51
- var action_content = action_parameters.next('.action_content').first();
52
-
53
- action_parameters.toggleClass('active')
54
- action_content.toggleClass('shifted')
55
-
56
- $.scrollTo(action_controller, {axis:'y'})
57
-
58
- return false
59
- }
60
-
61
- function setup_action(){
62
-
63
- show_actions = function(){
64
- var link = $(this);
65
- var action_list_item = link.parent('li');
66
- var action_list = action_list_item.parent('ul.actions');
67
- action_list.addClass('select')
68
-
69
- return false
70
- };
71
-
72
- activate_action = function(){
73
- var link = $(this);
74
- load_action(link);
75
-
76
- var action_list_item = link.parent('li');
77
- var action_list = action_list_item.parent('ul.actions');
78
- action_list.removeClass('select')
79
-
80
- return false
81
- };
82
-
83
- reload_action = function(){
84
- var link = $(this);
85
-
86
- var action_list_item = link.parent('li');
87
- var action_list = action_list_item.parent('ul.controls');
88
- var action_controller = action_list.parent('.action_controller');
89
- var action_div = action_controller.next('.action_loader').first();
90
-
91
- if (action_div.attr('target-href') != undefined){
92
- update_embedded(action_div, true)
93
- }
94
-
95
- return false
96
- };
97
-
98
- var body = $('body');
99
-
100
- body.on('click', '.action_controller > ul.actions li > a.entity_map_action', activate_action)
101
- body.on('click', '.action_controller > ul.actions li > a.entity_list_action', activate_action)
102
- body.on('click', '.action_controller > ul.actions li > a.entity_action', activate_action)
103
- body.on('click', '.action_controller > ul.actions > li.select > a', show_actions)
104
- body.on('click', '.action_controller > ul.controls > li > a.reload_action', reload_action)
105
- body.on('click', '.action_controller > ul.controls > li.parameters > a', display_parameters)
106
- }
107
-
108
-
@@ -1,121 +0,0 @@
1
- function setup_action_old(){
2
- $('div.actions > ul > li > a.entity_list_action').click(function(){
3
- var link = $(this);
4
- var action_list_item = link.parent('li');
5
- var action_list = action_list_item.parent('ul');
6
- var action_list_div = action_list.parent('div.actions');
7
- var action_div = action_list_div.find('div.action');
8
- var href = link.attr('href')
9
-
10
-
11
- if( ! action_div.hasClass('reloading') ) {
12
- action_list.find('li').removeClass('active');
13
- action_list_item.addClass('active');
14
- replace_object(action_div, href, true);
15
- }
16
- return false
17
- })
18
-
19
- $('div.actions > ul > li.reload_action > a').click(function(){
20
- var link = $(this);
21
- var action_list = $(this).parents('div.actions').first();
22
- var action_div = action_list.find('div.action');
23
-
24
- if (action_div.attr('target-href') != undefined){
25
- update_embedded(action_div)
26
- }
27
-
28
- return false
29
- })
30
- }
31
-
32
-
33
- function setup_page_reload(){
34
- var body = $('body');
35
- body.on('click', 'a#reload_page', function(){
36
- var url = window.location.toString();
37
- url = url.replace(/#$/, '');
38
-
39
- url = remove_parameter(url, '_update');
40
- url = add_parameters(url, '_update=reload');
41
-
42
- url = remove_parameter(url, '_');
43
- url = add_parameters(url, '_=' + Math.random().toString());
44
-
45
- window.location = url
46
- return false
47
- })
48
- }
49
-
50
- function setup_fragments(){
51
-
52
- register_dom_update(('a.fragment'), function(link){
53
- link.each(function(){replace_link($(this))});
54
- })
55
-
56
- register_dom_update(('a.modal_fragment'), function(link){
57
- link.click(function(){
58
- var modal = $('#modal1')
59
- link.attr('data-reveal-id', 'modal1')
60
- replace_object(modal, $(this).attr('href'), true)
61
- return true
62
- })
63
- })
64
-
65
- }
66
-
67
- function deactivate_off_links(){
68
- var body = $('body');
69
- body.on('click', 'a.off', function(){return false})
70
- }
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
-
79
- function setup_finder(){
80
- //register_dom_update("#header li.search input", function(elem){
81
- // elem.autocomplete({
82
- // source: "/find",
83
- // minLength: 2,
84
- // appendTo: '#find_wrapper'
85
- // }).data( "autocomplete" )._renderItem = function( ul, item ) {
86
- // var litem = $( "<li></li>" ).data( "item.autocomplete", item )
87
- // var link = $("<a class='select_autocomplete'></a>");
88
-
89
- // link.append("<span class='match'>" + item.best + "</span>" )
90
- // link.append( "<span class='code'>" + item.value + "</span>")
91
- // link.appendTo(litem);
92
- // litem.appendTo( ul );
93
- // };
94
- //})
95
- }
96
-
97
- function fit_content(){
98
- var height = window.innerHeight - $('#header').outerHeight(true) - $('footer').outerHeight(true);
99
- $('#body').css('min-height', height)
100
- }
101
-
102
- function update_rbbt(){
103
- update_dom();
104
- start_defferred();
105
- apply_highlights();
106
- }
107
-
108
- function setup_rbbt(){
109
- setup_fragments();
110
- setup_action();
111
- setup_page_reload();
112
- deactivate_off_links();
113
- update_favourite_entities_star();
114
- setup_finder();
115
- setup_offcanvas();
116
- setup_list_management();
117
- setup_tabs();
118
- fit_content();
119
-
120
- update_rbbt();
121
- }
@@ -1,441 +0,0 @@
1
- // HELPERS
2
-
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
- }
7
-
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
- }
12
-
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
- }
17
-
18
- function toggle_favourite(link){
19
- var link = $(link);
20
- var path;
21
-
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
-
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
-
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;
41
-
42
- $.ajax({url: url, type: 'POST', data: entity_info, success: function (){ update_favourite_entities() }})
43
-
44
- return false
45
- case "entity_list":
46
- var entity_list = page_entity_list(path);
47
- var entity_type = page_entity_type(path);
48
-
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);
55
-
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
- }
73
- }
74
-
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
-
84
-
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);
96
- switch(type){
97
- case "entity":
98
- if (undefined === favourites){ favourites = get_favourite_entities(path); }
99
-
100
- var entity = page_entity(path);
101
- var type = page_entity_base_type(path);
102
-
103
- if ((favourites[type] != undefined) && (favourites[type][entity] != undefined)){
104
- link.addClass('active').removeClass('inactive');
105
- }else{
106
- link.removeClass('active').addClass('inactive');
107
- }
108
- break
109
-
110
- case "entity_list":
111
- if (undefined === favourites){ favourites = get_favourite_entity_lists(path); }
112
-
113
- var entity_list = page_entity_list(path);
114
- var type = page_entity_base_type(path);
115
-
116
- if ((favourites[type] != undefined) && ($.inArray(entity_list, favourites[type]) != -1 )){
117
- link.addClass('active').removeClass('inactive');
118
- }else{
119
- link.removeClass('active').addClass('inactive');
120
- }
121
- break
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
- }
135
-
136
- break
137
- }
138
- }
139
-
140
- //{{{{ FAVOURITE MENUS
141
-
142
- function favourite_type_ul(entities){
143
- var type_ul = $('<ul>')
144
- for (var entity in entities){
145
- var entity_hash = entities[entity];
146
- var link = entity_hash["link"];
147
- var entity_li = $('<li>');
148
- entity_li.html(link);
149
- type_ul.append(entity_li);
150
- }
151
- return type_ul
152
- }
153
-
154
- function favourite_list_type_ul(type, lists){
155
- var type_ul = $('<ul>')
156
- for (var list in lists){
157
- var list = lists[list];
158
- var link = list_link(type, list)
159
- var entity_li = $('<li>');
160
- entity_li.html(link);
161
- type_ul.append(entity_li);
162
- }
163
- return type_ul
164
- }
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
-
178
- function update_favourite_entities(favourites){
179
- if (undefined === favourites){ favourites = get_favourite_entities(); }
180
-
181
- var favourites_ul = $('<ul class="dropdown favourite_entities" >');
182
- var title_li = $('<li class="title back js-generated rbbt-generated"><h5><a href="#">Favourite Entities</a></h5></li>');
183
- favourites_ul.append(title_li);
184
-
185
- for (var type in favourites){
186
-
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);
191
-
192
- var type_li = $('<li class="has-dropdown">')
193
- type_li.append($('<a href="#">' + type + '</a>')).append(type_ul);
194
-
195
- favourites_ul.append(type_li);
196
- }
197
-
198
- var current_favourites = $('li#top-favourites ul.favourite_entities')
199
- current_favourites.replaceWith(favourites_ul);
200
- update_favourite_entities_star(favourites);
201
- }
202
-
203
- function update_favourite_entity_lists(favourites){
204
- if (undefined === favourites){ favourites = get_favourite_entity_lists(); }
205
-
206
- var favourites_ul = $('<ul class="dropdown favourite_entity_lists" >');
207
- var title_li = $('<li class="title back js-generated rbbt-generated"><h5><a href="#">Favourite Entities Lists</a></h5></li>');
208
- favourites_ul.append(title_li);
209
-
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
- }
228
-
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);
241
-
242
- type_ul.addClass("dropdown").prepend(title_li);
243
-
244
- var type_li = $('<li class="has-dropdown">')
245
- type_li.append($('<a href="#">' + type + ' - ' + column + '</a>')).append(type_ul);
246
-
247
- favourites_ul.append(type_li);
248
- }
249
-
250
- }
251
-
252
- var current_favourites = $('li#top-favourite_maps ul.favourite_entity_maps')
253
- current_favourites.replaceWith(favourites_ul);
254
- update_favourite_entities_star(favourites);
255
- update_map_selects(favourites);
256
- }
257
-
258
- //{{{{ LIST SELECTS
259
-
260
- function update_list_select(select, type, lists){
261
- if (select.attr('attr-allow-empty') == 'true'){
262
- var option = $('<option value="none" class="loaded">none</option>')
263
- select.append(option);
264
- }
265
-
266
- var selected = null;
267
-
268
- if (select.attr('attr-selected') != undefined ){
269
- selected = select.attr('attr-selected');
270
- }
271
-
272
- $.each(lists, function(name, elems){
273
- var option = null;
274
- var name = elems
275
- if (selected == null || name != selected){
276
- option = $('<option attr-entity_type="' + type + '" class="automatic_load" value="' + name + '">' + name + '</option>');
277
- }else{
278
- option = $('<option attr-entity_type="' + type + '" class="automatic_load" selected=selected value="' + name + '">' + name + '</option>');
279
- }
280
- select.append(option);
281
- return true
282
- })
283
- }
284
-
285
- function update_list_selects(favourites){
286
- if (undefined === favourites){ favourites = get_favourite_entity_lists(); }
287
-
288
- $('select.favourite_lists').find('option.automatic_load').remove()
289
-
290
- $.each(favourites, function(type, lists){
291
- $('select.favourite_lists[type=' + type + ']').each(function(){
292
- var select = $(this);
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);
299
- })
300
- });
301
-
302
- }
303
-
304
- register_dom_update('select.favourite_lists', function(select){
305
- $.each(select, function(){
306
- var select = $(this);
307
- var type = select.attr('type');
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)
439
- }
440
- apply_highlights()
441
- })