1- if ( typeof PAYPAL === " undefined" || ! PAYPAL ) {
1+ if ( typeof PAYPAL === ' undefined' || ! PAYPAL ) {
22 var PAYPAL = { } ;
33}
44
@@ -7,24 +7,24 @@ PAYPAL.apps = PAYPAL.apps || {};
77
88( function ( ) {
99
10- " use strict" ;
10+ ' use strict' ;
1111
1212
1313 var app = { } ,
14- paypalURL = " https://www.paypal.com/cgi-bin/webscr" ,
15- qrCodeURL = " https://www.paypal.com/webapps/ppint/qrcode?data={url}&pattern={pattern}&height={size}" ,
16- bnCode = " JavaScriptButton_{type}" ,
14+ paypalURL = ' https://www.paypal.com/cgi-bin/webscr' ,
15+ qrCodeURL = ' https://www.paypal.com/webapps/ppint/qrcode?data={url}&pattern={pattern}&height={size}' ,
16+ bnCode = ' JavaScriptButton_{type}' ,
1717 prettyParams = {
18- id : " hosted_button_id" ,
19- name : " item_name" ,
20- number : " item_number" ,
21- lang : "lc"
18+ id : ' hosted_button_id' ,
19+ name : ' item_name' ,
20+ number : ' item_number' ,
21+ lang : 'lc'
2222 } ,
2323 buttonImgs = {
24- buynow : " //www.paypalobjects.com/{locale}/i/btn/btn_buynow_{size}.gif" ,
25- cart : " //www.paypalobjects.com/{locale}/i/btn/btn_cart_{size}.gif" ,
26- donate : " //www.paypalobjects.com/{locale}/i/btn/btn_donate_{size}.gif" ,
27- subscribe : " //www.paypalobjects.com/{locale}/i/btn/btn_subscribe_{size}.gif"
24+ buynow : ' //www.paypalobjects.com/{locale}/i/btn/btn_buynow_{size}.gif' ,
25+ cart : ' //www.paypalobjects.com/{locale}/i/btn/btn_cart_{size}.gif' ,
26+ donate : ' //www.paypalobjects.com/{locale}/i/btn/btn_donate_{size}.gif' ,
27+ subscribe : ' //www.paypalobjects.com/{locale}/i/btn/btn_subscribe_{size}.gif'
2828 } ;
2929
3030 if ( ! PAYPAL . apps . ButtonFactory ) {
@@ -34,10 +34,10 @@ PAYPAL.apps = PAYPAL.apps || {};
3434 */
3535 app . config = {
3636 labels : {
37- item_name : " Item" ,
38- item_number : " Number" ,
39- amount : " Amount" ,
40- quantity : " Quantity"
37+ item_name : ' Item' ,
38+ item_number : ' Number' ,
39+ amount : ' Amount' ,
40+ quantity : ' Quantity'
4141 }
4242 } ;
4343
@@ -73,35 +73,35 @@ PAYPAL.apps = PAYPAL.apps || {};
7373 }
7474
7575 // Defaults
76- type = type || " buynow" ;
76+ type = type || ' buynow' ;
7777
7878 // Hosted buttons
7979 if ( data . items . hosted_button_id ) {
80- type = " hosted" ;
81- data . add ( " cmd" , " _s-xclick" ) ;
80+ type = ' hosted' ;
81+ data . add ( ' cmd' , ' _s-xclick' ) ;
8282 // Cart buttons
83- } else if ( type === " cart" ) {
84- data . add ( " cmd" , " _cart" ) ;
85- data . add ( " add" , true ) ;
83+ } else if ( type === ' cart' ) {
84+ data . add ( ' cmd' , ' _cart' ) ;
85+ data . add ( ' add' , true ) ;
8686 // Donation buttons
87- } else if ( type === " donate" ) {
88- data . add ( " cmd" , " _donations" ) ;
87+ } else if ( type === ' donate' ) {
88+ data . add ( ' cmd' , ' _donations' ) ;
8989 // Subscribe buttons
90- } else if ( type === " subscribe" ) {
91- data . add ( " cmd" , " _xclick-subscriptions" ) ;
90+ } else if ( type === ' subscribe' ) {
91+ data . add ( ' cmd' , ' _xclick-subscriptions' ) ;
9292 // Buy Now buttons
9393 } else {
94- data . add ( " cmd" , " _xclick" ) ;
94+ data . add ( ' cmd' , ' _xclick' ) ;
9595 }
9696
9797 // Add common data
98- data . add ( " business" , business ) ;
99- data . add ( "bn" , bnCode . replace ( / \{ t y p e \} / , type ) ) ;
98+ data . add ( ' business' , business ) ;
99+ data . add ( 'bn' , bnCode . replace ( / \{ t y p e \} / , type ) ) ;
100100
101101 // Build the UI components
102- if ( type === "qr" ) {
102+ if ( type === 'qr' ) {
103103 button = buildQR ( data , data . items . size ) ;
104- data . remove ( " size" ) ;
104+ data . remove ( ' size' ) ;
105105 } else {
106106 button = buildForm ( data , type ) ;
107107 }
@@ -130,36 +130,36 @@ PAYPAL.apps = PAYPAL.apps || {};
130130 * @return {HTMLElement }
131131 */
132132 function buildForm ( data , type ) {
133- var form = document . createElement ( " form" ) ,
134- btn = document . createElement ( " input" ) ,
135- hidden = document . createElement ( " input" ) ,
133+ var form = document . createElement ( ' form' ) ,
134+ btn = document . createElement ( ' input' ) ,
135+ hidden = document . createElement ( ' input' ) ,
136136 items = data . items ,
137137 item , child , label , input , key , size , locale ;
138138
139- btn . type = " image" ;
140- hidden . type = " hidden" ;
141- form . method = " post" ;
139+ btn . type = ' image' ;
140+ hidden . type = ' hidden' ;
141+ form . method = ' post' ;
142142 form . action = paypalURL ;
143- form . className = " paypal-button" ;
144- form . target = " _top" ;
143+ form . className = ' paypal-button' ;
144+ form . target = ' _top' ;
145145
146146 for ( key in items ) {
147147 item = items [ key ] ;
148148
149149 if ( item . isEditable ) {
150- input = document . createElement ( " input" ) ;
151- input . type = " text" ;
152- input . className = " paypal-input" ;
150+ input = document . createElement ( ' input' ) ;
151+ input . type = ' text' ;
152+ input . className = ' paypal-input' ;
153153 input . name = item . key ;
154154 input . value = item . value ;
155155
156- label = document . createElement ( " label" ) ;
157- label . className = " paypal-label" ;
158- label . appendChild ( document . createTextNode ( app . config . labels [ item . key ] + " " || "" ) ) ;
156+ label = document . createElement ( ' label' ) ;
157+ label . className = ' paypal-label' ;
158+ label . appendChild ( document . createTextNode ( app . config . labels [ item . key ] + ' ' || '' ) ) ;
159159 label . appendChild ( input ) ;
160160
161- child = document . createElement ( "p" ) ;
162- child . className = " paypal-group" ;
161+ child = document . createElement ( 'p' ) ;
162+ child . className = ' paypal-group' ;
163163 child . appendChild ( label ) ;
164164 } else {
165165 input = child = hidden . cloneNode ( true ) ;
@@ -177,7 +177,7 @@ PAYPAL.apps = PAYPAL.apps || {};
177177 btn . src = getButtonImg ( type , size , locale ) ;
178178
179179 // If the Mini Cart is present then register the form
180- if ( PAYPAL . apps . MiniCart && data . items . cmd . value === " _cart" ) {
180+ if ( PAYPAL . apps . MiniCart && data . items . cmd . value === ' _cart' ) {
181181 var MiniCart = PAYPAL . apps . MiniCart ;
182182
183183 if ( ! MiniCart . UI . itemList ) {
@@ -199,8 +199,8 @@ PAYPAL.apps = PAYPAL.apps || {};
199199 * @return {HTMLElement }
200200 */
201201 function buildQR ( data , size ) {
202- var img = document . createElement ( " img" ) ,
203- url = paypalURL + "?" ,
202+ var img = document . createElement ( ' img' ) ,
203+ url = paypalURL + '?' ,
204204 pattern = 13 ,
205205 items = data . items ,
206206 item , key ;
@@ -210,11 +210,11 @@ PAYPAL.apps = PAYPAL.apps || {};
210210
211211 for ( key in items ) {
212212 item = items [ key ] ;
213- url += item . key + "=" + encodeURIComponent ( item . value ) + "&" ;
213+ url += item . key + '=' + encodeURIComponent ( item . value ) + '&' ;
214214 }
215215
216216 url = encodeURIComponent ( url ) ;
217- img . src = qrCodeURL . replace ( " {url}" , url ) . replace ( " {pattern}" , pattern ) . replace ( " {size}" , size ) ;
217+ img . src = qrCodeURL . replace ( ' {url}' , url ) . replace ( ' {pattern}' , pattern ) . replace ( ' {size}' , size ) ;
218218
219219 return img ;
220220 }
@@ -232,8 +232,8 @@ PAYPAL.apps = PAYPAL.apps || {};
232232 var img = buttonImgs [ type ] || buttonImgs . buynow ;
233233
234234 // Image defaults
235- locale = locale || " en_US" ;
236- size = ( size === " small" ) ? "SM" : "LG" ;
235+ locale = locale || ' en_US' ;
236+ size = ( size === ' small' ) ? 'SM' : 'LG' ;
237237
238238 return img . replace ( / \{ l o c a l e \} / , locale ) . replace ( / \{ s i z e \} / , size ) ;
239239 }
@@ -286,9 +286,9 @@ PAYPAL.apps = PAYPAL.apps || {};
286286
287287
288288 // Init the buttons
289- if ( typeof document !== " undefined" ) {
289+ if ( typeof document !== ' undefined' ) {
290290 var ButtonFactory = PAYPAL . apps . ButtonFactory ,
291- nodes = document . getElementsByTagName ( " script" ) ,
291+ nodes = document . getElementsByTagName ( ' script' ) ,
292292 node , data , type , business , i , len ;
293293
294294 for ( i = 0 , len = nodes . length ; i < len ; i ++ ) {
@@ -298,7 +298,7 @@ PAYPAL.apps = PAYPAL.apps || {};
298298
299299 data = node && getDataSet ( node ) ;
300300 type = data && data . button && data . button . value ;
301- business = node . src . split ( " ?merchant=" ) [ 1 ] ;
301+ business = node . src . split ( ' ?merchant=' ) [ 1 ] ;
302302
303303 if ( business ) {
304304 ButtonFactory . create ( business , data , type , node . parentNode ) ;
@@ -314,6 +314,6 @@ PAYPAL.apps = PAYPAL.apps || {};
314314
315315
316316// Export for CommonJS environments
317- if ( typeof module === " object" && typeof module . exports === " object" ) {
317+ if ( typeof module === ' object' && typeof module . exports === ' object' ) {
318318 module . exports = PAYPAL ;
319319}
0 commit comments