js file reorganization, basic name spacing
This commit is contained in:
parent
53b6c16fb6
commit
5f378a7520
@ -47,9 +47,10 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var goat=angular.module("goatApp", ['ngAnimate','ui.bootstrap']);
|
var goat=angular.module("goatApp", ['ngAnimate','ui.bootstrap']);
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="js/ui-util.js"></script>
|
|
||||||
<script type="text/javascript" src="js/goat.js"></script>
|
|
||||||
<script type="text/javascript" src="js/goatConstants.js"></script>
|
<script type="text/javascript" src="js/goatConstants.js"></script>
|
||||||
|
<script type="text/javascript" src="js/goatUtil.js"></script>
|
||||||
|
<script type="text/javascript" src="js/goatData.js"></script>
|
||||||
|
<script type="text/javascript" src="js/goatControllers.js"></script>
|
||||||
<!-- end of JS -->
|
<!-- end of JS -->
|
||||||
|
|
||||||
|
|
||||||
@ -211,7 +212,7 @@
|
|||||||
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
|
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
|
||||||
'\n\nThe output div should have already been updated with the responseText.');
|
'\n\nThe output div should have already been updated with the responseText.');
|
||||||
}
|
}
|
||||||
makeFormsAjax();
|
goat.utils.makeFormsAjax();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
//goatConstants
|
//goatConstants
|
||||||
|
|
||||||
var goatConstants = {};
|
var goatConstants = {
|
||||||
|
CATEGORYCLASS:'fa-angle-right pull-right',
|
||||||
goatConstants.CATEGORYCLASS = 'fa-angle-right pull-right';
|
menuPrefix : [
|
||||||
goatConstants.menuPrefix = [
|
|
||||||
{
|
{
|
||||||
name:'LESSONS',
|
name:'LESSONS',
|
||||||
type:'STATIC',
|
type:'STATIC',
|
||||||
@ -11,5 +10,7 @@ goatConstants.menuPrefix = [
|
|||||||
link:'',
|
link:'',
|
||||||
children:null,
|
children:null,
|
||||||
class:'fa-bars static'
|
class:'fa-bars static'
|
||||||
}
|
}],
|
||||||
];
|
lessonService: 'service/lessonmenu.mvc'
|
||||||
|
};
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
* prepares and updates menu topic items for the view
|
* prepares and updates menu topic items for the view
|
||||||
*/
|
*/
|
||||||
goat.controller('goatLesson', function($scope, $http, $modal, $log) {
|
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 (goat.data.loadMenuData())
|
||||||
$http({method: 'GET', url: 'service/lessonmenu.mvc'}).then(
|
$http({method: 'GET', url: goatConstants.lessonService}).then(
|
||||||
function(menuData) {
|
function(menuData) {
|
||||||
var menuItems = goat.addMenuClasses(goatConstants.menuPrefix.concat(menuData.data));
|
var menuItems = goat.utils.addMenuClasses(goatConstants.menuPrefix.concat(menuData.data));
|
||||||
$scope.menuTopics = menuItems;
|
$scope.menuTopics = menuItems;
|
||||||
},
|
},
|
||||||
function(error) {
|
function(error) {
|
||||||
@ -21,12 +21,12 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
|
|||||||
$scope.renderLesson = function(url) {
|
$scope.renderLesson = function(url) {
|
||||||
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(
|
goat.data.loadLessonContent(url).then(
|
||||||
function(reply) {
|
function(reply) {
|
||||||
$("#lesson_content").html(reply);
|
$("#lesson_content").html(reply);
|
||||||
// hook forms
|
// hook forms
|
||||||
makeFormsAjax();
|
goat.utils.makeFormsAjax();
|
||||||
$('#lessonTitle').text(extractLessonTitle($(reply)));
|
$('#lessonTitle').text(goat.utils.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());
|
||||||
@ -43,6 +43,7 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
|
|||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
//TODO: Move show Source into it's own angular controller
|
||||||
/*
|
/*
|
||||||
* Function to load lesson source
|
* Function to load lesson source
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
@ -93,34 +94,6 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//TODO add recursion to handle arr[i].children objects
|
|
||||||
// ... in case lower-level's need classes as well ... don't right now
|
|
||||||
goat.addMenuClasses = function(arr) {
|
|
||||||
for (var i = 0; i < arr.length; i++) {
|
|
||||||
var menuItem = arr[i];
|
|
||||||
//console.log(menuItem);
|
|
||||||
if (menuItem.type && menuItem.type === 'CATEGORY') {
|
|
||||||
menuItem.class = 'fa-angle-right pull-right';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* ### GOAT DATA/PROMISES ### */
|
|
||||||
|
|
||||||
|
|
||||||
function loadLessonContent(_url) {
|
|
||||||
//TODO: switch to $http (angular) later
|
|
||||||
//return $http({method:'GET', url: _url});
|
|
||||||
return $.get(_url, {}, null, "html");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadMenuData() {
|
|
||||||
return $http({method: 'GET', url: 'service/lessonmenu.mvc'});
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Controllers for modal instances */
|
/* Controllers for modal instances */
|
||||||
var showSourceController = function($scope, $modalInstance, lessonSource) {
|
var showSourceController = function($scope, $modalInstance, lessonSource) {
|
||||||
|
|
13
src/main/webapp/js/goatData.js
Normal file
13
src/main/webapp/js/goatData.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/* ### GOAT DATA/PROMISES ### */
|
||||||
|
|
||||||
|
goat.data = {
|
||||||
|
loadLessonContent: function (_url) {
|
||||||
|
//TODO: switch to $http (angular) later
|
||||||
|
//return $http({method:'GET', url: _url});
|
||||||
|
return $.get(_url, {}, null, "html");
|
||||||
|
},
|
||||||
|
loadMenuData: function() {
|
||||||
|
//TODO use goatConstants var for url
|
||||||
|
return $http({method: 'GET', url: 'service/lessonmenu.mvc'});
|
||||||
|
}
|
||||||
|
};
|
34
src/main/webapp/js/goatUtil.js
Normal file
34
src/main/webapp/js/goatUtil.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
goat.utils = {
|
||||||
|
//TODO add recursion to handle arr[i].children objects
|
||||||
|
// ... in case lower-level's need classes as well ... don't right now
|
||||||
|
addMenuClasses: function(arr) {
|
||||||
|
for (var i = 0; i < arr.length; i++) {
|
||||||
|
var menuItem = arr[i];
|
||||||
|
//console.log(menuItem);
|
||||||
|
if (menuItem.type && menuItem.type === 'CATEGORY') {
|
||||||
|
menuItem.class = 'fa-angle-right pull-right';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
},
|
||||||
|
makeFormsAjax: function() {
|
||||||
|
//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();
|
||||||
|
return title;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// ### GLOBAL FUNCTIONS ## //
|
||||||
|
|
||||||
|
|
||||||
|
$(window).resize(function() {
|
||||||
|
//$('#leftside-navigation').css('height',$('div.panel-body').height());
|
||||||
|
console.log($(window).height());
|
||||||
|
});
|
@ -1,15 +0,0 @@
|
|||||||
function makeFormsAjax() {
|
|
||||||
//console.log("Hooking any lesson forms to make them ajax");
|
|
||||||
$("form").ajaxForm(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractLessonTitle(el) {
|
|
||||||
var title = $('h1',el).text();
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(window).resize(function() {
|
|
||||||
//$('#leftside-navigation').css('height',$('div.panel-body').height());
|
|
||||||
console.log($(window).height());
|
|
||||||
});
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user