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,18 @@
1
+ /*
2
+ =require foundation/foundation
3
+ =require foundation/foundation.alerts
4
+ =require foundation/foundation.clearing
5
+ =require foundation/foundation.cookie
6
+ =require foundation/foundation.dropdown
7
+ =require foundation/foundation.forms
8
+ =require foundation/foundation.joyride
9
+ =require foundation/foundation.magellan
10
+ =require foundation/foundation.orbit
11
+ =require foundation/foundation.reveal
12
+ =require foundation/foundation.section
13
+ =require foundation/foundation.tooltips
14
+ =require foundation/foundation.topbar
15
+ =require foundation/foundation.interchange
16
+ =require foundation/foundation.placeholder
17
+ =require foundation/foundation.abide
18
+ */
@@ -58,6 +58,7 @@ function parse_parameters(params){
58
58
 
59
59
  function require_js(url, success){
60
60
  var async = false;
61
+ var cache = production;
61
62
  console.log("Require js: " + url)
62
63
  if (undefined === success){
63
64
  async = false;
@@ -65,7 +66,8 @@ function require_js(url, success){
65
66
  async = true;
66
67
  }
67
68
 
68
- $.ajax({url: url, dataType:'script', async: async, success: success} ).fail(function(jqxhr, settings, exception){
69
+ url = url.replace('/js/', '/js-find/')
70
+ $.ajax({url: url, cache:cache, dataType:'script', async: async, success: success} ).fail(function(jqxhr, settings, exception){
69
71
  console.log('Exception loading: ' + url)
70
72
  console.log(exception)
71
73
  console.log(jqxhr)
@@ -73,7 +75,36 @@ function require_js(url, success){
73
75
  }
74
76
 
75
77
  function remove_from_array(array, elem){
76
- jQuery.grep(array, function(value) {
78
+ return jQuery.grep(array, function(value) {
77
79
  return value != elem;
78
80
  });
79
81
  }
82
+
83
+ function array_values(hash){
84
+ var tmp_arr = [], key = '';
85
+ for (key in hash) {
86
+ tmp_arr[tmp_arr.length] = hash[key];
87
+ }
88
+
89
+ return tmp_arr;
90
+ }
91
+
92
+ function clean_attr(text){
93
+ //return escape(text).replace(/\%/g, '\\%').replace(/\//g, '\\/').replace(/\./g, '\\.')
94
+ return encodeURIComponent(text)//.replace(/[^\w-_]/g, function(s){return '\\' + s})
95
+ }
96
+
97
+ function uniq(ary) {
98
+ var seen = {};
99
+ return ary.filter(function(elem) {
100
+ var k = elem;
101
+ return (seen[k] === 1) ? 0 : seen[k] = 1;
102
+ })
103
+ }
104
+ function uniqBy(ary, key) {
105
+ var seen = {};
106
+ return ary.filter(function(elem) {
107
+ var k = key(elem);
108
+ return (seen[k] === 1) ? 0 : seen[k] = 1;
109
+ })
110
+ }
@@ -0,0 +1,313 @@
1
+ //Jquery UI
2
+
3
+ (function( $, undefined ) {
4
+
5
+ var uuid = 0,
6
+ runiqueId = /^ui-id-\d+$/;
7
+
8
+ // $.ui might exist from components with no dependencies, e.g., $.ui.position
9
+ $.ui = $.ui || {};
10
+
11
+ $.extend( $.ui, {
12
+ version: "1.10.3",
13
+
14
+ keyCode: {
15
+ BACKSPACE: 8,
16
+ COMMA: 188,
17
+ DELETE: 46,
18
+ DOWN: 40,
19
+ END: 35,
20
+ ENTER: 13,
21
+ ESCAPE: 27,
22
+ HOME: 36,
23
+ LEFT: 37,
24
+ NUMPAD_ADD: 107,
25
+ NUMPAD_DECIMAL: 110,
26
+ NUMPAD_DIVIDE: 111,
27
+ NUMPAD_ENTER: 108,
28
+ NUMPAD_MULTIPLY: 106,
29
+ NUMPAD_SUBTRACT: 109,
30
+ PAGE_DOWN: 34,
31
+ PAGE_UP: 33,
32
+ PERIOD: 190,
33
+ RIGHT: 39,
34
+ SPACE: 32,
35
+ TAB: 9,
36
+ UP: 38
37
+ }
38
+ });
39
+
40
+ // plugins
41
+ $.fn.extend({
42
+ focus: (function( orig ) {
43
+ return function( delay, fn ) {
44
+ return typeof delay === "number" ?
45
+ this.each(function() {
46
+ var elem = this;
47
+ setTimeout(function() {
48
+ $( elem ).focus();
49
+ if ( fn ) {
50
+ fn.call( elem );
51
+ }
52
+ }, delay );
53
+ }) :
54
+ orig.apply( this, arguments );
55
+ };
56
+ })( $.fn.focus ),
57
+
58
+ scrollParent: function() {
59
+ var scrollParent;
60
+ if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
61
+ scrollParent = this.parents().filter(function() {
62
+ return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
63
+ }).eq(0);
64
+ } else {
65
+ scrollParent = this.parents().filter(function() {
66
+ return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
67
+ }).eq(0);
68
+ }
69
+
70
+ return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
71
+ },
72
+
73
+ zIndex: function( zIndex ) {
74
+ if ( zIndex !== undefined ) {
75
+ return this.css( "zIndex", zIndex );
76
+ }
77
+
78
+ if ( this.length ) {
79
+ var elem = $( this[ 0 ] ), position, value;
80
+ while ( elem.length && elem[ 0 ] !== document ) {
81
+ // Ignore z-index if position is set to a value where z-index is ignored by the browser
82
+ // This makes behavior of this function consistent across browsers
83
+ // WebKit always returns auto if the element is positioned
84
+ position = elem.css( "position" );
85
+ if ( position === "absolute" || position === "relative" || position === "fixed" ) {
86
+ // IE returns 0 when zIndex is not specified
87
+ // other browsers return a string
88
+ // we ignore the case of nested elements with an explicit value of 0
89
+ // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
90
+ value = parseInt( elem.css( "zIndex" ), 10 );
91
+ if ( !isNaN( value ) && value !== 0 ) {
92
+ return value;
93
+ }
94
+ }
95
+ elem = elem.parent();
96
+ }
97
+ }
98
+
99
+ return 0;
100
+ },
101
+
102
+ uniqueId: function() {
103
+ return this.each(function() {
104
+ if ( !this.id ) {
105
+ this.id = "ui-id-" + (++uuid);
106
+ }
107
+ });
108
+ },
109
+
110
+ removeUniqueId: function() {
111
+ return this.each(function() {
112
+ if ( runiqueId.test( this.id ) ) {
113
+ $( this ).removeAttr( "id" );
114
+ }
115
+ });
116
+ }
117
+ });
118
+
119
+ // selectors
120
+ function focusable( element, isTabIndexNotNaN ) {
121
+ var map, mapName, img,
122
+ nodeName = element.nodeName.toLowerCase();
123
+ if ( "area" === nodeName ) {
124
+ map = element.parentNode;
125
+ mapName = map.name;
126
+ if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
127
+ return false;
128
+ }
129
+ img = $( "img[usemap=#" + mapName + "]" )[0];
130
+ return !!img && visible( img );
131
+ }
132
+ return ( /input|select|textarea|button|object/.test( nodeName ) ?
133
+ !element.disabled :
134
+ "a" === nodeName ?
135
+ element.href || isTabIndexNotNaN :
136
+ isTabIndexNotNaN) &&
137
+ // the element and all of its ancestors must be visible
138
+ visible( element );
139
+ }
140
+
141
+ function visible( element ) {
142
+ return $.expr.filters.visible( element ) &&
143
+ !$( element ).parents().addBack().filter(function() {
144
+ return $.css( this, "visibility" ) === "hidden";
145
+ }).length;
146
+ }
147
+
148
+ $.extend( $.expr[ ":" ], {
149
+ data: $.expr.createPseudo ?
150
+ $.expr.createPseudo(function( dataName ) {
151
+ return function( elem ) {
152
+ return !!$.data( elem, dataName );
153
+ };
154
+ }) :
155
+ // support: jQuery <1.8
156
+ function( elem, i, match ) {
157
+ return !!$.data( elem, match[ 3 ] );
158
+ },
159
+
160
+ focusable: function( element ) {
161
+ return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
162
+ },
163
+
164
+ tabbable: function( element ) {
165
+ var tabIndex = $.attr( element, "tabindex" ),
166
+ isTabIndexNaN = isNaN( tabIndex );
167
+ return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
168
+ }
169
+ });
170
+
171
+ // support: jQuery <1.8
172
+ if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
173
+ $.each( [ "Width", "Height" ], function( i, name ) {
174
+ var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
175
+ type = name.toLowerCase(),
176
+ orig = {
177
+ innerWidth: $.fn.innerWidth,
178
+ innerHeight: $.fn.innerHeight,
179
+ outerWidth: $.fn.outerWidth,
180
+ outerHeight: $.fn.outerHeight
181
+ };
182
+
183
+ function reduce( elem, size, border, margin ) {
184
+ $.each( side, function() {
185
+ size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
186
+ if ( border ) {
187
+ size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
188
+ }
189
+ if ( margin ) {
190
+ size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
191
+ }
192
+ });
193
+ return size;
194
+ }
195
+
196
+ $.fn[ "inner" + name ] = function( size ) {
197
+ if ( size === undefined ) {
198
+ return orig[ "inner" + name ].call( this );
199
+ }
200
+
201
+ return this.each(function() {
202
+ $( this ).css( type, reduce( this, size ) + "px" );
203
+ });
204
+ };
205
+
206
+ $.fn[ "outer" + name] = function( size, margin ) {
207
+ if ( typeof size !== "number" ) {
208
+ return orig[ "outer" + name ].call( this, size );
209
+ }
210
+
211
+ return this.each(function() {
212
+ $( this).css( type, reduce( this, size, true, margin ) + "px" );
213
+ });
214
+ };
215
+ });
216
+ }
217
+
218
+ // support: jQuery <1.8
219
+ if ( !$.fn.addBack ) {
220
+ $.fn.addBack = function( selector ) {
221
+ return this.add( selector == null ?
222
+ this.prevObject : this.prevObject.filter( selector )
223
+ );
224
+ };
225
+ }
226
+
227
+ // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
228
+ if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
229
+ $.fn.removeData = (function( removeData ) {
230
+ return function( key ) {
231
+ if ( arguments.length ) {
232
+ return removeData.call( this, $.camelCase( key ) );
233
+ } else {
234
+ return removeData.call( this );
235
+ }
236
+ };
237
+ })( $.fn.removeData );
238
+ }
239
+
240
+
241
+
242
+
243
+
244
+ // deprecated
245
+ $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
246
+
247
+ $.support.selectstart = "onselectstart" in document.createElement( "div" );
248
+ $.fn.extend({
249
+ disableSelection: function() {
250
+ return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
251
+ ".ui-disableSelection", function( event ) {
252
+ event.preventDefault();
253
+ });
254
+ },
255
+
256
+ enableSelection: function() {
257
+ return this.unbind( ".ui-disableSelection" );
258
+ }
259
+ });
260
+
261
+ $.extend( $.ui, {
262
+ // $.ui.plugin is deprecated. Use $.widget() extensions instead.
263
+ plugin: {
264
+ add: function( module, option, set ) {
265
+ var i,
266
+ proto = $.ui[ module ].prototype;
267
+ for ( i in set ) {
268
+ proto.plugins[ i ] = proto.plugins[ i ] || [];
269
+ proto.plugins[ i ].push( [ option, set[ i ] ] );
270
+ }
271
+ },
272
+ call: function( instance, name, args ) {
273
+ var i,
274
+ set = instance.plugins[ name ];
275
+ if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
276
+ return;
277
+ }
278
+
279
+ for ( i = 0; i < set.length; i++ ) {
280
+ if ( instance.options[ set[ i ][ 0 ] ] ) {
281
+ set[ i ][ 1 ].apply( instance.element, args );
282
+ }
283
+ }
284
+ }
285
+ },
286
+
287
+ // only used by resizable
288
+ hasScroll: function( el, a ) {
289
+
290
+ //If overflow is hidden, the element might have extra content, but the user wants to hide it
291
+ if ( $( el ).css( "overflow" ) === "hidden") {
292
+ return false;
293
+ }
294
+
295
+ var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
296
+ has = false;
297
+
298
+ if ( el[ scroll ] > 0 ) {
299
+ return true;
300
+ }
301
+
302
+ // TODO: determine which cases actually cause this to happen
303
+ // if the element doesn't have the scroll set, see if it's possible to
304
+ // set the scroll
305
+ el[ scroll ] = 1;
306
+ has = ( el[ scroll ] > 0 );
307
+ el[ scroll ] = 0;
308
+ return has;
309
+ }
310
+ });
311
+
312
+ })( jQuery );
313
+
@@ -0,0 +1,264 @@
1
+ $.widget("rbbt.action_controller", {
2
+
3
+ options: {
4
+ saved: {},
5
+ },
6
+
7
+ _dump: function(){
8
+ localStorage['rbbt.action_controller.saved'] = JSON.stringify(this.options.saved)
9
+ localStorage['rbbt.action_controller.bookmarked'] = JSON.stringify(this.options.bookmarked)
10
+ },
11
+
12
+ _load: function(){
13
+ if (undefined === localStorage['rbbt.action_controller.bookmarked']){
14
+ this.options.saved = {};
15
+ this.options.bookmarked = []
16
+ this._dump();
17
+ }else{
18
+ this.options.saved = JSON.parse(localStorage['rbbt.action_controller.saved'])
19
+ this.options.bookmarked = JSON.parse(localStorage['rbbt.action_controller.bookmarked'])
20
+ }
21
+ },
22
+
23
+ _untrack: function(url){
24
+ this.options.bookmarked = remove_from_array(this.options.bookmarked, url);
25
+ this._dump();
26
+ this._update_jobs();
27
+ },
28
+
29
+ _track: function(){
30
+ var url = this._url();
31
+ if ($.inArray(url, this.options.bookmarked) == -1){
32
+ this.options.bookmarked.push(url);
33
+ }
34
+ this._dump();
35
+ this._update_jobs();
36
+ },
37
+
38
+ _update_jobs: function(){
39
+ var job_list = $('#top_menu .user ul.jobs')
40
+ job_list.html("")
41
+ for(i in this.options.bookmarked){
42
+ var url = this.options.bookmarked[i];
43
+
44
+ var action = url.split('?')[0].split("/")[3]
45
+ var element = url.split('?')[0].split("/")[4]
46
+
47
+ action = unescape(action)
48
+ element = unescape(element)
49
+ var name = [action, element].join(" - ");
50
+ var a = $('<a>').attr('href', url).html(name);
51
+ var li = $('<li>').append(a);
52
+
53
+ var icon = $('<i class="general foundicon-minus">')
54
+ var remove = $('<a class=remove_element></a>').append(icon)
55
+ li.prepend(remove)
56
+
57
+ job_list.append(li);
58
+ }
59
+ this._update_flag()
60
+ },
61
+
62
+ _toogle_track: function(){
63
+ if (this.element.find('ul.controls > li.url.bookmarked').length > 0){
64
+ this._untrack(this._url());
65
+ }else{
66
+ this._track();
67
+ }
68
+ },
69
+
70
+ _create: function() {
71
+ var tool = this
72
+ var controller = tool.element;
73
+
74
+ controller.on('click', '> ul.actions li', function(e){ tool._activate_action(this); return false});
75
+ controller.on('click', '> ul.controls > li.reload', function(e){ tool._reload_action(this); return false});
76
+ controller.on('click', '> ul.controls > li.parameters', function(e){ tool._display_parameters(this); return false});
77
+ controller.on('click', '> ul.controls > li.pin', function(e){ tool._toggle_pin(this); return false});
78
+ controller.on('click', '> ul.controls > li.url', function(e){ tool._toogle_track(this); return false});
79
+ $('#top_menu li.user ul.jobs').on('click', 'a.remove_element', function(){
80
+ var link = $(this).next('a')
81
+ tool._untrack(link.attr('href'))
82
+ })
83
+
84
+ this.options.controller = controller
85
+ this.options.action_controls = controller.find('> ul.controls')
86
+ this.options.action_list = controller.find('> ul.actions')
87
+
88
+ this.options.complete = function(jqXHR, textStatus){
89
+ var action_controller = tool.options.controller
90
+ var action_list_item = action_controller.find('li.loading, li.active')
91
+ var action_div = action_controller.next('.action_loader');
92
+
93
+ if (jqXHR.status == 202){
94
+ action_controller.removeClass('active').addClass('loading');
95
+ action_list_item.removeClass('active').addClass('loading');
96
+
97
+ var response = $(jqXHR.responseText)
98
+ var stat = response.find('span.status').html()
99
+ var message = response.find('ul.step_messages li:first').html()
100
+
101
+ if (undefined === message){
102
+ action_div.html("<span class='loading'>Loading [" + stat + "] ...</span>");
103
+ }else{
104
+ action_div.html("<span class='loading'>Loading [" + stat + ": " + message + "] ...</span>");
105
+ };
106
+
107
+ }else{
108
+ action_controller.removeClass('loading').addClass('active');
109
+ action_list_item.removeClass('loading').addClass('active');
110
+
111
+ action_controller.find('ul.controls > li.reload').addClass('active');
112
+ }
113
+
114
+ var action_div = action_controller.next('.action_loader').first();
115
+ action_controller.find('ul.controls > li.url').addClass('active');
116
+ if (action_div.find('> .action_card > .action_parameters').length > 0){
117
+ action_controller.find('ul.controls > li.parameters').addClass('active');
118
+ action_controller.find('ul.controls > li.pin').addClass('active');
119
+ }else{
120
+ action_controller.find('ul.controls > li.parameters').removeClass('active');
121
+ action_controller.find('ul.controls > li.pin').removeClass('active');
122
+ }
123
+ }
124
+
125
+ this._load();
126
+ this._update_jobs();
127
+ },
128
+
129
+ _update_flag: function(){
130
+ if ($.inArray(this._url(), this.options.bookmarked) != -1){
131
+ $(this.element).find('> ul.controls > li.url').addClass('bookmarked')
132
+ }else{
133
+ $(this.element).find('> ul.controls > li.url').removeClass('bookmarked')
134
+ }
135
+ },
136
+
137
+ _activate_action: function(e){
138
+ var action_list_item = $(e)
139
+ var action_list = action_list_item.parent('ul.actions');
140
+ var link = action_list_item.find('> a')
141
+
142
+ this._load_action(link);
143
+
144
+ var action = link.html()
145
+ if (this.options.saved[action] !== undefined){
146
+ $(this.element).find('> ul.controls > li.pin').addClass('saved')
147
+ }else{
148
+ $(this.element).find('> ul.controls > li.pin').removeClass('saved')
149
+ }
150
+
151
+ this._update_flag()
152
+
153
+ action_list.addClass('active');
154
+
155
+ return false
156
+ },
157
+
158
+ _unpin_parameters: function(){
159
+ var controller = $(this.element)
160
+ var action = controller.find('ul.actions li.active a').first().html()
161
+ this.options.saved[action] = undefined
162
+ controller.find('> ul.controls > li.pin').removeClass('saved')
163
+ },
164
+
165
+ _pin_parameters: function(){
166
+ var controller = $(this.element)
167
+ var action = $(this.element).find('ul.actions li.active a').first().html()
168
+ var loader = $(this.element).next('.action_loader').first();
169
+ this.options.saved[action] = loader.attr('form-params')
170
+ controller.find('> ul.controls > li.pin').addClass('saved')
171
+ this._dump()
172
+ },
173
+
174
+ _toggle_pin: function(){
175
+ var action = $(this.element).find('ul.actions li.active a').first().html()
176
+
177
+ if (this.options.saved[action] != undefined){
178
+ this._unpin_parameters();
179
+ }else{
180
+ this._pin_parameters();
181
+ }
182
+ },
183
+
184
+ _loader: function(){
185
+ return $(this.element).next('.action_loader')
186
+ },
187
+
188
+ _url: function(){
189
+ var url = this._loader().attr('target-href');
190
+ if (undefined === url){ return url}
191
+ return unescape(remove_parameter(url, '_'))
192
+ },
193
+
194
+ _open_url: function(){
195
+ var action_controller = this.element
196
+ var action_div = action_controller.next('.action_loader').first();
197
+
198
+ if (this._url() !== undefined){
199
+ window.location = this._url();
200
+ }
201
+
202
+ return false
203
+ },
204
+
205
+
206
+ _reload_action: function(e){
207
+ if(! $(e).hasClass('active')){ return false}
208
+ var action_list_item = $(e);
209
+ var action_list = action_list_item.parent('ul.controls');
210
+ var action_controller = action_list.parent('.action_controller');
211
+ var action_div = action_controller.next('.action_loader').first();
212
+
213
+ if (action_div.attr('target-href') != undefined){
214
+ update_embedded(action_div, true, this.options.complete)
215
+ }
216
+
217
+ return false
218
+ },
219
+
220
+ _display_parameters: function(e){
221
+ if(! $(e).hasClass('active')){ return false}
222
+ var link = $(e);
223
+ var action_controller = link.parents('.action_controller').first()
224
+ var action_loader = action_controller.next('.action_loader').first();
225
+ var action_parameters = action_loader.find('.action_parameters').first();
226
+ var action_content = action_parameters.next('.action_content').first();
227
+
228
+ action_parameters.toggleClass('active');
229
+ action_content.toggleClass('shifted');
230
+
231
+ $.scrollTo(this.element, {axis:'y', offset:{top: -$("#top_menu").height() - 20}})
232
+
233
+ return false
234
+ },
235
+
236
+ _load_action: function(link){
237
+ var action_list_item = link.parent('li');
238
+ var action_list = action_list_item.parent('ul');
239
+ var action_controller = action_list.parents('.action_controller').first();
240
+ var action_div = action_controller.next('.action_loader');
241
+ var href = link.attr('href')
242
+
243
+ var action = link.html()
244
+ var saved = this.options.saved[action]
245
+
246
+ if (undefined !== saved){
247
+ href = add_parameters(href, saved)
248
+ }
249
+
250
+
251
+ if( ! action_div.hasClass('reloading') ) {
252
+ action_div.removeClass('active');
253
+ action_controller.find('ul.controls > li.reload').removeClass('active');
254
+ action_controller.find('ul.controls > li.parameters').removeClass('active');
255
+ action_list.find('li').removeClass('active').removeClass('loading');
256
+ action_list_item.addClass('loading');
257
+ action_controller.addClass('loading');
258
+ replace_object(action_div, href, true, this.options.complete);
259
+
260
+ return false
261
+ }
262
+ }
263
+ })
264
+