diff --git a/devwidgets/contentmetadata/javascript/contentmetadata.js b/devwidgets/contentmetadata/javascript/contentmetadata.js index d65cff4d7e0..f20344967f6 100755 --- a/devwidgets/contentmetadata/javascript/contentmetadata.js +++ b/devwidgets/contentmetadata/javascript/contentmetadata.js @@ -98,7 +98,9 @@ require(["jquery", "sakai/sakai.api.core", "/dev/javascript/content_profile.js"] if ( !tags ) { $(contentmetadataInputEdit).blur( editInputBlur ); } else { - sakai.api.Util.hideOnClickOut( $( ".autosuggest_wrapper", $contentmetadataTagsContainer ) , "#assignlocation_container, " + $contentmetadataTagsContainer.selector + " .autosuggest_wrapper" , editInputBlur ); + sakai.api.Util.hideOnClickOut( $( ".autosuggest_wrapper", $contentmetadataTagsContainer ) , "#assignlocation_container, " + $contentmetadataTagsContainer.selector + " .autosuggest_wrapper", function() { + editInputBlur(false, "tags"); + }); } } }; @@ -207,7 +209,7 @@ require(["jquery", "sakai/sakai.api.core", "/dev/javascript/content_profile.js"] } else { $("#contentpreview_download_button").attr("href", sakai_global.content_profile.content_data.smallPath + "/" + sakai.api.Util.safeURL(sakai_global.content_profile.content_data.data["sakai:pooled-content-file-name"])); } - } + }; /** * Render the Tags template @@ -360,6 +362,10 @@ require(["jquery", "sakai/sakai.api.core", "/dev/javascript/content_profile.js"] if ( !$( ev.target ).is( "a, select, option, textarea" ) ) { $target = $( ev.target ).closest( ".contentmetadata_editable" ); if ( $target.length ) { + // Need to clear out any active editingElements before creating a new one + if (editingElement !== "") { + editInputBlur(false, editingElement); + } editingElement = $target.attr( "data-edit-field" ); switch ( editingElement ) { case "description": @@ -384,9 +390,13 @@ require(["jquery", "sakai/sakai.api.core", "/dev/javascript/content_profile.js"] /** * Handle losing of focus on an input element - * @param {Object} el Element that lost the focus + * @param {Object} e Element that lost the focus + * @param {String} forceElt Force the editingElement here, to indicate that only that should be blurred */ - var editInputBlur = function( e ) { + var editInputBlur = function( e, forceElt ) { + if ( !e && forceElt !== editingElement ) { + return; + } switch ( editingElement ) { case "description": updateDescription(); @@ -401,6 +411,7 @@ require(["jquery", "sakai/sakai.api.core", "/dev/javascript/content_profile.js"] updateCopyright(); break; } + editingElement = ""; }; ////////////////////////