7
7
"underscore" ,
8
8
"mage/template" ,
9
9
"text!ui/template/dialog/dialog.html" ,
10
- "jquery/ui"
10
+ "jquery/ui" ,
11
+ "mage/translate"
11
12
] , function ( $ , _ , template , dialogTemplate ) {
12
13
"use strict" ;
13
14
@@ -21,7 +22,7 @@ define([
21
22
template : dialogTemplate ,
22
23
buttons : [ {
23
24
text : $ . mage . __ ( 'Ok' ) ,
24
- ' class' : 'action-primary' ,
25
+ class : 'action-primary' ,
25
26
click : function ( ) {
26
27
this . closeDialog ( ) ;
27
28
}
@@ -70,33 +71,35 @@ define([
70
71
return this . dialog . find ( elem ) ;
71
72
} ,
72
73
openDialog : function ( ) {
73
- this . _isOpen = true ;
74
+ this . options . isOpen = true ;
74
75
this . _position ( ) ;
75
76
this . _createOverlay ( ) ;
76
77
this . dialog . show ( ) ;
77
78
this . dialog . addClass ( this . options . dialogActiveClass ) ;
78
79
79
- return this . dialog ;
80
+ return this . element ;
80
81
} ,
81
82
closeDialog : function ( ) {
82
83
var that = this ;
83
84
84
- this . _isOpen = false ;
85
+ this . options . isOpen = false ;
85
86
this . dialog . one ( this . options . transitionEvent , function ( ) {
86
- that . dialog . hide ( ) ;
87
- that . _destroyOverlay ( ) ;
87
+ that . _close ( ) ;
88
88
} ) ;
89
89
this . dialog . removeClass ( this . options . dialogActiveClass ) ;
90
90
if ( ! this . options . transitionEvent ) {
91
- this . dialog . hide ( ) ;
92
- this . _destroyOverlay ( ) ;
91
+ that . _close ( ) ;
93
92
}
94
93
95
- return this . dialog ;
94
+ return this . element ;
95
+ } ,
96
+ _close : function ( ) {
97
+ this . dialog . hide ( ) ;
98
+ this . _destroyOverlay ( ) ;
99
+ this . _trigger ( 'dialogClosed' ) ;
96
100
} ,
97
101
_createWrapper : function ( ) {
98
102
this . dialogWrapper = $ ( '#' + this . options . wrapperId ) ;
99
-
100
103
if ( ! this . dialogWrapper . length ) {
101
104
this . dialogWrapper = $ ( '<div></div>' )
102
105
. attr ( 'id' , this . options . wrapperId )
@@ -120,7 +123,7 @@ define([
120
123
_ . each ( this . options . buttons , function ( btn , key ) {
121
124
var button = that . buttons [ key ] ;
122
125
123
- button . on ( 'click' , _ . bind ( btn . click , that ) ) ;
126
+ $ ( button ) . on ( 'click' , _ . bind ( btn . click , that ) ) ;
124
127
} ) ;
125
128
} ,
126
129
_createOverlay : function ( ) {
@@ -172,7 +175,7 @@ define([
172
175
this . dialog . css ( this . options . position [ type ] ) ;
173
176
} ,
174
177
whichTransitionEvent : function ( ) {
175
- var t ,
178
+ var transition ,
176
179
el = document . createElement ( 'fakeelement' ) ,
177
180
transitions = {
178
181
'transition' : 'transitionend' ,
@@ -181,9 +184,9 @@ define([
181
184
'WebkitTransition' : 'webkitTransitionEnd'
182
185
} ;
183
186
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 ] ;
187
190
}
188
191
}
189
192
}
0 commit comments