@@ -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 : '' ,
@@ -72,17 +73,7 @@ define([
72
73
this . $popup = $ ( $ ( this . popupDOM ) . html ( ) ) ;
73
74
74
75
$ ( 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 ) ;
76
+ this . openPopup ( e ) ;
86
77
} . bind ( this ) ) ;
87
78
}
88
79
@@ -113,7 +104,26 @@ define([
113
104
} . bind ( this ) ) ;
114
105
}
115
106
} ,
116
-
107
+ /**
108
+ * Open and set up popup
109
+ *
110
+ * @param element
111
+ */
112
+ openPopup : function ( element ) {
113
+ this . popUpOptions . position . of = $ ( element . target ) ;
114
+ this . $popup . find ( this . options . msrpLabelId ) . html ( this . options . msrpPrice ) ;
115
+ this . $popup . find ( this . options . priceLabelId ) . html ( this . options . realPrice ) ;
116
+ this . $popup . dropdownDialog ( this . popUpOptions ) . dropdownDialog ( 'open' ) ;
117
+ this . $popup . find ( 'button' ) . on ( 'click' , function ( ) {
118
+ if ( this . options . addToCartButton ) {
119
+ $ ( this . options . addToCartButton ) . click ( ) ;
120
+ }
121
+ } . bind ( this ) ) ;
122
+ this . _toggle ( this . $popup ) ;
123
+ if ( ! this . options . isSaleable ) {
124
+ this . $popup . find ( 'form' ) . hide ( ) ;
125
+ }
126
+ } ,
117
127
/**
118
128
*
119
129
* @param $elem
0 commit comments