Added service for fetching the title of a lesson

This commit is contained in:
nbaars
2014-09-09 18:18:45 +02:00
parent ac46ddd4d9
commit f9d14c9b79
6 changed files with 53 additions and 16 deletions

View File

@ -19,6 +19,7 @@ var goatConstants = {
solutionService:'service/solution.mvc',
lessonPlanService:'service/lessonplan.mvc',
menuService: 'service/lessonmenu.mvc',
lessonTitleService: 'service/lessontitle.mvc',
// literals
notFound: 'Could not find',
noHints: 'There are no hints defined.'

View File

@ -27,19 +27,20 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log, $templateCac
$scope.hintIndex = 0;
var curScope = $scope;
curScope.parameters = goat.utils.scrapeParams(url);
goat.data.loadLessonContent(url).then(
function(reply) {
$("#lesson_content").html(reply);
goat.data.loadLessonTitle().then(
function(reply) {
$("#lessonTitle").text(reply);
}
);
//hook forms
goat.utils.makeFormsAjax();
$('#hintsView').hide();
//render lesson title
$('#lessonTitle').text(goat.utils.extractLessonTitle($(reply)));
//@KLUGE to remove h1 after extracting and moving it to top
$('#lesson_content h1').remove()
// adjust menu to lessonContent size if necssary
//@TODO: this is still clunky ... needs some TLC
if ($('div.panel-body').height() > 400) {

View File

@ -18,7 +18,7 @@ goat.data = {
return $.get(goatConstants.sourceService, {});
},
loadSolution: function () {
return $.get(goatConstants.solutionService, {})
return $.get(goatConstants.solutionService, {});
},
loadPlan: function () {
return $.get(goatConstants.lessonPlanService, {});
@ -30,5 +30,8 @@ goat.data = {
loadMenuData: function() {
//TODO use goatConstants var for url
return $http({method: 'GET', url: goatConstants.menuService});
},
loadLessonTitle: function () {
return $.get(goatConstants.lessonTitleService, {});
}
};

View File

@ -15,15 +15,6 @@ goat.utils = {
//console.log("Hooking any lesson forms to make them ajax");
$("form").ajaxForm(options);
},
/**goatApp.extractLessonTitle
*pulls lesson title from html fragment returned (looks for it in h1 element)
*@param - html rendered to object passed in
*/
extractLessonTitle: function(el) {
var title = $('h1', el).text();
// remove title
return title;
},
displayButton: function(id,show) {
if ($('#'+id)) {
if (show) {