contour 0.0.0 → 0.1.1

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 (78) hide show
  1. data/.gitignore +7 -0
  2. data/CHANGELOG.rdoc +13 -0
  3. data/README.rdoc +56 -0
  4. data/app/controllers/contour/authentications_controller.rb +60 -0
  5. data/app/controllers/contour/registrations_controller.rb +16 -0
  6. data/app/controllers/contour/samples_controller.rb +5 -0
  7. data/app/controllers/contour/sessions_controller.rb +3 -0
  8. data/app/views/contour/authentications/_index.html.erb +25 -0
  9. data/app/views/contour/authentications/_menu.html.erb +25 -0
  10. data/app/views/contour/authentications/index.html.erb +27 -0
  11. data/app/views/contour/layouts/_menu.html.erb +32 -0
  12. data/app/views/contour/layouts/_message.html.erb +8 -0
  13. data/app/views/contour/layouts/application.html.erb +47 -0
  14. data/app/views/contour/registrations/edit.html.erb +25 -0
  15. data/app/views/contour/registrations/new.html.erb +37 -0
  16. data/app/views/contour/samples/index.html.erb +27 -0
  17. data/app/views/contour/sessions/new.html.erb +25 -0
  18. data/app/views/devise/passwords/edit.html.erb +16 -0
  19. data/app/views/devise/passwords/new.html.erb +12 -0
  20. data/contour.gemspec +27 -0
  21. data/lib/contour.rb +36 -0
  22. data/lib/contour/engine.rb +8 -0
  23. data/lib/contour/version.rb +1 -1
  24. data/lib/generators/contour/install_generator.rb +38 -0
  25. data/lib/generators/templates/contour.rb +30 -0
  26. data/lib/generators/templates/devise.rb +153 -0
  27. data/lib/generators/templates/omniauth.rb +22 -0
  28. data/lib/generators/templates/omniauth_fix.rb +98 -0
  29. data/lib/generators/templates/rack_fix.rb +44 -0
  30. data/vendor/assets/images/authbuttons/cas_32.png +0 -0
  31. data/vendor/assets/images/authbuttons/cas_64.png +0 -0
  32. data/vendor/assets/images/authbuttons/facebook_32.png +0 -0
  33. data/vendor/assets/images/authbuttons/facebook_64.png +0 -0
  34. data/vendor/assets/images/authbuttons/google_apps_32.png +0 -0
  35. data/vendor/assets/images/authbuttons/google_apps_64.png +0 -0
  36. data/vendor/assets/images/authbuttons/ldap_32.png +0 -0
  37. data/vendor/assets/images/authbuttons/ldap_64.png +0 -0
  38. data/vendor/assets/images/authbuttons/linkedin_32.png +0 -0
  39. data/vendor/assets/images/authbuttons/linkedin_64.png +0 -0
  40. data/vendor/assets/images/authbuttons/openid_32.png +0 -0
  41. data/vendor/assets/images/authbuttons/openid_64.png +0 -0
  42. data/vendor/assets/images/authbuttons/twitter_32.png +0 -0
  43. data/vendor/assets/images/authbuttons/twitter_64.png +0 -0
  44. data/vendor/assets/images/redmond/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  45. data/vendor/assets/images/redmond/ui-bg_flat_55_fbec88_40x100.png +0 -0
  46. data/vendor/assets/images/redmond/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  47. data/vendor/assets/images/redmond/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  48. data/vendor/assets/images/redmond/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  49. data/vendor/assets/images/redmond/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  50. data/vendor/assets/images/redmond/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  51. data/vendor/assets/images/redmond/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  52. data/vendor/assets/images/redmond/ui-icons_217bc0_256x240.png +0 -0
  53. data/vendor/assets/images/redmond/ui-icons_2e83ff_256x240.png +0 -0
  54. data/vendor/assets/images/redmond/ui-icons_469bdd_256x240.png +0 -0
  55. data/vendor/assets/images/redmond/ui-icons_6da8d5_256x240.png +0 -0
  56. data/vendor/assets/images/redmond/ui-icons_cd0a0a_256x240.png +0 -0
  57. data/vendor/assets/images/redmond/ui-icons_d8e7f3_256x240.png +0 -0
  58. data/vendor/assets/images/redmond/ui-icons_f9bd01_256x240.png +0 -0
  59. data/vendor/assets/javascripts/contour.js +8 -0
  60. data/vendor/assets/javascripts/errors.js.coffee +10 -0
  61. data/vendor/assets/javascripts/external/exporting-2.1.4.src.js +673 -0
  62. data/vendor/assets/javascripts/external/highcharts-2.1.4.src.js +10668 -0
  63. data/vendor/assets/javascripts/external/jquery-ui-1.8.10.custom.min.js +782 -0
  64. data/vendor/assets/javascripts/external/waypoints.js +610 -0
  65. data/vendor/assets/javascripts/global.js.coffee +38 -0
  66. data/vendor/assets/javascripts/menu.js.coffee +6 -0
  67. data/vendor/assets/javascripts/popup.js.coffee +67 -0
  68. data/vendor/assets/stylesheets/authentication.css +63 -0
  69. data/vendor/assets/stylesheets/bluetrip-screen.css +324 -0
  70. data/vendor/assets/stylesheets/contour.css +15 -0
  71. data/vendor/assets/stylesheets/global.css +59 -0
  72. data/vendor/assets/stylesheets/header.css +18 -0
  73. data/vendor/assets/stylesheets/jquery-ui-1.8.10.custom.css +574 -0
  74. data/vendor/assets/stylesheets/menu.css +77 -0
  75. data/vendor/assets/stylesheets/message.css +27 -0
  76. data/vendor/assets/stylesheets/popup.css +79 -0
  77. metadata +114 -29
  78. data/README +0 -18
@@ -0,0 +1,610 @@
1
+ /*!
2
+ jQuery Waypoints - v1.1
3
+ Copyright (c) 2011 Caleb Troughton
4
+ Dual licensed under the MIT license and GPL license.
5
+ https://github.com/imakewebthings/jquery-waypoints/blob/master/MIT-license.txt
6
+ https://github.com/imakewebthings/jquery-waypoints/blob/master/GPL-license.txt
7
+ */
8
+
9
+ /*
10
+ Waypoints is a small jQuery plugin that makes it easy to execute a function
11
+ whenever you scroll to an element.
12
+
13
+ GitHub Repository: https://github.com/imakewebthings/jquery-waypoints
14
+ Documentation and Examples: http://imakewebthings.github.com/jquery-waypoints
15
+
16
+ Changelog:
17
+ v1.1.
18
+ - Moved the continuous option out of global settings and into the options
19
+ object for individual waypoints.
20
+ - Added the context option, which allows for using waypoints within any
21
+ scrollable element, not just the window.
22
+ v1.0.2
23
+ - Moved scroll and resize handler bindings out of load. Should play nicer
24
+ with async loaders like Head JS and LABjs.
25
+ - Fixed a 1px off error when using certain % offsets.
26
+ - Added unit tests.
27
+ v1.0.1
28
+ - Added $.waypoints('viewportHeight').
29
+ - Fixed iOS bug (using the new viewportHeight method).
30
+ - Added offset function alias: 'bottom-in-view'.
31
+ v1.0
32
+ - Initial release.
33
+
34
+ Support:
35
+ - jQuery versions 1.4+
36
+ - IE6+, FF3+, Chrome 6+, Safari 4+, Opera 11
37
+ - Other versions and browsers may work, these are just the ones I've looked at.
38
+ */
39
+
40
+ (function($, wp, wps, window, undefined){
41
+ '$:nomunge';
42
+
43
+ var $w = $(window),
44
+
45
+ // Keeping common strings as variables = better minification
46
+ eventName = 'waypoint.reached',
47
+
48
+ /*
49
+ For the waypoint and direction passed in, trigger the waypoint.reached
50
+ event and deal with the triggerOnce option.
51
+ */
52
+ triggerWaypoint = function(way, dir) {
53
+ way.element.trigger(eventName, dir);
54
+ if (way.options.triggerOnce) {
55
+ way.element[wp]('destroy');
56
+ }
57
+ },
58
+
59
+ /*
60
+ Given a jQuery element and Context, returns the index of that element in the waypoints
61
+ array. Returns the index, or -1 if the element is not a waypoint.
62
+ */
63
+ waypointIndex = function(el, context) {
64
+ var i = context.waypoints.length - 1;
65
+ while (i >= 0 && context.waypoints[i].element[0] !== el[0]) {
66
+ i -= 1;
67
+ }
68
+ return i;
69
+ },
70
+
71
+ // Private list of all elements used as scrolling contexts for waypoints.
72
+ contexts = [],
73
+
74
+ /*
75
+ Context Class - represents a scrolling context. Properties include:
76
+ element: jQuery object containing a single HTML element.
77
+ waypoints: Array of waypoints operating under this scroll context.
78
+ oldScroll: Keeps the previous scroll position to determine scroll direction.
79
+ didScroll: Flag used in scrolling the context's scroll event.
80
+ didResize: Flag used in scrolling the context's resize event.
81
+ doScroll: Function that checks for crossed waypoints. Called from throttler.
82
+ */
83
+ Context = function(context) {
84
+ $.extend(this, {
85
+ 'element': $(context),
86
+
87
+ /*
88
+ Starting at a ridiculous negative number allows for a 'down' trigger of 0 or
89
+ negative offset waypoints on load. Useful for setting initial states.
90
+ */
91
+ 'oldScroll': -99999,
92
+
93
+ /*
94
+ List of all elements that have been registered as waypoints.
95
+ Each object in the array contains:
96
+ element: jQuery object containing a single HTML element.
97
+ offset: The window scroll offset, in px, that triggers the waypoint event.
98
+ options: Options object that was passed to the waypoint fn function.
99
+ */
100
+ 'waypoints': [],
101
+
102
+ didScroll: false,
103
+ didResize: false,
104
+
105
+ doScroll: $.proxy(function() {
106
+ var newScroll = this.element.scrollTop(),
107
+
108
+ // Are we scrolling up or down? Used for direction argument in callback.
109
+ isDown = newScroll > this.oldScroll,
110
+ that = this,
111
+
112
+ // Get a list of all waypoints that were crossed since last scroll move.
113
+ pointsHit = $.grep(this.waypoints, function(el, i) {
114
+ return isDown ?
115
+ (el.offset > that.oldScroll && el.offset <= newScroll) :
116
+ (el.offset <= that.oldScroll && el.offset > newScroll);
117
+ }),
118
+ len = pointsHit.length;
119
+
120
+ // iOS adjustment
121
+ if (!this.oldScroll || !newScroll) {
122
+ $[wps]('refresh');
123
+ }
124
+
125
+ // Done with scroll comparisons, store new scroll before ejection
126
+ this.oldScroll = newScroll;
127
+
128
+ // No waypoints crossed? Eject.
129
+ if (!len) return;
130
+
131
+ // If several waypoints triggered, need to do so in reverse order going up
132
+ if (!isDown) pointsHit.reverse();
133
+
134
+ /*
135
+ One scroll move may cross several waypoints. If the waypoint's continuous
136
+ option is true it should fire even if it isn't the last waypoint. If false,
137
+ it will only fire if it's the last one.
138
+ */
139
+ $.each(pointsHit, function(i, point) {
140
+ if (point.options.continuous || i === len - 1) {
141
+ triggerWaypoint(point, [isDown ? 'down' : 'up']);
142
+ }
143
+ });
144
+ }, this)
145
+ });
146
+
147
+ // Setup scroll and resize handlers. Throttled at the settings-defined rate limits.
148
+ $(context).scroll($.proxy(function() {
149
+ if (!this.didScroll) {
150
+ this.didScroll = true;
151
+ window.setTimeout($.proxy(function() {
152
+ this.doScroll();
153
+ this.didScroll = false;
154
+ }, this), $[wps].settings.scrollThrottle);
155
+ }
156
+ }, this)).resize($.proxy(function() {
157
+ if (!this.didResize) {
158
+ this.didResize = true;
159
+ window.setTimeout($.proxy(function() {
160
+ $[wps]('refresh');
161
+ this.didResize = false;
162
+ }, this), $[wps].settings.resizeThrottle);
163
+ }
164
+ }, this));
165
+
166
+ $w.load($.proxy(function() {
167
+ /*
168
+ Fire a scroll check, should the page be loaded at a non-zero scroll value,
169
+ as with a fragment id link or a page refresh.
170
+ */
171
+ this.doScroll();
172
+ }, this));
173
+ },
174
+
175
+ /* Returns a Context object from the contexts array, given the raw HTML element
176
+ for that context. */
177
+ getContextByElement = function(element) {
178
+ var found = null;
179
+
180
+ $.each(contexts, function(i, c) {
181
+ if (c.element[0] === element) {
182
+ found = c;
183
+ return false;
184
+ }
185
+ });
186
+
187
+ return found;
188
+ },
189
+
190
+ // Methods exposed to the effin' object
191
+ methods = {
192
+ /*
193
+ jQuery.fn.waypoint([handler], [options])
194
+
195
+ handler
196
+ function, optional
197
+ A callback function called when the user scrolls past the element.
198
+ The function signature is function(event, direction) where event is
199
+ a standard jQuery Event Object and direction is a string, either 'down'
200
+ or 'up' indicating which direction the user is scrolling.
201
+
202
+ options
203
+ object, optional
204
+ A map of options to apply to this set of waypoints, including where on
205
+ the browser window the waypoint is triggered. For a full list of
206
+ options and their defaults, see $.fn.waypoint.defaults.
207
+
208
+ This is how you register an element as a waypoint. When the user scrolls past
209
+ that element it triggers waypoint.reached, a custom event. Since the
210
+ parameters for creating a waypoint are optional, we have a few different
211
+ possible signatures. Let’s look at each of them.
212
+
213
+ someElements.waypoint();
214
+
215
+ Calling .waypoint with no parameters will register the elements as waypoints
216
+ using the default options. The elements will fire the waypoint.reached event,
217
+ but calling it in this way does not bind any handler to the event. You can
218
+ bind to the event yourself, as with any other event, like so:
219
+
220
+ someElements.bind('waypoint.reached', function(event, direction) {
221
+ // make it rain
222
+ });
223
+
224
+ You will usually want to create a waypoint and immediately bind a function to
225
+ waypoint.reached, and can do so by passing a handler as the first argument to
226
+ .waypoint:
227
+
228
+ someElements.waypoint(function(event, direction) {
229
+ if (direction === 'down') {
230
+ // do this on the way down
231
+ }
232
+ else {
233
+ // do this on the way back up through the waypoint
234
+ }
235
+ });
236
+
237
+ This will still use the default options, which will trigger the waypoint when
238
+ the top of the element hits the top of the window. We can pass .waypoint an
239
+ options object to customize things:
240
+
241
+ someElements.waypoint(function(event, direction) {
242
+ // do something amazing
243
+ }, {
244
+ offset: '50%' // middle of the page
245
+ });
246
+
247
+ You can also pass just an options object.
248
+
249
+ someElements.waypoint({
250
+ offset: 100 // 100px from the top
251
+ });
252
+
253
+ This behaves like .waypoint(), in that it registers the elements as waypoints
254
+ but binds no event handlers.
255
+
256
+ Calling .waypoint on an existing waypoint will extend the previous options.
257
+ If the call includes a handler, it will be bound to waypoint.reached without
258
+ unbinding any other handlers.
259
+ */
260
+ init: function(f, options) {
261
+ // Register each element as a waypoint, add to array.
262
+ this.each(function() {
263
+ var cElement = $.fn[wp].defaults.context,
264
+ context,
265
+ $this = $(this);
266
+
267
+ // Default window context or a specific element?
268
+ if (options && options.context) {
269
+ cElement = options.context;
270
+ }
271
+
272
+ // Find the closest element that matches the context
273
+ if (!$.isWindow(cElement)) {
274
+ cElement = $this.closest(cElement)[0];
275
+ }
276
+ context = getContextByElement(cElement);
277
+
278
+ // Not a context yet? Create and push.
279
+ if (!context) {
280
+ context = new Context(cElement);
281
+ contexts.push(context);
282
+ }
283
+
284
+ // Extend default and preexisting options
285
+ var ndx = waypointIndex($this, context),
286
+ base = ndx < 0 ? $.fn[wp].defaults : context.waypoints[ndx].options,
287
+ opts = $.extend({}, base, options);
288
+
289
+ // Offset aliases
290
+ opts.offset = opts.offset === "bottom-in-view" ?
291
+ function() {
292
+ var cHeight = $.isWindow(cElement) ? $[wps]('viewportHeight')
293
+ : $(cElement).height();
294
+ return cHeight - $(this).outerHeight();
295
+ } : opts.offset;
296
+
297
+ // Update, or create new waypoint
298
+ if (ndx < 0) {
299
+ context.waypoints.push({
300
+ 'element': $this,
301
+ 'offset': $this.offset().top,
302
+ 'options': opts
303
+ });
304
+ }
305
+ else {
306
+ context.waypoints[ndx].options = opts;
307
+ }
308
+
309
+ // Bind the function if it was passed in.
310
+ if (f) {
311
+ $this.bind(eventName, f);
312
+ }
313
+ });
314
+
315
+ // Need to re-sort+refresh the waypoints array after new elements are added.
316
+ $[wps]('refresh');
317
+
318
+ return this;
319
+ },
320
+
321
+
322
+ /*
323
+ jQuery.fn.waypoint('remove')
324
+
325
+ Passing the string 'remove' to .waypoint unregisters the elements as waypoints
326
+ and wipes any custom options, but leaves the waypoint.reached events bound.
327
+ Calling .waypoint again in the future would reregister the waypoint and the old
328
+ handlers would continue to work.
329
+ */
330
+ remove: function() {
331
+ return this.each(function(i, el) {
332
+ var $el = $(el);
333
+
334
+ $.each(contexts, function(i, c) {
335
+ var ndx = waypointIndex($el, c);
336
+
337
+ if (ndx >= 0) {
338
+ c.waypoints.splice(ndx, 1);
339
+ }
340
+ });
341
+ });
342
+ },
343
+
344
+ /*
345
+ jQuery.fn.waypoint('destroy')
346
+
347
+ Passing the string 'destroy' to .waypoint will unbind all waypoint.reached
348
+ event handlers on those elements and unregisters them as waypoints.
349
+ */
350
+ destroy: function() {
351
+ return this.unbind(eventName)[wp]('remove');
352
+ }
353
+ },
354
+
355
+ /*
356
+ Methods used by the jQuery object extension.
357
+ */
358
+ jQMethods = {
359
+
360
+ /*
361
+ jQuery.waypoints('refresh')
362
+
363
+ This will force a recalculation of each waypoint’s trigger point based on
364
+ its offset option and context. This is called automatically whenever the window
365
+ (or other defined context) is resized, new waypoints are added, or a waypoint’s
366
+ options are modified. If your project is changing the DOM or page layout without
367
+ doing one of these things, you may want to manually call this refresh.
368
+ */
369
+ refresh: function() {
370
+ $.each(contexts, function(i, c) {
371
+ var isWin = $.isWindow(c.element[0]),
372
+ contextOffset = isWin ? 0 : c.element.offset().top,
373
+ contextHeight = isWin ? $[wps]('viewportHeight') : c.element.height(),
374
+ contextScroll = isWin ? 0 : c.element.scrollTop();
375
+
376
+ $.each(c.waypoints, function(j, o) {
377
+ // Adjustment is just the offset if it's a px value
378
+ var adjustment = o.options.offset,
379
+ oldOffset = o.offset;
380
+
381
+ // Set adjustment to the return value if offset is a function.
382
+ if (typeof o.options.offset === "function") {
383
+ adjustment = o.options.offset.apply(o.element);
384
+ }
385
+ // Calculate the adjustment if offset is a percentage.
386
+ else if (typeof o.options.offset === "string") {
387
+ var amount = parseFloat(o.options.offset);
388
+ adjustment = o.options.offset.indexOf("%") ?
389
+ Math.ceil(contextHeight * (amount / 100)) : amount;
390
+ }
391
+
392
+ /*
393
+ Set the element offset to the window scroll offset, less
394
+ all our adjustments.
395
+ */
396
+ o.offset = o.element.offset().top - contextOffset
397
+ + contextScroll - adjustment;
398
+
399
+ /*
400
+ An element offset change across the current scroll point triggers
401
+ the event, just as if we scrolled past it.
402
+ */
403
+ if (c.oldScroll > oldOffset && c.oldScroll <= o.offset) {
404
+ triggerWaypoint(o, ['up']);
405
+ }
406
+ else if (c.oldScroll < oldOffset && c.oldScroll >= o.offset) {
407
+ triggerWaypoint(o, ['down']);
408
+ }
409
+ });
410
+
411
+ // Keep waypoints sorted by offset value.
412
+ c.waypoints.sort(function(a, b) {
413
+ return a.offset - b.offset;
414
+ });
415
+ });
416
+ },
417
+
418
+
419
+ /*
420
+ jQuery.waypoints('viewportHeight')
421
+
422
+ This will return the height of the viewport, adjusting for inconsistencies
423
+ that come with calling $(window).height() in iOS. Recommended for use
424
+ within any offset functions.
425
+ */
426
+ viewportHeight: function() {
427
+ return (window.innerHeight ? window.innerHeight : $w.height());
428
+ },
429
+
430
+
431
+ /*
432
+ jQuery.waypoints()
433
+
434
+ This will return a jQuery object with a collection of all registered waypoint
435
+ elements.
436
+
437
+ $('.post').waypoint();
438
+ $('.ad-unit').waypoint(function(event, direction) {
439
+ // Passed an ad unit
440
+ });
441
+ console.log($.waypoints());
442
+
443
+ The example above would log a jQuery object containing all .post and .ad-unit
444
+ elements.
445
+ */
446
+ aggregate: function() {
447
+ var points = $();
448
+ $.each(contexts, function(i, c) {
449
+ $.each(c.waypoints, function(i, e) {
450
+ points = points.add(e.element);
451
+ });
452
+ });
453
+ return points;
454
+ }
455
+ };
456
+
457
+
458
+ /*
459
+ fn extension. Delegates to appropriate method.
460
+ */
461
+ $.fn[wp] = function(method) {
462
+
463
+ if (methods[method]) {
464
+ return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
465
+ }
466
+ else if (typeof method === "function" || !method) {
467
+ return methods.init.apply(this, arguments);
468
+ }
469
+ else if (typeof method === "object") {
470
+ return methods.init.apply(this, [null, method]);
471
+ }
472
+ else {
473
+ $.error( 'Method ' + method + ' does not exist on jQuery ' + wp );
474
+ }
475
+ };
476
+
477
+
478
+ /*
479
+ The default options object that is extended when calling .waypoint. It has the
480
+ following properties:
481
+
482
+ context
483
+ string | element | jQuery*
484
+ default: window
485
+ The context defines which scrollable element the waypoint belongs to and acts
486
+ within. The default, window, means the waypoint offset is calculated with relation
487
+ to the whole viewport. You can set this to another element to use the waypoints
488
+ within that element. Accepts a selector string, *but if you use jQuery 1.6+ it
489
+ also accepts a raw HTML element or jQuery object.
490
+
491
+ continuous
492
+ boolean
493
+ default: true
494
+ If true, and multiple waypoints are triggered in one scroll, this waypoint will
495
+ trigger even if it is not the last waypoint reached. If false, it will only
496
+ trigger if it is the last waypoint.
497
+
498
+ offset
499
+ number | string | function
500
+ default: 0
501
+ Determines how far the top of the element must be from the top of the browser
502
+ window to trigger a waypoint. It can be a number, which is taken as a number
503
+ of pixels, a string representing a percentage of the viewport height, or a
504
+ function that will return a number of pixels.
505
+
506
+ triggerOnce
507
+ boolean
508
+ default: false
509
+ If true, the waypoint will be destroyed when triggered.
510
+
511
+ An offset of 250 would trigger the waypoint when the top of the element is 250px
512
+ from the top of the viewport. Negative values for any offset work as you might
513
+ expect. A value of -100 would trigger the waypoint when the element is 100px above
514
+ the top of the window.
515
+
516
+ offset: '100%'
517
+
518
+ A string percentage will determine the pixel offset based on the height of the
519
+ window. When resizing the window, this offset will automatically be recalculated
520
+ without needing to call $.waypoints('refresh').
521
+
522
+ // The bottom of the element is in view
523
+ offset: function() {
524
+ return $.waypoints('viewportHeight') - $(this).outerHeight();
525
+ }
526
+
527
+ Offset can take a function, which must return a number of pixels from the top of
528
+ the window. The this value will always refer to the raw HTML element of the
529
+ waypoint. As with % values, functions are recalculated automatically when the
530
+ window resizes. For more on recalculating offsets, see $.waypoints('refresh').
531
+
532
+ An offset value of 'bottom-in-view' will act as an alias for the function in the
533
+ example above, as this is a common usage.
534
+
535
+ offset: 'bottom-in-view'
536
+
537
+ You can see this alias in use on the Scroll Analytics example page.
538
+
539
+ The triggerOnce flag, if true, will destroy the waypoint after the first trigger.
540
+ This is just a shortcut for calling .waypoint('destroy') within the waypoint
541
+ handler. This is useful in situations such as scroll analytics, where you only
542
+ want to record an event once for each page visit.
543
+
544
+ The context option lets you use Waypoints within an element other than the window.
545
+ You can define the context with a selector string and the waypoint will act within
546
+ the nearest ancestor that matches this selector.
547
+
548
+ $('.something-scrollable .waypoint').waypoint({
549
+ context: '.something-scrollable'
550
+ });
551
+
552
+ You can see this in action on the Dial Controls example.
553
+ */
554
+ $.fn[wp].defaults = {
555
+ continuous: true,
556
+ offset: 0,
557
+ triggerOnce: false,
558
+ context: window
559
+ };
560
+
561
+
562
+
563
+
564
+
565
+ /*
566
+ jQuery object extension. Delegates to appropriate methods above.
567
+ */
568
+ $[wps] = function(method) {
569
+ if (jQMethods[method]) {
570
+ return jQMethods[method].apply(this);
571
+ }
572
+ else {
573
+ return jQMethods['aggregate']();
574
+ }
575
+ };
576
+
577
+
578
+ /*
579
+ $.waypoints.settings
580
+
581
+ Settings object that determines some of the plugin’s behavior.
582
+
583
+ resizeThrottle
584
+ number
585
+ default: 200
586
+ For performance reasons, the refresh performed during resizes is
587
+ throttled. This value is the rate-limit in milliseconds between resize
588
+ refreshes. For more information on throttling, check out Ben Alman’s
589
+ throttle / debounce plugin.
590
+ http://benalman.com/projects/jquery-throttle-debounce-plugin/
591
+
592
+ scrollThrottle
593
+ number
594
+ default: 100
595
+ For performance reasons, checking for any crossed waypoints during a
596
+ scroll event is throttled. This value is the rate-limit in milliseconds
597
+ between scroll checks. For more information on throttling, check out Ben
598
+ Alman’s throttle / debounce plugin.
599
+ http://benalman.com/projects/jquery-throttle-debounce-plugin/
600
+ */
601
+ $[wps].settings = {
602
+ resizeThrottle: 200,
603
+ scrollThrottle: 100
604
+ };
605
+
606
+ $w.load(function() {
607
+ // Calculate everything once on load.
608
+ $[wps]('refresh');
609
+ });
610
+ })(jQuery, 'waypoint', 'waypoints', this);