@@ -6,174 +6,174 @@ define([
66 "jquery" ,
77 "underscore" ,
88 "mage/template" ,
9- "text!ui/template/popup/popup- modal.html" ,
10- "text!ui/template/popup/popup -slide.html" ,
9+ "text!ui/template/modal/ modal-popup .html" ,
10+ "text!ui/template/modal/modal -slide.html" ,
1111 "jquery/ui" ,
1212 "mage/translate"
13- ] , function ( $ , _ , template , modalTpl , slideTpl ) {
13+ ] , function ( $ , _ , template , popupTpl , slideTpl ) {
1414 "use strict" ;
1515
1616 /**
17- * Dialog Widget
17+ * Modal Window Widget
1818 */
19- $ . widget ( 'mage.popup ' , {
19+ $ . widget ( 'mage.modal ' , {
2020 options : {
21- type : 'modal ' ,
21+ type : 'popup ' ,
2222 title : '' ,
23- dialogClass : '' ,
24- modalTpl : modalTpl ,
23+ modalClass : '' ,
24+ popupTpl : popupTpl ,
2525 slideTpl : slideTpl ,
26- dialogVisibleClass : '_show' ,
27- parentDialogClass : '_has-dialog ' ,
26+ modalVisibleClass : '_show' ,
27+ parentModalClass : '_has-modal ' ,
2828 innerScrollClass : '_inner-scroll' ,
2929 responsive : false ,
3030 innerScroll : false ,
31- dialogBlock : '[data-role="dialog "]' ,
32- dialogCloseBtn : '[data-role="closeBtn"]' ,
33- dialogContent : '[data-role="content"]' ,
34- dialogAction : '[data-role="action"]' ,
31+ modalBlock : '[data-role="modal "]' ,
32+ modalCloseBtn : '[data-role="closeBtn"]' ,
33+ modalContent : '[data-role="content"]' ,
34+ modalAction : '[data-role="action"]' ,
3535 appendTo : 'body' ,
36- wrapperClass : 'dialogs -wrapper' ,
36+ wrapperClass : 'modals -wrapper' ,
3737 overlayClass : 'overlay_magento' ,
38- responsiveClass : 'dialog -slide' ,
39- dialogLeftMargin : 45 ,
38+ responsiveClass : 'modal -slide' ,
39+ modalLeftMargin : 45 ,
4040 closeText : $ . mage . __ ( 'Close' ) ,
4141 buttons : [ {
4242 text : $ . mage . __ ( 'Ok' ) ,
4343 class : '' ,
4444 click : function ( ) {
45- this . closeDialog ( ) ;
45+ this . closeModal ( ) ;
4646 }
4747 } ]
4848 } ,
4949 /**
50- * Creates dialog widget.
50+ * Creates modal widget.
5151 */
5252 _create : function ( ) {
5353 this . options . transitionEvent = this . whichTransitionEvent ( ) ;
5454 this . _createWrapper ( ) ;
55- this . _renderDialog ( ) ;
55+ this . _renderModal ( ) ;
5656 this . _createButtons ( ) ;
5757
58- this . dialog . find ( this . options . dialogCloseBtn ) . on ( 'click' , _ . bind ( this . closeDialog , this ) ) ;
59- this . element . on ( 'openDialog ' , _ . bind ( this . openDialog , this ) ) ;
60- this . element . on ( 'closeDialog ' , _ . bind ( this . closeDialog , this ) ) ;
58+ this . modal . find ( this . options . modalCloseBtn ) . on ( 'click' , _ . bind ( this . closeModal , this ) ) ;
59+ this . element . on ( 'openModal ' , _ . bind ( this . openModal , this ) ) ;
60+ this . element . on ( 'closeModal ' , _ . bind ( this . closeModal , this ) ) ;
6161 } ,
6262 /**
63- * Returns element from dialog node.
63+ * Returns element from modal node.
6464 * @return {Object } - element.
6565 */
6666 _getElem : function ( elem ) {
67- return this . dialog . find ( elem ) ;
67+ return this . modal . find ( elem ) ;
6868 } ,
6969 /**
70- * Gets visible dialog count.
71- * * @return {Number } - visible dialog count.
70+ * Gets visible modal count.
71+ * * @return {Number } - visible modal count.
7272 */
7373 _getVisibleCount : function ( ) {
74- return this . dialogWrapper . find ( '.' + this . options . dialogVisibleClass ) . length ;
74+ return this . modalWrapper . find ( '.' + this . options . modalVisibleClass ) . length ;
7575 } ,
7676 /**
77- * Gets visible slide type dialog count .
78- * * @return {Number } - visible dialog count.
77+ * Gets count of visible modal by slide type .
78+ * * @return {Number } - visible modal count.
7979 */
8080 _getVisibleSlideCount : function ( ) {
81- var elems = this . dialogWrapper . find ( '[data-type="slide"]' ) ;
81+ var elems = this . modalWrapper . find ( '[data-type="slide"]' ) ;
8282
83- return elems . filter ( '.' + this . options . dialogVisibleClass ) . length ;
83+ return elems . filter ( '.' + this . options . modalVisibleClass ) . length ;
8484 } ,
85- openDialog : function ( ) {
85+ openModal : function ( ) {
8686 var that = this ;
8787
8888 this . options . isOpen = true ;
8989 this . _createOverlay ( ) ;
9090 this . _setActive ( ) ;
91- this . dialog . one ( this . options . transitionEvent , function ( ) {
91+ this . modal . one ( this . options . transitionEvent , function ( ) {
9292 that . _trigger ( 'opened' ) ;
9393 } ) ;
94- this . dialog . addClass ( this . options . dialogVisibleClass ) ;
94+ this . modal . addClass ( this . options . modalVisibleClass ) ;
9595 if ( ! this . options . transitionEvent ) {
9696 that . _trigger ( 'opened' ) ;
9797 }
9898
9999 return this . element ;
100100 } ,
101- closeDialog : function ( ) {
101+ closeModal : function ( ) {
102102 var that = this ;
103103
104104 this . options . isOpen = false ;
105- this . dialog . one ( this . options . transitionEvent , function ( ) {
105+ this . modal . one ( this . options . transitionEvent , function ( ) {
106106 that . _close ( ) ;
107107 } ) ;
108- this . dialog . removeClass ( this . options . dialogVisibleClass ) ;
108+ this . modal . removeClass ( this . options . modalVisibleClass ) ;
109109 if ( ! this . options . transitionEvent ) {
110110 that . _close ( ) ;
111111 }
112112
113113 return this . element ;
114114 } ,
115115 /**
116- * Helper for closeDialog function.
116+ * Helper for closeModal function.
117117 */
118118 _close : function ( ) {
119- var trigger = _ . bind ( this . _trigger , this , 'closed' , this . dialog ) ;
119+ var trigger = _ . bind ( this . _trigger , this , 'closed' , this . modal ) ;
120120
121121 this . _destroyOverlay ( ) ;
122122 this . _unsetActive ( ) ;
123123 _ . defer ( trigger , this ) ;
124124 } ,
125125 /**
126- * Set z-index and margin for dialog and overlay.
126+ * Set z-index and margin for modal and overlay.
127127 */
128128 _setActive : function ( ) {
129- var zIndex = this . dialog . zIndex ( ) ;
129+ var zIndex = this . modal . zIndex ( ) ;
130130
131131 this . prevOverlayIndex = this . overlay . zIndex ( ) ;
132- this . dialog . zIndex ( zIndex + this . _getVisibleCount ( ) ) ;
132+ this . modal . zIndex ( zIndex + this . _getVisibleCount ( ) ) ;
133133 this . overlay . zIndex ( zIndex + ( this . _getVisibleCount ( ) - 1 ) ) ;
134134 if ( this . _getVisibleSlideCount ( ) ) {
135- this . dialog . css ( 'marginLeft' , this . options . dialogLeftMargin * this . _getVisibleSlideCount ( ) ) ;
135+ this . modal . css ( 'marginLeft' , this . options . modalLeftMargin * this . _getVisibleSlideCount ( ) ) ;
136136 }
137137 } ,
138138 /**
139- * Unset styles for dialog and set z-index for previous dialog .
139+ * Unset styles for modal and set z-index for previous modal .
140140 */
141141 _unsetActive : function ( ) {
142- this . dialog . removeAttr ( 'style' ) ;
142+ this . modal . removeAttr ( 'style' ) ;
143143 if ( this . overlay ) {
144144 this . overlay . zIndex ( this . prevOverlayIndex ) ;
145145 }
146146 } ,
147147 /**
148- * Creates wrapper to hold all dialogs .
148+ * Creates wrapper to hold all modals .
149149 */
150150 _createWrapper : function ( ) {
151- this . dialogWrapper = $ ( '.' + this . options . wrapperClass ) ;
152- if ( ! this . dialogWrapper . length ) {
153- this . dialogWrapper = $ ( '<div></div>' )
151+ this . modalWrapper = $ ( '.' + this . options . wrapperClass ) ;
152+ if ( ! this . modalWrapper . length ) {
153+ this . modalWrapper = $ ( '<div></div>' )
154154 . addClass ( this . options . wrapperClass )
155155 . appendTo ( this . options . appendTo ) ;
156156 }
157157 } ,
158158 /**
159159 * Compile template and append to wrapper.
160160 */
161- _renderDialog : function ( ) {
161+ _renderModal : function ( ) {
162162 $ ( template (
163163 this . options [ this . options . type + 'Tpl' ] ,
164164 {
165165 data : this . options
166- } ) ) . appendTo ( this . dialogWrapper ) ;
167- this . dialog = this . dialogWrapper . find ( this . options . dialogBlock ) . last ( ) ;
168- this . element . show ( ) . appendTo ( this . _getElem ( this . options . dialogContent ) ) ;
166+ } ) ) . appendTo ( this . modalWrapper ) ;
167+ this . modal = this . modalWrapper . find ( this . options . modalBlock ) . last ( ) ;
168+ this . element . show ( ) . appendTo ( this . _getElem ( this . options . modalContent ) ) ;
169169 } ,
170170 /**
171171 * Creates buttons pane.
172172 */
173173 _createButtons : function ( ) {
174174 var that = this ;
175175
176- this . buttons = this . _getElem ( this . options . dialogAction ) ;
176+ this . buttons = this . _getElem ( this . options . modalAction ) ;
177177 _ . each ( this . options . buttons , function ( btn , key ) {
178178 var button = that . buttons [ key ] ;
179179
@@ -189,28 +189,28 @@ define([
189189
190190 this . overlay = $ ( '.' + this . options . overlayClass ) ;
191191 if ( ! this . overlay . length ) {
192- $ ( this . options . appendTo ) . addClass ( this . options . parentDialogClass ) ;
192+ $ ( this . options . appendTo ) . addClass ( this . options . parentModalClass ) ;
193193 this . overlay = $ ( '<div></div>' )
194194 . addClass ( this . options . overlayClass )
195- . appendTo ( this . dialogWrapper ) ;
195+ . appendTo ( this . modalWrapper ) ;
196196 }
197197
198198 events = $ . _data ( this . overlay . get ( 0 ) , 'events' ) ;
199199 if ( events ) {
200200 this . prevOverlayHandler = events . click [ 0 ] . handler ;
201201 }
202202 this . overlay . unbind ( ) . on ( 'click' , function ( ) {
203- that . closeDialog ( ) ;
203+ that . closeModal ( ) ;
204204 } ) ;
205205 } ,
206206 /**
207207 * Destroy overlay.
208208 */
209209 _destroyOverlay : function ( ) {
210- var dialogCount = this . dialogWrapper . find ( '.' + this . options . dialogVisibleClass ) . length ;
210+ var modalCount = this . modalWrapper . find ( '.' + this . options . modalVisibleClass ) . length ;
211211
212- if ( ! dialogCount ) {
213- $ ( this . options . appendTo ) . removeClass ( this . options . parentDialogClass ) ;
212+ if ( ! modalCount ) {
213+ $ ( this . options . appendTo ) . removeClass ( this . options . parentModalClass ) ;
214214 this . overlay . remove ( ) ;
215215 this . overlay = null ;
216216
@@ -239,5 +239,5 @@ define([
239239 }
240240 } ) ;
241241
242- return $ . mage . popup ;
242+ return $ . mage . modal ;
243243} ) ;
0 commit comments