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,330 @@
1
+ /*jslint unparam: true, browser: true, indent: 2 */
2
+
3
+ ;(function ($, window, document, undefined) {
4
+ 'use strict';
5
+
6
+ Foundation.libs.reveal = {
7
+ name : 'reveal',
8
+
9
+ version : '4.2.2',
10
+
11
+ locked : false,
12
+
13
+ settings : {
14
+ animation: 'fadeAndPop',
15
+ animationSpeed: 250,
16
+ closeOnBackgroundClick: true,
17
+ closeOnEsc: true,
18
+ dismissModalClass: 'close-reveal-modal',
19
+ bgClass: 'reveal-modal-bg',
20
+ open: function(){},
21
+ opened: function(){},
22
+ close: function(){},
23
+ closed: function(){},
24
+ bg : $('.reveal-modal-bg'),
25
+ css : {
26
+ open : {
27
+ 'opacity': 0,
28
+ 'visibility': 'visible',
29
+ 'display' : 'block'
30
+ },
31
+ close : {
32
+ 'opacity': 1,
33
+ 'visibility': 'hidden',
34
+ 'display': 'none'
35
+ }
36
+ }
37
+ },
38
+
39
+ init : function (scope, method, options) {
40
+ Foundation.inherit(this, 'data_options delay');
41
+
42
+ if (typeof method === 'object') {
43
+ $.extend(true, this.settings, method);
44
+ } else if (typeof options !== 'undefined') {
45
+ $.extend(true, this.settings, options);
46
+ }
47
+
48
+ if (typeof method !== 'string') {
49
+ this.events();
50
+
51
+ return this.settings.init;
52
+ } else {
53
+ return this[method].call(this, options);
54
+ }
55
+ },
56
+
57
+ events : function () {
58
+ var self = this;
59
+
60
+ $(this.scope)
61
+ .off('.fndtn.reveal')
62
+ .on('click.fndtn.reveal', '[data-reveal-id]', function (e) {
63
+ e.preventDefault();
64
+
65
+ if (!self.locked) {
66
+ var element = $(this),
67
+ ajax = element.data('reveal-ajax');
68
+
69
+ self.locked = true;
70
+
71
+ if (typeof ajax === 'undefined') {
72
+ self.open.call(self, element);
73
+ } else {
74
+ var url = ajax === true ? element.attr('href') : ajax;
75
+
76
+ self.open.call(self, element, {url: url});
77
+ }
78
+ }
79
+ })
80
+ .on('click.fndtn.reveal', this.close_targets(), function (e) {
81
+ e.preventDefault();
82
+ if (!self.locked) {
83
+ var settings = $.extend({}, self.settings, self.data_options($('.reveal-modal.open')));
84
+ if ($(e.target)[0] === $('.' + settings.bgClass)[0] && !settings.closeOnBackgroundClick) {
85
+ return;
86
+ }
87
+
88
+ self.locked = true;
89
+ self.close.call(self, $(this).closest('.reveal-modal'));
90
+ }
91
+ })
92
+ .on('open.fndtn.reveal', '.reveal-modal', this.settings.open)
93
+ .on('opened.fndtn.reveal', '.reveal-modal', this.settings.opened)
94
+ .on('opened.fndtn.reveal', '.reveal-modal', this.open_video)
95
+ .on('close.fndtn.reveal', '.reveal-modal', this.settings.close)
96
+ .on('closed.fndtn.reveal', '.reveal-modal', this.settings.closed)
97
+ .on('closed.fndtn.reveal', '.reveal-modal', this.close_video);
98
+
99
+ $( 'body' ).bind( 'keyup.reveal', function ( event ) {
100
+ var open_modal = $('.reveal-modal.open'),
101
+ settings = $.extend({}, self.settings, self.data_options(open_modal));
102
+ if ( event.which === 27 && settings.closeOnEsc) { // 27 is the keycode for the Escape key
103
+ open_modal.foundation('reveal', 'close');
104
+ }
105
+ });
106
+
107
+ return true;
108
+ },
109
+
110
+ open : function (target, ajax_settings) {
111
+ if (target) {
112
+ if (typeof target.selector !== 'undefined') {
113
+ var modal = $('#' + target.data('reveal-id'));
114
+ } else {
115
+ var modal = $(this.scope);
116
+
117
+ ajax_settings = target;
118
+ }
119
+ } else {
120
+ var modal = $(this.scope);
121
+ }
122
+
123
+ if (!modal.hasClass('open')) {
124
+ var open_modal = $('.reveal-modal.open');
125
+
126
+ if (typeof modal.data('css-top') === 'undefined') {
127
+ modal.data('css-top', parseInt(modal.css('top'), 10))
128
+ .data('offset', this.cache_offset(modal));
129
+ }
130
+
131
+ modal.trigger('open');
132
+
133
+ if (open_modal.length < 1) {
134
+ this.toggle_bg(modal);
135
+ }
136
+
137
+ if (typeof ajax_settings === 'undefined' || !ajax_settings.url) {
138
+ this.hide(open_modal, this.settings.css.close);
139
+ this.show(modal, this.settings.css.open);
140
+ } else {
141
+ var self = this,
142
+ old_success = typeof ajax_settings.success !== 'undefined' ? ajax_settings.success : null;
143
+
144
+ $.extend(ajax_settings, {
145
+ success: function (data, textStatus, jqXHR) {
146
+ if ( $.isFunction(old_success) ) {
147
+ old_success(data, textStatus, jqXHR);
148
+ }
149
+
150
+ modal.html(data);
151
+ $(modal).foundation('section', 'reflow');
152
+
153
+ self.hide(open_modal, self.settings.css.close);
154
+ self.show(modal, self.settings.css.open);
155
+ }
156
+ });
157
+
158
+ $.ajax(ajax_settings);
159
+ }
160
+ }
161
+ },
162
+
163
+ close : function (modal) {
164
+
165
+ var modal = modal && modal.length ? modal : $(this.scope),
166
+ open_modals = $('.reveal-modal.open');
167
+
168
+ if (open_modals.length > 0) {
169
+ this.locked = true;
170
+ modal.trigger('close');
171
+ this.toggle_bg(modal);
172
+ this.hide(open_modals, this.settings.css.close);
173
+ }
174
+ },
175
+
176
+ close_targets : function () {
177
+ var base = '.' + this.settings.dismissModalClass;
178
+
179
+ if (this.settings.closeOnBackgroundClick) {
180
+ return base + ', .' + this.settings.bgClass;
181
+ }
182
+
183
+ return base;
184
+ },
185
+
186
+ toggle_bg : function (modal) {
187
+ if ($('.reveal-modal-bg').length === 0) {
188
+ this.settings.bg = $('<div />', {'class': this.settings.bgClass})
189
+ .appendTo('body');
190
+ }
191
+
192
+ if (this.settings.bg.filter(':visible').length > 0) {
193
+ this.hide(this.settings.bg);
194
+ } else {
195
+ this.show(this.settings.bg);
196
+ }
197
+ },
198
+
199
+ show : function (el, css) {
200
+ // is modal
201
+ if (css) {
202
+ if (/pop/i.test(this.settings.animation)) {
203
+ css.top = $(window).scrollTop() - el.data('offset') + 'px';
204
+ var end_css = {
205
+ top: $(window).scrollTop() + el.data('css-top') + 'px',
206
+ opacity: 1
207
+ };
208
+
209
+ return this.delay(function () {
210
+ return el
211
+ .css(css)
212
+ .animate(end_css, this.settings.animationSpeed, 'linear', function () {
213
+ this.locked = false;
214
+ el.trigger('opened');
215
+ }.bind(this))
216
+ .addClass('open');
217
+ }.bind(this), this.settings.animationSpeed / 2);
218
+ }
219
+
220
+ if (/fade/i.test(this.settings.animation)) {
221
+ var end_css = {opacity: 1};
222
+
223
+ return this.delay(function () {
224
+ return el
225
+ .css(css)
226
+ .animate(end_css, this.settings.animationSpeed, 'linear', function () {
227
+ this.locked = false;
228
+ el.trigger('opened');
229
+ }.bind(this))
230
+ .addClass('open');
231
+ }.bind(this), this.settings.animationSpeed / 2);
232
+ }
233
+
234
+ return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened');
235
+ }
236
+
237
+ // should we animate the background?
238
+ if (/fade/i.test(this.settings.animation)) {
239
+ return el.fadeIn(this.settings.animationSpeed / 2);
240
+ }
241
+
242
+ return el.show();
243
+ },
244
+
245
+ hide : function (el, css) {
246
+ // is modal
247
+ if (css) {
248
+ if (/pop/i.test(this.settings.animation)) {
249
+ var end_css = {
250
+ top: - $(window).scrollTop() - el.data('offset') + 'px',
251
+ opacity: 0
252
+ };
253
+
254
+ return this.delay(function () {
255
+ return el
256
+ .animate(end_css, this.settings.animationSpeed, 'linear', function () {
257
+ this.locked = false;
258
+ el.css(css).trigger('closed');
259
+ }.bind(this))
260
+ .removeClass('open');
261
+ }.bind(this), this.settings.animationSpeed / 2);
262
+ }
263
+
264
+ if (/fade/i.test(this.settings.animation)) {
265
+ var end_css = {opacity: 0};
266
+
267
+ return this.delay(function () {
268
+ return el
269
+ .animate(end_css, this.settings.animationSpeed, 'linear', function () {
270
+ this.locked = false;
271
+ el.css(css).trigger('closed');
272
+ }.bind(this))
273
+ .removeClass('open');
274
+ }.bind(this), this.settings.animationSpeed / 2);
275
+ }
276
+
277
+ return el.hide().css(css).removeClass('open').trigger('closed');
278
+ }
279
+
280
+ // should we animate the background?
281
+ if (/fade/i.test(this.settings.animation)) {
282
+ return el.fadeOut(this.settings.animationSpeed / 2);
283
+ }
284
+
285
+ return el.hide();
286
+ },
287
+
288
+ close_video : function (e) {
289
+ var video = $(this).find('.flex-video'),
290
+ iframe = video.find('iframe');
291
+
292
+ if (iframe.length > 0) {
293
+ iframe.attr('data-src', iframe[0].src);
294
+ iframe.attr('src', 'about:blank');
295
+ video.hide();
296
+ }
297
+ },
298
+
299
+ open_video : function (e) {
300
+ var video = $(this).find('.flex-video'),
301
+ iframe = video.find('iframe');
302
+
303
+ if (iframe.length > 0) {
304
+ var data_src = iframe.attr('data-src');
305
+ if (typeof data_src === 'string') {
306
+ iframe[0].src = iframe.attr('data-src');
307
+ } else {
308
+ var src = iframe[0].src;
309
+ iframe[0].src = undefined;
310
+ iframe[0].src = src;
311
+ }
312
+ video.show();
313
+ }
314
+ },
315
+
316
+ cache_offset : function (modal) {
317
+ var offset = modal.show().height() + parseInt(modal.css('top'), 10);
318
+
319
+ modal.hide();
320
+
321
+ return offset;
322
+ },
323
+
324
+ off : function () {
325
+ $(this.scope).off('.fndtn.reveal');
326
+ },
327
+
328
+ reflow : function () {}
329
+ };
330
+ }(Foundation.zj, this, this.document));
@@ -0,0 +1,400 @@
1
+ /*jslint unparam: true, browser: true, indent: 2 */
2
+
3
+ ;
4
+ (function($, window, document) {
5
+ 'use strict';
6
+
7
+ Foundation.libs.section = {
8
+ name : 'section',
9
+
10
+ version : '4.3.1',
11
+
12
+ settings: {
13
+ deep_linking: false,
14
+ small_breakpoint: 768,
15
+ one_up: true,
16
+ section_selector: '[data-section]',
17
+ region_selector: 'section, .section, [data-section-region]',
18
+ title_selector: '.title, [data-section-title]',
19
+ //marker: container is resized
20
+ resized_data_attr: 'data-section-resized',
21
+ //marker: container should apply accordion style
22
+ small_style_data_attr: 'data-section-small-style',
23
+ content_selector: '.content, [data-section-content]',
24
+ nav_selector: '[data-section="vertical-nav"], [data-section="horizontal-nav"]',
25
+ active_class: 'active',
26
+ callback: function() {}
27
+ },
28
+
29
+ init: function(scope, method, options) {
30
+ var self = this;
31
+ Foundation.inherit(this, 'throttle data_options position_right offset_right');
32
+
33
+ if (typeof method === 'object') {
34
+ $.extend(true, self.settings, method);
35
+ }
36
+
37
+ if (typeof method !== 'string') {
38
+ this.events();
39
+ return true;
40
+ } else {
41
+ return this[method].call(this, options);
42
+ }
43
+ },
44
+
45
+ events: function() {
46
+ var self = this;
47
+
48
+ //combine titles selector from settings for click event binding
49
+ var click_title_selectors = [],
50
+ section_selector = self.settings.section_selector,
51
+ region_selectors = self.settings.region_selector.split(","),
52
+ title_selectors = self.settings.title_selector.split(",");
53
+
54
+ for (var i = 0, len = region_selectors.length; i < len; i++) {
55
+ var region_selector = region_selectors[i];
56
+
57
+ for (var j = 0, len1 = title_selectors.length; j < len1; j++) {
58
+ var title_selector = section_selector + ">" + region_selector + ">" + title_selectors[j];
59
+
60
+ click_title_selectors.push(title_selector + " a"); //or we can not do preventDefault for click event of <a>
61
+ click_title_selectors.push(title_selector);
62
+ }
63
+ }
64
+
65
+ $(self.scope)
66
+ .on('click.fndtn.section', click_title_selectors.join(","), function(e) {
67
+ var title = $(this).closest(self.settings.title_selector);
68
+
69
+ self.close_navs(title);
70
+ if (title.siblings(self.settings.content_selector).length > 0) {
71
+ self.toggle_active.call(title[0], e);
72
+ }
73
+ });
74
+
75
+ $(window)
76
+ .on('resize.fndtn.section', self.throttle(function() { self.resize(); }, 30))
77
+ .on('hashchange.fndtn.section', self.set_active_from_hash);
78
+
79
+ $(document).on('click.fndtn.section', function (e) {
80
+ if (e.isPropagationStopped && e.isPropagationStopped()) return;
81
+ if (e.target === document) return;
82
+ self.close_navs($(e.target).closest(self.settings.title_selector));
83
+ });
84
+
85
+ $(window).triggerHandler('resize.fndtn.section');
86
+ $(window).triggerHandler('hashchange.fndtn.section');
87
+ },
88
+
89
+ //close nav !one_up on click elsewhere
90
+ close_navs: function(except_nav_with_title) {
91
+ var self = Foundation.libs.section,
92
+ navsToClose = $(self.settings.nav_selector)
93
+ .filter(function() { return !$.extend({},
94
+ self.settings, self.data_options($(this))).one_up; });
95
+
96
+ if (except_nav_with_title.length > 0) {
97
+ var section = except_nav_with_title.parent().parent();
98
+
99
+ if (self.is_horizontal_nav(section) || self.is_vertical_nav(section)) {
100
+ //exclude current nav from list
101
+ navsToClose = navsToClose.filter(function() { return this !== section[0]; });
102
+ }
103
+ }
104
+ //close navs on click on title
105
+ navsToClose.children(self.settings.region_selector).removeClass(self.settings.active_class);
106
+ },
107
+
108
+ toggle_active: function(e) {
109
+ var $this = $(this),
110
+ self = Foundation.libs.section,
111
+ region = $this.parent(),
112
+ content = $this.siblings(self.settings.content_selector),
113
+ section = region.parent(),
114
+ settings = $.extend({}, self.settings, self.data_options(section)),
115
+ prev_active_region = section.children(self.settings.region_selector).filter("." + self.settings.active_class);
116
+
117
+ //for anchors inside [data-section-title]
118
+ if (!settings.deep_linking && content.length > 0) {
119
+ e.preventDefault();
120
+ }
121
+
122
+ e.stopPropagation(); //do not catch same click again on parent
123
+
124
+ if (!region.hasClass(self.settings.active_class)) {
125
+ prev_active_region.removeClass(self.settings.active_class);
126
+ region.addClass(self.settings.active_class);
127
+ //force resize for better performance (do not wait timer)
128
+ self.resize(region.find(self.settings.section_selector).not("[" + self.settings.resized_data_attr + "]"), true);
129
+ } else if (!settings.one_up && (self.small(section) || self.is_vertical_nav(section) || self.is_horizontal_nav(section) || self.is_accordion(section))) {
130
+ region.removeClass(self.settings.active_class);
131
+ }
132
+ settings.callback(section);
133
+ },
134
+
135
+ check_resize_timer: null,
136
+
137
+ //main function that sets title and content positions; runs for :not(.resized) and :visible once when window width is medium up
138
+ //sections:
139
+ // selected sections to resize, are defined on resize forced by visibility changes
140
+ //ensure_has_active_region:
141
+ // is true when we force resize for no resized sections that were hidden and became visible,
142
+ // these sections can have no selected region, because all regions were hidden along with section on executing set_active_from_hash
143
+ resize: function(sections, ensure_has_active_region) {
144
+
145
+ var self = Foundation.libs.section,
146
+ is_small_window = self.small($(document)),
147
+ //filter for section resize
148
+ should_be_resized = function (section, now_is_hidden) {
149
+ return !self.is_accordion(section) &&
150
+ !section.is("[" + self.settings.resized_data_attr + "]") &&
151
+ (!is_small_window || self.is_horizontal_tabs(section)) &&
152
+ now_is_hidden === (section.css('display') === 'none' ||
153
+ !section.parent().is(':visible'));
154
+ };
155
+
156
+ sections = sections || $(self.settings.section_selector);
157
+
158
+ clearTimeout(self.check_resize_timer);
159
+
160
+ if (!is_small_window) {
161
+ sections.removeAttr(self.settings.small_style_data_attr);
162
+ }
163
+
164
+ //resize
165
+ sections.filter(function() { return should_be_resized($(this), false); })
166
+ .each(function() {
167
+ var section = $(this),
168
+ regions = section.children(self.settings.region_selector),
169
+ titles = regions.children(self.settings.title_selector),
170
+ content = regions.children(self.settings.content_selector),
171
+ titles_max_height = 0;
172
+
173
+ if (ensure_has_active_region &&
174
+ section.children(self.settings.region_selector).filter("." + self.settings.active_class).length == 0) {
175
+ var settings = $.extend({}, self.settings, self.data_options(section));
176
+
177
+ if (!settings.deep_linking && (settings.one_up || !self.is_horizontal_nav(section) &&
178
+ !self.is_vertical_nav(section) && !self.is_accordion(section))) {
179
+ regions.filter(":visible").first().addClass(self.settings.active_class);
180
+ }
181
+ }
182
+
183
+ if (self.is_horizontal_tabs(section) || self.is_auto(section)) {
184
+ // region: position relative
185
+ // title: position absolute
186
+ // content: position static
187
+ var titles_sum_width = 0;
188
+
189
+ titles.each(function() {
190
+ var title = $(this);
191
+
192
+ if (title.is(":visible")) {
193
+ title.css(!self.rtl ? 'left' : 'right', titles_sum_width);
194
+ var title_h_border_width = parseInt(title.css("border-" + (self.rtl ? 'left' : 'right') + "-width"), 10);
195
+
196
+ if (title_h_border_width.toString() === 'Nan') {
197
+ title_h_border_width = 0;
198
+ }
199
+
200
+ titles_sum_width += self.outerWidth(title) - title_h_border_width;
201
+ titles_max_height = Math.max(titles_max_height, self.outerHeight(title));
202
+ }
203
+ });
204
+ titles.css('height', titles_max_height);
205
+ regions.each(function() {
206
+ var region = $(this),
207
+ region_content = region.children(self.settings.content_selector),
208
+ content_top_border_width = parseInt(region_content.css("border-top-width"), 10);
209
+
210
+ if (content_top_border_width.toString() === 'Nan') {
211
+ content_top_border_width = 0;
212
+ }
213
+
214
+ region.css('padding-top', titles_max_height - content_top_border_width);
215
+ });
216
+
217
+ section.css("min-height", titles_max_height);
218
+ } else if (self.is_horizontal_nav(section)) {
219
+ var first = true;
220
+ // region: positon relative, float left
221
+ // title: position static
222
+ // content: position absolute
223
+ titles.each(function() {
224
+ titles_max_height = Math.max(titles_max_height, self.outerHeight($(this)));
225
+ });
226
+
227
+ regions.each(function() {
228
+ var region = $(this);
229
+
230
+ region.css("margin-left", "-" + (first ? section : region.children(self.settings.title_selector)).css("border-left-width"));
231
+ first = false;
232
+ });
233
+
234
+ regions.css("margin-top", "-" + section.css("border-top-width"));
235
+ titles.css('height', titles_max_height);
236
+ content.css('top', titles_max_height);
237
+ section.css("min-height", titles_max_height);
238
+ } else if (self.is_vertical_tabs(section)) {
239
+ var titles_sum_height = 0;
240
+ // region: position relative, for .active: fixed padding==title.width
241
+ // title: fixed width, position absolute
242
+ // content: position static
243
+ titles.each(function() {
244
+ var title = $(this);
245
+
246
+ if (title.is(":visible")) {
247
+ title.css('top', titles_sum_height);
248
+ var title_top_border_width = parseInt(title.css("border-top-width"), 10);
249
+
250
+ if (title_top_border_width.toString() === 'Nan') {
251
+ title_top_border_width = 0;
252
+ }
253
+
254
+ titles_sum_height += self.outerHeight(title) - title_top_border_width;
255
+ }
256
+ });
257
+
258
+ content.css('min-height', titles_sum_height + 1);
259
+ } else if (self.is_vertical_nav(section)) {
260
+ var titles_max_width = 0,
261
+ first1 = true;
262
+ // region: positon relative
263
+ // title: position static
264
+ // content: position absolute
265
+ titles.each(function() {
266
+ titles_max_width = Math.max(titles_max_width, self.outerWidth($(this)));
267
+ });
268
+
269
+ regions.each(function () {
270
+ var region = $(this);
271
+
272
+ region.css("margin-top", "-" + (first1 ? section : region.children(self.settings.title_selector)).css("border-top-width"));
273
+ first1 = false;
274
+ });
275
+
276
+ titles.css('width', titles_max_width);
277
+ content.css(!self.rtl ? 'left' : 'right', titles_max_width);
278
+ section.css('width', titles_max_width);
279
+ }
280
+
281
+ section.attr(self.settings.resized_data_attr, true);
282
+ });
283
+
284
+ //wait elements to become visible then resize
285
+ if ($(self.settings.section_selector).filter(function() { return should_be_resized($(this), true); }).length > 0)
286
+ self.check_resize_timer = setTimeout(function() {
287
+ self.resize(sections.filter(function() { return should_be_resized($(this), false); }), true);
288
+ }, 700);
289
+
290
+ if (is_small_window) {
291
+ sections.attr(self.settings.small_style_data_attr, true);
292
+ }
293
+ },
294
+
295
+ is_vertical_nav: function(el) {
296
+ return /vertical-nav/i.test(el.data('section'));
297
+ },
298
+
299
+ is_horizontal_nav: function(el) {
300
+ return /horizontal-nav/i.test(el.data('section'));
301
+ },
302
+
303
+ is_accordion: function(el) {
304
+ return /accordion/i.test(el.data('section'));
305
+ },
306
+
307
+ is_horizontal_tabs: function(el) {
308
+ return /^tabs$/i.test(el.data('section'));
309
+ },
310
+
311
+ is_vertical_tabs: function(el) {
312
+ return /vertical-tabs/i.test(el.data('section'));
313
+ },
314
+
315
+ is_auto: function (el) {
316
+ var data_section = el.data('section');
317
+ return data_section === '' || /auto/i.test(data_section);
318
+ },
319
+
320
+ set_active_from_hash: function() {
321
+ var self = Foundation.libs.section,
322
+ hash = window.location.hash.substring(1),
323
+ sections = $(self.settings.section_selector);
324
+
325
+ sections.each(function() {
326
+ var section = $(this),
327
+ settings = $.extend({}, self.settings, self.data_options(section)),
328
+ regions = section.children(self.settings.region_selector),
329
+ set_active_from_hash = settings.deep_linking && hash.length > 0,
330
+ selected = false;
331
+
332
+ regions.each(function() {
333
+ var region = $(this);
334
+
335
+ if (selected) {
336
+ region.removeClass(self.settings.active_class);
337
+ } else if (set_active_from_hash) {
338
+ var data_slug = region.children(self.settings.content_selector).data('slug');
339
+
340
+ if (data_slug && new RegExp(data_slug, 'i').test(hash)) {
341
+ if (!region.hasClass(self.settings.active_class))
342
+ region.addClass(self.settings.active_class);
343
+ selected = true;
344
+ } else {
345
+ region.removeClass(self.settings.active_class);
346
+ }
347
+ } else if (region.hasClass(self.settings.active_class)) {
348
+ selected = true;
349
+ }
350
+ });
351
+
352
+ if (!selected && !settings.deep_linking && (settings.one_up || !self.is_horizontal_nav(section) &&
353
+ !self.is_vertical_nav(section) && !self.is_accordion(section)))
354
+ regions.filter(":visible").first().addClass(self.settings.active_class);
355
+ });
356
+ },
357
+
358
+ reflow: function() {
359
+ var self = Foundation.libs.section;
360
+
361
+ $(self.settings.section_selector).removeAttr(self.settings.resized_data_attr);
362
+ self.throttle(function() { self.resize(); }, 30)();
363
+ },
364
+
365
+ small: function(el) {
366
+ var settings = $.extend({}, this.settings, this.data_options(el));
367
+
368
+ if (this.is_horizontal_tabs(el)) {
369
+ return false;
370
+ }
371
+ if (el && this.is_accordion(el)) {
372
+ return true;
373
+ }
374
+ if ($('html').hasClass('lt-ie9')) {
375
+ return true;
376
+ }
377
+ if ($('html').hasClass('ie8compat')) {
378
+ return true;
379
+ }
380
+ return $(this.scope).width() < settings.small_breakpoint;
381
+ },
382
+
383
+ off: function() {
384
+ $(this.scope).off('.fndtn.section');
385
+ $(window).off('.fndtn.section');
386
+ $(document).off('.fndtn.section');
387
+ }
388
+ };
389
+
390
+ //resize selected sections
391
+ $.fn.reflow_section = function(ensure_has_active_region) {
392
+ var section = this,
393
+ self = Foundation.libs.section;
394
+
395
+ section.removeAttr(self.settings.resized_data_attr);
396
+ self.throttle(function() { self.resize(section, ensure_has_active_region); }, 30)();
397
+ return this;
398
+ };
399
+
400
+ }(Foundation.zj, window, document));