Skip to content

Commit

Permalink
Merge branch 'feature-2507-fix-search-input'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Hammond committed Jun 12, 2012
2 parents 438e7eb + 2a5714b commit 667e665
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 1 addition & 3 deletions ckan/public/css/style.css
Expand Up @@ -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;
Expand All @@ -740,7 +739,6 @@ input.search {
display: inline-block;
float: left;
margin-left: 9px;
margin-right: -100px;
}


Expand Down
18 changes: 18 additions & 0 deletions ckan/public/scripts/application.js
Expand Up @@ -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
Expand Down

0 comments on commit 667e665

Please sign in to comment.