From cf9130a8112f62596e6e915aca6c5a6140056c90 Mon Sep 17 00:00:00 2001 From: kimth Date: Thu, 13 Sep 2012 17:51:25 -0400 Subject: [PATCH 1/3] Widow prevention should be active when there are actual words --- lms/templates/courseware/courseware.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index 15e4dead9a..9dc0fa2a55 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -41,7 +41,7 @@ $(".ui-accordion-header a, .ui-accordion-content .subtitle").each(function() { var wordArray = $(this).text().split(" "); var finalTitle = ""; - if ($.isEmptyObject(wordArray)) { + if (!($.isEmptyObject(wordArray))) { for (i=0;i<=wordArray.length-1;i++) { finalTitle += wordArray[i]; if (i == (wordArray.length-2)) { From 5dbc0b7e7aabf0f2775313a890fc1c48eeb70fe2 Mon Sep 17 00:00:00 2001 From: kimth Date: Thu, 13 Sep 2012 18:02:46 -0400 Subject: [PATCH 2/3] Fix widow prevent logic --- lms/templates/courseware/courseware.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index 9dc0fa2a55..ee6460ffec 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -39,7 +39,8 @@ $(function(){ $(".ui-accordion-header a, .ui-accordion-content .subtitle").each(function() { - var wordArray = $(this).text().split(" "); + var elemText = $(this).text().replace(/^\s+|\s+$/g,''); // Strip leading and trailing whitespace + var wordArray = elemText.split(" "); var finalTitle = ""; if (!($.isEmptyObject(wordArray))) { for (i=0;i<=wordArray.length-1;i++) { @@ -50,8 +51,8 @@ finalTitle += " "; } } - $(this).html(finalTitle); } + $(this).html(finalTitle); }); }); From a40e8eaefbb73544c7033a9f85b1d6cc5abe3a54 Mon Sep 17 00:00:00 2001 From: kimth Date: Thu, 13 Sep 2012 18:10:11 -0400 Subject: [PATCH 3/3] Clean up widow prevention logic --- lms/templates/courseware/courseware.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lms/templates/courseware/courseware.html b/lms/templates/courseware/courseware.html index ee6460ffec..761237fd76 100644 --- a/lms/templates/courseware/courseware.html +++ b/lms/templates/courseware/courseware.html @@ -42,11 +42,13 @@ var elemText = $(this).text().replace(/^\s+|\s+$/g,''); // Strip leading and trailing whitespace var wordArray = elemText.split(" "); var finalTitle = ""; - if (!($.isEmptyObject(wordArray))) { + if (wordArray.length > 0) { for (i=0;i<=wordArray.length-1;i++) { finalTitle += wordArray[i]; if (i == (wordArray.length-2)) { finalTitle += " "; + } else if (i == (wordArray.length-1)) { + // Do nothing } else { finalTitle += " "; }