pushnote 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rspec +3 -0
  4. data/README.md +11 -30
  5. data/Rakefile +20 -0
  6. data/bin/pushnote +20 -2
  7. data/config.codekit +1005 -0
  8. data/config.ru +2 -0
  9. data/config/database.yml +17 -0
  10. data/db/migrate/20150131202537_create_notes_table.rb +9 -0
  11. data/db/schema.rb +23 -0
  12. data/lib/pushnote.rb +0 -3
  13. data/lib/pushnote/adapters.rb +1 -0
  14. data/lib/pushnote/adapters/base.rb +7 -0
  15. data/lib/pushnote/adapters/local.rb +17 -0
  16. data/lib/pushnote/app.rb +50 -0
  17. data/lib/pushnote/models/note.rb +4 -0
  18. data/lib/pushnote/public/css/foundation.css +6139 -0
  19. data/lib/pushnote/public/css/foundation.min.css +1 -0
  20. data/lib/pushnote/public/css/normalize.css +427 -0
  21. data/lib/pushnote/public/humans.txt +8 -0
  22. data/lib/pushnote/public/img/.gitkeep +1 -0
  23. data/lib/pushnote/public/index.html +166 -0
  24. data/lib/pushnote/public/js/foundation.min.js +5960 -0
  25. data/lib/pushnote/public/js/foundation/foundation.abide.js +318 -0
  26. data/lib/pushnote/public/js/foundation/foundation.accordion.js +67 -0
  27. data/lib/pushnote/public/js/foundation/foundation.alert.js +43 -0
  28. data/lib/pushnote/public/js/foundation/foundation.clearing.js +558 -0
  29. data/lib/pushnote/public/js/foundation/foundation.dropdown.js +439 -0
  30. data/lib/pushnote/public/js/foundation/foundation.equalizer.js +73 -0
  31. data/lib/pushnote/public/js/foundation/foundation.interchange.js +348 -0
  32. data/lib/pushnote/public/js/foundation/foundation.joyride.js +924 -0
  33. data/lib/pushnote/public/js/foundation/foundation.js +690 -0
  34. data/lib/pushnote/public/js/foundation/foundation.magellan.js +198 -0
  35. data/lib/pushnote/public/js/foundation/foundation.offcanvas.js +152 -0
  36. data/lib/pushnote/public/js/foundation/foundation.orbit.js +472 -0
  37. data/lib/pushnote/public/js/foundation/foundation.reveal.js +449 -0
  38. data/lib/pushnote/public/js/foundation/foundation.slider.js +267 -0
  39. data/lib/pushnote/public/js/foundation/foundation.tab.js +217 -0
  40. data/lib/pushnote/public/js/foundation/foundation.tooltip.js +300 -0
  41. data/lib/pushnote/public/js/foundation/foundation.topbar.js +445 -0
  42. data/lib/pushnote/public/js/vendor/fastclick.js +9 -0
  43. data/lib/pushnote/public/js/vendor/jquery.cookie.js +8 -0
  44. data/lib/pushnote/public/js/vendor/jquery.js +26 -0
  45. data/lib/pushnote/public/js/vendor/modernizr.js +8 -0
  46. data/lib/pushnote/public/js/vendor/placeholder.js +2 -0
  47. data/lib/pushnote/public/robots.txt +4 -0
  48. data/lib/pushnote/version.rb +1 -1
  49. data/lib/pushnote/views/index.erb +15 -0
  50. data/lib/pushnote/views/layout.erb +48 -0
  51. data/lib/pushnote/views/show.erb +8 -0
  52. data/pushnote.gemspec +15 -5
  53. data/spec/lib/controllers/notes_spec.rb +21 -0
  54. data/spec/spec_helper.rb +16 -0
  55. metadata +193 -9
  56. data/.pushnote.yml +0 -1
  57. data/lib/pushnote/cli.rb +0 -40
  58. data/lib/pushnote/configuration.rb +0 -12
  59. data/lib/pushnote/note.rb +0 -36
@@ -0,0 +1,198 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs['magellan-expedition'] = {
5
+ name : 'magellan-expedition',
6
+
7
+ version : '5.5.0',
8
+
9
+ settings : {
10
+ active_class: 'active',
11
+ threshold: 0, // pixels from the top of the expedition for it to become fixes
12
+ destination_threshold: 20, // pixels from the top of destination for it to be considered active
13
+ throttle_delay: 30, // calculation throttling to increase framerate
14
+ fixed_top: 0, // top distance in pixels assigend to the fixed element on scroll
15
+ offset_by_height: true, // whether to offset the destination by the expedition height. Usually you want this to be true, unless your expedition is on the side.
16
+ duration: 700, // animation duration time
17
+ easing: 'swing' // animation easing
18
+ },
19
+
20
+ init : function (scope, method, options) {
21
+ Foundation.inherit(this, 'throttle');
22
+ this.bindings(method, options);
23
+ },
24
+
25
+ events : function () {
26
+ var self = this,
27
+ S = self.S,
28
+ settings = self.settings;
29
+
30
+ // initialize expedition offset
31
+ self.set_expedition_position();
32
+
33
+ S(self.scope)
34
+ .off('.magellan')
35
+ .on('click.fndtn.magellan', '[' + self.add_namespace('data-magellan-arrival') + '] a[href^="#"]', function (e) {
36
+ e.preventDefault();
37
+ var expedition = $(this).closest('[' + self.attr_name() + ']'),
38
+ settings = expedition.data('magellan-expedition-init'),
39
+ hash = this.hash.split('#').join(''),
40
+ target = $('a[name="'+hash+'"]');
41
+
42
+ if (target.length === 0) {
43
+ target = $('#'+hash);
44
+
45
+ }
46
+
47
+
48
+ // Account for expedition height if fixed position
49
+ var scroll_top = target.offset().top - settings.destination_threshold + 1;
50
+ if (settings.offset_by_height) {
51
+ scroll_top = scroll_top - expedition.outerHeight();
52
+ }
53
+
54
+ $('html, body').stop().animate({
55
+ 'scrollTop': scroll_top
56
+ }, settings.duration, settings.easing, function () {
57
+ if(history.pushState) {
58
+ history.pushState(null, null, '#'+hash);
59
+ }
60
+ else {
61
+ location.hash = '#'+hash;
62
+ }
63
+ });
64
+ })
65
+ .on('scroll.fndtn.magellan', self.throttle(this.check_for_arrivals.bind(this), settings.throttle_delay));
66
+
67
+ $(window)
68
+ .on('resize.fndtn.magellan', self.throttle(this.set_expedition_position.bind(this), settings.throttle_delay));
69
+ },
70
+
71
+ check_for_arrivals : function() {
72
+ var self = this;
73
+ self.update_arrivals();
74
+ self.update_expedition_positions();
75
+ },
76
+
77
+ set_expedition_position : function() {
78
+ var self = this;
79
+ $('[' + this.attr_name() + '=fixed]', self.scope).each(function(idx, el) {
80
+ var expedition = $(this),
81
+ settings = expedition.data('magellan-expedition-init'),
82
+ styles = expedition.attr('styles'), // save styles
83
+ top_offset, fixed_top;
84
+
85
+ expedition.attr('style', '');
86
+ top_offset = expedition.offset().top + settings.threshold;
87
+
88
+ //set fixed-top by attribute
89
+ fixed_top = parseInt(expedition.data('magellan-fixed-top'));
90
+ if(!isNaN(fixed_top))
91
+ self.settings.fixed_top = fixed_top;
92
+
93
+ expedition.data(self.data_attr('magellan-top-offset'), top_offset);
94
+ expedition.attr('style', styles);
95
+ });
96
+ },
97
+
98
+ update_expedition_positions : function() {
99
+ var self = this,
100
+ window_top_offset = $(window).scrollTop();
101
+
102
+ $('[' + this.attr_name() + '=fixed]', self.scope).each(function() {
103
+ var expedition = $(this),
104
+ settings = expedition.data('magellan-expedition-init'),
105
+ styles = expedition.attr('style'), // save styles
106
+ top_offset = expedition.data('magellan-top-offset');
107
+
108
+ //scroll to the top distance
109
+ if (window_top_offset+self.settings.fixed_top >= top_offset) {
110
+ // Placeholder allows height calculations to be consistent even when
111
+ // appearing to switch between fixed/non-fixed placement
112
+ var placeholder = expedition.prev('[' + self.add_namespace('data-magellan-expedition-clone') + ']');
113
+ if (placeholder.length === 0) {
114
+ placeholder = expedition.clone();
115
+ placeholder.removeAttr(self.attr_name());
116
+ placeholder.attr(self.add_namespace('data-magellan-expedition-clone'),'');
117
+ expedition.before(placeholder);
118
+ }
119
+ expedition.css({position:'fixed', top: settings.fixed_top}).addClass('fixed');
120
+ } else {
121
+ expedition.prev('[' + self.add_namespace('data-magellan-expedition-clone') + ']').remove();
122
+ expedition.attr('style',styles).css('position','').css('top','').removeClass('fixed');
123
+ }
124
+ });
125
+ },
126
+
127
+ update_arrivals : function() {
128
+ var self = this,
129
+ window_top_offset = $(window).scrollTop();
130
+
131
+ $('[' + this.attr_name() + ']', self.scope).each(function() {
132
+ var expedition = $(this),
133
+ settings = expedition.data(self.attr_name(true) + '-init'),
134
+ offsets = self.offsets(expedition, window_top_offset),
135
+ arrivals = expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']'),
136
+ active_item = false;
137
+ offsets.each(function(idx, item) {
138
+ if (item.viewport_offset >= item.top_offset) {
139
+ var arrivals = expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']');
140
+ arrivals.not(item.arrival).removeClass(settings.active_class);
141
+ item.arrival.addClass(settings.active_class);
142
+ active_item = true;
143
+ return true;
144
+ }
145
+ });
146
+
147
+ if (!active_item) arrivals.removeClass(settings.active_class);
148
+ });
149
+ },
150
+
151
+ offsets : function(expedition, window_offset) {
152
+ var self = this,
153
+ settings = expedition.data(self.attr_name(true) + '-init'),
154
+ viewport_offset = window_offset;
155
+
156
+ return expedition.find('[' + self.add_namespace('data-magellan-arrival') + ']').map(function(idx, el) {
157
+ var name = $(this).data(self.data_attr('magellan-arrival')),
158
+ dest = $('[' + self.add_namespace('data-magellan-destination') + '=' + name + ']');
159
+ if (dest.length > 0) {
160
+ var top_offset = dest.offset().top - settings.destination_threshold;
161
+ if (settings.offset_by_height) {
162
+ top_offset = top_offset - expedition.outerHeight();
163
+ }
164
+ top_offset = Math.floor(top_offset);
165
+ return {
166
+ destination : dest,
167
+ arrival : $(this),
168
+ top_offset : top_offset,
169
+ viewport_offset : viewport_offset
170
+ }
171
+ }
172
+ }).sort(function(a, b) {
173
+ if (a.top_offset < b.top_offset) return -1;
174
+ if (a.top_offset > b.top_offset) return 1;
175
+ return 0;
176
+ });
177
+ },
178
+
179
+ data_attr: function (str) {
180
+ if (this.namespace.length > 0) {
181
+ return this.namespace + '-' + str;
182
+ }
183
+
184
+ return str;
185
+ },
186
+
187
+ off : function () {
188
+ this.S(this.scope).off('.magellan');
189
+ this.S(window).off('.magellan');
190
+ },
191
+
192
+ reflow : function () {
193
+ var self = this;
194
+ // remove placeholder expeditions used for height calculation purposes
195
+ $('[' + self.add_namespace('data-magellan-expedition-clone') + ']', self.scope).remove();
196
+ }
197
+ };
198
+ }(jQuery, window, window.document));
@@ -0,0 +1,152 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ Foundation.libs.offcanvas = {
5
+ name : 'offcanvas',
6
+
7
+ version : '5.5.0',
8
+
9
+ settings : {
10
+ open_method: 'move',
11
+ close_on_click: false
12
+ },
13
+
14
+ init : function (scope, method, options) {
15
+ this.bindings(method, options);
16
+ },
17
+
18
+ events : function () {
19
+ var self = this,
20
+ S = self.S,
21
+ move_class = '',
22
+ right_postfix = '',
23
+ left_postfix = '';
24
+
25
+ if (this.settings.open_method === 'move') {
26
+ move_class = 'move-';
27
+ right_postfix = 'right';
28
+ left_postfix = 'left';
29
+ } else if (this.settings.open_method === 'overlap_single') {
30
+ move_class = 'offcanvas-overlap-';
31
+ right_postfix = 'right';
32
+ left_postfix = 'left';
33
+ } else if (this.settings.open_method === 'overlap') {
34
+ move_class = 'offcanvas-overlap';
35
+ }
36
+
37
+ S(this.scope).off('.offcanvas')
38
+ .on('click.fndtn.offcanvas', '.left-off-canvas-toggle', function (e) {
39
+ self.click_toggle_class(e, move_class + right_postfix);
40
+ if (self.settings.open_method !== 'overlap'){
41
+ S('.left-submenu').removeClass(move_class + right_postfix);
42
+ }
43
+ $('.left-off-canvas-toggle').attr('aria-expanded', 'true');
44
+ })
45
+ .on('click.fndtn.offcanvas', '.left-off-canvas-menu a', function (e) {
46
+ var settings = self.get_settings(e);
47
+ var parent = S(this).parent();
48
+
49
+ if(settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')){
50
+ self.hide.call(self, move_class + right_postfix, self.get_wrapper(e));
51
+ parent.parent().removeClass(move_class + right_postfix);
52
+ }else if(S(this).parent().hasClass('has-submenu')){
53
+ e.preventDefault();
54
+ S(this).siblings('.left-submenu').toggleClass(move_class + right_postfix);
55
+ }else if(parent.hasClass('back')){
56
+ e.preventDefault();
57
+ parent.parent().removeClass(move_class + right_postfix);
58
+ }
59
+ $('.left-off-canvas-toggle').attr('aria-expanded', 'true');
60
+ })
61
+ .on('click.fndtn.offcanvas', '.right-off-canvas-toggle', function (e) {
62
+ self.click_toggle_class(e, move_class + left_postfix);
63
+ if (self.settings.open_method !== 'overlap'){
64
+ S('.right-submenu').removeClass(move_class + left_postfix);
65
+ }
66
+ $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
67
+ })
68
+ .on('click.fndtn.offcanvas', '.right-off-canvas-menu a', function (e) {
69
+ var settings = self.get_settings(e);
70
+ var parent = S(this).parent();
71
+
72
+ if(settings.close_on_click && !parent.hasClass('has-submenu') && !parent.hasClass('back')){
73
+ self.hide.call(self, move_class + left_postfix, self.get_wrapper(e));
74
+ parent.parent().removeClass(move_class + left_postfix);
75
+ }else if(S(this).parent().hasClass('has-submenu')){
76
+ e.preventDefault();
77
+ S(this).siblings('.right-submenu').toggleClass(move_class + left_postfix);
78
+ }else if(parent.hasClass('back')){
79
+ e.preventDefault();
80
+ parent.parent().removeClass(move_class + left_postfix);
81
+ }
82
+ $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
83
+ })
84
+ .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
85
+ self.click_remove_class(e, move_class + left_postfix);
86
+ S('.right-submenu').removeClass(move_class + left_postfix);
87
+ if (right_postfix){
88
+ self.click_remove_class(e, move_class + right_postfix);
89
+ S('.left-submenu').removeClass(move_class + left_postfix);
90
+ }
91
+ $('.right-off-canvas-toggle').attr('aria-expanded', 'true');
92
+ })
93
+ .on('click.fndtn.offcanvas', '.exit-off-canvas', function (e) {
94
+ self.click_remove_class(e, move_class + left_postfix);
95
+ $('.left-off-canvas-toggle').attr('aria-expanded', 'false');
96
+ if (right_postfix) {
97
+ self.click_remove_class(e, move_class + right_postfix);
98
+ $('.right-off-canvas-toggle').attr('aria-expanded', 'false');
99
+ }
100
+ });
101
+ },
102
+
103
+ toggle: function(class_name, $off_canvas) {
104
+ $off_canvas = $off_canvas || this.get_wrapper();
105
+ if ($off_canvas.is('.' + class_name)) {
106
+ this.hide(class_name, $off_canvas);
107
+ } else {
108
+ this.show(class_name, $off_canvas);
109
+ }
110
+ },
111
+
112
+ show: function(class_name, $off_canvas) {
113
+ $off_canvas = $off_canvas || this.get_wrapper();
114
+ $off_canvas.trigger('open').trigger('open.fndtn.offcanvas');
115
+ $off_canvas.addClass(class_name);
116
+ },
117
+
118
+ hide: function(class_name, $off_canvas) {
119
+ $off_canvas = $off_canvas || this.get_wrapper();
120
+ $off_canvas.trigger('close').trigger('close.fndtn.offcanvas');
121
+ $off_canvas.removeClass(class_name);
122
+ },
123
+
124
+ click_toggle_class: function(e, class_name) {
125
+ e.preventDefault();
126
+ var $off_canvas = this.get_wrapper(e);
127
+ this.toggle(class_name, $off_canvas);
128
+ },
129
+
130
+ click_remove_class: function(e, class_name) {
131
+ e.preventDefault();
132
+ var $off_canvas = this.get_wrapper(e);
133
+ this.hide(class_name, $off_canvas);
134
+ },
135
+
136
+ get_settings: function(e) {
137
+ var offcanvas = this.S(e.target).closest('[' + this.attr_name() + ']');
138
+ return offcanvas.data(this.attr_name(true) + '-init') || this.settings;
139
+ },
140
+
141
+ get_wrapper: function(e) {
142
+ var $off_canvas = this.S(e ? e.target : this.scope).closest('.off-canvas-wrap');
143
+
144
+ if ($off_canvas.length === 0) {
145
+ $off_canvas = this.S('.off-canvas-wrap');
146
+ }
147
+ return $off_canvas;
148
+ },
149
+
150
+ reflow : function () {}
151
+ };
152
+ }(jQuery, window, window.document));
@@ -0,0 +1,472 @@
1
+ ;(function ($, window, document, undefined) {
2
+ 'use strict';
3
+
4
+ var noop = function() {};
5
+
6
+ var Orbit = function(el, settings) {
7
+ // Don't reinitialize plugin
8
+ if (el.hasClass(settings.slides_container_class)) {
9
+ return this;
10
+ }
11
+
12
+ var self = this,
13
+ container,
14
+ slides_container = el,
15
+ number_container,
16
+ bullets_container,
17
+ timer_container,
18
+ idx = 0,
19
+ animate,
20
+ timer,
21
+ locked = false,
22
+ adjust_height_after = false;
23
+
24
+
25
+ self.slides = function() {
26
+ return slides_container.children(settings.slide_selector);
27
+ };
28
+
29
+ self.slides().first().addClass(settings.active_slide_class);
30
+
31
+ self.update_slide_number = function(index) {
32
+ if (settings.slide_number) {
33
+ number_container.find('span:first').text(parseInt(index)+1);
34
+ number_container.find('span:last').text(self.slides().length);
35
+ }
36
+ if (settings.bullets) {
37
+ bullets_container.children().removeClass(settings.bullets_active_class);
38
+ $(bullets_container.children().get(index)).addClass(settings.bullets_active_class);
39
+ }
40
+ };
41
+
42
+ self.update_active_link = function(index) {
43
+ var link = $('[data-orbit-link="'+self.slides().eq(index).attr('data-orbit-slide')+'"]');
44
+ link.siblings().removeClass(settings.bullets_active_class);
45
+ link.addClass(settings.bullets_active_class);
46
+ };
47
+
48
+ self.build_markup = function() {
49
+ slides_container.wrap('<div class="'+settings.container_class+'"></div>');
50
+ container = slides_container.parent();
51
+ slides_container.addClass(settings.slides_container_class);
52
+
53
+ if (settings.stack_on_small) {
54
+ container.addClass(settings.stack_on_small_class);
55
+ }
56
+
57
+ if (settings.navigation_arrows) {
58
+ container.append($('<a href="#"><span></span></a>').addClass(settings.prev_class));
59
+ container.append($('<a href="#"><span></span></a>').addClass(settings.next_class));
60
+ }
61
+
62
+ if (settings.timer) {
63
+ timer_container = $('<div>').addClass(settings.timer_container_class);
64
+ timer_container.append('<span>');
65
+ timer_container.append($('<div>').addClass(settings.timer_progress_class));
66
+ timer_container.addClass(settings.timer_paused_class);
67
+ container.append(timer_container);
68
+ }
69
+
70
+ if (settings.slide_number) {
71
+ number_container = $('<div>').addClass(settings.slide_number_class);
72
+ number_container.append('<span></span> ' + settings.slide_number_text + ' <span></span>');
73
+ container.append(number_container);
74
+ }
75
+
76
+ if (settings.bullets) {
77
+ bullets_container = $('<ol>').addClass(settings.bullets_container_class);
78
+ container.append(bullets_container);
79
+ bullets_container.wrap('<div class="orbit-bullets-container"></div>');
80
+ self.slides().each(function(idx, el) {
81
+ var bullet = $('<li>').attr('data-orbit-slide', idx).on('click', self.link_bullet);;
82
+ bullets_container.append(bullet);
83
+ });
84
+ }
85
+
86
+ };
87
+
88
+ self._goto = function(next_idx, start_timer) {
89
+ // if (locked) {return false;}
90
+ if (next_idx === idx) {return false;}
91
+ if (typeof timer === 'object') {timer.restart();}
92
+ var slides = self.slides();
93
+
94
+ var dir = 'next';
95
+ locked = true;
96
+ if (next_idx < idx) {dir = 'prev';}
97
+ if (next_idx >= slides.length) {
98
+ if (!settings.circular) return false;
99
+ next_idx = 0;
100
+ } else if (next_idx < 0) {
101
+ if (!settings.circular) return false;
102
+ next_idx = slides.length - 1;
103
+ }
104
+
105
+ var current = $(slides.get(idx));
106
+ var next = $(slides.get(next_idx));
107
+
108
+ current.css('zIndex', 2);
109
+ current.removeClass(settings.active_slide_class);
110
+ next.css('zIndex', 4).addClass(settings.active_slide_class);
111
+
112
+ slides_container.trigger('before-slide-change.fndtn.orbit');
113
+ settings.before_slide_change();
114
+ self.update_active_link(next_idx);
115
+
116
+ var callback = function() {
117
+ var unlock = function() {
118
+ idx = next_idx;
119
+ locked = false;
120
+ if (start_timer === true) {timer = self.create_timer(); timer.start();}
121
+ self.update_slide_number(idx);
122
+ slides_container.trigger('after-slide-change.fndtn.orbit',[{slide_number: idx, total_slides: slides.length}]);
123
+ settings.after_slide_change(idx, slides.length);
124
+ };
125
+ if (slides_container.height() != next.height() && settings.variable_height) {
126
+ slides_container.animate({'height': next.height()}, 250, 'linear', unlock);
127
+ } else {
128
+ unlock();
129
+ }
130
+ };
131
+
132
+ if (slides.length === 1) {callback(); return false;}
133
+
134
+ var start_animation = function() {
135
+ if (dir === 'next') {animate.next(current, next, callback);}
136
+ if (dir === 'prev') {animate.prev(current, next, callback);}
137
+ };
138
+
139
+ if (next.height() > slides_container.height() && settings.variable_height) {
140
+ slides_container.animate({'height': next.height()}, 250, 'linear', start_animation);
141
+ } else {
142
+ start_animation();
143
+ }
144
+ };
145
+
146
+ self.next = function(e) {
147
+ e.stopImmediatePropagation();
148
+ e.preventDefault();
149
+ self._goto(idx + 1);
150
+ };
151
+
152
+ self.prev = function(e) {
153
+ e.stopImmediatePropagation();
154
+ e.preventDefault();
155
+ self._goto(idx - 1);
156
+ };
157
+
158
+ self.link_custom = function(e) {
159
+ e.preventDefault();
160
+ var link = $(this).attr('data-orbit-link');
161
+ if ((typeof link === 'string') && (link = $.trim(link)) != '') {
162
+ var slide = container.find('[data-orbit-slide='+link+']');
163
+ if (slide.index() != -1) {self._goto(slide.index());}
164
+ }
165
+ };
166
+
167
+ self.link_bullet = function(e) {
168
+ var index = $(this).attr('data-orbit-slide');
169
+ if ((typeof index === 'string') && (index = $.trim(index)) != '') {
170
+ if(isNaN(parseInt(index)))
171
+ {
172
+ var slide = container.find('[data-orbit-slide='+index+']');
173
+ if (slide.index() != -1) {self._goto(slide.index() + 1);}
174
+ }
175
+ else
176
+ {
177
+ self._goto(parseInt(index));
178
+ }
179
+ }
180
+
181
+ }
182
+
183
+ self.timer_callback = function() {
184
+ self._goto(idx + 1, true);
185
+ }
186
+
187
+ self.compute_dimensions = function() {
188
+ var current = $(self.slides().get(idx));
189
+ var h = current.height();
190
+ if (!settings.variable_height) {
191
+ self.slides().each(function(){
192
+ if ($(this).height() > h) { h = $(this).height(); }
193
+ });
194
+ }
195
+ slides_container.height(h);
196
+ };
197
+
198
+ self.create_timer = function() {
199
+ var t = new Timer(
200
+ container.find('.'+settings.timer_container_class),
201
+ settings,
202
+ self.timer_callback
203
+ );
204
+ return t;
205
+ };
206
+
207
+ self.stop_timer = function() {
208
+ if (typeof timer === 'object') timer.stop();
209
+ };
210
+
211
+ self.toggle_timer = function() {
212
+ var t = container.find('.'+settings.timer_container_class);
213
+ if (t.hasClass(settings.timer_paused_class)) {
214
+ if (typeof timer === 'undefined') {timer = self.create_timer();}
215
+ timer.start();
216
+ }
217
+ else {
218
+ if (typeof timer === 'object') {timer.stop();}
219
+ }
220
+ };
221
+
222
+ self.init = function() {
223
+ self.build_markup();
224
+ if (settings.timer) {
225
+ timer = self.create_timer();
226
+ Foundation.utils.image_loaded(this.slides().children('img'), timer.start);
227
+ }
228
+ animate = new FadeAnimation(settings, slides_container);
229
+ if (settings.animation === 'slide')
230
+ animate = new SlideAnimation(settings, slides_container);
231
+
232
+ container.on('click', '.'+settings.next_class, self.next);
233
+ container.on('click', '.'+settings.prev_class, self.prev);
234
+
235
+ if (settings.next_on_click) {
236
+ container.on('click', '.'+settings.slides_container_class+' [data-orbit-slide]', self.link_bullet);
237
+ }
238
+
239
+ container.on('click', self.toggle_timer);
240
+ if (settings.swipe) {
241
+ container.on('touchstart.fndtn.orbit', function(e) {
242
+ if (!e.touches) {e = e.originalEvent;}
243
+ var data = {
244
+ start_page_x: e.touches[0].pageX,
245
+ start_page_y: e.touches[0].pageY,
246
+ start_time: (new Date()).getTime(),
247
+ delta_x: 0,
248
+ is_scrolling: undefined
249
+ };
250
+ container.data('swipe-transition', data);
251
+ e.stopPropagation();
252
+ })
253
+ .on('touchmove.fndtn.orbit', function(e) {
254
+ if (!e.touches) { e = e.originalEvent; }
255
+ // Ignore pinch/zoom events
256
+ if(e.touches.length > 1 || e.scale && e.scale !== 1) return;
257
+
258
+ var data = container.data('swipe-transition');
259
+ if (typeof data === 'undefined') {data = {};}
260
+
261
+ data.delta_x = e.touches[0].pageX - data.start_page_x;
262
+
263
+ if ( typeof data.is_scrolling === 'undefined') {
264
+ data.is_scrolling = !!( data.is_scrolling || Math.abs(data.delta_x) < Math.abs(e.touches[0].pageY - data.start_page_y) );
265
+ }
266
+
267
+ if (!data.is_scrolling && !data.active) {
268
+ e.preventDefault();
269
+ var direction = (data.delta_x < 0) ? (idx+1) : (idx-1);
270
+ data.active = true;
271
+ self._goto(direction);
272
+ }
273
+ })
274
+ .on('touchend.fndtn.orbit', function(e) {
275
+ container.data('swipe-transition', {});
276
+ e.stopPropagation();
277
+ })
278
+ }
279
+ container.on('mouseenter.fndtn.orbit', function(e) {
280
+ if (settings.timer && settings.pause_on_hover) {
281
+ self.stop_timer();
282
+ }
283
+ })
284
+ .on('mouseleave.fndtn.orbit', function(e) {
285
+ if (settings.timer && settings.resume_on_mouseout) {
286
+ timer.start();
287
+ }
288
+ });
289
+
290
+ $(document).on('click', '[data-orbit-link]', self.link_custom);
291
+ $(window).on('load resize', self.compute_dimensions);
292
+ Foundation.utils.image_loaded(this.slides().children('img'), self.compute_dimensions);
293
+ Foundation.utils.image_loaded(this.slides().children('img'), function() {
294
+ container.prev('.'+settings.preloader_class).css('display', 'none');
295
+ self.update_slide_number(0);
296
+ self.update_active_link(0);
297
+ slides_container.trigger('ready.fndtn.orbit');
298
+ });
299
+ };
300
+
301
+ self.init();
302
+ };
303
+
304
+ var Timer = function(el, settings, callback) {
305
+ var self = this,
306
+ duration = settings.timer_speed,
307
+ progress = el.find('.'+settings.timer_progress_class),
308
+ start,
309
+ timeout,
310
+ left = -1;
311
+
312
+ this.update_progress = function(w) {
313
+ var new_progress = progress.clone();
314
+ new_progress.attr('style', '');
315
+ new_progress.css('width', w+'%');
316
+ progress.replaceWith(new_progress);
317
+ progress = new_progress;
318
+ };
319
+
320
+ this.restart = function() {
321
+ clearTimeout(timeout);
322
+ el.addClass(settings.timer_paused_class);
323
+ left = -1;
324
+ self.update_progress(0);
325
+ };
326
+
327
+ this.start = function() {
328
+ if (!el.hasClass(settings.timer_paused_class)) {return true;}
329
+ left = (left === -1) ? duration : left;
330
+ el.removeClass(settings.timer_paused_class);
331
+ start = new Date().getTime();
332
+ progress.animate({'width': '100%'}, left, 'linear');
333
+ timeout = setTimeout(function() {
334
+ self.restart();
335
+ callback();
336
+ }, left);
337
+ el.trigger('timer-started.fndtn.orbit')
338
+ };
339
+
340
+ this.stop = function() {
341
+ if (el.hasClass(settings.timer_paused_class)) {return true;}
342
+ clearTimeout(timeout);
343
+ el.addClass(settings.timer_paused_class);
344
+ var end = new Date().getTime();
345
+ left = left - (end - start);
346
+ var w = 100 - ((left / duration) * 100);
347
+ self.update_progress(w);
348
+ el.trigger('timer-stopped.fndtn.orbit');
349
+ };
350
+ };
351
+
352
+ var SlideAnimation = function(settings, container) {
353
+ var duration = settings.animation_speed;
354
+ var is_rtl = ($('html[dir=rtl]').length === 1);
355
+ var margin = is_rtl ? 'marginRight' : 'marginLeft';
356
+ var animMargin = {};
357
+ animMargin[margin] = '0%';
358
+
359
+ this.next = function(current, next, callback) {
360
+ current.animate({marginLeft:'-100%'}, duration);
361
+ next.animate(animMargin, duration, function() {
362
+ current.css(margin, '100%');
363
+ callback();
364
+ });
365
+ };
366
+
367
+ this.prev = function(current, prev, callback) {
368
+ current.animate({marginLeft:'100%'}, duration);
369
+ prev.css(margin, '-100%');
370
+ prev.animate(animMargin, duration, function() {
371
+ current.css(margin, '100%');
372
+ callback();
373
+ });
374
+ };
375
+ };
376
+
377
+ var FadeAnimation = function(settings, container) {
378
+ var duration = settings.animation_speed;
379
+ var is_rtl = ($('html[dir=rtl]').length === 1);
380
+ var margin = is_rtl ? 'marginRight' : 'marginLeft';
381
+
382
+ this.next = function(current, next, callback) {
383
+ next.css({'margin':'0%', 'opacity':'0.01'});
384
+ next.animate({'opacity':'1'}, duration, 'linear', function() {
385
+ current.css('margin', '100%');
386
+ callback();
387
+ });
388
+ };
389
+
390
+ this.prev = function(current, prev, callback) {
391
+ prev.css({'margin':'0%', 'opacity':'0.01'});
392
+ prev.animate({'opacity':'1'}, duration, 'linear', function() {
393
+ current.css('margin', '100%');
394
+ callback();
395
+ });
396
+ };
397
+ };
398
+
399
+
400
+ Foundation.libs = Foundation.libs || {};
401
+
402
+ Foundation.libs.orbit = {
403
+ name: 'orbit',
404
+
405
+ version: '5.5.0',
406
+
407
+ settings: {
408
+ animation: 'slide',
409
+ timer_speed: 10000,
410
+ pause_on_hover: true,
411
+ resume_on_mouseout: false,
412
+ next_on_click: true,
413
+ animation_speed: 500,
414
+ stack_on_small: false,
415
+ navigation_arrows: true,
416
+ slide_number: true,
417
+ slide_number_text: 'of',
418
+ container_class: 'orbit-container',
419
+ stack_on_small_class: 'orbit-stack-on-small',
420
+ next_class: 'orbit-next',
421
+ prev_class: 'orbit-prev',
422
+ timer_container_class: 'orbit-timer',
423
+ timer_paused_class: 'paused',
424
+ timer_progress_class: 'orbit-progress',
425
+ slides_container_class: 'orbit-slides-container',
426
+ preloader_class: 'preloader',
427
+ slide_selector: '*',
428
+ bullets_container_class: 'orbit-bullets',
429
+ bullets_active_class: 'active',
430
+ slide_number_class: 'orbit-slide-number',
431
+ caption_class: 'orbit-caption',
432
+ active_slide_class: 'active',
433
+ orbit_transition_class: 'orbit-transitioning',
434
+ bullets: true,
435
+ circular: true,
436
+ timer: true,
437
+ variable_height: false,
438
+ swipe: true,
439
+ before_slide_change: noop,
440
+ after_slide_change: noop
441
+ },
442
+
443
+ init : function (scope, method, options) {
444
+ var self = this;
445
+ this.bindings(method, options);
446
+ },
447
+
448
+ events : function (instance) {
449
+ var orbit_instance = new Orbit(this.S(instance), this.S(instance).data('orbit-init'));
450
+ this.S(instance).data(this.name + '-instance', orbit_instance);
451
+ },
452
+
453
+ reflow : function () {
454
+ var self = this;
455
+
456
+ if (self.S(self.scope).is('[data-orbit]')) {
457
+ var $el = self.S(self.scope);
458
+ var instance = $el.data(self.name + '-instance');
459
+ instance.compute_dimensions();
460
+ } else {
461
+ self.S('[data-orbit]', self.scope).each(function(idx, el) {
462
+ var $el = self.S(el);
463
+ var opts = self.data_options($el);
464
+ var instance = $el.data(self.name + '-instance');
465
+ instance.compute_dimensions();
466
+ });
467
+ }
468
+ }
469
+ };
470
+
471
+
472
+ }(jQuery, window, window.document));