summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Bootstrap/bootstrap-scrollspy.js
Unidiff
Diffstat (limited to 'frontend/gamma/js/Bootstrap/bootstrap-scrollspy.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Bootstrap/bootstrap-scrollspy.js185
1 files changed, 0 insertions, 185 deletions
diff --git a/frontend/gamma/js/Bootstrap/bootstrap-scrollspy.js b/frontend/gamma/js/Bootstrap/bootstrap-scrollspy.js
deleted file mode 100644
index 4366f26..0000000
--- a/frontend/gamma/js/Bootstrap/bootstrap-scrollspy.js
+++ b/dev/null
@@ -1,185 +0,0 @@
1/*
2
3Copyright 2008-2013 Clipperz Srl
4
5This file is part of Clipperz, the online password manager.
6For further information about its features and functionalities please
7refer to http://www.clipperz.com.
8
9* Clipperz is free software: you can redistribute it and/or modify it
10 under the terms of the GNU Affero General Public License as published
11 by the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14* Clipperz is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 See the GNU Affero General Public License for more details.
18
19* You should have received a copy of the GNU Affero General Public
20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
21
22*/
23
24/* =============================================================
25 * bootstrap-scrollspy.js v2.2.2
26 * http://twitter.github.com/bootstrap/javascript.html#scrollspy
27 * =============================================================
28 * Copyright 2012 Twitter, Inc.
29 *
30 * Licensed under the Apache License, Version 2.0 (the "License");
31 * you may not use this file except in compliance with the License.
32 * You may obtain a copy of the License at
33 *
34 * http://www.apache.org/licenses/LICENSE-2.0
35 *
36 * Unless required by applicable law or agreed to in writing, software
37 * distributed under the License is distributed on an "AS IS" BASIS,
38 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39 * See the License for the specific language governing permissions and
40 * limitations under the License.
41 * ============================================================== */
42
43
44!function ($) {
45
46 "use strict"; // jshint ;_;
47
48
49 /* SCROLLSPY CLASS DEFINITION
50 * ========================== */
51
52 function ScrollSpy(element, options) {
53 var process = $.proxy(this.process, this)
54 , $element = $(element).is('body') ? $(window) : $(element)
55 , href
56 this.options = $.extend({}, $.fn.scrollspy.defaults, options)
57 this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
58 this.selector = (this.options.target
59 || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
60 || '') + ' .nav li > a'
61 this.$body = $('body')
62 this.refresh()
63 this.process()
64 }
65
66 ScrollSpy.prototype = {
67
68 constructor: ScrollSpy
69
70 , refresh: function () {
71 var self = this
72 , $targets
73
74 this.offsets = $([])
75 this.targets = $([])
76
77 $targets = this.$body
78 .find(this.selector)
79 .map(function () {
80 var $el = $(this)
81 , href = $el.data('target') || $el.attr('href')
82 , $href = /^#\w/.test(href) && $(href)
83 return ( $href
84 && $href.length
85 && [[ $href.position().top + self.$scrollElement.scrollTop(), href ]] ) || null
86 })
87 .sort(function (a, b) { return a[0] - b[0] })
88 .each(function () {
89 self.offsets.push(this[0])
90 self.targets.push(this[1])
91 })
92 }
93
94 , process: function () {
95 var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
96 , scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
97 , maxScroll = scrollHeight - this.$scrollElement.height()
98 , offsets = this.offsets
99 , targets = this.targets
100 , activeTarget = this.activeTarget
101 , i
102
103 if (scrollTop >= maxScroll) {
104 return activeTarget != (i = targets.last()[0])
105 && this.activate ( i )
106 }
107
108 for (i = offsets.length; i--;) {
109 activeTarget != targets[i]
110 && scrollTop >= offsets[i]
111 && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
112 && this.activate( targets[i] )
113 }
114 }
115
116 , activate: function (target) {
117 var active
118 , selector
119
120 this.activeTarget = target
121
122 $(this.selector)
123 .parent('.active')
124 .removeClass('active')
125
126 selector = this.selector
127 + '[data-target="' + target + '"],'
128 + this.selector + '[href="' + target + '"]'
129
130 active = $(selector)
131 .parent('li')
132 .addClass('active')
133
134 if (active.parent('.dropdown-menu').length) {
135 active = active.closest('li.dropdown').addClass('active')
136 }
137
138 active.trigger('activate')
139 }
140
141 }
142
143
144 /* SCROLLSPY PLUGIN DEFINITION
145 * =========================== */
146
147 var old = $.fn.scrollspy
148
149 $.fn.scrollspy = function (option) {
150 return this.each(function () {
151 var $this = $(this)
152 , data = $this.data('scrollspy')
153 , options = typeof option == 'object' && option
154 if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
155 if (typeof option == 'string') data[option]()
156 })
157 }
158
159 $.fn.scrollspy.Constructor = ScrollSpy
160
161 $.fn.scrollspy.defaults = {
162 offset: 10
163 }
164
165
166 /* SCROLLSPY NO CONFLICT
167 * ===================== */
168
169 $.fn.scrollspy.noConflict = function () {
170 $.fn.scrollspy = old
171 return this
172 }
173
174
175 /* SCROLLSPY DATA-API
176 * ================== */
177
178 $(window).on('load', function () {
179 $('[data-spy="scroll"]').each(function () {
180 var $spy = $(this)
181 $spy.scrollspy($spy.data())
182 })
183 })
184
185}(window.jQuery); \ No newline at end of file