diff --git a/ckan/public/css/style.css b/ckan/public/css/style.css index 9644473089b..3d9758013ce 100644 --- a/ckan/public/css/style.css +++ b/ckan/public/css/style.css @@ -719,10 +719,9 @@ body.package.search #menusearch { } .dataset-search { margin-bottom: 35px; - padding-right: 100px; } input.search { - width: 100%; + width: 380px; float: left; font-size: 1.2em; margin: 0px; @@ -740,7 +739,6 @@ input.search { display: inline-block; float: left; margin-left: 9px; - margin-right: -100px; } diff --git a/ckan/public/scripts/application.js b/ckan/public/scripts/application.js index 72124f00f18..b897c4ae6e1 100644 --- a/ckan/public/scripts/application.js +++ b/ckan/public/scripts/application.js @@ -51,6 +51,24 @@ CKAN.Utils = CKAN.Utils || {}; CKAN.DataPreview.loadEmbeddedPreview(preload_resource, reclineState); } + if ($(document.body).hasClass('search')) { + // Calculate the optimal width for the search input regardless of the + // width of the submit button (which can vary depending on translation). + (function resizeSearchInput() { + var form = $('#dataset-search'), + input = form.find('[name=q]'), + button = form.find('[type=submit]'), + offset = parseFloat(button.css('margin-left')); + + // Grab the horizontal properties of the input that affect the width. + $.each(['padding-left', 'padding-right', 'border-left-width', 'border-right-width'], function (i, prop) { + offset += parseFloat(input.css(prop)) || 0; + }); + + input.width(form.outerWidth() - button.outerWidth() - offset); + })(); + } + var isDatasetNew = $('body.package.new').length > 0; if (isDatasetNew) { // Set up magic URL slug editor