diff --git a/src/main/webapp/WEB-INF/pages/main_new.jsp b/src/main/webapp/WEB-INF/pages/main_new.jsp
index b1d6ae446..98da7e0c2 100644
--- a/src/main/webapp/WEB-INF/pages/main_new.jsp
+++ b/src/main/webapp/WEB-INF/pages/main_new.jsp
@@ -47,9 +47,10 @@
-
-
+
+
+
@@ -211,7 +212,7 @@
alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
'\n\nThe output div should have already been updated with the responseText.');
}
- makeFormsAjax();
+ goat.utils.makeFormsAjax();
}
diff --git a/src/main/webapp/js/goatConstants.js b/src/main/webapp/js/goatConstants.js
index 2c7ee6e5c..6880e5fc8 100644
--- a/src/main/webapp/js/goatConstants.js
+++ b/src/main/webapp/js/goatConstants.js
@@ -1,9 +1,8 @@
//goatConstants
-var goatConstants = {};
-
-goatConstants.CATEGORYCLASS = 'fa-angle-right pull-right';
-goatConstants.menuPrefix = [
+var goatConstants = {
+ CATEGORYCLASS:'fa-angle-right pull-right',
+ menuPrefix : [
{
name:'LESSONS',
type:'STATIC',
@@ -11,5 +10,7 @@ goatConstants.menuPrefix = [
link:'',
children:null,
class:'fa-bars static'
- }
-];
+ }],
+ lessonService: 'service/lessonmenu.mvc'
+};
+
diff --git a/src/main/webapp/js/goat.js b/src/main/webapp/js/goatControllers.js
similarity index 75%
rename from src/main/webapp/js/goat.js
rename to src/main/webapp/js/goatControllers.js
index c920e1b43..c6bacc381 100644
--- a/src/main/webapp/js/goat.js
+++ b/src/main/webapp/js/goatControllers.js
@@ -7,10 +7,10 @@
* prepares and updates menu topic items for the view
*/
goat.controller('goatLesson', function($scope, $http, $modal, $log) {
- //TODO: implement via separate promise and use config for menu
- $http({method: 'GET', url: 'service/lessonmenu.mvc'}).then(
+ //TODO: implement via separate promise and use config for menu (goat.data.loadMenuData())
+ $http({method: 'GET', url: goatConstants.lessonService}).then(
function(menuData) {
- var menuItems = goat.addMenuClasses(goatConstants.menuPrefix.concat(menuData.data));
+ var menuItems = goat.utils.addMenuClasses(goatConstants.menuPrefix.concat(menuData.data));
$scope.menuTopics = menuItems;
},
function(error) {
@@ -21,12 +21,12 @@ goat.controller('goatLesson', function($scope, $http, $modal, $log) {
$scope.renderLesson = function(url) {
console.log(url + ' was passed in');
// use jquery to render lesson content to div
- loadLessonContent(url).then(
+ goat.data.loadLessonContent(url).then(
function(reply) {
$("#lesson_content").html(reply);
// hook forms
- makeFormsAjax();
- $('#lessonTitle').text(extractLessonTitle($(reply)));
+ goat.utils.makeFormsAjax();
+ $('#lessonTitle').text(goat.utils.extractLessonTitle($(reply)));
// adjust menu to lessonContent size if necssary
if ($('div.panel-body').height() > 400) {
$('#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
* @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 */
var showSourceController = function($scope, $modalInstance, lessonSource) {
diff --git a/src/main/webapp/js/goatData.js b/src/main/webapp/js/goatData.js
new file mode 100644
index 000000000..8c7f86881
--- /dev/null
+++ b/src/main/webapp/js/goatData.js
@@ -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'});
+ }
+};
diff --git a/src/main/webapp/js/goatUtil.js b/src/main/webapp/js/goatUtil.js
new file mode 100644
index 000000000..115c8eaf4
--- /dev/null
+++ b/src/main/webapp/js/goatUtil.js
@@ -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());
+});
\ No newline at end of file
diff --git a/src/main/webapp/js/ui-util.js b/src/main/webapp/js/ui-util.js
deleted file mode 100644
index b67534369..000000000
--- a/src/main/webapp/js/ui-util.js
+++ /dev/null
@@ -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());
-});
-