Skip to content

Commit

Permalink
Lsnbldr 653a (sakaiproject#3199)
Browse files Browse the repository at this point in the history
* LSNBLDR-653; width spec was being ignored for images; see Jira -- this may not be regarded by everyone as a fix

* LSNBLDR-653; maintain aspect ratio for images
  • Loading branch information
clhedrick authored Aug 15, 2016
1 parent 8946622 commit b6ffa1e
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lessonbuilder/tool/src/webapp/js/show-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,29 @@ $(document).ready(function() {
$(this).height($(this).width() * 0.75);
});

$("li.multimediaType img").each(function() {
var width = $(this).attr("width");
var height = $(this).attr("height");
// if just width specified, we're fine. it will scale. But if height is specified narrow windows
// will give us the wrong aspect ration
if (typeof height !== 'undefined' && height !== '') {
if (typeof width !== 'undefined' && width !== '') {
// both specified. use specified aspect ratio
if ($(this).width() != width) {
var aspect = height / width;
$(this).height($(this).width() * aspect);
}
} else {
var aspect = $(this)[0].naturalHeight / $(this)[0].naturalWidth;
// -1 to avoid triggering because of rounding
if ($(this).width() * aspect < (height-1)) {
// width has been reduced because of max-width 100%
$(this).height($(this).width() * aspect);
}
}
}
});

$("input[type=checkbox].checklist-checkbox").on("change", function(){

$(this).next("span").addClass("savingChecklistItem");
Expand Down

0 comments on commit b6ffa1e

Please sign in to comment.