From b8f3e875e739a0f008a78f421d6a12dfd9dfca86 Mon Sep 17 00:00:00 2001 From: Tim Steiner <tsteiner2@unl.edu> Date: Wed, 20 Nov 2013 11:24:45 -0600 Subject: [PATCH] Add a remove button to each FYP concentration tab. @0h45 --- .../fouryearplans/views/scripts/edit/index.phtml | 7 ++++++- document_root/css/fouryearplans/edit.css | 13 +++++++++++++ document_root/javascript/fouryearplans/edit.js | 13 +++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/application/modules/fouryearplans/views/scripts/edit/index.phtml b/application/modules/fouryearplans/views/scripts/edit/index.phtml index d22771a6..3ca18ba6 100644 --- a/application/modules/fouryearplans/views/scripts/edit/index.phtml +++ b/application/modules/fouryearplans/views/scripts/edit/index.phtml @@ -26,7 +26,12 @@ $stubConcentrations = array('stub' => '+'); <ul class="wdn_tabs"> <?php foreach ($this->fourYearPlan->getConcentrations() + $stubConcentrations as $concentrationId => $concentration) { ?> - <li><a href="#concentration-<?php echo $concentrationId; ?>"><?php echo $this->escape($concentration); ?></a></li> + <li> + <a href="#concentration-<?php echo $concentrationId; ?>"> + <span class="name"><?php echo $this->escape($concentration); ?></span> + <span class="minibutton remove">x</span> + </a> + </li> <?php } ?> </ul> <div class="wdn_tabs_content"> diff --git a/document_root/css/fouryearplans/edit.css b/document_root/css/fouryearplans/edit.css index 352a80fe..d5053c13 100644 --- a/document_root/css/fouryearplans/edit.css +++ b/document_root/css/fouryearplans/edit.css @@ -1,2 +1,15 @@ .input-hours {width: 3em;} .semester td {white-space: nowrap;} +a[href="#concentration-stub"] span.minibutton {display: none;} +.minibutton.remove { + margin-right: -0.4em; + padding: 0 0.4em; + border: 1px solid transparent; + border-radius: 1em; + color: #888; +} +.minibutton.remove:hover { + border-color: #c44; + background-color: #fcc; + color: #c44; +} diff --git a/document_root/javascript/fouryearplans/edit.js b/document_root/javascript/fouryearplans/edit.js index 873cec37..ac301fc9 100644 --- a/document_root/javascript/fouryearplans/edit.js +++ b/document_root/javascript/fouryearplans/edit.js @@ -102,6 +102,7 @@ WDN.jQuery(function() { var newTabIndex = 0; + WDN.tabs.useHashChange = false; WDN.jQuery('ul.wdn_tabs').on('tabchanged', function() { var selectedTab = WDN.jQuery(this).find('.selected'); if (selectedTab.find('a').attr('href') != '#concentration-stub') { @@ -114,7 +115,7 @@ WDN.jQuery(function() { selectedTab.before(newTab); newTab.find('a').attr('href', '#concentration-new' + newTabIndex); - newTab.find('a').text('New Concentration'); + newTab.find('a span.name').text('New Concentration'); var stubContent = WDN.jQuery('#concentration-stub'); var newContent = stubContent.clone(); @@ -138,9 +139,17 @@ WDN.jQuery(function() { newTab.find('a').trigger('click'); }, 50); }); + WDN.jQuery('ul.wdn_tabs').on('click', '.minibutton.remove', function() { + var tab = WDN.jQuery(this).parent().parent(); + var content = WDN.jQuery(tab.find('a').attr('href')); + + tab.remove(); + content.remove(); + return false; + }); WDN.jQuery('.wdn_tabs_content').on('keyup', '.concentration-name', function() { - WDN.jQuery('.wdn_tabs .selected a').text(this.value); + WDN.jQuery('.wdn_tabs .selected a span.name').text(this.value); }) WDN.jQuery('.semester').on('click', '.course-row .text-hours', function() { -- GitLab