@@ -27,6 +27,7 @@ define([
27
27
cartButtonId : '' , // better to be cartButton
28
28
popupId : '' , // better to be popup
29
29
realPrice : '' ,
30
+ isSaleable : '' ,
30
31
msrpPrice : '' ,
31
32
helpLinkId : '' , // better to be helpLink
32
33
addToCartButton : '' ,
@@ -71,19 +72,7 @@ define([
71
72
$ ( 'body' ) . append ( $ ( this . popupDOM ) . html ( ) ) ;
72
73
this . $popup = $ ( $ ( this . popupDOM ) . html ( ) ) ;
73
74
74
- $ ( this . options . popupId ) . on ( 'click' , function ( e ) {
75
- this . popUpOptions . position . of = $ ( e . target ) ;
76
- this . $popup . find ( this . options . msrpLabelId ) . html ( this . options . msrpPrice ) ;
77
- this . $popup . find ( this . options . priceLabelId ) . html ( this . options . realPrice ) ;
78
- this . $popup . dropdownDialog ( this . popUpOptions ) . dropdownDialog ( 'open' ) ;
79
-
80
- this . $popup . find ( 'button' ) . on ( 'click' , function ( ) {
81
- if ( this . options . addToCartButton ) {
82
- $ ( this . options . addToCartButton ) . click ( ) ;
83
- }
84
- } . bind ( this ) ) ;
85
- this . _toggle ( this . $popup ) ;
86
- } . bind ( this ) ) ;
75
+ $ ( this . options . popupId ) . on ( 'click' , this . openPopup . bind ( this ) ) ;
87
76
}
88
77
89
78
if ( this . options . helpLinkId ) {
@@ -113,7 +102,26 @@ define([
113
102
} . bind ( this ) ) ;
114
103
}
115
104
} ,
116
-
105
+ /**
106
+ * Open and set up popup
107
+ *
108
+ * @param event
109
+ */
110
+ openPopup : function ( event ) {
111
+ this . popUpOptions . position . of = $ ( event . target ) ;
112
+ this . $popup . find ( this . options . msrpLabelId ) . html ( this . options . msrpPrice ) ;
113
+ this . $popup . find ( this . options . priceLabelId ) . html ( this . options . realPrice ) ;
114
+ this . $popup . dropdownDialog ( this . popUpOptions ) . dropdownDialog ( 'open' ) ;
115
+ this . $popup . find ( 'button' ) . on ( 'click' , function ( ) {
116
+ if ( this . options . addToCartButton ) {
117
+ $ ( this . options . addToCartButton ) . click ( ) ;
118
+ }
119
+ } . bind ( this ) ) ;
120
+ this . _toggle ( this . $popup ) ;
121
+ if ( ! this . options . isSaleable ) {
122
+ this . $popup . find ( 'form' ) . hide ( ) ;
123
+ }
124
+ } ,
117
125
/**
118
126
*
119
127
* @param $elem
0 commit comments