MDL-43979 Javascript: Correct checking of attributes during dialogue init

Various dialogue attributes are optional and are provided by the parent and
not provided as attributes to the dialogue being initted.

As a result, if the setting is not provided during init, we were assuming
that the value would be false rather than checking the real attribute.
This commit is contained in:
Andrew Nicols
2014-02-10 22:00:44 +08:00
parent 27ebbdd703
commit 5ce1ff33ce
4 changed files with 58 additions and 25 deletions
@@ -119,16 +119,16 @@ Y.extend(DIALOGUE, Y.Panel, {
* @method initializer
* @return void
*/
initializer : function(config) {
initializer : function() {
var bb;
if (config.render && !this.get('rendered')) {
if (this.get('render') && !this.get('rendered')) {
this.render();
}
this.makeResponsive();
this.after('visibleChange', this.visibilityChanged, this);
if (config.center) {
if (this.get('center')) {
this.centerDialogue();
}
this.set('COUNT', COUNT);
@@ -141,10 +141,10 @@ Y.extend(DIALOGUE, Y.Panel, {
// and allow setting of z-index in theme.
bb = this.get('boundingBox');
if (config.extraClasses) {
Y.Array.each(config.extraClasses, bb.addClass, bb);
}
if (config.visible) {
// Add any additional classes that were specified.
Y.Array.each(this.get('extraClasses'), bb.addClass, bb);
if (this.get('visible')) {
this.applyZIndex();
}
// Recalculate the zIndex every time the modal is altered.
@@ -153,7 +153,7 @@ Y.extend(DIALOGUE, Y.Panel, {
// either by centerDialogue or makeResonsive. This is because the show() will trigger
// a focus on the dialogue, which will scroll the page. If the dialogue has not
// been positioned it will scroll back to the top of the page.
if (config.visible) {
if (this.get('visible')) {
this.show();
this.keyDelegation();
}
@@ -498,6 +498,17 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
responsiveWidth : {
value : 768
},
/**
* Any additional classes to add to the boundingBox.
*
* @attributes extraClasses
* @type Array
* @default []
*/
extraClasses: {
value: []
}
}
});
File diff suppressed because one or more lines are too long
@@ -119,16 +119,16 @@ Y.extend(DIALOGUE, Y.Panel, {
* @method initializer
* @return void
*/
initializer : function(config) {
initializer : function() {
var bb;
if (config.render && !this.get('rendered')) {
if (this.get('render') && !this.get('rendered')) {
this.render();
}
this.makeResponsive();
this.after('visibleChange', this.visibilityChanged, this);
if (config.center) {
if (this.get('center')) {
this.centerDialogue();
}
this.set('COUNT', COUNT);
@@ -141,10 +141,10 @@ Y.extend(DIALOGUE, Y.Panel, {
// and allow setting of z-index in theme.
bb = this.get('boundingBox');
if (config.extraClasses) {
Y.Array.each(config.extraClasses, bb.addClass, bb);
}
if (config.visible) {
// Add any additional classes that were specified.
Y.Array.each(this.get('extraClasses'), bb.addClass, bb);
if (this.get('visible')) {
this.applyZIndex();
}
// Recalculate the zIndex every time the modal is altered.
@@ -153,7 +153,7 @@ Y.extend(DIALOGUE, Y.Panel, {
// either by centerDialogue or makeResonsive. This is because the show() will trigger
// a focus on the dialogue, which will scroll the page. If the dialogue has not
// been positioned it will scroll back to the top of the page.
if (config.visible) {
if (this.get('visible')) {
this.show();
this.keyDelegation();
}
@@ -498,6 +498,17 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
responsiveWidth : {
value : 768
},
/**
* Any additional classes to add to the boundingBox.
*
* @attributes extraClasses
* @type Array
* @default []
*/
extraClasses: {
value: []
}
}
});
+19 -8
View File
@@ -88,16 +88,16 @@ Y.extend(DIALOGUE, Y.Panel, {
* @method initializer
* @return void
*/
initializer : function(config) {
initializer : function() {
var bb;
if (config.render && !this.get('rendered')) {
if (this.get('render') && !this.get('rendered')) {
this.render();
}
this.makeResponsive();
this.after('visibleChange', this.visibilityChanged, this);
if (config.center) {
if (this.get('center')) {
this.centerDialogue();
}
this.set('COUNT', COUNT);
@@ -110,10 +110,10 @@ Y.extend(DIALOGUE, Y.Panel, {
// and allow setting of z-index in theme.
bb = this.get('boundingBox');
if (config.extraClasses) {
Y.Array.each(config.extraClasses, bb.addClass, bb);
}
if (config.visible) {
// Add any additional classes that were specified.
Y.Array.each(this.get('extraClasses'), bb.addClass, bb);
if (this.get('visible')) {
this.applyZIndex();
}
// Recalculate the zIndex every time the modal is altered.
@@ -122,7 +122,7 @@ Y.extend(DIALOGUE, Y.Panel, {
// either by centerDialogue or makeResonsive. This is because the show() will trigger
// a focus on the dialogue, which will scroll the page. If the dialogue has not
// been positioned it will scroll back to the top of the page.
if (config.visible) {
if (this.get('visible')) {
this.show();
this.keyDelegation();
}
@@ -467,6 +467,17 @@ Y.extend(DIALOGUE, Y.Panel, {
*/
responsiveWidth : {
value : 768
},
/**
* Any additional classes to add to the boundingBox.
*
* @attributes extraClasses
* @type Array
* @default []
*/
extraClasses: {
value: []
}
}
});