Skip to content

Commit

Permalink
MDL-43979 Javascript: Correct checking of attributes during dialogue …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
andrewnicols committed Feb 10, 2014
1 parent 974c2cd commit 2f5c144
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ Y.extend(DIALOGUE, Y.Panel, {
* @method initializer
* @return void
*/
initializer : function(config) {
initializer : function() {
var bb;

if (this.get('render')) {
this.render();
}
this.makeResponsive();
this.after('visibleChange', this.visibilityChanged, this);
if (config.center) {
if (this.get('center')) {
this.centerDialogue();
}
this.set('COUNT', COUNT);
Expand All @@ -126,10 +126,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.
Expand All @@ -138,7 +138,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();
}
Expand Down Expand Up @@ -567,6 +567,17 @@ Y.Base.modifyAttrs(DIALOGUE, {
render : {
value : true,
writeOnce : true
},

/**
* Any additional classes to add to the boundingBox.
*
* @attributes extraClasses
* @type Array
* @default []
*/
extraClasses: {
value: []
}
});

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ Y.extend(DIALOGUE, Y.Panel, {
* @method initializer
* @return void
*/
initializer : function(config) {
initializer : function() {
var bb;

if (this.get('render')) {
this.render();
}
this.makeResponsive();
this.after('visibleChange', this.visibilityChanged, this);
if (config.center) {
if (this.get('center')) {
this.centerDialogue();
}
this.set('COUNT', COUNT);
Expand All @@ -126,10 +126,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.
Expand All @@ -138,7 +138,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();
}
Expand Down Expand Up @@ -565,6 +565,17 @@ Y.Base.modifyAttrs(DIALOGUE, {
render : {
value : true,
writeOnce : true
},

/**
* Any additional classes to add to the boundingBox.
*
* @attributes extraClasses
* @type Array
* @default []
*/
extraClasses: {
value: []
}
});

Expand Down
25 changes: 18 additions & 7 deletions lib/yui/src/notification/js/dialogue.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ Y.extend(DIALOGUE, Y.Panel, {
* @method initializer
* @return void
*/
initializer : function(config) {
initializer : function() {
var bb;

if (this.get('render')) {
this.render();
}
this.makeResponsive();
this.after('visibleChange', this.visibilityChanged, this);
if (config.center) {
if (this.get('center')) {
this.centerDialogue();
}
this.set('COUNT', COUNT);
Expand All @@ -95,10 +95,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.
Expand All @@ -107,7 +107,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();
}
Expand Down Expand Up @@ -536,6 +536,17 @@ Y.Base.modifyAttrs(DIALOGUE, {
render : {
value : true,
writeOnce : true
},

/**
* Any additional classes to add to the boundingBox.
*
* @attributes extraClasses
* @type Array
* @default []
*/
extraClasses: {
value: []
}
});

Expand Down

0 comments on commit 2f5c144

Please sign in to comment.