MDL-59936 javascript: hide modal footer without content
This commit is contained in:
committed by
Andrew Nicols
parent
40f1801c4b
commit
368832d51c
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+39
-1
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user