teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

改善

2016/01/07 14:27

投稿

pac894398
pac894398

スコア429

title CHANGED
File without changes
body CHANGED
@@ -1,34 +1,6 @@
1
1
  アクセスされているファイル名と同じリンク先を持つリストのクラスに任意のものを加えているのだと思うのですが、よくわからないので解説をお願いします。
2
2
 
3
3
  ```jsvascript
4
- $(function() {
5
-
6
- $('#side-menu').metisMenu();
7
-
8
- });
9
-
10
- //Loads the correct sidebar on window load,
11
- //collapses the sidebar on window resize.
12
- // Sets the min-height of #page-wrapper to window size
13
- $(function() {
14
- $(window).bind("load resize", function() {
15
- topOffset = 50;
16
- width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
17
- if (width < 768) {
18
- $('div.navbar-collapse').addClass('collapse');
19
- topOffset = 100; // 2-row-menu
20
- } else {
21
- $('div.navbar-collapse').removeClass('collapse');
22
- }
23
-
24
- height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
25
- height = height - topOffset;
26
- if (height < 1) height = 1;
27
- if (height > topOffset) {
28
- $("#page-wrapper").css("min-height", (height) + "px");
29
- }
30
- });
31
-
32
4
  var url = window.location;
33
5
  var element = $('ul.nav a').filter(function() {
34
6
  return this.href == url || url.href.indexOf(this.href) == 0;

1

全般

2016/01/07 14:27

投稿

pac894398
pac894398

スコア429

title CHANGED
@@ -1,1 +1,1 @@
1
- 6行程のJSの解説をお願いします
1
+ JSの解説をお願いします
body CHANGED
@@ -1,6 +1,34 @@
1
1
  アクセスされているファイル名と同じリンク先を持つリストのクラスに任意のものを加えているのだと思うのですが、よくわからないので解説をお願いします。
2
2
 
3
3
  ```jsvascript
4
+ $(function() {
5
+
6
+ $('#side-menu').metisMenu();
7
+
8
+ });
9
+
10
+ //Loads the correct sidebar on window load,
11
+ //collapses the sidebar on window resize.
12
+ // Sets the min-height of #page-wrapper to window size
13
+ $(function() {
14
+ $(window).bind("load resize", function() {
15
+ topOffset = 50;
16
+ width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
17
+ if (width < 768) {
18
+ $('div.navbar-collapse').addClass('collapse');
19
+ topOffset = 100; // 2-row-menu
20
+ } else {
21
+ $('div.navbar-collapse').removeClass('collapse');
22
+ }
23
+
24
+ height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
25
+ height = height - topOffset;
26
+ if (height < 1) height = 1;
27
+ if (height > topOffset) {
28
+ $("#page-wrapper").css("min-height", (height) + "px");
29
+ }
30
+ });
31
+
4
32
  var url = window.location;
5
33
  var element = $('ul.nav a').filter(function() {
6
34
  return this.href == url || url.href.indexOf(this.href) == 0;
@@ -9,4 +37,5 @@
9
37
  element.addClass('active');
10
38
  }
11
39
  });
40
+
12
41
  ```