fixed_footer-rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/fixed_footer-rails/version.rb +1 -1
- data/vendor/assets/javascripts/fixed-footer.js +15 -33
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61c03c1beeb3efa7570f7f65ec776bbd3c6b3477
|
4
|
+
data.tar.gz: becc29d3871ecd8a8618a4aa0aa99c5e1ef3fbf4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 573100e9ecb1fb191583cf7f612d9211ef59000ba17eb273d7e6528f9cdc7c5530b6be0c8fc3dc231f9ee50c8ec0ec1df69660569744297b2706a2c17f6e1df2
|
7
|
+
data.tar.gz: 87084cf1dfae1c208697d7ec929fe2447d94f5696c54c5cd2f4b408b533101e2db680a82952718e7fa66db2e90cb717a2b6ee790d13d0e1136b979613aa0edf7
|
data/README.md
CHANGED
@@ -26,8 +26,8 @@ And in your application.js manifest:
|
|
26
26
|
|
27
27
|
Call constructor.
|
28
28
|
|
29
|
-
```
|
30
|
-
# app/assets/javascripts/
|
29
|
+
```coffeescript
|
30
|
+
# app/assets/javascripts/footer.coffee
|
31
31
|
$(document).on "turbolinks:load", ->
|
32
32
|
new FixedFooter("your-footer-id")
|
33
33
|
```
|
@@ -1,15 +1,14 @@
|
|
1
1
|
window.FixedFooter = function(id) {
|
2
|
-
var
|
3
|
-
footer
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
var dh, fh, ft, wh;
|
9
|
-
dh = document.getElementsByTagName("body")[0].clientHeight;
|
2
|
+
var footer = document.getElementById(id);
|
3
|
+
if (!footer) { return null; }
|
4
|
+
|
5
|
+
var footerFixed = function() {
|
6
|
+
var footer = document.getElementById(id);
|
7
|
+
var dh = document.getElementsByTagName("body")[0].clientHeight;
|
10
8
|
footer.style.top = "0px";
|
11
|
-
ft = footer.offsetTop;
|
12
|
-
fh = footer.offsetHeight;
|
9
|
+
var ft = footer.offsetTop;
|
10
|
+
var fh = footer.offsetHeight;
|
11
|
+
var wh;
|
13
12
|
if (window.innerHeight) {
|
14
13
|
wh = window.innerHeight;
|
15
14
|
} else if (document.documentElement && document.documentElement.clientHeight !== 0) {
|
@@ -17,29 +16,11 @@ window.FixedFooter = function(id) {
|
|
17
16
|
}
|
18
17
|
if (ft + fh < wh) {
|
19
18
|
footer.style.position = "relative";
|
20
|
-
|
19
|
+
footer.style.top = wh - fh - ft - 1 + "px";
|
21
20
|
}
|
22
21
|
};
|
23
|
-
|
24
|
-
|
25
|
-
e = document.createElement("div");
|
26
|
-
s = document.createTextNode("S");
|
27
|
-
checkBoxSize = function() {
|
28
|
-
var defHeight;
|
29
|
-
if (defHeight !== e.offsetHeight) {
|
30
|
-
callback();
|
31
|
-
return defHeight = e.offsetHeight;
|
32
|
-
}
|
33
|
-
};
|
34
|
-
e.appendChild(s);
|
35
|
-
e.style.visibility = "hidden";
|
36
|
-
e.style.position = "absolute";
|
37
|
-
e.style.top = "0";
|
38
|
-
document.body.appendChild(e);
|
39
|
-
defHeight = e.offsetHeight;
|
40
|
-
return setInterval(checkBoxSize, 1000);
|
41
|
-
};
|
42
|
-
addEvent = function(elm, listener, fn) {
|
22
|
+
|
23
|
+
var addEvent = function(elm, listener, fn) {
|
43
24
|
var e;
|
44
25
|
try {
|
45
26
|
elm.addEventListener(listener, fn, false);
|
@@ -48,6 +29,7 @@ window.FixedFooter = function(id) {
|
|
48
29
|
elm.attachEvent("on" + listener, fn);
|
49
30
|
}
|
50
31
|
};
|
51
|
-
|
52
|
-
|
32
|
+
|
33
|
+
footerFixed();
|
34
|
+
addEvent(window, "resize", footerFixed);
|
53
35
|
};
|