Skip to content

Commit 0b38f7a

Browse files
committed
MAGETWO-37594: Implementation and fixes after review
1 parent 7acd5fe commit 0b38f7a

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

app/code/Magento/Catalog/view/adminhtml/web/js/new-category-dialog.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@ define([
108108
//);
109109
}
110110
}]
111-
});
112-
this.insideDialog = $('<div>lol</div>').dialog({
111+
}).data('mage-dialog');
112+
113+
this.insideDialog = $('<div>Another dialog</div>').dialog({
113114
type: 'slideOut',
114115
dialogClass: 'mage-new-category-dialog form-inline'
115-
});
116+
}).data('mage-dialog');
116117
}
117118
});
118119

app/code/Magento/Ui/view/base/web/js/dialog/dialog.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ define([
77
"underscore",
88
"mage/template",
99
"text!ui/template/dialog/dialog.html",
10-
"jquery/ui"
10+
"jquery/ui",
11+
"mage/translate"
1112
], function($, _,template, dialogTemplate){
1213
"use strict";
1314

@@ -21,7 +22,7 @@ define([
2122
template: dialogTemplate,
2223
buttons: [{
2324
text: $.mage.__('Ok'),
24-
'class': 'action-primary',
25+
class: 'action-primary',
2526
click: function(){
2627
this.closeDialog();
2728
}
@@ -70,33 +71,35 @@ define([
7071
return this.dialog.find(elem);
7172
},
7273
openDialog: function() {
73-
this._isOpen = true;
74+
this.options.isOpen = true;
7475
this._position();
7576
this._createOverlay();
7677
this.dialog.show();
7778
this.dialog.addClass(this.options.dialogActiveClass);
7879

79-
return this.dialog;
80+
return this.element;
8081
},
8182
closeDialog: function() {
8283
var that = this;
8384

84-
this._isOpen = false;
85+
this.options.isOpen = false;
8586
this.dialog.one(this.options.transitionEvent, function() {
86-
that.dialog.hide();
87-
that._destroyOverlay();
87+
that._close();
8888
});
8989
this.dialog.removeClass(this.options.dialogActiveClass);
9090
if ( !this.options.transitionEvent ) {
91-
this.dialog.hide();
92-
this._destroyOverlay();
91+
that._close();
9392
}
9493

95-
return this.dialog;
94+
return this.element;
95+
},
96+
_close: function() {
97+
this.dialog.hide();
98+
this._destroyOverlay();
99+
this._trigger('dialogClosed');
96100
},
97101
_createWrapper: function() {
98102
this.dialogWrapper = $('#'+this.options.wrapperId);
99-
100103
if ( !this.dialogWrapper.length ) {
101104
this.dialogWrapper = $('<div></div>')
102105
.attr('id', this.options.wrapperId)
@@ -120,7 +123,7 @@ define([
120123
_.each(this.options.buttons, function(btn, key) {
121124
var button = that.buttons[key];
122125

123-
button.on('click', _.bind(btn.click, that));
126+
$(button).on('click', _.bind(btn.click, that));
124127
});
125128
},
126129
_createOverlay: function() {
@@ -172,7 +175,7 @@ define([
172175
this.dialog.css(this.options.position[type]);
173176
},
174177
whichTransitionEvent: function() {
175-
var t,
178+
var transition,
176179
el = document.createElement('fakeelement'),
177180
transitions = {
178181
'transition': 'transitionend',
@@ -181,9 +184,9 @@ define([
181184
'WebkitTransition': 'webkitTransitionEnd'
182185
};
183186

184-
for (t in transitions){
185-
if ( el.style[t] !== undefined && transitions.hasOwnProperty(t) ) {
186-
return transitions[t];
187+
for (transition in transitions){
188+
if ( el.style[transition] !== undefined && transitions.hasOwnProperty(transition) ) {
189+
return transitions[transition];
187190
}
188191
}
189192
}

0 commit comments

Comments
 (0)