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
@@ -0,0 +1,425 @@
1
+
2
+ function get_favourite_entities(complete){
3
+ return get_ajax({url: '/favourite_entities', async: false, cache: false}, complete)
4
+ }
5
+
6
+ function get_favourite_entity_lists(complete){
7
+ return get_ajax({url: '/favourite_entity_lists', async: false, cache: false}, complete)
8
+ }
9
+
10
+ function get_favourite_entity_maps(complete){
11
+ return get_ajax({url: '/favourite_entity_maps', async: false, cache: false}, complete)
12
+ }
13
+
14
+ //{{{{ FAVOURITE MENUS
15
+
16
+ function favourite_type_ul(entities){
17
+ var type_ul = $('<ul>').addClass('entities')
18
+ for (var entity in entities){
19
+ var entity_hash = entities[entity];
20
+ var link = entity_hash["link"];
21
+ var entity_li = $('<li>');
22
+ entity_li.append(link);
23
+ type_ul.append(entity_li);
24
+ }
25
+ return type_ul
26
+ }
27
+
28
+ function favourite_list_type_ul(type, lists){
29
+ var type_ul = $('<ul>').addClass('lists')
30
+ for (var list in lists){
31
+ var list = lists[list];
32
+ var link = list_link(type, list)
33
+ var entity_li = $('<li>');
34
+ entity_li.html(link);
35
+ type_ul.append(entity_li);
36
+ }
37
+ return type_ul
38
+ }
39
+
40
+ function favourite_map_type_ul(type, column, maps){
41
+ var type_ul = $('<ul>').addClass('maps')
42
+ for (var map in maps){
43
+ var map = maps[map];
44
+ var link = map_link(type, column, map)
45
+ var entity_li = $('<li>');
46
+ entity_li.html(link);
47
+ type_ul.append(entity_li);
48
+ }
49
+ return type_ul
50
+ }
51
+
52
+ $.widget("rbbt.favourites", {
53
+ options: {
54
+ entities: {},
55
+ lists: {},
56
+ maps: {}
57
+ },
58
+
59
+ _create: function() {
60
+ this.update();
61
+ var tool = this;
62
+ this.element.on('click', 'dt.star', function(){
63
+ tool.toggle()
64
+ return false
65
+ })
66
+ this.element.on('click', 'a.remove_element', function(){
67
+ tool._remove_element($(this).siblings('a.entity, a.entity_list, a.entity_map'))
68
+ })
69
+ },
70
+
71
+ _menu: function(){
72
+ return(this.element)
73
+ },
74
+
75
+ _sync: function(){
76
+ var tool = this
77
+
78
+ get_favourite_entities(function(entities){
79
+ tool.options.entities = entities;
80
+ tool._update_entities()
81
+ tool._update_star()
82
+ })
83
+
84
+ get_favourite_entity_lists(function(lists){
85
+ tool.options.lists = lists;
86
+ tool._update_lists()
87
+ tool._update_star()
88
+ })
89
+
90
+
91
+ get_favourite_entity_maps(function(maps){
92
+ tool.options.maps = maps;
93
+ tool._update_maps()
94
+ tool._update_star()
95
+ })
96
+ },
97
+
98
+ //{{{ REMOVE ELEMENT
99
+ //----------
100
+
101
+ _remove_element: function(link){
102
+ var item = link.parent('li');
103
+ var ul = item.parent('ul');
104
+ var type = ul.attr('class');
105
+ var dt = ul.parent('dd').prev('dt');
106
+ var element = link.attr('title');
107
+ var entity_type = dt.attr('entity_type');
108
+ var entity_column = dt.attr('entity_column');
109
+ var url;
110
+ var tool = this;
111
+
112
+ switch(type){
113
+ case "entities":
114
+ method = "/remove_favourite_entity/";
115
+ element = link.attr('attr-entity_id')
116
+ url = method + clean_element(entity_type) + "/" + element;
117
+ break;
118
+
119
+ case "lists":
120
+ method = "/remove_favourite_entity_list/";
121
+ url = method + clean_element(entity_type) + "/" + clean_element(element);
122
+ break;
123
+
124
+ case "maps":
125
+ method = "/remove_favourite_entity_map/";
126
+ url = method + clean_element(entity_type) + "/" + clean_element(entity_column) + "/" + clean_element(element);
127
+ break;
128
+ };
129
+
130
+ $.ajax({url: url, type: 'POST', success: function (){ tool.update()}})
131
+ },
132
+
133
+ _add_destructors: function(list){
134
+ var icon = $('<i class="general foundicon-minus">')
135
+ var remove = $('<a class=remove_element></a>').append(icon)
136
+ list.find('li').prepend(remove)
137
+ },
138
+
139
+
140
+ //{{{ TOGGLE PAGE STAR
141
+ //----------
142
+
143
+ _update_star: function(){
144
+ if (this.is_favourite() == true){
145
+ this.element.find('dt.star').addClass('active');
146
+ }else{
147
+ this.element.find('dt.star').removeClass('active');
148
+ }
149
+ },
150
+ _toggle_page: function(){
151
+ this.toggle_page(undefined)
152
+ },
153
+
154
+ toggle: function(){
155
+ this._toggle_page();
156
+ },
157
+
158
+ //{{{ UPDATE
159
+ //----------
160
+
161
+ _update_entities: function(){
162
+ var menu = this._menu()
163
+ menu.find('ul.entities').addClass('remove');
164
+
165
+ var entities = menu.find('dt.entities').next('dd').find('> dl')
166
+ for(type in this.options.entities){
167
+ var ul = favourite_type_ul(this.options.entities[type]);
168
+ this._add_destructors(ul)
169
+ var dt = entities.find('dt[entity_type=' + clean_attr(type) + ']')
170
+
171
+ if (dt.length == 0){
172
+ var dt = $('<dt>').html(type).addClass('next').addClass('type').attr('entity_type', type);
173
+ var dd = $('<dd>').append(ul);
174
+ entities.append(dt).append(dd);
175
+ update_rbbt();
176
+ }else{
177
+ if (dt.next('dd').find('ul.entities').length == 0){
178
+ dt.next('dd').append(ul);
179
+ }else{
180
+ dt.next('dd').find('ul.entities').replaceWith(ul);
181
+ }
182
+ }
183
+
184
+ menu.find('dt[entity_type=' + clean_attr(type) + ']').next('dd').find('ul.entities').replaceWith(ul);
185
+ }
186
+ menu.find('ul.entities.remove').remove()
187
+ },
188
+
189
+ _update_lists: function(){
190
+ var menu = this._menu()
191
+ menu.find('ul.lists').addClass('remove');
192
+
193
+ var lists = menu.find('dt.lists').next('dd').find('> dl')
194
+ for(type in this.options.lists){
195
+ var ul = favourite_list_type_ul(type, this.options.lists[type])
196
+ this._add_destructors(ul)
197
+ var dt = lists.find('dt[entity_type=' + clean_attr(type) + ']');
198
+
199
+ if (dt.length == 0){
200
+ var dt = $('<dt>').html(type).addClass('next').addClass('type').attr('entity_type', type);
201
+ var dd = $('<dd>').append(ul);
202
+ lists.append(dt).append(dd);
203
+ update_rbbt();
204
+ }else{
205
+ if (dt.next('dd').find('ul.lists').length == 0){
206
+ dt.next('dd').append(ul);
207
+ }else{
208
+ dt.next('dd').find('ul.lists').replaceWith(ul);
209
+ }
210
+ }
211
+ }
212
+ menu.find('ul.lists.remove').remove();
213
+ },
214
+
215
+ _update_maps: function(){
216
+ var menu = this._menu()
217
+ menu.find('ul.maps').addClass('remove')
218
+
219
+ var maps = menu.find('dt.maps').next('dd').find('> dl')
220
+ for(type in this.options.maps){
221
+ for(column in this.options.maps[type]){
222
+ var ul = favourite_map_type_ul(type, column, this.options.maps[type][column]);
223
+ this._add_destructors(ul)
224
+ var dt = maps.find('dt[entity_type=\'' + clean_attr(type) + '\'][entity_column=\'' + clean_attr(column) + '\']');
225
+
226
+ if (dt.length == 0){
227
+ var dt = $('<dt>').html(type + ' - ' + column).addClass('next').addClass('type').attr('entity_type', clean_attr(type)).attr('entity_column', clean_attr(column));
228
+ var dd = $('<dd>').append(ul);
229
+ maps.append(dt).append(dd);
230
+ update_rbbt();
231
+ }else{
232
+ if (dt.next('dd').find('ul.maps').length == 0){
233
+ dt.next('dd').append(ul);
234
+ }else{
235
+ dt.next('dd').find('ul.maps').replaceWith(ul);
236
+ }
237
+ }
238
+ }
239
+ }
240
+ menu.find('ul.maps.remove').remove()
241
+ },
242
+
243
+
244
+ //{{{ SELECTS
245
+ //
246
+ _update_list_select: function(select, type, lists){
247
+ if (select.attr('attr-allow-empty') == 'true'){
248
+ var option = $('<option value="none" class="loaded">none</option>')
249
+ select.append(option);
250
+ }
251
+
252
+ var selected = null;
253
+
254
+ if (select.attr('attr-selected') != undefined ){
255
+ selected = select.attr('attr-selected');
256
+ }
257
+
258
+ $.each(lists, function(name, elems){
259
+ var option = null;
260
+ var name = elems
261
+ if (selected == null || name != selected){
262
+ option = $('<option attr-entity_type="' + type + '" class="automatic_load" value="' + name + '">' + name + '</option>');
263
+ }else{
264
+ option = $('<option attr-entity_type="' + type + '" class="automatic_load" selected=selected value="' + name + '">' + name + '</option>');
265
+ }
266
+ select.append(option);
267
+ return true
268
+ })
269
+ },
270
+
271
+ _update_map_select: function(select, type, map_lists){
272
+ if (select.attr('attr-allow-empty') == 'true'){
273
+ var option = $('<option value="none" class="loaded">none</option>');
274
+ select.append(option);
275
+ }
276
+
277
+ var selected = null;
278
+
279
+ if (select.attr('attr-selected') != undefined ){
280
+ selected = select.attr('attr-selected');
281
+ }
282
+
283
+ for (column in map_lists){
284
+ var maps = map_lists[column];
285
+ if (undefined === select.attr('column') || select.attr('column') == column){
286
+ $.each(maps, function(name, elems){
287
+ var option = null;
288
+ var name = elems
289
+ if (selected == null || name != selected){
290
+ option = $('<option class="automatic_load" attr-entity_type="' + clean_attr(type) + '" attr-column="'+ clean_attr(column) + '" value="' + name + '">' + name + '</option>');
291
+ }else{
292
+ option = $('<option class="automatic_load" attr-entity_type="' + clean_attr(type) + '" attr-column="'+ clean_attr(column) + '" selected=selected value="' + name + '">' + name + '</option>');
293
+ }
294
+ select.append(option);
295
+ return true
296
+ })
297
+ }
298
+ }
299
+ },
300
+
301
+ //{{{ UPDATES
302
+ //
303
+ update_list_selects: function(){
304
+ var tool = this;
305
+ $('select.favourite_lists').find('option.automatic_load').remove()
306
+
307
+ $.each(this.options.lists, function(type, lists){
308
+ $('select.favourite_lists[type=' + type + ']').each(function(){
309
+ var select = $(this);
310
+ tool._update_list_select(select, type, lists);
311
+ })
312
+ $('select.favourite_lists[type=All]').each(function(){
313
+ var select = $(this);
314
+ select.append($('<option class="automatic_load" disabled>'+ type +'</option>'));
315
+ tool._update_list_select(select, type, lists);
316
+ })
317
+ });
318
+ },
319
+
320
+ update_map_selects: function(){
321
+ var tool = this;
322
+ $('select.favourite_maps').find('option.automatic_load').remove()
323
+
324
+ $.each(this.options.maps, function(type, maps){
325
+ $('select.favourite_maps[type=' + type + ']').each(function(){
326
+ var select = $(this);
327
+ tool._update_map_select(select, type, maps);
328
+ })
329
+ $('select.favourite_maps[type=All]').each(function(){
330
+ var select = $(this);
331
+ select.append($('<option class="automatic_load" disabled>'+ type +'</option>'));
332
+ tool._update_map_select(select, type, maps);
333
+ })
334
+ });
335
+ },
336
+
337
+ close: function(){
338
+ this.element.find('.show').removeClass('show')
339
+ },
340
+
341
+ is_favourite: function(path){
342
+ var type = page_type(path);
343
+
344
+ switch(type){
345
+
346
+ case "entity":
347
+ var entity = page_entity(path);
348
+ var entity_type = page_entity_base_type(path);
349
+ return this.options.entities[entity_type] !== undefined && this.options.entities[entity_type][entity] !== undefined
350
+
351
+ case "entity_list":
352
+ var list = page_entity_list(path);
353
+ var entity_type = page_entity_base_type(path);
354
+ return this.options.lists[entity_type] !== undefined && _.indexOf(this.options.lists[entity_type], list) !== -1
355
+
356
+ case "entity_map":
357
+ var map = page_entity_map(path);
358
+ var entity_type = page_entity_base_type(path);
359
+ var entity_column = page_entity_map_column(path);
360
+ return this.options.maps[entity_type] !== undefined && this.options.maps[entity_type][entity_column] !== undefined && _.indexOf(this.options.maps[entity_type][entity_column], map) !== -1
361
+ }
362
+
363
+ return false
364
+ },
365
+
366
+ toggle_page: function(path){
367
+ var type = page_type(path);
368
+ var tool = this
369
+ switch(type){
370
+
371
+ case "entity":
372
+ var entity = page_entity(path);
373
+ var entity_type = page_entity_type(path);
374
+ var entity_info = page_entity_info(path);
375
+
376
+ if (this.is_favourite(path)){
377
+ method = "/remove_favourite_entity/";
378
+ }else{
379
+ method = "/add_favourite_entity/";
380
+ }
381
+ var url = method + clean_element(entity_type) + "/" + entity;
382
+ $.ajax({url: url, type: 'POST', data: entity_info, success: function (){ tool.update()}})
383
+ break;
384
+
385
+ case "entity_list":
386
+ var list = page_entity_list(path);
387
+ var entity_type = page_entity_type(path);
388
+ if (this.is_favourite(path)){
389
+ method = "/remove_favourite_entity_list/";
390
+ }else{
391
+ method = "/add_favourite_entity_list/";
392
+ }
393
+ var url = method + clean_element(entity_type) + "/" + clean_element(list);
394
+ $.ajax({url: url, type: 'POST', success: function (){ tool.update() }})
395
+ break;
396
+
397
+ case "entity_map":
398
+ var map = page_entity_map(path);
399
+ var entity_type = page_entity_type(path);
400
+ var entity_column = page_entity_map_column(path);
401
+ if (this.is_favourite(path)){
402
+ method = "/remove_favourite_entity_map/";
403
+ }else{
404
+ method = "/add_favourite_entity_map/";
405
+ }
406
+ var url = method + clean_element(entity_type) + "/" + clean_element(entity_column) + "/" + clean_element(map);
407
+ $.ajax({url: url, type: 'POST', success: function (){ tool.update()}})
408
+ break;
409
+ }
410
+ },
411
+
412
+
413
+ update: function(){
414
+ this._sync()
415
+ //this._update_entities()
416
+ //this._update_lists()
417
+ //this._update_maps()
418
+ //this._update_star()
419
+ //this._add_destructors()
420
+ $('#modal.url.entity').modal('update_star')
421
+ }
422
+
423
+ })
424
+
425
+
@@ -0,0 +1,13 @@
1
+ register_dom_update(('a.fragment'), function(link){
2
+ link.each(function(){replace_link($(this))});
3
+ })
4
+
5
+ register_dom_update(('a.modal_fragment'), function(link){
6
+ link.click(function(){
7
+ var modal = $('#modal1')
8
+ link.attr('data-reveal-id', 'modal1')
9
+ replace_object(modal, $(this).attr('href'), true)
10
+ return true
11
+ })
12
+ })
13
+
@@ -0,0 +1,60 @@
1
+ $.widget("rbbt.hide_toggle", {
2
+ options: {
3
+ },
4
+
5
+ _create: function() {
6
+ var tool = this
7
+ var element = this.element
8
+ if (this.options.title === undefined){ this.options.title = element.attr('hide-title') }
9
+ if (this.options.title === undefined){ this.options.title = "toggle" }
10
+
11
+ var button = this.options.button = $('<a>').addClass('hide_toggle').html(this.options.title)
12
+
13
+ button.click(function(){ tool.toggle(); update_rbbt(); return false })
14
+ if (this.options.container !== undefined){
15
+ $(this.options.container).first().append(button)
16
+ }
17
+ this.hide()
18
+ },
19
+
20
+ _swap: function(){
21
+ this.options.saved = this.element.html()
22
+ this.element.html(this.options.button)
23
+ },
24
+
25
+ _restore: function(){
26
+ this.element.html(this.options.saved)
27
+ },
28
+
29
+
30
+ hide: function(){
31
+ var tool = this;
32
+ this.element.addClass('hidden').removeClass('shown')
33
+ this.options.button.addClass('hidden').removeClass('shown')
34
+
35
+ if (this.options.container === undefined){ this._swap(); }
36
+ },
37
+
38
+ show: function(){
39
+ if (this.options.container === undefined){
40
+ this._restore();
41
+ }else{
42
+ $(this.options.container).find('.hide_toggle.shown').trigger('click')
43
+ }
44
+ this.element.addClass('shown').removeClass('hidden')
45
+ this.options.button.addClass('shown').removeClass('hidden')
46
+ },
47
+
48
+ toggle: function(){
49
+ if (this.element.hasClass('shown')){
50
+ this.hide();
51
+ }else{
52
+ this.show();
53
+ }
54
+ }
55
+
56
+ })
57
+
58
+ $('#top_menu > ul > li.hide').hide_toggle({container: '#top_menu li.container'})
59
+
60
+ $('.sidebar').hide_toggle({container: '#top_menu li.container', title: 'Side'})