contour 1.0.0.beta6 → 1.0.0.beta7
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.
- data/CHANGELOG.rdoc +2 -0
- data/app/assets/images/twitter-bootstrap/v2.0.3/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/twitter-bootstrap/v2.0.3/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/contour.js +1 -1
- data/app/assets/javascripts/twitter-bootstrap/v2.0.3/bootstrap.js +1824 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.css +14 -0
- data/app/assets/stylesheets/contour.css +2 -0
- data/app/assets/stylesheets/twitter-bootstrap/v2.0.3/bootstrap-responsive.css +808 -0
- data/app/assets/stylesheets/twitter-bootstrap/v2.0.3/bootstrap.css +4960 -0
- data/app/views/contour/authentications/_menu.html.erb +1 -1
- data/app/views/contour/authentications/index.html.erb +4 -3
- data/app/views/contour/layouts/_menu.html.erb +2 -2
- data/contour.gemspec +0 -1
- data/lib/contour/version.rb +1 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +528 -0
- metadata +30 -38
- data/app/assets/javascripts/contour/errors.js.coffee +0 -10
- data/app/assets/javascripts/external/waypoints.js +0 -610
- data/app/assets/stylesheets/bootstrap_and_overrides.css.less +0 -42
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta7
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70239203187000 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,21 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.2.3
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: twitter-bootstrap-rails
|
27
|
-
requirement: &70302274218560 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 2.0.6
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70302274218560
|
24
|
+
version_requirements: *70239203187000
|
36
25
|
- !ruby/object:Gem::Dependency
|
37
26
|
name: jquery-rails
|
38
|
-
requirement: &
|
27
|
+
requirement: &70239203186500 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
29
|
requirements:
|
41
30
|
- - ~>
|
@@ -43,10 +32,10 @@ dependencies:
|
|
43
32
|
version: 2.0.2
|
44
33
|
type: :runtime
|
45
34
|
prerelease: false
|
46
|
-
version_requirements: *
|
35
|
+
version_requirements: *70239203186500
|
47
36
|
- !ruby/object:Gem::Dependency
|
48
37
|
name: devise
|
49
|
-
requirement: &
|
38
|
+
requirement: &70239203186040 !ruby/object:Gem::Requirement
|
50
39
|
none: false
|
51
40
|
requirements:
|
52
41
|
- - ~>
|
@@ -54,10 +43,10 @@ dependencies:
|
|
54
43
|
version: 2.0.4
|
55
44
|
type: :runtime
|
56
45
|
prerelease: false
|
57
|
-
version_requirements: *
|
46
|
+
version_requirements: *70239203186040
|
58
47
|
- !ruby/object:Gem::Dependency
|
59
48
|
name: omniauth
|
60
|
-
requirement: &
|
49
|
+
requirement: &70239203185580 !ruby/object:Gem::Requirement
|
61
50
|
none: false
|
62
51
|
requirements:
|
63
52
|
- - ~>
|
@@ -65,10 +54,10 @@ dependencies:
|
|
65
54
|
version: 1.0.3
|
66
55
|
type: :runtime
|
67
56
|
prerelease: false
|
68
|
-
version_requirements: *
|
57
|
+
version_requirements: *70239203185580
|
69
58
|
- !ruby/object:Gem::Dependency
|
70
59
|
name: omniauth-openid
|
71
|
-
requirement: &
|
60
|
+
requirement: &70239203185120 !ruby/object:Gem::Requirement
|
72
61
|
none: false
|
73
62
|
requirements:
|
74
63
|
- - ~>
|
@@ -76,10 +65,10 @@ dependencies:
|
|
76
65
|
version: 1.0.1
|
77
66
|
type: :runtime
|
78
67
|
prerelease: false
|
79
|
-
version_requirements: *
|
68
|
+
version_requirements: *70239203185120
|
80
69
|
- !ruby/object:Gem::Dependency
|
81
70
|
name: omniauth-ldap
|
82
|
-
requirement: &
|
71
|
+
requirement: &70239203184660 !ruby/object:Gem::Requirement
|
83
72
|
none: false
|
84
73
|
requirements:
|
85
74
|
- - ~>
|
@@ -87,10 +76,10 @@ dependencies:
|
|
87
76
|
version: 1.0.2
|
88
77
|
type: :runtime
|
89
78
|
prerelease: false
|
90
|
-
version_requirements: *
|
79
|
+
version_requirements: *70239203184660
|
91
80
|
- !ruby/object:Gem::Dependency
|
92
81
|
name: omniauth-twitter
|
93
|
-
requirement: &
|
82
|
+
requirement: &70239203184200 !ruby/object:Gem::Requirement
|
94
83
|
none: false
|
95
84
|
requirements:
|
96
85
|
- - ~>
|
@@ -98,10 +87,10 @@ dependencies:
|
|
98
87
|
version: 0.0.11
|
99
88
|
type: :runtime
|
100
89
|
prerelease: false
|
101
|
-
version_requirements: *
|
90
|
+
version_requirements: *70239203184200
|
102
91
|
- !ruby/object:Gem::Dependency
|
103
92
|
name: omniauth-facebook
|
104
|
-
requirement: &
|
93
|
+
requirement: &70239203183740 !ruby/object:Gem::Requirement
|
105
94
|
none: false
|
106
95
|
requirements:
|
107
96
|
- - ~>
|
@@ -109,10 +98,10 @@ dependencies:
|
|
109
98
|
version: 1.2.0
|
110
99
|
type: :runtime
|
111
100
|
prerelease: false
|
112
|
-
version_requirements: *
|
101
|
+
version_requirements: *70239203183740
|
113
102
|
- !ruby/object:Gem::Dependency
|
114
103
|
name: omniauth-linkedin
|
115
|
-
requirement: &
|
104
|
+
requirement: &70239203183280 !ruby/object:Gem::Requirement
|
116
105
|
none: false
|
117
106
|
requirements:
|
118
107
|
- - ~>
|
@@ -120,10 +109,10 @@ dependencies:
|
|
120
109
|
version: 0.0.6
|
121
110
|
type: :runtime
|
122
111
|
prerelease: false
|
123
|
-
version_requirements: *
|
112
|
+
version_requirements: *70239203183280
|
124
113
|
- !ruby/object:Gem::Dependency
|
125
114
|
name: omniauth-cas
|
126
|
-
requirement: &
|
115
|
+
requirement: &70239203182820 !ruby/object:Gem::Requirement
|
127
116
|
none: false
|
128
117
|
requirements:
|
129
118
|
- - ~>
|
@@ -131,10 +120,10 @@ dependencies:
|
|
131
120
|
version: 0.0.6
|
132
121
|
type: :runtime
|
133
122
|
prerelease: false
|
134
|
-
version_requirements: *
|
123
|
+
version_requirements: *70239203182820
|
135
124
|
- !ruby/object:Gem::Dependency
|
136
125
|
name: sqlite3
|
137
|
-
requirement: &
|
126
|
+
requirement: &70239203182440 !ruby/object:Gem::Requirement
|
138
127
|
none: false
|
139
128
|
requirements:
|
140
129
|
- - ! '>='
|
@@ -142,7 +131,7 @@ dependencies:
|
|
142
131
|
version: '0'
|
143
132
|
type: :development
|
144
133
|
prerelease: false
|
145
|
-
version_requirements: *
|
134
|
+
version_requirements: *70239203182440
|
146
135
|
description: Basic Rails Framework files and assets for layout and authentication
|
147
136
|
email: remosm@gmail.com
|
148
137
|
executables: []
|
@@ -423,24 +412,27 @@ files:
|
|
423
412
|
- app/assets/images/gentleface/16/wrench_plus_2.png
|
424
413
|
- app/assets/images/gentleface/16/zoom.png
|
425
414
|
- app/assets/images/gentleface/LICENSE
|
426
|
-
- app/assets/
|
415
|
+
- app/assets/images/twitter-bootstrap/v2.0.3/glyphicons-halflings-white.png
|
416
|
+
- app/assets/images/twitter-bootstrap/v2.0.3/glyphicons-halflings.png
|
427
417
|
- app/assets/javascripts/contour/global.js.coffee
|
428
418
|
- app/assets/javascripts/contour.js
|
429
419
|
- app/assets/javascripts/external/exporting-2.1.9.src.js
|
430
420
|
- app/assets/javascripts/external/highcharts-2.1.9.src.js
|
431
421
|
- app/assets/javascripts/external/jquery-ui-1.8.10.custom.min.js
|
432
422
|
- app/assets/javascripts/external/jquery.qtip.min.js
|
433
|
-
- app/assets/javascripts/external/waypoints.js
|
434
423
|
- app/assets/javascripts/twitter-bootstrap/bootstrap-collapse.js
|
435
424
|
- app/assets/javascripts/twitter-bootstrap/bootstrap-dropdown.js
|
436
425
|
- app/assets/javascripts/twitter-bootstrap/bootstrap-modal.js
|
437
426
|
- app/assets/javascripts/twitter-bootstrap/bootstrap-tab.js
|
438
427
|
- app/assets/javascripts/twitter-bootstrap/bootstrap.js.coffee
|
439
|
-
- app/assets/
|
428
|
+
- app/assets/javascripts/twitter-bootstrap/v2.0.3/bootstrap.js
|
429
|
+
- app/assets/stylesheets/bootstrap_and_overrides.css
|
440
430
|
- app/assets/stylesheets/contour/authentication.css
|
441
431
|
- app/assets/stylesheets/contour.css
|
442
432
|
- app/assets/stylesheets/jquery-ui-1.8.10.custom.css
|
443
433
|
- app/assets/stylesheets/jquery.qtip.css
|
434
|
+
- app/assets/stylesheets/twitter-bootstrap/v2.0.3/bootstrap-responsive.css
|
435
|
+
- app/assets/stylesheets/twitter-bootstrap/v2.0.3/bootstrap.css
|
444
436
|
- app/controllers/contour/authentications_controller.rb
|
445
437
|
- app/controllers/contour/confirmations_controller.rb
|
446
438
|
- app/controllers/contour/passwords_controller.rb
|
@@ -1,10 +0,0 @@
|
|
1
|
-
jQuery ->
|
2
|
-
$(".field_with_errors input, .field_with_errors_cleared input, .field_with_errors textarea, .field_with_errors_cleared textarea, .field_with_errors select, .field_with_errors_cleared select").change( () ->
|
3
|
-
el = $(this)
|
4
|
-
if el.val() != '' && el.val() != null
|
5
|
-
$(el).parent().removeClass('field_with_errors')
|
6
|
-
$(el).parent().addClass('field_with_errors_cleared')
|
7
|
-
else
|
8
|
-
$(el).parent().removeClass('field_with_errors_cleared')
|
9
|
-
$(el).parent().addClass('field_with_errors')
|
10
|
-
)
|
@@ -1,610 +0,0 @@
|
|
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);
|