From 2a5cd82143ea294e08783cf0aa401056d257e311 Mon Sep 17 00:00:00 2001 From: cgwennap Date: Tue, 5 Nov 2013 17:31:37 -0500 Subject: [PATCH 1/2] improved internal layout of course listing, enabled truncation --- app/assets/javascripts/filters.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/assets/javascripts/filters.js diff --git a/app/assets/javascripts/filters.js b/app/assets/javascripts/filters.js new file mode 100644 index 0000000..0d7010b --- /dev/null +++ b/app/assets/javascripts/filters.js @@ -0,0 +1,18 @@ +angular.module('filters', []). + filter('truncate', function () { + return function (text, length, end) { + if (isNaN(length)) + length = 10; + + if (end === undefined) + end = "..."; + + if (text.length <= length || text.length - end.length <= length) { + return text; + } + else { + return String(text).substring(0, length-end.length) + end; + } + + }; + }); From e0df328815fc597326e2c1696507e3ccb38ef0ae Mon Sep 17 00:00:00 2001 From: cgwennap Date: Tue, 5 Nov 2013 17:31:37 -0500 Subject: [PATCH 2/2] improved internal layout of course listing, enabled truncation --- app/assets/javascripts/app.js.coffee | 4 ++-- app/assets/javascripts/filters.js | 18 ++++++++++++++++++ public/views/courseList.html | 17 +++++++++++++---- 3 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 app/assets/javascripts/filters.js diff --git a/app/assets/javascripts/app.js.coffee b/app/assets/javascripts/app.js.coffee index 48a5ab2..dcab302 100644 --- a/app/assets/javascripts/app.js.coffee +++ b/app/assets/javascripts/app.js.coffee @@ -1,4 +1,4 @@ -CourseRegistrationApp = angular.module('CourseRegistrationApp', ['Controllers', 'Services', 'Directives']); +CourseRegistrationApp = angular.module('CourseRegistrationApp', ['Controllers', 'Services', 'Directives', 'filters']); CourseRegistrationApp.config(['$routeProvider', ($routeProvider) -> $routeProvider.when('/', {templateUrl: '/views/requirements.html', controller: 'RequirementsController', resolve: {ClassesStub: 'ClassesStub'}}) @@ -6,4 +6,4 @@ CourseRegistrationApp.config(['$routeProvider', ($routeProvider) -> $routeProvider.when('/search/:searchQuery', { templateUrl: '/views/courseList.html', controller: 'ClassListController', resolve: {ClassesStub: 'ClassesStub'} } ); $routeProvider.when('/requirements', { templateUrl: '/views/requirements.html', controller: 'RequirementsController', resolve: {ClassesStub: 'ClassesStub'}} ) $routeProvider.otherwise('/') -]); \ No newline at end of file +]); diff --git a/app/assets/javascripts/filters.js b/app/assets/javascripts/filters.js new file mode 100644 index 0000000..0d7010b --- /dev/null +++ b/app/assets/javascripts/filters.js @@ -0,0 +1,18 @@ +angular.module('filters', []). + filter('truncate', function () { + return function (text, length, end) { + if (isNaN(length)) + length = 10; + + if (end === undefined) + end = "..."; + + if (text.length <= length || text.length - end.length <= length) { + return text; + } + else { + return String(text).substring(0, length-end.length) + end; + } + + }; + }); diff --git a/public/views/courseList.html b/public/views/courseList.html index af968c3..0a54f58 100644 --- a/public/views/courseList.html +++ b/public/views/courseList.html @@ -8,14 +8,23 @@
-

{{course.className}}

-

{{course.professor}}

+
+
+

{{course.className}}

+
+
+

{{course.professor}}

+
+
-
-

{{course.description}}

+
+

{{course.description|truncate:25:"..."}}

+
+
+