Skip to content

Commit 1483df8

Browse files
committed
really fixed page load for lesson tests
1 parent 8e9f825 commit 1483df8

File tree

4 files changed

+73
-19
lines changed

4 files changed

+73
-19
lines changed

main/lessonTests/lessonTestsDirective.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,27 @@ angular.module('myApp')
77
controller: 'lessonTestsController',
88
link: function(scope, ele, attr) {
99

10+
// lesson test page load
1011
$('.lesson-test').click(function() {
11-
let testsParents = this.parentNode.parentNode.parentNode.parentNode;
12-
// console.log(testsParents.id); // id of parent lesson name
13-
// $('.lesson-tests-wrapper').html('<span>' + testsParents.id + '</span>');
14-
$('.lesson-tests-wrapper').load('./html/lessonTests/lessonFiles/' + testsParents.id + '.html');
12+
let selectedParent = this.parentNode.parentNode.parentNode.parentNode;
13+
let testNavigation = function() {
14+
$('.lesson-tests-wrapper').load('./html/lessonTests/lessonFiles/' + selectedParent.id + '.html');
15+
}
16+
1517
$('html, body').animate({ scrollTop: 0 }, 300);
16-
})
17-
if ($state.name !== 'lessonTests') {
18-
$state.go('lessonTests');
19-
}
18+
if ($state.name !== 'lessonTests') {
19+
$state.go('lessonTests');
20+
setTimeout(function() {
21+
testNavigation();
22+
$('.lesson-sections', this).toggle('expand');
23+
}, 100)
24+
} else {
25+
testNavigation();
26+
}
27+
}) // end lesson-test click
28+
2029

21-
}
30+
} // end link attr
2231
}
2332

2433
})

main/lessons/lessonsSideBarDirective.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ angular.module('myApp')
99
$('.lesson-title').click(function() {
1010
// console.log(this.parentNode);
1111
$('.lesson-sections', this.parentNode).toggle('expand');
12+
13+
// let closeOthers = allSiblings(this);
14+
// console.log(closeOthers);
1215
})
1316

1417
// $('.lesson-group').click(function() {
@@ -22,6 +25,20 @@ angular.module('myApp')
2225
// console.log(this.parentNode.parentNode.parentNode.parentNode);
2326
// })
2427

28+
// let allSiblings = function(elem) {
29+
// let siblings = [];
30+
// let sibling = elem.parentNode.firstChild;
31+
// var skipMe = elem;
32+
// for ( ; sibling; sibling = sibling.nextSibling) {
33+
// if (sibling.nodeType == 1 && sibling != elem) {
34+
// siblings.push(sibling);
35+
// }
36+
// }
37+
// return siblings;
38+
// }
39+
40+
41+
2542
}
2643
}
2744

main/navigation/navigationDirective.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ angular.module('myApp')
1313
})
1414

1515
profileMenu.click(function() {
16+
$('.lessons-wrapper').load();
1617
profileMenu.toggle('expand');
1718
})
1819
}

public/scripts/all.js

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ angular.module('myApp')
135135
$('.lesson-title').click(function() {
136136
// console.log(this.parentNode);
137137
$('.lesson-sections', this.parentNode).toggle('expand');
138+
139+
// let closeOthers = allSiblings(this);
140+
// console.log(closeOthers);
138141
})
139142

140143
// $('.lesson-group').click(function() {
@@ -148,6 +151,20 @@ angular.module('myApp')
148151
// console.log(this.parentNode.parentNode.parentNode.parentNode);
149152
// })
150153

154+
// let allSiblings = function(elem) {
155+
// let siblings = [];
156+
// let sibling = elem.parentNode.firstChild;
157+
// var skipMe = elem;
158+
// for ( ; sibling; sibling = sibling.nextSibling) {
159+
// if (sibling.nodeType == 1 && sibling != elem) {
160+
// siblings.push(sibling);
161+
// }
162+
// }
163+
// return siblings;
164+
// }
165+
166+
167+
151168
}
152169
}
153170

@@ -168,18 +185,27 @@ angular.module('myApp')
168185
controller: 'lessonTestsController',
169186
link: function(scope, ele, attr) {
170187

188+
// lesson test page load
171189
$('.lesson-test').click(function() {
172-
let testsParents = this.parentNode.parentNode.parentNode.parentNode;
173-
// console.log(testsParents.id); // id of parent lesson name
174-
// $('.lesson-tests-wrapper').html('<span>' + testsParents.id + '</span>');
175-
$('.lesson-tests-wrapper').load('./html/lessonTests/lessonFiles/' + testsParents.id + '.html');
176-
$('html, body').animate({ scrollTop: 0 }, 300);
177-
})
178-
if ($state.name !== 'lessonTests') {
179-
$state.go('lessonTests');
180-
}
190+
let selectedParent = this.parentNode.parentNode.parentNode.parentNode;
191+
let testNavigation = function() {
192+
$('.lesson-tests-wrapper').load('./html/lessonTests/lessonFiles/' + selectedParent.id + '.html');
193+
}
181194

182-
}
195+
$('html, body').animate({ scrollTop: 0 }, 300);
196+
if ($state.name !== 'lessonTests') {
197+
$state.go('lessonTests');
198+
setTimeout(function() {
199+
testNavigation();
200+
$('.lesson-sections', this).toggle('expand');
201+
}, 100)
202+
} else {
203+
testNavigation();
204+
}
205+
}) // end lesson-test click
206+
207+
208+
} // end link attr
183209
}
184210

185211
}])
@@ -301,6 +327,7 @@ angular.module('myApp')
301327
})
302328

303329
profileMenu.click(function() {
330+
$('.lessons-wrapper').load();
304331
profileMenu.toggle('expand');
305332
})
306333
}

0 commit comments

Comments
 (0)