Commit 368832d5 authored by Ryan Wyllie's avatar Ryan Wyllie Committed by Andrew Nicols
Browse files

MDL-59936 javascript: hide modal footer without content

parent 40f1801c
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -358,7 +358,8 @@ define(['jquery', 'core/templates', 'core/notification', 'core/key_codes',
};
/**
* Set the modal footer element.
* Set the modal footer element. The footer element is made visible, if it
* isn't already.
*
* This method is overloaded to take either a string
* value for the body or a jQuery promise that is resolved with HTML and Javascript
......@@ -368,6 +369,9 @@ define(['jquery', 'core/templates', 'core/notification', 'core/key_codes',
* @param {(string|object)} value The footer string or jQuery promise
*/
Modal.prototype.setFooter = function(value) {
// Make sure the footer is visible.
this.showFooter();
var footer = this.getFooter();
if (typeof value === 'string') {
......@@ -396,6 +400,34 @@ define(['jquery', 'core/templates', 'core/notification', 'core/key_codes',
}
};
/**
* Check if the footer has any content in it.
*
* @method hasFooterContent
* @return {bool}
*/
Modal.prototype.hasFooterContent = function() {
return this.getFooter().children().length ? true : false;
};
/**
* Hide the footer element.
*
* @method hideFooter
*/
Modal.prototype.hideFooter = function() {
this.getFooter().addClass('hidden');
};
/**
* Show the footer element.
*
* @method showFooter
*/
Modal.prototype.showFooter = function() {
this.getFooter().removeClass('hidden');
};
/**
* Mark the modal as a large modal.
*
......@@ -508,6 +540,12 @@ define(['jquery', 'core/templates', 'core/notification', 'core/key_codes',
return;
}
if (this.hasFooterContent()) {
this.showFooter();
} else {
this.hideFooter();
}
if (!this.isAttached) {
this.attachToDOM();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment