MDL-59784 core: Modal should accept title as a promise

This commit is contained in:
Andrew Nicols
2017-08-18 11:19:50 +08:00
parent 2f8dec8a00
commit fb6da21229
2 changed files with 16 additions and 7 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+15 -6
View File
@@ -215,23 +215,32 @@ define(['jquery', 'core/templates', 'core/notification', 'core/key_codes',
/**
* Set the modal title element.
*
* This method is overloaded to take either a string value for the title or a jQuery promise that is resolved with
* HTML most commonly from a Str.get_string call.
*
* @method setTitle
* @param {string} value The title string
* @param {(string|object)} value The title string or jQuery promise which resolves to the title.
*/
Modal.prototype.setTitle = function(value) {
var title = this.getTitle();
title.html(value);
if (typeof value === 'string') {
title.html(value);
} else {
value.then(function(content) {
return title.html(content);
});
}
};
/**
* Set the modal body element.
*
* This method is overloaded to take either a string
* value for the body or a jQuery promise that is resolved with HTML and Javascript
* most commonly from a Templates.render call.
* This method is overloaded to take either a string value for the body or a jQuery promise that is resolved with
* HTML and Javascript most commonly from a Templates.render call.
*
* @method setBody
* @param {(string|object)} value The body string or jQuery promise
* @param {(string|object)} value The body string or jQuery promise which resolves to the body.
*/
Modal.prototype.setBody = function(value) {
var body = this.getBody();