pageflow-progress-navigation-bar 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NWI2M2IyODk5ZmM1YmVhMGMwODBkZWE5OTFhYTZlODNhMGFkODM3Yw==
5
+ data.tar.gz: !binary |-
6
+ OWMwODE2OGU3ZWU0MTYyNjg3NzI5MTc1MDQwZWM1MTM3YTY5YmM5Mg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZmVkODdjNTJlNjcyOTE5YThkN2RlYzNjNTIxMDViYjg3MWY5ZjdiYzc3ODY5
10
+ NDBmYzU3YTQyZjdhMjU5MzliZGJjYzBjYmMwNmE2MWVlZGFiM2I0NTZhMWQ4
11
+ ZTFiYzI5Zjk1NjMzYWMyNjg0NTUwMjQ2NDNiOTVlNzAyOWIyZGQ=
12
+ data.tar.gz: !binary |-
13
+ OTVjMmUzNWVmNmM3MzY4ZmQ2ZTdkYjUxNTkzOTNiZmE0MDYwYTcyYWVlOWYx
14
+ NGQ3MjZjMzIwOWVlNzc4NmM3MDA2NDg5OWY0Y2M4YjlmOTVjZjkwNzk5N2I3
15
+ YjY3ZDQwY2ZlZDczNzBkNTRjMjMxOTI0MWRjZDUyYjY4NDg1Y2Y=
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ *.sqlite3
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ .idea
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ log
20
+ Gemfile.lock
21
+
22
+ .localeapp
data/.jshintrc ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "browser": true,
3
+ "undef": true,
4
+ "immed": true,
5
+ "trailing": true,
6
+ "globals": {
7
+ "jQuery": true,
8
+ "$": true,
9
+ "Backbone": true,
10
+ "_": true,
11
+ "I18n": true,
12
+
13
+ "pageflow": true,
14
+
15
+ "confirm": true,
16
+ "alert": true
17
+ }
18
+ }
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # CHANGELOG
2
+
3
+ ### Version 0.1.0
4
+
5
+ 2015-02-03
6
+
7
+ Initial release.
8
+
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chart.gemspec
4
+ gemspec
5
+
6
+ # Rails 4 compat
7
+ gem 'activeadmin', git: 'https://github.com/codevise/active_admin.git', branch: 'rails4'
8
+ gem 'ransack'
9
+ gem 'inherited_resources', '1.4.1'
10
+ gem 'formtastic', '2.3.0.rc2'
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Pageflow Progress Navigation Bar
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/pageflow-progress-navigation-bar.svg)](http://badge.fury.io/rb/pageflow-progress-navigation-bar)
4
+
5
+ A navigation bar resembling a progress bar.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's `Gemfile`:
10
+
11
+ gem 'pageflow-progress-navigation-bar'
12
+
13
+ Register the widget type inside the configure block in `config/initializers/pageflow.rb`
14
+
15
+ Pageflow.configure do |config|
16
+ config.widget_types.register(Pageflow::ProgressNavigationBar.widget_type)
17
+ end
18
+
19
+ Include javascripts and stylesheets:
20
+
21
+ # app/assets/javascripts/pageflow/application.js
22
+ //= require pageflow/progress_navigation_bar
23
+
24
+ # app/assets/stylesheets/pageflow/application.css.scss
25
+ @import "pageflow/progress_navigation_bar";
26
+
27
+ # Adding basic style to your theme
28
+ # app/assets/stylesheets/pageflow/themes/default.css.scss
29
+ @import "pageflow/progress_navigation_bar/themes/default";
30
+
31
+ Execute `bundle install` Restart the application server.
32
+
33
+ ## Troubleshooting
34
+
35
+ If you run into problems while installing the page type, please also refer to the
36
+ [Troubleshooting](https://github.com/codevise/pageflow/wiki/Troubleshooting) wiki
37
+ page in the [Pageflow repository](https://github.com/codevise/pageflow). If that
38
+ doesn't help, consider
39
+ [filing an issue](https://github.com/codevise/pageflow-progress-navigation-bar/issues).
40
+
41
+ ## Contributing Locales
42
+
43
+ Edit the translations directly on the
44
+ [pageflow-progress-navigation-bar](http://www.localeapp.com/projects/public?search=tf/pageflow-progress-navigation-bar)
45
+ locale project.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,8 @@
1
+ //= require_self
2
+ //= require ./progress_navigation_bar/widget
3
+
4
+ pageflow.widgetTypes.register('progress_navigation_bar', {
5
+ enhance: function(element) {
6
+ element.progressNavigationBar();
7
+ }
8
+ });
@@ -0,0 +1,342 @@
1
+ /*global IScroll*/
2
+
3
+ (function($) {
4
+ $.widget('pageflow.progressNavigationBar', {
5
+ _create: function() {
6
+ var overlays = this.element.find('.navigation_site_detail'),
7
+ that = this,
8
+ hasHomeButton = !!this.element.find('.navigation_home').length;
9
+
10
+ this.element.addClass('js').append(overlays);
11
+
12
+ $('a.navigation_top', this.element).topButton();
13
+
14
+ $('.navigation_bar_bottom', this.element)
15
+ .append($('.navigation_bar_top > li', this.element).slice(hasHomeButton ? 4 : 3));
16
+
17
+
18
+ /* open menu magic */
19
+ var checkingForMouseDelta = false,
20
+ lastPosition,
21
+ openBarTimeout,
22
+ closeBarTimeout,
23
+ measuringDistance = 600,
24
+ recentPosition;
25
+
26
+ $('body').on('mousemove', function(e) {
27
+ recentPosition = e.pageX;
28
+ var measuredDistance = that.element.offset().left - e.pageX;
29
+ if(measuredDistance < measuringDistance && !checkingForMouseDelta && measuredDistance > 0) {
30
+ checkingForMouseDelta = true;
31
+ lastPosition = e.pageX;
32
+
33
+ closeBarTimeout = setTimeout(function() {
34
+ that.element.removeClass('hover');
35
+ checkingForMouseDelta = false;
36
+ }, 2000);
37
+
38
+ openBarTimeout = setTimeout(function() {
39
+ if(recentPosition - lastPosition > 100 * (measuredDistance / measuringDistance) + 10) {
40
+ that.element.addClass('hover');
41
+
42
+ }
43
+ else {
44
+ checkingForMouseDelta = false;
45
+ clearTimeout(closeBarTimeout);
46
+ }
47
+ },50);
48
+ }
49
+ });
50
+
51
+ pageflow.slides.on('slideshowchangepage', function() {
52
+ that.element.addClass('show_on_mobile');
53
+ setTimeout(function() {
54
+ that.element.removeClass('show_on_mobile');
55
+ }, 1000);
56
+ });
57
+
58
+
59
+
60
+ that.element.on('mouseenter', function() { that.element.addClass('hover'); clearTimeout(closeBarTimeout);});
61
+ that.element.on('mousemove', function() { clearTimeout(closeBarTimeout); });
62
+ that.element.on('mouseleave', function() { that.element.removeClass('hover'); checkingForMouseDelta = false; });
63
+
64
+
65
+ /* keyboard / skiplinks */
66
+
67
+ that.element.find('a, *[tabindex]').on('blur', function() {
68
+ that.element.removeClass('focus');
69
+ });
70
+
71
+ that.element.find('a, *[tabindex]').on('focus', function() {
72
+ that.element.addClass('focus');
73
+ });
74
+
75
+ /*that.element.on('mousemove', function() {
76
+ clearTimeout(closeBarTimeout);
77
+ closeBarTimeout = setTimeout(function() {
78
+ that.element.removeClass('hover');
79
+ }, 500);
80
+ });*/
81
+
82
+ /* Volume */
83
+
84
+ var handlingVolume = false;
85
+ var volumeBeforeMute = 1;
86
+ var muteButton = $('.navigation_bg.navigation_mute', that.element);
87
+ var changeVolume = function(event) {
88
+ var volume = 1 - (event.pageY - $('.volume-slider', that.element).offset().top) / $(('.volume-slider')).height();
89
+ if (volume > 1) { volume = 1; }
90
+ if (volume < 0) { volume = 0; }
91
+ setVolume(volume);
92
+ };
93
+
94
+ var setVolume = function(volume) {
95
+ $('.volume-level', that.element).css({height: volume * 100 + "%"});
96
+ pageflow.settings.set('volume', volume);
97
+
98
+ if (volume === 0) {
99
+ muteButton
100
+ .attr('title', muteButton.attr('data-muted-title'))
101
+ .addClass('muted');
102
+ }
103
+ else {
104
+ muteButton
105
+ .attr('title', muteButton.attr('data-not-muted-title'))
106
+ .removeClass('muted');
107
+ }
108
+ };
109
+
110
+ var toggleMute = function () {
111
+ if (pageflow.settings.get('volume') > 0) {
112
+ volumeBeforeMute = pageflow.settings.get('volume');
113
+ setVolume(0);
114
+ }
115
+ else {
116
+ setVolume(volumeBeforeMute);
117
+ }
118
+ };
119
+
120
+ muteButton.on("click", function() {
121
+ toggleMute();
122
+ });
123
+
124
+ $('.volume-level', this.element).css({
125
+ height: pageflow.settings.get("volume") * 100 + "%"
126
+ });
127
+
128
+ $('.navigation_volume_box', this.element).on("mousedown", function(event) {
129
+ handlingVolume = true;
130
+ changeVolume(event);
131
+ });
132
+
133
+ $('.navigation_volume_box', this.element).on("mousemove", function(event) {
134
+ if(handlingVolume) {
135
+ changeVolume(event);
136
+ }
137
+ });
138
+
139
+ setVolume(pageflow.settings.get('volume'));
140
+
141
+ /* hide buttons on mobile devices */
142
+ if (pageflow.features.has('mobile platform')) {
143
+ that.element.find('.navigation_butten_area').hide();
144
+
145
+ }
146
+
147
+ /* header button */
148
+ $('.navigation_main', this.element).click(function() {
149
+ $(this)
150
+ .toggleClass('active')
151
+ .updateTitle();
152
+ $('.header').toggleClass('active');
153
+ that.element.toggleClass('header_active');
154
+ });
155
+
156
+ /* open header through skiplinks */
157
+ $('a[href="#header"], a[href="#search"]', '#skipLinks').click(function() {
158
+ $('.navigation_main', that.element).addClass('active');
159
+ $('.header').addClass('active');
160
+ $(this.getAttribute('href')).select();
161
+ });
162
+
163
+ /* share-button */
164
+ $('.navigation_menu .navigation_menu_box a', this.element).focus(function() {
165
+ $(this).parent().parent().addClass('focused');
166
+ }).blur(function() {
167
+ $(this).parent().parent().removeClass('focused');
168
+ });
169
+
170
+ var shareBox = $('.navigation_share_box', this.element),
171
+ links = $('> a', shareBox);
172
+ shareBox.shareMenu({
173
+ subMenu: $('.sub_share', shareBox),
174
+ links: links,
175
+ insertAfter: links.last(),
176
+ closeOnMouseLeaving: shareBox
177
+ });
178
+
179
+ /* pages */
180
+ var pageLinks = $('.navigation_dots a', that.element),
181
+ target;
182
+
183
+ function registerHandler() {
184
+ target = $(this);
185
+ target.one('mouseup touchend', goToPage);
186
+ }
187
+
188
+ function removeHandler() {
189
+ pageLinks.off('mouseup touchend', goToPage);
190
+ }
191
+
192
+ function closeOverview() {
193
+ $('.overview').removeClass("active");
194
+ $('.navigation_index', that.element).removeClass("active");
195
+ }
196
+
197
+ function hideOverlay() {
198
+ $(overlays).addClass('hidden').removeClass('visible');
199
+ }
200
+
201
+ function goToPage(e) {
202
+ if (target && target[0] != e.currentTarget) {
203
+ return;
204
+ }
205
+ hideOverlay();
206
+ closeOverview();
207
+ $('.page .content, .scroll_indicator').removeClass('hidden');
208
+ pageflow.slides.goToById(this.getAttribute("data-link"));
209
+ e.preventDefault();
210
+ }
211
+
212
+ pageLinks.each(function(index) {
213
+ var handlerIn = function() {
214
+ if (!('ontouchstart' in document.documentElement)) {
215
+ var calculatedOffset = $(this).offset().top + $(overlays[index]).outerHeight() > $('.progress_navigation_bar').height() ? $('.progress_navigation_bar').height() - $(overlays[index]).outerHeight() : $(this).offset().top;
216
+ $(overlays[index]).css("top", calculatedOffset).addClass('visible').removeClass('hidden');
217
+ }
218
+ };
219
+
220
+ $(this).on({
221
+ 'mouseenter focus': handlerIn,
222
+ 'mouseleave blur': hideOverlay,
223
+ 'mousedown touchstart': registerHandler,
224
+ 'click': goToPage
225
+ });
226
+ });
227
+
228
+ var resizeDots = function() {
229
+ var pageDotsMaxHeight = 20,
230
+ pageDotsMinHeight = 1,
231
+ maxBarHeight = $('#outer_wrapper').height() ? $('#outer_wrapper').height() : $('main').height(),
232
+ wantedHeight = maxBarHeight / pageLinks.length,
233
+ appliedHeight = pageDotsMinHeight;
234
+
235
+
236
+ if(wantedHeight <= pageDotsMaxHeight && wantedHeight > pageDotsMinHeight) {
237
+ appliedHeight = wantedHeight;
238
+ }
239
+ else if(wantedHeight > pageDotsMinHeight) {
240
+ appliedHeight = pageDotsMaxHeight;
241
+ }
242
+
243
+ $('.navigation_dots > li').css('height', appliedHeight + 'px');
244
+ };
245
+
246
+ resizeDots();
247
+
248
+ $(window).on('resize', function () {
249
+ $(overlays).css("top","0");
250
+ resizeDots();
251
+ });
252
+
253
+ $('.scroller', this.element).each(function () {
254
+ var scrollerOptions = {
255
+ mouseWheel: true,
256
+ bounce : false,
257
+ probeType : 2
258
+ };
259
+
260
+ /*
261
+ This is just a quick fix to detect IE10. We should
262
+ refactor this condition if we decide to use Modernizr
263
+ or another more global detection.
264
+ */
265
+ if (window.navigator.msPointerEnabled) {
266
+ scrollerOptions.preventDefault = false;
267
+ }
268
+
269
+ var scroller = new IScroll(this, scrollerOptions);
270
+
271
+ $('ul.navigation_dots', that.element).pageNavigationList({
272
+ scroller: scroller,
273
+ scrollToActive: true
274
+ });
275
+
276
+ });
277
+
278
+ /* hide text button */
279
+ var hideText = $('.navigation_hide_text', this.element);
280
+
281
+ hideText.click(function() {
282
+ pageflow.hideText.toggle();
283
+ });
284
+
285
+ pageflow.hideText.on('activate deactivate', function() {
286
+ hideText.toggleClass('active', pageflow.hideText.isActive()).updateTitle();
287
+ });
288
+
289
+ /* fullscreen button */
290
+ if ($.support.fullscreen) {
291
+ var fs = $('.navigation_fullscreen', this.element),
292
+ fullscreenCallback = function(isFullScreen) {
293
+ fs
294
+ .toggleClass('active', !!isFullScreen)
295
+ .updateTitle();
296
+ };
297
+
298
+ fs.click(function() {
299
+ fs.toggleClass('fs').updateTitle();
300
+ $('#outer_wrapper').fullScreen({'callback': fullscreenCallback});
301
+ });
302
+ }
303
+ else {
304
+ $('.navigation_bar_bottom .fullscreen a', this.element).css('visibility', 'hidden');
305
+ }
306
+
307
+ $('.button, .navigation_mute, .scroll_indicator', this.element).on({
308
+ 'touchstart mousedown': function() {
309
+ $(this).parent().addClass('pressed');
310
+ },
311
+ 'touchend mouseup': function() {
312
+ $(this).parent().removeClass('pressed');
313
+ }
314
+ });
315
+
316
+ $('.navigation_share, .navigation_credits', this.element).on({
317
+ 'touchstart': function() {
318
+ var element = $(this).parent().parent();
319
+ element.addClass('open');
320
+
321
+ function close(e) {
322
+ if (!element.find(e.target).length) {
323
+ element.removeClass('open');
324
+ $('body').off('touchstart', close);
325
+ }
326
+ }
327
+ $('body').on('touchstart', close);
328
+ }
329
+ });
330
+
331
+ $('li', this.element).on('mouseleave', function() {
332
+ $(this).blur();
333
+ });
334
+
335
+ $('body').on({
336
+ 'mouseup': function() {
337
+ handlingVolume = false;
338
+ }
339
+ });
340
+ }
341
+ });
342
+ }(jQuery));