wire up show source service to button
This commit is contained in:
parent
48c31458aa
commit
53b6c16fb6
@ -74,7 +74,7 @@
|
|||||||
<button type="button" class="btn btn-primary btn-sm">Params/Cookies</button>
|
<button type="button" class="btn btn-primary btn-sm">Params/Cookies</button>
|
||||||
<button type="button" class="btn btn-primary btn-sm">Hints</button>
|
<button type="button" class="btn btn-primary btn-sm">Hints</button>
|
||||||
<button type="button" class="btn btn-primary btn-sm">Lesson Plan</button>
|
<button type="button" class="btn btn-primary btn-sm">Lesson Plan</button>
|
||||||
<button type="button" class="btn btn-primary btn-sm">Java [Source]</button>
|
<button type="button" class="btn btn-primary btn-sm" ng-click="showSource('lg')">Java [Source]</button>
|
||||||
<button type="button" class="btn btn-primary btn-sm">Solution</button>
|
<button type="button" class="btn btn-primary btn-sm">Solution</button>
|
||||||
</div><!--toggle navigation end-->
|
</div><!--toggle navigation end-->
|
||||||
</header>
|
</header>
|
||||||
@ -115,7 +115,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<h4>Lesson Source Code</h4>
|
<h4>Lesson Source Code</h4>
|
||||||
@ -126,6 +126,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
-->
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@ -133,7 +134,6 @@
|
|||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
||||||
<!-- <script src="plugins/waypoints/waypoints.min.js"></script> -->
|
<!-- <script src="plugins/waypoints/waypoints.min.js"></script> -->
|
||||||
<!-- <script src="js/application.js"></script> -->
|
<!-- <script src="js/application.js"></script> -->
|
||||||
|
|
||||||
@ -216,4 +216,21 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
<!-- Modals -->
|
||||||
|
<script type="text/ng-template" id="showSource.html">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button class="btn btn-primary pull-right" ng-click="ok()">Close</button>
|
||||||
|
<h3 class="modal-title">Lesson Source</h3>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<pre>{{lessonSource}}</pre>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-primary" ng-click="ok()">Close</button>
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/** Menu Controller
|
/** Menu Controller
|
||||||
* prepares and updates menu topic items for the view
|
* prepares and updates menu topic items for the view
|
||||||
*/
|
*/
|
||||||
goat.controller('goatLesson', function($scope, $http) {
|
goat.controller('goatLesson', function($scope, $http, $modal, $log) {
|
||||||
//TODO: implement via separate promise and use config for menu
|
//TODO: implement via separate promise and use config for menu
|
||||||
$http({method: 'GET', url: 'service/lessonmenu.mvc'}).then(
|
$http({method: 'GET', url: 'service/lessonmenu.mvc'}).then(
|
||||||
function(menuData) {
|
function(menuData) {
|
||||||
@ -22,42 +22,75 @@ goat.controller('goatLesson', function($scope, $http) {
|
|||||||
console.log(url + ' was passed in');
|
console.log(url + ' was passed in');
|
||||||
// use jquery to render lesson content to div
|
// use jquery to render lesson content to div
|
||||||
loadLessonContent(url).then(
|
loadLessonContent(url).then(
|
||||||
function(reply) {
|
function(reply) {
|
||||||
$("#lesson_content").html(reply);
|
$("#lesson_content").html(reply);
|
||||||
// hook forms
|
// hook forms
|
||||||
makeFormsAjax();
|
makeFormsAjax();
|
||||||
$('#lessonTitle').text(extractLessonTitle($(reply)));
|
$('#lessonTitle').text(extractLessonTitle($(reply)));
|
||||||
// adjust menu to lessonContent size if necssary
|
// adjust menu to lessonContent size if necssary
|
||||||
if ($('div.panel-body').height() > 400) {
|
if ($('div.panel-body').height() > 400) {
|
||||||
$('#leftside-navigation').height($(window).height());
|
$('#leftside-navigation').height($(window).height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
/*
|
||||||
console.log("Updating Lesson Source...");
|
console.log("Updating Lesson Source...");
|
||||||
$http.get('service/source.mvc').success( function(data){
|
$http.get('service/source.mvc').success(function(data) {
|
||||||
|
$scope.lessonSource = data.source;
|
||||||
|
}).error(function(data) {
|
||||||
|
$scope.lessonSource = data.message;
|
||||||
|
console.log("LessonSource = '" + data.message + "'");
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
/*
|
||||||
|
* Function to load lesson source
|
||||||
|
* @returns {undefined}
|
||||||
|
*/
|
||||||
|
$scope.showSource = function(size) {
|
||||||
|
// fetch source from web service
|
||||||
|
$http.get('service/source.mvc').success(function(data) {
|
||||||
$scope.lessonSource = data.source;
|
$scope.lessonSource = data.source;
|
||||||
}).error( function(data){
|
$scope.openSourceModal(size);
|
||||||
|
}).error(function(data) {
|
||||||
$scope.lessonSource = data.message;
|
$scope.lessonSource = data.message;
|
||||||
console.log("LessonSource = '" + data.message + "'");
|
console.log("LessonSource = '" + data.message + "'");
|
||||||
|
$scope.openSourceModal(size);
|
||||||
})
|
})
|
||||||
};
|
|
||||||
})
|
}
|
||||||
.animation('.slideDown', function() {
|
|
||||||
var NgHideClassName = 'ng-hide';
|
$scope.openSourceModal = function(size) {
|
||||||
return {
|
var modalInstance = $modal.open({
|
||||||
beforeAddClass: function(element, className, done) {
|
templateUrl: 'showSource.html',
|
||||||
if (className === NgHideClassName) {
|
controller: showSourceController,
|
||||||
$(element).slideUp(done);
|
size: size,
|
||||||
}
|
resolve: {
|
||||||
},
|
lessonSource: function() {
|
||||||
removeClass: function(element, className, done) {
|
return $scope.lessonSource;
|
||||||
if (className === NgHideClassName) {
|
|
||||||
$(element).hide().slideDown(done);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
modalInstance.result.then(function() {
|
||||||
|
$log.info('Modal dismissed at: ' + new Date());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}).animation('.slideDown', function() {
|
||||||
|
var NgHideClassName = 'ng-hide';
|
||||||
|
return {
|
||||||
|
beforeAddClass: function(element, className, done) {
|
||||||
|
if (className === NgHideClassName) {
|
||||||
|
$(element).slideUp(done);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
removeClass: function(element, className, done) {
|
||||||
|
if (className === NgHideClassName) {
|
||||||
|
$(element).hide().slideDown(done);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//TODO add recursion to handle arr[i].children objects
|
//TODO add recursion to handle arr[i].children objects
|
||||||
@ -80,7 +113,7 @@ goat.addMenuClasses = function(arr) {
|
|||||||
function loadLessonContent(_url) {
|
function loadLessonContent(_url) {
|
||||||
//TODO: switch to $http (angular) later
|
//TODO: switch to $http (angular) later
|
||||||
//return $http({method:'GET', url: _url});
|
//return $http({method:'GET', url: _url});
|
||||||
return $.get(_url,{},null,"html");
|
return $.get(_url, {}, null, "html");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,4 +121,19 @@ function loadMenuData() {
|
|||||||
return $http({method: 'GET', url: 'service/lessonmenu.mvc'});
|
return $http({method: 'GET', url: 'service/lessonmenu.mvc'});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Controllers for modal instances */
|
||||||
|
var showSourceController = function($scope, $modalInstance, lessonSource) {
|
||||||
|
|
||||||
|
$scope.lessonSource = lessonSource;
|
||||||
|
|
||||||
|
$scope.ok = function() {
|
||||||
|
$modalInstance.close();
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.cancel = function() {
|
||||||
|
$modalInstance.dismiss('cancel');
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user