From e22ff6f8bb653559a4419ae609f32ed24431a13a Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Wed, 21 Dec 2016 16:41:28 +0100 Subject: [PATCH 1/4] Fix an issue with sample editing and type/group dropdowns [SCI-819] --- .../samples/sample_datatable.js.erb | 2 -- app/assets/javascripts/sitewide/utils.js | 33 ------------------- 2 files changed, 35 deletions(-) diff --git a/app/assets/javascripts/samples/sample_datatable.js.erb b/app/assets/javascripts/samples/sample_datatable.js.erb index f26483041..fec699502 100644 --- a/app/assets/javascripts/samples/sample_datatable.js.erb +++ b/app/assets/javascripts/samples/sample_datatable.js.erb @@ -782,7 +782,6 @@ function createSampleTypeSelect(data, selected) { .attr('value', val.id).text(val.name); $selectType.append($option); }); - $selectType.makeDropdownOptionsLinks(selected, 'add-mode'); return $selectType; } @@ -810,7 +809,6 @@ function createSampleGroupSelect(data, selected) { $selectGroup.append($option); }); - $selectGroup.makeDropdownOptionsLinks(selected, 'add-mode'); return $selectGroup; } diff --git a/app/assets/javascripts/sitewide/utils.js b/app/assets/javascripts/sitewide/utils.js index aed8f6623..f42f515c2 100644 --- a/app/assets/javascripts/sitewide/utils.js +++ b/app/assets/javascripts/sitewide/utils.js @@ -215,36 +215,3 @@ function initPageTutorialSteps(pageFirstStepN, pageLastStepN, nextPagePath, }); } } - -/** - * Add redirection links on dropdown elements. You must specify 'href' - * attribute yourself, and the dropdown elments which don't have them, will get - * '#' by default. - * @param {number} selectedIdx Index of element to be selected - * @param {string} urlParam URL parameter to pass to the link URLs - * @return {Object} This - */ -$.fn.makeDropdownOptionsLinks = function(selectedIdx, urlParam) { - selectedIdx = _.isUndefined(selectedIdx) ? -1 : selectedIdx; - - $(this).change(function() { - window.location.href = addParam($(this).find('option:selected') - .attr('href'), urlParam); - }); - - $(this).find('option') - .each(function() { - if ($(this).is('[href]')) { - $(this).addClass('link-look'); - } else { - $(this).attr('href', '#'); - } - }); - var selectedOpt = $(this).find('option[value="' + selectedIdx + '"]'); - if (!selectedOpt.length) { - selectedOpt = $(this).find('option').eq(0); - } - selectedOpt.attr('selected', true); - - return this; -}; From 4065be9e4eedd947bf87337f511e102058917d88 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 22 Dec 2016 12:57:49 +0100 Subject: [PATCH 2/4] Fix marking of selected option [SCI-819] --- .../samples/sample_datatable.js.erb | 7 ++++- app/assets/javascripts/sitewide/utils.js | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/samples/sample_datatable.js.erb b/app/assets/javascripts/samples/sample_datatable.js.erb index fec699502..bdd205888 100644 --- a/app/assets/javascripts/samples/sample_datatable.js.erb +++ b/app/assets/javascripts/samples/sample_datatable.js.erb @@ -780,6 +780,9 @@ function createSampleTypeSelect(data, selected) { $.each(data, function(i, val) { var $option = $('') .attr('value', val.id).text(val.name); + if((i + 1) === selected) { + $option.attr('selected', true); + } $selectType.append($option); }); return $selectType; @@ -806,7 +809,9 @@ function createSampleGroupSelect(data, selected) { var $option = $('') .attr('value', val.id).text(val.name) .attr('data-content', $span.prop('outerHTML') + ' ' + val.name); - + if((i + 1) === selected) { + $option.attr('selected', true); + } $selectGroup.append($option); }); return $selectGroup; diff --git a/app/assets/javascripts/sitewide/utils.js b/app/assets/javascripts/sitewide/utils.js index f42f515c2..50224bb57 100644 --- a/app/assets/javascripts/sitewide/utils.js +++ b/app/assets/javascripts/sitewide/utils.js @@ -215,3 +215,32 @@ function initPageTutorialSteps(pageFirstStepN, pageLastStepN, nextPagePath, }); } } + +/** + * Add redirection links on dropdown elements. You must specify 'href' + * attribute yourself, and the dropdown elments which don't have them, will get + * '#' by default. + * @param {number} selectedIdx Index of element to be selected + * @param {string} urlParam URL parameter to pass to the link URLs + * @return {Object} This + */ +$.fn.makeDropdownOptionsLinks = function(selectedIdx, urlParam) { + selectedIdx = _.isUndefined(selectedIdx) ? 1 : selectedIdx; + + $(this).change(function() { + window.location.href = addParam($(this).find('option:selected') + .attr('href'), urlParam); + }); + + $(this).find('option') + .each(function() { + if ($(this).is('[href]')) { + $(this).addClass('link-look'); + } else { + $(this).attr('href', '#'); + } + }) + .eq(selectedIdx).attr('selected', true); + + return this; +}; From 0d01a4b2bd7ab6ebc6d483456c3601fce559aaff Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Thu, 22 Dec 2016 13:01:37 +0100 Subject: [PATCH 3/4] Remove unneeded function from utils.js [SCI-819] --- app/assets/javascripts/sitewide/utils.js | 29 ------------------------ 1 file changed, 29 deletions(-) diff --git a/app/assets/javascripts/sitewide/utils.js b/app/assets/javascripts/sitewide/utils.js index 50224bb57..f42f515c2 100644 --- a/app/assets/javascripts/sitewide/utils.js +++ b/app/assets/javascripts/sitewide/utils.js @@ -215,32 +215,3 @@ function initPageTutorialSteps(pageFirstStepN, pageLastStepN, nextPagePath, }); } } - -/** - * Add redirection links on dropdown elements. You must specify 'href' - * attribute yourself, and the dropdown elments which don't have them, will get - * '#' by default. - * @param {number} selectedIdx Index of element to be selected - * @param {string} urlParam URL parameter to pass to the link URLs - * @return {Object} This - */ -$.fn.makeDropdownOptionsLinks = function(selectedIdx, urlParam) { - selectedIdx = _.isUndefined(selectedIdx) ? 1 : selectedIdx; - - $(this).change(function() { - window.location.href = addParam($(this).find('option:selected') - .attr('href'), urlParam); - }); - - $(this).find('option') - .each(function() { - if ($(this).is('[href]')) { - $(this).addClass('link-look'); - } else { - $(this).attr('href', '#'); - } - }) - .eq(selectedIdx).attr('selected', true); - - return this; -}; From c77c83752effa8a39473d8794797bda19ce8e8f8 Mon Sep 17 00:00:00 2001 From: Oleksii Kriuchykhin Date: Fri, 30 Dec 2016 12:18:11 +0100 Subject: [PATCH 4/4] Remove unused css class link-look [SCI-819] --- app/assets/stylesheets/themes/scinote.scss | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/app/assets/stylesheets/themes/scinote.scss b/app/assets/stylesheets/themes/scinote.scss index fbdfa45f2..067fc0128 100644 --- a/app/assets/stylesheets/themes/scinote.scss +++ b/app/assets/stylesheets/themes/scinote.scss @@ -235,18 +235,6 @@ body { a { color: $color-theme-primary; - - // Override to make link look and behave as a normal link (e.g. used for - // elements which have links) - &.link-look { - color: $color-theme-primary !important; - - :hover, - :focus { - color: $color-visited-link !important; - text-decoration: underline !important; - } - } } .jumbotron {