Soundy Background Music - Version 2.0

Version Description

  • IMPORTANT: After having upgraded Soundy to 2.0, please clear your browser's cache. The reason is that a few CSS and Javascript files have been modified or deleted and these files are typically cached by browsers.
  • Soundy PRO and its HTML5 Play/Pause Button Designer application is now available.
Download this release

Release Info

Developer bducouedic
Plugin Icon 128x128 Soundy Background Music
Version 2.0
Comparing to
See all releases

Code changes from version 1.2 to 2.0

css/style-back-end-firefox.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ input[type=button].war_soundy,
2
+ button.war_soundy
3
+ {
4
+ line-height: 25px !important;
5
+ }
6
+
7
+ button.war_soundy_button_media_library_pp_button
8
+ {
9
+ line-height: 25px !important;
10
+ }
css/style-back-end.css CHANGED
@@ -1,17 +1,21 @@
1
 
2
  a:active,
3
- a:focus {
 
4
  outline: 0 !important;
5
  text-decoration: none !important;
6
  }
7
 
8
- table.war_soundy th {
 
9
  width: 25% !important;
10
  vertical-align: top !important;
11
  text-align: left !important;
12
  }
13
 
14
- input[type=button].war_soundy {
 
 
15
  height: 30px !important;
16
  line-height: 28px !important;
17
  padding: 0 12px 20px !important;
@@ -20,44 +24,96 @@ input[type=button].war_soundy {
20
  border-radius: 3px !important;
21
  border: #0074a2 1px solid !important;
22
  cursor: pointer !important;
 
23
  }
24
 
25
- audio.war_soundy {
26
- margin: 8px 0 0 2px !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
 
29
- img.war_soundy {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  margin: 0 0 0 0 !important;
31
  }
32
 
33
  table.war_soundy_no_border,
34
  table.war_soundy_no_border th,
35
- table.war_soundy_no_border td {
 
36
  border: 0px solid red !important;
37
  margin: 0 !important;
38
  padding: 0 !important;
39
  }
40
 
41
- .war_soundy_txt_input {
 
42
  width: 95%;
43
  }
44
 
45
- .war_soundy_audio_volume {
 
46
  width: 40px;
47
  }
48
 
49
- @media only screen and (max-width: 480px) {
 
 
 
 
 
 
 
50
 
51
  }
52
 
53
- @media only screen and (min-width: 481px) and (max-width: 768px) {
 
54
 
55
  }
56
 
57
- @media only screen and (min-width: 769px) and (max-width: 1024px) {
 
58
 
59
  }
60
 
61
- @media only screen and (min-width: 1025px) {
 
62
 
63
  }
1
 
2
  a:active,
3
+ a:focus
4
+ {
5
  outline: 0 !important;
6
  text-decoration: none !important;
7
  }
8
 
9
+ table.war_soundy th
10
+ {
11
  width: 25% !important;
12
  vertical-align: top !important;
13
  text-align: left !important;
14
  }
15
 
16
+ input[type=button].war_soundy,
17
+ button.war_soundy
18
+ {
19
  height: 30px !important;
20
  line-height: 28px !important;
21
  padding: 0 12px 20px !important;
24
  border-radius: 3px !important;
25
  border: #0074a2 1px solid !important;
26
  cursor: pointer !important;
27
+ vertical-align: middle !important;
28
  }
29
 
30
+ button.war_soundy_button_media_library_pp_button
31
+ {
32
+ height: 30px !important;
33
+ line-height: 28px !important;
34
+ padding: 0 12px 20px !important;
35
+ color: #ffffff !important;
36
+ background-color: #2eaecc !important;
37
+ border-radius: 3px !important;
38
+ border: #0074a2 1px solid !important;
39
+ cursor: pointer !important;
40
+ vertical-align: top !important;
41
+ margin-right: 10px !important;
42
+ }
43
+
44
+ a.war_soundy_hit_link
45
+ {
46
+ color: #ffffff !important;
47
+ background-color: #2eaecc !important;
48
+ border-radius: 3px !important;
49
+ padding-left: 5px !important;
50
+ padding-right: 5px !important;
51
  }
52
 
53
+ .war_soundy_page_preview_label
54
+ {
55
+ vertical-align: middle;
56
+ }
57
+
58
+ .war_soundy_page_preview_url
59
+ {
60
+ vertical-align: middle;
61
+ }
62
+
63
+ audio.war_soundy
64
+ {
65
+ margin: 0 0 0 2px !important;
66
+ vertical-align: middle !important;
67
+ width: 300px;
68
+ border-radius: 3px;
69
+ }
70
+
71
+ img.war_soundy
72
+ {
73
  margin: 0 0 0 0 !important;
74
  }
75
 
76
  table.war_soundy_no_border,
77
  table.war_soundy_no_border th,
78
+ table.war_soundy_no_border td
79
+ {
80
  border: 0px solid red !important;
81
  margin: 0 !important;
82
  padding: 0 !important;
83
  }
84
 
85
+ .war_soundy_txt_input
86
+ {
87
  width: 95%;
88
  }
89
 
90
+ .war_soundy_audio_volume
91
+ {
92
  width: 40px;
93
  }
94
 
95
+ #war_soundy_img_preview_here
96
+ {
97
+ display: none;
98
+ cursor: pointer;
99
+ }
100
+
101
+ @media only screen and (max-width: 480px)
102
+ {
103
 
104
  }
105
 
106
+ @media only screen and (min-width: 481px) and (max-width: 768px)
107
+ {
108
 
109
  }
110
 
111
+ @media only screen and (min-width: 769px) and (max-width: 1024px)
112
+ {
113
 
114
  }
115
 
116
+ @media only screen and (min-width: 1025px)
117
+ {
118
 
119
  }
js/back-end.js CHANGED
@@ -1,11 +1,40 @@
1
- function war_initTabs()
2
  {
3
- jQuery( document ).ready( function( $ )
 
 
4
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  if( ! sessionStorage.getItem( 'war_soundy_tab_index' ) )
6
  sessionStorage.setItem( 'war_soundy_tab_index', 0 );
7
 
8
- $( '#war_soundy_tabs' ).tabs(
9
  {
10
  active: sessionStorage.war_soundy_tab_index,
11
  activate : function( event, ui )
@@ -15,150 +44,209 @@ function war_initTabs()
15
  sessionStorage.setItem( 'war_soundy_tab_index', new_index );
16
  }
17
  } );
18
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  }
20
 
21
- function war_initSoundTrack( default_url )
22
  {
23
- jQuery( document ).ready( function( $ )
24
- {
25
- if( $( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked' ) )
26
- {
27
- $( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
28
- }
29
-
30
- $( '#war_soundy_audio_file_url' ).click( function()
31
- {
32
- $( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked', true );
33
- $( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
34
- } );
35
-
36
- $( '#war_soundy_audio_file_url' ).change( function()
37
- {
38
- $( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked', true );
39
- $( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
40
- } );
41
-
42
- $( '#war_soundy_soundtrack_default' ).change( function() // called when Default radio button is clicked
43
- {
44
- var audio_type = war_getAudioTypeFromURL( default_url );
45
-
46
- var player_was_playing = ! jQuery( '#war_soundy_audio_player' )[ 0 ].paused;
47
-
48
- jQuery( '#war_soundy_audio_file_url' ).val( default_url );
49
- jQuery( '#war_soundy_audio_player_source' ).attr( 'src', default_url );
50
- jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
51
- jQuery( '#war_soundy_audio_player' )[ 0 ].load();
52
-
53
- if( player_was_playing ) jQuery( '#war_soundy_audio_player' )[ 0 ].play();
54
- $( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '' );
55
- } );
56
 
57
- $( '#war_soundy_soundtrack_custom' ).change( function() // called when Custom radio button is clicked
58
- {
59
- $( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
60
- } );
 
 
 
 
 
 
61
  } );
62
  }
63
 
64
- function war_initAudioVolume( is_meta_box, default_volume )
65
  {
66
- jQuery( document ).ready( function( $ )
 
 
67
  {
68
- var audio_player = $( '#war_soundy_audio_player' ).get( 0 );
69
- var audio_volume_jquery = $( '#war_soundy_audio_volume' );
70
- var audio_volume = audio_volume_jquery.val();
71
- audio_player.volume = audio_volume / 100;
72
- var audio_volume_slider_jquery = $( '#war_soundy_audio_volume_slider' );
73
-
74
- audio_volume_slider_jquery.slider(
75
- {
76
- min: 0,
77
- max: 100,
78
- value: audio_volume,
79
- range: 'min',
80
- animate: true,
81
- slide: function( event, ui )
82
- {
83
- audio_player.volume = ui.value / 100;
84
- audio_volume_jquery.val( ui.value );
85
- }
86
- } );
87
-
88
- audio_volume_jquery.change( function()
89
- {
90
- audio_volume_slider_jquery.slider( 'value', this.value );
91
- audio_player.volume = this.value / 100;
92
- } );
93
 
94
- if( is_meta_box )
95
- {
96
- if( $( 'input[name=war_soundy_audio_volume_def][value=custom]' ).prop( 'checked' ) )
97
- {
98
- audio_volume_jquery.css( 'backgroundColor', '#c0e7f0' );
99
- }
100
 
101
- audio_volume_jquery.click( function()
102
- {
103
- $('input[name=war_soundy_audio_volume_def][value=custom]').prop( 'checked', true );
104
- audio_volume_jquery.css( 'backgroundColor', '#c0e7f0' );
105
- } );
 
 
 
 
 
 
 
 
 
106
 
107
- var audio_volume_jquery_default = $( '#war_soundy_audio_volume_default' );
108
- audio_volume_jquery_default.change( function() // called when Default radio button is clicked
109
- {
110
- audio_volume_jquery.val( default_volume );
111
- audio_volume_slider_jquery.slider( 'value', default_volume );
112
- audio_player.volume = default_volume / 100;
113
- audio_volume_jquery.css( 'backgroundColor', '' );
114
- } );
115
-
116
- audio_volume_slider_jquery.on( "slidestart", function( event, ui )
117
- {
118
- $('input[name=war_soundy_audio_volume_def][value=custom]').prop( 'checked', true );
119
- audio_volume_jquery.css( 'backgroundColor', '#c0e7f0' );
120
- } );
121
-
122
- var audio_volume_jquery_custom = $( '#war_soundy_audio_volume_custom' );
123
- audio_volume_jquery_custom.change( function() // called when Custom radio button is clicked
124
- {
125
- audio_volume_jquery.css( 'backgroundColor', '#c0e7f0' );
126
- audio_volume_slider_jquery.css( 'backgroundColor', '#c0e7f0' );
127
- } );
128
- }
129
  } );
130
  }
131
 
132
- function war_initAudioTitle( default_title )
133
  {
134
- jQuery( document ).ready( function( $ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  {
136
- if( $( 'input[name=war_soundy_audio_title_def][value=custom]' ).prop( 'checked' ) )
137
  {
138
- $( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
139
  }
140
-
141
- $( '#war_soundy_audio_title' ).click( function()
142
  {
143
- $( 'input[name=war_soundy_audio_title_def][value=custom]' ).prop( 'checked', true );
144
- $( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
145
  } );
146
 
147
- $( '#war_soundy_audio_title_default' ).change( function() // called when Default radio button is clicked
 
148
  {
149
- jQuery( '#war_soundy_audio_title' ).val( default_title );
150
- $( '#war_soundy_audio_title' ).css( 'backgroundColor', '' );
 
 
151
  } );
152
-
153
- $( '#war_soundy_audio_title_custom' ).change( function() // called when Custom radio button is clicked
154
  {
155
- $( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
 
156
  } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  } );
158
  }
159
 
160
- function war_setDefaultButtonURL( button_type, url )
 
161
  {
 
 
162
  jQuery( '#war_soundy_url_' + button_type ).val( url );
163
  jQuery( '#war_soundy_url_' + button_type + '_img' ).attr( 'src', url );
164
 
@@ -184,90 +272,290 @@ function war_setDefaultButtonURL( button_type, url )
184
  if( event.preventDefault ) event.preventDefault(); else event.returnValue = false;
185
  }
186
 
187
- function war_setDefaultButtons( dimensions, default_dimensions, url_play_button,
188
- url_play_hover,
189
- url_pause_button,
190
- url_pause_hover )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  {
192
- url_play_button = url_play_button.replace( default_dimensions, dimensions );
193
- url_play_hover = url_play_hover.replace( default_dimensions, dimensions );
194
- url_pause_button = url_pause_button.replace( default_dimensions, dimensions );
195
- url_pause_hover = url_pause_hover.replace( default_dimensions, dimensions );
196
 
197
- jQuery( '#war_soundy_url_play_button' ).val( url_play_button );
198
- jQuery( '#war_soundy_url_play_button_img' ).attr( 'src', url_play_button );
 
 
 
 
199
 
200
- jQuery( '#war_soundy_url_play_hover' ).val( url_play_hover );
201
- jQuery( '#war_soundy_url_play_hover_img' ).attr( 'src', url_play_hover );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
 
203
- jQuery( '#war_soundy_url_pause_button' ).val( url_pause_button );
204
- jQuery( '#war_soundy_url_pause_button_img' ).attr( 'src', url_pause_button );
 
 
 
 
 
 
 
 
 
 
205
 
206
- jQuery( '#war_soundy_url_pause_hover' ).val( url_pause_hover );
207
- jQuery( '#war_soundy_url_pause_hover_img' ).attr( 'src', url_pause_hover );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  }
209
 
210
- function war_setDefaultAudio( url, title, volume )
211
  {
212
- var audio_type = war_getAudioTypeFromURL( url );
213
-
214
- var player_was_playing = ! jQuery( '#war_soundy_audio_player' )[ 0 ].paused;
215
-
216
- jQuery( '#war_soundy_audio_file_url' ).val( url );
217
- jQuery( '#war_soundy_audio_title' ).val( title );
218
- jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
219
- jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
220
- jQuery( '#war_soundy_audio_player' )[ 0 ].load();
221
- jQuery( '#war_soundy_audio_player' )[ 0 ].volume = volume / 100;
222
- jQuery( '#war_soundy_audio_volume' ).val( volume );
223
- jQuery( '#war_soundy_audio_volume_slider' ).slider( 'value', volume );
224
 
225
- if( player_was_playing ) jQuery( '#war_soundy_audio_player' )[ 0 ].play();
 
226
 
227
- alert( 'Audio File URL reset to default.\n' +
228
- 'Audio Title reset to default.\n' +
229
- 'Audio Volume reset to default.\n' +
230
- 'You still have to save the changes.' );
 
231
  }
232
 
233
- function war_lengthUnitChanged( element )
234
  {
235
- var element_value = element.options[ element.selectedIndex ].value;
236
- var unit_map = {
237
- 'px' : '(pixels)',
238
- '%' : '(percentage)',
239
- 'in' : '(inches)',
240
- 'mm' : '(millimeters)',
241
- 'cm' : '(centimeters)'
242
- };
243
- switch( element.name )
244
  {
245
- case 'war_soundy_offset_x_unit':
246
- jQuery( '#war_soundy_unit_comment_x' ).html( unit_map[ element_value ] );
247
- break;
248
- case 'war_soundy_offset_y_unit':
249
- jQuery( '#war_soundy_unit_comment_y' ).html( unit_map[ element_value ] );
250
- break;
251
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  }
253
 
254
- function war_ppPositionChanged( element )
255
  {
256
- var element_value = element.options[ element.selectedIndex ].value;
257
- var position_map = {
258
- 'document' : '(absolute position)',
259
- 'window' : '(fixed position)'
260
- };
261
- jQuery( '#war_soundy_pp_comment' ).html( position_map[ element_value ] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  }
263
 
264
- function war_imgUrlChanged( element )
265
  {
266
- jQuery( '#' + element.name + '_img' ).attr( 'src', element.value );
 
 
 
 
 
 
 
 
 
 
 
 
267
  }
268
 
269
- function war_getAudioTypeFromURL( url )
270
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  var file_extension = url.substr( url.lastIndexOf( '.' ) + 1 );
272
  var audio_type = '';
273
 
@@ -290,77 +578,96 @@ function war_getAudioTypeFromURL( url )
290
  return audio_type;
291
  }
292
 
293
- function war_audioUrlChanged( element )
294
  {
295
- var url = element.value;
296
- var audio_type = war_getAudioTypeFromURL( url );
297
-
298
- jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
299
- jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
300
- jQuery( '#war_soundy_audio_player' )[ 0 ].load();
 
 
 
 
 
301
  }
302
 
303
- function war_bindMediaUploader( field_name, button_name, field_type )
304
  {
305
- jQuery( document ).ready( function()
 
 
306
  {
307
- jQuery( '#' + button_name ).click( function()
 
 
 
308
  {
309
- jQuery( '#TB_window' ).html( '' ); // to avoid multiple title bars
310
- tb_show( '', 'media-upload.php?type=' + field_type + '&TB_iframe=true');
311
-
312
- window.send_to_editor = function( html )
313
  {
314
- if( field_type == 'image' )
315
- {
316
- var url = jQuery( 'img', html ).attr( 'src' );
317
- jQuery( '#' + field_name + '_img' ).attr( 'src', url );
318
- }
319
- else if( field_type == 'audio' )
320
- {
321
- var url = jQuery( html ).attr( 'href' );
322
- var file_extension = url.substr( url.lastIndexOf( '.' ) + 1 );
323
- switch( file_extension )
324
- {
325
- case 'mp3':
326
- case 'mpeg':
327
- var audio_type = 'mpeg';
328
- break;
329
- case 'ogg':
330
- var audio_type = 'ogg';
331
- break;
332
- case 'wav':
333
- var audio_type = 'wav';
334
- break;
335
- default:
336
- alert( 'Audio field_type Error' );
337
- return;
338
- }
339
- var player_was_playing = ! jQuery( '#war_soundy_audio_player' )[ 0 ].paused;
340
- jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
341
- jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
342
- jQuery( '#war_soundy_audio_player' )[ 0 ].load();
343
- if( player_was_playing ) jQuery( '#war_soundy_audio_player' )[ 0 ].play();
344
-
345
- var title = jQuery( html ).text().trim();
346
- if( title != '' )
347
- {
348
- jQuery( '#war_soundy_audio_title' ).val( title );
349
- }
350
- }
351
-
352
- jQuery( '#' + field_name ).val( url );
353
- tb_remove();
354
- if( jQuery( '#war_soundy_soundtrack_default' ).length ) // war_soundy_soundtrack_default exists if meta box
355
- {
356
- jQuery( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked', true );
357
- jQuery( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
358
- jQuery( 'input[name=war_soundy_audio_title_def][value=custom]' ).prop( 'checked', true );
359
- jQuery( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
360
- }
361
- }
362
-
363
- return false;
364
- } );
 
 
 
 
 
 
 
 
 
 
 
 
365
  } );
366
  }
1
+ function war_SoundyAdmin( mode, args )
2
  {
3
+ var _this = this;
4
+
5
+ jQuery( document ).ready( function()
6
  {
7
+ if( mode == 'settings' )
8
+ {
9
+ _this.initSettingsTabs( args );
10
+ }
11
+ else
12
+ {
13
+ _this.initMetaBox( args );
14
+ }
15
+ } );
16
+ }
17
+
18
+ war_SoundyAdmin.prototype.initSettingsTabs = function( args )
19
+ {
20
+ var _this = this;
21
+
22
+ _this.default_button_dimensions = args.default_button_dimensions;
23
+ _this.default_play_button_url = args.default_play_button_url;
24
+ _this.default_play_hover_url = args.default_play_hover_url;
25
+ _this.default_pause_button_url = args.default_pause_button_url;
26
+ _this.default_pause_hover_url = args.default_pause_hover_url;
27
+ _this.default_audio_url = args.default_audio_url;
28
+ _this.default_audio_title = args.default_audio_title;
29
+ _this.default_audio_volume = args.default_audio_volume;
30
+ _this.is_pro = args.is_pro;
31
+ _this.is_trial = args.is_trial;
32
+ _this.soundy_pro_home_url = args.soundy_pro_home_url;
33
+
34
  if( ! sessionStorage.getItem( 'war_soundy_tab_index' ) )
35
  sessionStorage.setItem( 'war_soundy_tab_index', 0 );
36
 
37
+ jQuery( '#war_soundy_tabs' ).tabs(
38
  {
39
  active: sessionStorage.war_soundy_tab_index,
40
  activate : function( event, ui )
44
  sessionStorage.setItem( 'war_soundy_tab_index', new_index );
45
  }
46
  } );
47
+
48
+ // Prevent Enter Key to submit the form:
49
+ jQuery( document ).keydown( function( event )
50
+ {
51
+ if( event.keyCode == 13 )
52
+ {
53
+ event.preventDefault();
54
+ if( jQuery( event.target ).is( 'input' ) )
55
+ {
56
+ jQuery( event.target ).change();
57
+ }
58
+ return false;
59
+ }
60
+ } );
61
+
62
+ _this.bindMediaUploader( 'war_soundy_audio_file_url', 'war_audio_library_button', 'audio' );
63
+ _this.bindMediaUploader( 'war_soundy_url_play_button', 'img_play_button_library_button', 'image' );
64
+ _this.bindMediaUploader( 'war_soundy_url_play_hover', 'img_play_hover_library_button', 'image' );
65
+ _this.bindMediaUploader( 'war_soundy_url_pause_button', 'img_pause_button_library_button', 'image' );
66
+ _this.bindMediaUploader( 'war_soundy_url_pause_hover', 'img_pause_hover_library_button', 'image' );
67
+ _this.initBuySoundyPro();
68
+ _this.initAudioFileURL();
69
+ _this.initAudioVolume();
70
+ _this.initDefaultAudio();
71
+ _this.initPlayPauseImagesToUse();
72
+ _this.initButtonImgUrls();
73
+ _this.initSwapNormalHover();
74
+ _this.initDefaultButtons();
75
+ _this.initImgPreviewHere();
76
+ _this.initImgPreviewInContextDefault();
77
+ _this.initPlayPausePosition();
78
+ _this.initLengthUnits();
79
+ _this.initImgPreviewInContextPosition();
80
  }
81
 
82
+ war_SoundyAdmin.prototype.initMetaBox = function( args )
83
  {
84
+ var _this = this;
85
+
86
+ _this.default_audio_url = args.default_audio_url;
87
+ _this.default_audio_title = args.default_audio_title;
88
+ _this.default_audio_volume = args.default_audio_volume;
89
+
90
+ _this.bindMediaUploader( 'war_soundy_audio_file_url', 'war_audio_library_button', 'audio' );
91
+ _this.initSoundTrack( _this.default_audio_url );
92
+ _this.initAudioVolume( true );
93
+ _this.initAudioTitle();
94
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
+ war_SoundyAdmin.prototype.initBuySoundyPro = function()
97
+ {
98
+ var _this = this;
99
+
100
+ if( _this.is_pro && ! _this.is_trial ) return;
101
+
102
+ var jquery_pro_buy = jQuery( '#war_soundy_pro_buy' );
103
+ jquery_pro_buy.click( function()
104
+ {
105
+ window.open( _this.soundy_pro_home_url, 'soundy_pro_home' );
106
  } );
107
  }
108
 
109
+ war_SoundyAdmin.prototype.initSoundTrack = function()
110
  {
111
+ var _this = this;
112
+
113
+ if( jQuery( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked' ) )
114
  {
115
+ jQuery( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
116
+ }
117
+
118
+ jQuery( '#war_soundy_audio_file_url' ).click( function()
119
+ {
120
+ jQuery( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked', true );
121
+ jQuery( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
122
+ } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
+ jQuery( '#war_soundy_audio_file_url' ).change( function()
125
+ {
126
+ jQuery( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked', true );
127
+ jQuery( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
128
+ } );
 
129
 
130
+ jQuery( '#war_soundy_soundtrack_default' ).change( function() // called when Default radio button is clicked
131
+ {
132
+ var audio_type = _this.getAudioTypeFromURL( _this.default_audio_url );
133
+
134
+ var player_was_playing = ! jQuery( '#war_soundy_audio_player' )[ 0 ].paused;
135
+
136
+ jQuery( '#war_soundy_audio_file_url' ).val( _this.default_audio_url );
137
+ jQuery( '#war_soundy_audio_player_source' ).attr( 'src', _this.default_audio_url );
138
+ jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
139
+ jQuery( '#war_soundy_audio_player' )[ 0 ].load();
140
+
141
+ if( player_was_playing ) jQuery( '#war_soundy_audio_player' )[ 0 ].play();
142
+ jQuery( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '' );
143
+ } );
144
 
145
+ jQuery( '#war_soundy_soundtrack_custom' ).change( function() // called when Custom radio button is clicked
146
+ {
147
+ jQuery( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  } );
149
  }
150
 
151
+ war_SoundyAdmin.prototype.initAudioVolume = function( is_meta_box )
152
  {
153
+ var _this = this;
154
+
155
+ var audio_player = jQuery( '#war_soundy_audio_player' ).get( 0 );
156
+ var audio_volume_jquery = jQuery( '#war_soundy_audio_volume' );
157
+ var audio_volume = audio_volume_jquery.val();
158
+ audio_player.volume = audio_volume / 100;
159
+ var audio_volume_slider_jquery = jQuery( '#war_soundy_audio_volume_slider' );
160
+
161
+ audio_volume_slider_jquery.slider(
162
+ {
163
+ min: 0,
164
+ max: 100,
165
+ value: audio_volume,
166
+ range: 'min',
167
+ animate: true,
168
+ slide: function( event, ui )
169
+ {
170
+ audio_player.volume = ui.value / 100;
171
+ audio_volume_jquery.val( ui.value );
172
+ }
173
+ } );
174
+
175
+ audio_volume_jquery.change( function()
176
+ {
177
+ audio_volume_slider_jquery.slider( 'value', this.value );
178
+ audio_player.volume = this.value / 100;
179
+ } );
180
+
181
+ if( is_meta_box )
182
  {
183
+ if( jQuery( 'input[name=war_soundy_audio_volume_def][value=custom]' ).prop( 'checked' ) )
184
  {
185
+ audio_volume_jquery.css( 'backgroundColor', '#c0e7f0' );
186
  }
187
+
188
+ audio_volume_jquery.click( function()
189
  {
190
+ jQuery( 'input[name=war_soundy_audio_volume_def][value=custom]' ).prop( 'checked', true );
191
+ audio_volume_jquery.css( 'backgroundColor', '#c0e7f0' );
192
  } );
193
 
194
+ var audio_volume_jquery_default = jQuery( '#war_soundy_audio_volume_default' );
195
+ audio_volume_jquery_default.change( function() // called when Default radio button is clicked
196
  {
197
+ audio_volume_jquery.val( _this.default_audio_volume );
198
+ audio_volume_slider_jquery.slider( 'value', _this.default_audio_volume );
199
+ audio_player.volume = _this.default_audio_volume / 100;
200
+ audio_volume_jquery.css( 'backgroundColor', '' );
201
  } );
202
+
203
+ audio_volume_slider_jquery.on( "slidestart", function( event, ui )
204
  {
205
+ jQuery( 'input[name=war_soundy_audio_volume_def][value=custom]' ).prop( 'checked', true );
206
+ audio_volume_jquery.css( 'backgroundColor', '#c0e7f0' );
207
  } );
208
+
209
+ var audio_volume_jquery_custom = jQuery( '#war_soundy_audio_volume_custom' );
210
+ audio_volume_jquery_custom.change( function() // called when Custom radio button is clicked
211
+ {
212
+ audio_volume_jquery.css( 'backgroundColor', '#c0e7f0' );
213
+ audio_volume_slider_jquery.css( 'backgroundColor', '#c0e7f0' );
214
+ } );
215
+ }
216
+ }
217
+
218
+ war_SoundyAdmin.prototype.initAudioTitle = function()
219
+ {
220
+ var _this = this;
221
+
222
+ if( jQuery( 'input[name=war_soundy_audio_title_def][value=custom]' ).prop( 'checked' ) )
223
+ {
224
+ jQuery( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
225
+ }
226
+
227
+ jQuery( '#war_soundy_audio_title' ).click( function()
228
+ {
229
+ jQuery( 'input[name=war_soundy_audio_title_def][value=custom]' ).prop( 'checked', true );
230
+ jQuery( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
231
+ } );
232
+
233
+ jQuery( '#war_soundy_audio_title_default' ).change( function() // called when Default radio button is clicked
234
+ {
235
+ jQuery( '#war_soundy_audio_title' ).val( _this.default_audio_title );
236
+ jQuery( '#war_soundy_audio_title' ).css( 'backgroundColor', '' );
237
+ } );
238
+
239
+ jQuery( '#war_soundy_audio_title_custom' ).change( function() // called when Custom radio button is clicked
240
+ {
241
+ jQuery( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
242
  } );
243
  }
244
 
245
+ // Not used anymore:
246
+ war_SoundyAdmin.prototype.setDefaultButtonURL = function( button_type, url )
247
  {
248
+ var _this = this;
249
+
250
  jQuery( '#war_soundy_url_' + button_type ).val( url );
251
  jQuery( '#war_soundy_url_' + button_type + '_img' ).attr( 'src', url );
252
 
272
  if( event.preventDefault ) event.preventDefault(); else event.returnValue = false;
273
  }
274
 
275
+ war_SoundyAdmin.prototype.initSwapNormalHover = function()
276
+ {
277
+ jQuery( '#war_soundy_button_swap_normal_hover' ).click( function()
278
+ {
279
+ var url_play_button = jQuery( '#war_soundy_url_play_button' ).val();
280
+ var url_play_hover = jQuery( '#war_soundy_url_play_hover' ).val();
281
+ jQuery( '#war_soundy_url_play_button' ).val( url_play_hover );
282
+ jQuery( '#war_soundy_url_play_button' ).change();
283
+ jQuery( '#war_soundy_url_play_hover' ).val( url_play_button );
284
+ jQuery( '#war_soundy_url_play_hover' ).change();
285
+
286
+ var url_pause_button = jQuery( '#war_soundy_url_pause_button' ).val();
287
+ var url_pause_hover = jQuery( '#war_soundy_url_pause_hover' ).val();
288
+ jQuery( '#war_soundy_url_pause_button' ).val( url_pause_hover );
289
+ jQuery( '#war_soundy_url_pause_button' ).change();
290
+ jQuery( '#war_soundy_url_pause_hover' ).val( url_pause_button );
291
+ jQuery( '#war_soundy_url_pause_hover' ).change();
292
+ } );
293
+ }
294
+
295
+ war_SoundyAdmin.prototype.initDefaultButtons = function()
296
+ {
297
+ var _this = this;
298
+
299
+ var dims = [ 24, 32, 48, 64 ];
300
+ for( var index in dims )
301
+ {
302
+ var dim = dims[ index ];
303
+ jQuery( '#button_default_buttons_' + dim ).click( function()
304
+ {
305
+ var dimensions = this.value;
306
+ var url_play_button = _this.default_play_button_url.replace( _this.default_button_dimensions, dimensions );
307
+ var url_play_hover = _this.default_play_hover_url.replace( _this.default_button_dimensions, dimensions );
308
+ var url_pause_button = _this.default_pause_button_url.replace( _this.default_button_dimensions, dimensions );
309
+ var url_pause_hover = _this.default_pause_hover_url.replace( _this.default_button_dimensions, dimensions );
310
+
311
+ jQuery( '#war_soundy_url_play_button' ).val( url_play_button );
312
+ jQuery( '#war_soundy_url_play_button' ).change();
313
+ jQuery( '#war_soundy_url_play_button_img' ).attr( 'src', url_play_button );
314
+
315
+ jQuery( '#war_soundy_url_play_hover' ).val( url_play_hover );
316
+ jQuery( '#war_soundy_url_play_hover' ).change();
317
+ jQuery( '#war_soundy_url_play_hover_img' ).attr( 'src', url_play_hover );
318
+
319
+ jQuery( '#war_soundy_url_pause_button' ).val( url_pause_button );
320
+ jQuery( '#war_soundy_url_pause_button' ).change();
321
+ jQuery( '#war_soundy_url_pause_button_img' ).attr( 'src', url_pause_button );
322
+
323
+ jQuery( '#war_soundy_url_pause_hover' ).val( url_pause_hover );
324
+ jQuery( '#war_soundy_url_pause_hover' ).change();
325
+ jQuery( '#war_soundy_url_pause_hover_img' ).attr( 'src', url_pause_hover );
326
+ } );
327
+ }
328
+ }
329
+
330
+ war_SoundyAdmin.prototype.initImgPreviewHere = function()
331
  {
332
+ var _this = this;
 
 
 
333
 
334
+ var jquery_img_preview_here = jQuery( '#war_soundy_img_preview_here' );
335
+
336
+ _this.img_url_play_button = jQuery( '#war_soundy_url_play_button' ).val();
337
+ _this.img_url_play_hover = jQuery( '#war_soundy_url_play_hover' ).val();
338
+ _this.img_url_pause_button = jQuery( '#war_soundy_url_pause_button' ).val();
339
+ _this.img_url_pause_hover = jQuery( '#war_soundy_url_pause_hover' ).val();
340
 
341
+ //jquery_img_preview_here.css( 'background-image', 'url(' + jquery_img_data_grid.val() + ')' );
342
+ jquery_img_preview_here.attr( 'src', _this.img_url_play_button );
343
+ jquery_img_preview_here.fadeIn();
344
+
345
+ var hovering = false;
346
+ var is_play_img = true;
347
+
348
+ function displayImgPreviewHere()
349
+ {
350
+ if( hovering )
351
+ {
352
+ if( is_play_img )
353
+ {
354
+ jquery_img_preview_here.attr( 'src', _this.img_url_play_hover );
355
+ }
356
+ else
357
+ {
358
+ jquery_img_preview_here.attr( 'src', _this.img_url_pause_hover );
359
+ }
360
+ }
361
+ else
362
+ {
363
+ if( is_play_img )
364
+ {
365
+ jquery_img_preview_here.attr( 'src', _this.img_url_play_button );
366
+ }
367
+ else
368
+ {
369
+ jquery_img_preview_here.attr( 'src', _this.img_url_pause_button );
370
+ }
371
+ }
372
+ }
373
 
374
+ var types = [ 'play_button', 'play_hover', 'pause_button', 'pause_hover' ];
375
+ for( var index in types )
376
+ {
377
+ var type = types[ index ];
378
+ jQuery( '#war_soundy_url_' + type ).change( function()
379
+ {
380
+ var url = this.value;
381
+ var type = this.id.replace( 'war_soundy_url_', '' );
382
+ eval( '_this.img_url_' + type + '= url' );
383
+ displayImgPreviewHere();
384
+ } );
385
+ }
386
 
387
+ jquery_img_preview_here.hover(
388
+ function ()
389
+ {
390
+ hovering = true;
391
+ if( is_play_img )
392
+ {
393
+ jquery_img_preview_here.attr( 'src', _this.img_url_play_hover );
394
+ }
395
+ else
396
+ {
397
+ jquery_img_preview_here.attr( 'src', _this.img_url_pause_hover );
398
+ }
399
+ },
400
+ function ()
401
+ {
402
+ hovering = false;
403
+ if( is_play_img )
404
+ {
405
+ jquery_img_preview_here.attr( 'src', _this.img_url_play_button );
406
+ }
407
+ else
408
+ {
409
+ jquery_img_preview_here.attr( 'src', _this.img_url_pause_button );
410
+ }
411
+ } );
412
+
413
+ jquery_img_preview_here.click( function ()
414
+ {
415
+ if( is_play_img )
416
+ {
417
+ jquery_img_preview_here.attr( 'src', _this.img_url_pause_hover );
418
+ is_play_img = false;
419
+ }
420
+ else
421
+ {
422
+ jquery_img_preview_here.attr( 'src', _this.img_url_play_hover );
423
+ is_play_img = true;
424
+ }
425
+ } );
426
  }
427
 
428
+ war_SoundyAdmin.prototype.initImgPreviewInContextDefault = function()
429
  {
430
+ var _this = this;
 
 
 
 
 
 
 
 
 
 
 
431
 
432
+ var jquery_button_preview_in_context = jQuery( '#war_soundy_button_preview_in_context_default' );
433
+ var jquery_page_preview_url = jQuery( '#war_soundy_page_preview_url_default' );
434
 
435
+ jquery_button_preview_in_context.click( function ()
436
+ {
437
+ var page_url = jquery_page_preview_url.val();
438
+ window.open( page_url + '?war_soundy_preview=default', 'soundy_preview' );
439
+ } );
440
  }
441
 
442
+ war_SoundyAdmin.prototype.initImgPreviewInContextPosition = function()
443
  {
444
+ var _this = this;
445
+
446
+ var jquery_button_preview_in_context = jQuery( '#war_soundy_button_preview_in_context_position' );
447
+ var jquery_page_preview_url = jQuery( '#war_soundy_page_preview_url_position' );
448
+
449
+ if( ( ! _this.is_pro ) || _this.is_trial )
 
 
 
450
  {
451
+ var preview = 'default';
452
+ }
453
+ else
454
+ {
455
+ var preview = 'position';
 
456
  }
457
+
458
+ jquery_button_preview_in_context.click( function ()
459
+ {
460
+ var page_url = jquery_page_preview_url.val();
461
+ window.open( page_url + '?war_soundy_preview=' + preview, 'soundy_preview' );
462
+ } );
463
+ }
464
+
465
+ war_SoundyAdmin.prototype.initDefaultAudio = function()
466
+ {
467
+ var _this = this;
468
+
469
+ var url = _this.default_audio_url;
470
+ var title = _this.default_audio_title;
471
+ var volume = _this.default_audio_volume;
472
+ var audio_type = _this.getAudioTypeFromURL( url );
473
+
474
+ var player_was_playing = ! jQuery( '#war_soundy_audio_player' )[ 0 ].paused;
475
+
476
+ jQuery( '#war_audio_default_button' ).click( function()
477
+ {
478
+ jQuery( '#war_soundy_audio_file_url' ).val( url );
479
+ jQuery( '#war_soundy_audio_title' ).val( title );
480
+ jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
481
+ jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
482
+ jQuery( '#war_soundy_audio_player' )[ 0 ].load();
483
+ jQuery( '#war_soundy_audio_player' )[ 0 ].volume = volume / 100;
484
+ jQuery( '#war_soundy_audio_volume' ).val( volume );
485
+ jQuery( '#war_soundy_audio_volume_slider' ).slider( 'value', volume );
486
+
487
+ if( player_was_playing ) jQuery( '#war_soundy_audio_player' )[ 0 ].play();
488
+
489
+ alert( 'Audio File URL reset to default.\n' +
490
+ 'Audio Title reset to default.\n' +
491
+ 'Audio Volume reset to default.\n' +
492
+ 'You still have to save the changes.' );
493
+ } );
494
  }
495
 
496
+ war_SoundyAdmin.prototype.initLengthUnits = function()
497
  {
498
+ var _this = this;
499
+
500
+ var unit_map =
501
+ {
502
+ 'px' : '(pixels)',
503
+ '%' : '(percentage)',
504
+ 'in' : '(inches)',
505
+ 'mm' : '(millimeters)',
506
+ 'cm' : '(centimeters)'
507
+ };
508
+
509
+ jQuery( '#war_soundy_offset_x_unit' ).change( function()
510
+ {
511
+ var unit = this.options[ this.selectedIndex ].value;
512
+ jQuery( '#war_soundy_unit_comment_x' ).html( unit_map[ unit ] );
513
+ } );
514
+
515
+ jQuery( '#war_soundy_offset_y_unit' ).change( function()
516
+ {
517
+ var unit = this.options[ this.selectedIndex ].value;
518
+ jQuery( '#war_soundy_unit_comment_y' ).html( unit_map[ unit ] );
519
+ } );
520
  }
521
 
522
+ war_SoundyAdmin.prototype.initPlayPausePosition = function()
523
  {
524
+ var _this = this;
525
+
526
+ var position_map =
527
+ {
528
+ 'document' : '(absolute positioning: button will scroll with page content)',
529
+ 'window' : '(fixed positioning: button will NOT scroll with page content)'
530
+ };
531
+
532
+ jQuery( '#war_soundy_pp_position' ).change( function()
533
+ {
534
+ var position_type = this.options[ this.selectedIndex ].value;
535
+ jQuery( '#war_soundy_pp_comment' ).html( position_map[ position_type ] );
536
+ } );
537
  }
538
 
539
+ war_SoundyAdmin.prototype.initButtonImgUrls = function()
540
  {
541
+ var _this = this;
542
+
543
+ var types = [ 'play_button', 'play_hover', 'pause_button', 'pause_hover' ];
544
+ for( var index in types )
545
+ {
546
+ var type = types[ index ];
547
+ jQuery( '#war_soundy_url_' + type ).change( function()
548
+ {
549
+ var url = this.value;
550
+ jQuery( '#' + this.id + '_img' ).attr( 'src', url );
551
+ } );
552
+ }
553
+ }
554
+
555
+ war_SoundyAdmin.prototype.getAudioTypeFromURL = function( url )
556
+ {
557
+ var _this = this;
558
+
559
  var file_extension = url.substr( url.lastIndexOf( '.' ) + 1 );
560
  var audio_type = '';
561
 
578
  return audio_type;
579
  }
580
 
581
+ war_SoundyAdmin.prototype.initAudioFileURL = function( url )
582
  {
583
+ var _this = this;
584
+
585
+ jQuery( '#war_soundy_audio_file_url').change( function()
586
+ {
587
+ var url = this.value;
588
+ var audio_type = _this.getAudioTypeFromURL( url );
589
+
590
+ jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
591
+ jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
592
+ jQuery( '#war_soundy_audio_player' )[ 0 ].load();
593
+ } );
594
  }
595
 
596
+ war_SoundyAdmin.prototype.bindMediaUploader = function( field_name, button_name, field_type )
597
  {
598
+ var _this = this;
599
+
600
+ jQuery( '#' + button_name ).click( function()
601
  {
602
+ jQuery( '#TB_window' ).html( '' ); // to avoid multiple title bars
603
+ tb_show( '', 'media-upload.php?type=' + field_type + '&TB_iframe=true');
604
+
605
+ window.send_to_editor = function( html )
606
  {
607
+ if( field_type == 'image' )
 
 
 
608
  {
609
+ var url = jQuery( 'img', html ).attr( 'src' );
610
+ jQuery( '#' + field_name + '_img' ).attr( 'src', url );
611
+ }
612
+ else if( field_type == 'audio' )
613
+ {
614
+ var url = jQuery( html ).attr( 'href' );
615
+ var file_extension = url.substr( url.lastIndexOf( '.' ) + 1 );
616
+ switch( file_extension )
617
+ {
618
+ case 'mp3':
619
+ case 'mpeg':
620
+ var audio_type = 'mpeg';
621
+ break;
622
+ case 'ogg':
623
+ var audio_type = 'ogg';
624
+ break;
625
+ case 'wav':
626
+ var audio_type = 'wav';
627
+ break;
628
+ default:
629
+ alert( 'Audio field_type Error' );
630
+ return;
631
+ }
632
+ var player_was_playing = ! jQuery( '#war_soundy_audio_player' )[ 0 ].paused;
633
+ jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
634
+ jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
635
+ jQuery( '#war_soundy_audio_player' )[ 0 ].load();
636
+ if( player_was_playing ) jQuery( '#war_soundy_audio_player' )[ 0 ].play();
637
+
638
+ var title = jQuery( html ).text().trim();
639
+ if( title != '' )
640
+ {
641
+ jQuery( '#war_soundy_audio_title' ).val( title );
642
+ }
643
+ }
644
+
645
+ var jq = jQuery( '#' + field_name );
646
+ jq.val( url );
647
+ jq.change();
648
+
649
+ tb_remove();
650
+ if( jQuery( '#war_soundy_soundtrack_default' ).length ) // war_soundy_soundtrack_default exists if meta box
651
+ {
652
+ jQuery( 'input[name=war_soundy_soundtrack][value=custom]' ).prop( 'checked', true );
653
+ jQuery( '#war_soundy_audio_file_url' ).css( 'backgroundColor', '#c0e7f0' );
654
+ jQuery( 'input[name=war_soundy_audio_title_def][value=custom]' ).prop( 'checked', true );
655
+ jQuery( '#war_soundy_audio_title' ).css( 'backgroundColor', '#c0e7f0' );
656
+ }
657
+ }
658
+
659
+ return false;
660
+ } );
661
+ }
662
+
663
+ war_SoundyAdmin.prototype.initPlayPauseImagesToUse = function()
664
+ {
665
+ var _this = this;
666
+
667
+ _this.pp_images_to_use = jQuery( 'input[name=war_soundy_pp_images_to_use]:checked' ).val();
668
+
669
+ jQuery( 'input[name=war_soundy_pp_images_to_use]' ).change( function()
670
+ {
671
+ _this.pp_images_to_use = jQuery( 'input[name=war_soundy_pp_images_to_use]:checked' ).val();
672
  } );
673
  }
js/front-end.js CHANGED
@@ -1,136 +1,269 @@
1
- function war_setDefaultButtonURL( button_type, url )
 
 
 
 
 
 
 
 
 
2
  {
3
- jQuery( '#war_soundy_button_url_' + button_type ).val( url );
4
- jQuery( '#war_soundy_img_button_url_' + button_type ).attr( 'src', url );
5
 
6
- return false;
7
- }
 
 
 
 
 
 
 
8
 
9
- function war_setDefaultAudioURL( url )
10
- {
11
- var audio_type = war_getAudioTypeFromURL( url );
12
-
13
- jQuery( '#war_soundy_audio_file_url' ).val( url );
14
- jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
15
- jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
16
- jQuery( '#war_soundy_audio_player' )[ 0 ].load();
17
 
18
- return false;
19
- }
20
-
21
- function war_lengthUnitChanged( element )
22
- {
23
- var element_value = element.options[ element.selectedIndex ].value;
24
- var unit_map = {
25
- 'px' : '(pixels)',
26
- '%' : '(percentage)',
27
- 'in' : '(inches)',
28
- 'mm' : '(millimeters)',
29
- 'cm' : '(centimeters)'
30
- };
31
- switch( element.name )
32
  {
33
- case 'war_soundy_offset_x_unit':
34
- jQuery( '#war_soundy_unit_comment_x' ).html( unit_map[ element_value ] );
35
- break;
36
- case 'war_soundy_offset_y_unit':
37
- jQuery( '#war_soundy_unit_comment_y' ).html( unit_map[ element_value ] );
38
- break;
39
- }
40
- }
 
 
 
 
 
41
 
42
- function war_imgUrlChanged( element )
43
- {
44
- switch( element.name )
45
- {
46
- case 'war_soundy_button_url_play':
47
- jQuery( '#war_soundy_img_button_url_play' ).attr( 'src', element.value );
48
- break;
49
- case 'war_soundy_button_url_pause':
50
- jQuery( '#war_soundy_img_button_url_pause' ).attr( 'src', element.value );
51
- break;
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
 
55
- function war_getAudioTypeFromURL( url )
56
  {
57
- var file_extension = url.substr( url.lastIndexOf( '.' ) + 1 );
58
- var audio_type = '';
 
59
 
60
- switch( file_extension )
61
  {
62
- case 'mp3':
63
- case 'mpg':
64
- case 'mpeg':
65
- audio_type = 'mpeg';
66
- break;
67
- case 'ogg':
68
- audio_type = 'ogg';
69
- break;
70
- case 'wav':
71
- case 'wave':
72
- audio_type = 'wav';
73
- break;
 
 
 
74
  }
75
 
76
- return audio_type;
77
  }
78
 
79
- function war_audioUrlChanged( element )
80
- {
81
- var url = element.value;
82
- var audio_type = war_getAudioTypeFromURL( url );
83
-
84
- jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
85
- jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
86
- jQuery( '#war_soundy_audio_player' )[ 0 ].load();
87
- }
88
 
89
- function war_bindMediaUploader( field_name, button_name, field_type )
90
  {
91
- jQuery( document ).ready( function()
92
- {
93
- jQuery( '#' + button_name ).click( function()
94
- {
95
- tb_show( '', 'media-upload.php?type=' + field_type + '&TB_iframe=true');
96
 
97
- window.send_to_editor = function( html )
 
 
 
98
  {
99
- if( field_type == 'image' )
100
- {
101
- var url = jQuery( 'img', html ).attr( 'src' );
102
- jQuery( '#img_' + field_name ).attr( 'src', url );
103
- }
104
- else if( field_type == 'audio' )
105
- {
106
- var url = jQuery( html ).attr( 'href' );
107
- var file_extension = url.substr( url.lastIndexOf( '.' ) + 1 );
108
- switch( file_extension )
109
- {
110
- case 'mp3':
111
- case 'mpeg':
112
- var audio_type = 'mpeg';
113
- break;
114
- case 'ogg':
115
- var audio_type = 'ogg';
116
- break;
117
- case 'wav':
118
- var audio_type = 'wav';
119
- break;
120
- default:
121
- alert( 'Audio field_type Error' );
122
- return;
123
- }
124
- jQuery( '#war_soundy_audio_player_source' ).attr( 'src', url );
125
- jQuery( '#war_soundy_audio_player_source' ).attr( 'type', 'audio/' + audio_type );
126
- jQuery( '#war_soundy_audio_player' )[ 0 ].load();
127
- }
128
-
129
- jQuery( '#' + field_name ).val( url );
130
- tb_remove();
131
  }
132
-
133
- return false;
134
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  } );
136
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function war_SoundyFrontEnd(
2
+ pp_code,
3
+ audio_code,
4
+ audio_volume,
5
+ preview,
6
+ button_url_play_normal,
7
+ button_url_pause_normal,
8
+ button_url_play_hover,
9
+ button_url_pause_hover,
10
+ user_agent_is_IOS )
11
  {
12
+ var _this = this;
 
13
 
14
+ _this.pp_code = pp_code;
15
+ _this.audio_code = audio_code;
16
+ _this.audio_volume = audio_volume;
17
+ _this.preview = preview;
18
+ _this.button_url_play_normal = button_url_play_normal;
19
+ _this.button_url_pause_normal = button_url_pause_normal;
20
+ _this.button_url_play_hover = button_url_play_hover;
21
+ _this.button_url_pause_hover = button_url_pause_hover;
22
+ _this.user_agent_is_IOS = user_agent_is_IOS;
23
 
24
+ _this.pp_button_is_inserted = false;
25
+ _this.hovering = false;
 
 
 
 
 
 
26
 
27
+ jQuery( document ).ready( function()
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  {
29
+ if( _this.pp_code && ! _this.pp_button_is_inserted )
30
+ {
31
+ jQuery( 'body' ).append( _this.pp_code );
32
+ _this.pp_button_is_inserted = true;
33
+ }
34
+
35
+ jQuery( 'body' ).append( _this.audio_code );
36
+
37
+ _this.audio_control = jQuery( '#war_soundy_audio_control' );
38
+ _this.audio_player = jQuery( '#war_soundy_audio_player' );
39
+ _this.audio_player_element = _this.audio_player[ 0 ];
40
+
41
+ _this.audio_player_element.volume = audio_volume;
42
 
43
+ if( _this.preview != 'false' )
44
+ {
45
+ // Workaround for the preview player hanging:
46
+ var opener_player = window.opener.jQuery( '#war_soundy_audio_player' )[ 0 ];
47
+ opener_player.play();
48
+ opener_player.pause();
49
+
50
+ if( _this.preview == 'position' )
51
+ {
52
+ var pp_images_to_use = window.opener.jQuery( 'input[name=war_soundy_pp_images_to_use]:checked' ).val();
53
+
54
+ if( pp_images_to_use == 'none' )
55
+ {
56
+ _this.preview = 'default';
57
+ }
58
+ else
59
+ {
60
+ _this.preview = pp_images_to_use;
61
+ }
62
+ }
63
+
64
+ if( _this.preview == 'designer' )
65
+ {
66
+ _this.button_url_play_normal = window.opener.war_pp_design.img_data_play_normal;
67
+ _this.button_url_pause_normal = window.opener.war_pp_design.img_data_pause_normal;
68
+ _this.button_url_play_hover = window.opener.war_pp_design.img_data_play_hover;
69
+ _this.button_url_pause_hover = window.opener.war_pp_design.img_data_pause_hover;
70
+ }
71
+ else if( _this.preview == 'default' )
72
+ {
73
+ _this.button_url_play_normal = window.opener.jQuery( '#war_soundy_url_play_button' ).val();
74
+ _this.button_url_pause_normal = window.opener.jQuery( '#war_soundy_url_pause_button' ).val();
75
+ _this.button_url_play_hover = window.opener.jQuery( '#war_soundy_url_play_hover' ).val();
76
+ _this.button_url_pause_hover = window.opener.jQuery( '#war_soundy_url_pause_hover' ).val();
77
+ }
78
+
79
+ if( _this.audio_player_element.autoplay )
80
+ {
81
+ _this.audio_player_element.load();
82
+ _this.audio_player_element.play();
83
+ _this.audio_control.attr( 'src', _this.button_url_pause_normal );
84
+ }
85
+ else
86
+ {
87
+ _this.audio_control.attr( 'src', _this.button_url_play_normal );
88
+ }
89
+
90
+ var position = window.opener.jQuery( '#war_soundy_pp_position' ).children( 'option:selected' ).val();
91
+ if( position == 'document' )
92
+ {
93
+ _this.audio_control.css( 'position', 'absolute' );
94
+ }
95
+ else
96
+ {
97
+ _this.audio_control.css( 'position', 'fixed' );
98
+ }
99
+
100
+ var pp_corner = window.opener.jQuery( '#war_soundy_pp_corner' ).children( 'option:selected' ).val();
101
+ var offset_x = window.opener.jQuery( '#war_soundy_offset_x' ).val() + window.opener.jQuery( '#war_soundy_offset_x_unit' ).val();
102
+ var offset_y = window.opener.jQuery( '#war_soundy_offset_y' ).val() + window.opener.jQuery( '#war_soundy_offset_y_unit' ).val();
103
+ switch( pp_corner )
104
+ {
105
+ case 'upper_right':
106
+ _this.audio_control.css( 'top', offset_y );
107
+ _this.audio_control.css( 'right', offset_x );
108
+ _this.audio_control.css( 'bottom', '' );
109
+ _this.audio_control.css( 'left', '' );
110
+ break;
111
+ case 'upper_left':
112
+ _this.audio_control.css( 'top', offset_y );
113
+ _this.audio_control.css( 'right', '' );
114
+ _this.audio_control.css( 'bottom', '' );
115
+ _this.audio_control.css( 'left', offset_x );
116
+ break;
117
+ case 'bottom_right':
118
+ _this.audio_control.css( 'top', '' );
119
+ _this.audio_control.css( 'right', offset_x );
120
+ _this.audio_control.css( 'bottom', offset_y );
121
+ _this.audio_control.css( 'left', '' );
122
+ break;
123
+ case 'bottom_left':
124
+ _this.audio_control.css( 'top', '' );
125
+ _this.audio_control.css( 'right', '' );
126
+ _this.audio_control.css( 'bottom', offset_y );
127
+ _this.audio_control.css( 'left', offset_x );
128
+ break;
129
+ }
130
+ }
131
+
132
+ if( _this.pp_button_is_inserted )
133
+ {
134
+ _this.initPPButton();
135
+ }
136
+
137
+ /*
138
+ jQuery( window ).bind( 'beforeunload', function()
139
+ {
140
+ var volume = _this.audio_player.prop( 'volume' );
141
+ for( var i = 10000000000; i > 0; i-- )
142
+ {
143
+ // 1 slow 3: middle 6: fast
144
+ volume -= 0.00000001 * 1;
145
+ if( volume < 0 ) break;
146
+ if( ( i % 10000 ) == 0 )
147
+ {
148
+ _this.audio_player.prop( 'volume', volume );
149
+ }
150
+ }
151
+ } );
152
+ */
153
+ } );
154
  }
155
 
156
+ war_SoundyFrontEnd.prototype.animateVolume = function( audio_player_element, new_volume )
157
  {
158
+ var _this = this;
159
+
160
+ var volume = audio_player_element.volume;
161
 
162
+ function iterateVolume()
163
  {
164
+ var volume_diff = Math.abs( volume - new_volume );
165
+ if( volume_diff > 0.1 && volume < new_volume )
166
+ {
167
+ volume += 0.1;
168
+ }
169
+ else if( volume_diff > 0.1 && volume > new_volume )
170
+ {
171
+ volume -= 0.1;
172
+ }
173
+ else
174
+ {
175
+ clearInterval( interval_id );
176
+ return;
177
+ }
178
+ audio_player_element.volume = volume;
179
  }
180
 
181
+ var interval_id = setInterval( iterateVolume, 400 );
182
  }
183
 
 
 
 
 
 
 
 
 
 
184
 
185
+ war_SoundyFrontEnd.prototype.initPPButton = function()
186
  {
187
+ var _this = this;
 
 
 
 
188
 
189
+ _this.audio_control.click(
190
+ function()
191
+ {
192
+ if( _this.audio_player_element.paused )
193
  {
194
+ _this.audio_player_element.play();
195
+ _this.audio_control.attr( 'src', _this.button_url_pause_hover );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  }
197
+ else
198
+ {
199
+ _this.audio_player_element.pause();
200
+ _this.audio_control.attr( 'src', _this.button_url_play_hover );
201
+ }
202
+ } );
203
+
204
+ _this.audio_control.hover(
205
+ function()
206
+ {
207
+ _this.hovering = true;
208
+ if( _this.audio_player_element.paused )
209
+ {
210
+ _this.audio_control.attr( 'src', _this.button_url_play_hover );
211
+ }
212
+ else
213
+ {
214
+ _this.audio_control.attr( 'src', _this.button_url_pause_hover );
215
+ }
216
+ },
217
+ function()
218
+ {
219
+ _this.hovering = false;
220
+ if( _this.audio_player_element.paused )
221
+ {
222
+ _this.audio_control.attr( 'src', _this.button_url_play_normal );
223
+ }
224
+ else
225
+ {
226
+ _this.audio_control.attr( 'src', _this.button_url_pause_normal );
227
+ }
228
+ }
229
+ );
230
+
231
+ _this.audio_player.bind( 'ended' , function()
232
+ {
233
+ if( _this.hovering )
234
+ {
235
+ _this.audio_control.attr( 'src', _this.button_url_play_hover );
236
+ }
237
+ else
238
+ {
239
+ _this.audio_control.attr( 'src', _this.button_url_play_normal );
240
+ }
241
  } );
242
+
243
+ _this.audio_player.bind( 'play' , function()
244
+ {
245
+ if( _this.hovering )
246
+ {
247
+ _this.audio_control.attr( 'src', _this.button_url_pause_hover );
248
+ }
249
+ else
250
+ {
251
+ _this.audio_control.attr( 'src', _this.button_url_pause_normal );
252
+ }
253
+ } );
254
+
255
+ if( _this.audio_player_element.autoplay )
256
+ {
257
+ if( _this.user_agent_is_IOS )
258
+ {
259
+ if( _this.hovering )
260
+ {
261
+ _this.audio_control.attr( 'src', _this.button_url_play_hover );
262
+ }
263
+ else
264
+ {
265
+ _this.audio_control.attr( 'src', _this.button_url_play_normal );
266
+ }
267
+ }
268
+ }
269
+ }
js/jquery.form.js ADDED
@@ -0,0 +1,1278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery Form Plugin
3
+ * version: 3.50.0-2014.02.05
4
+ * Requires jQuery v1.5 or later
5
+ * Copyright (c) 2013 M. Alsup
6
+ * Examples and documentation at: http://malsup.com/jquery/form/
7
+ * Project repository: https://github.com/malsup/form
8
+ * Dual licensed under the MIT and GPL licenses.
9
+ * https://github.com/malsup/form#copyright-and-license
10
+ */
11
+ /*global ActiveXObject */
12
+
13
+ // AMD support
14
+ (function (factory) {
15
+ "use strict";
16
+ if (typeof define === 'function' && define.amd) {
17
+ // using AMD; register as anon module
18
+ define(['jquery'], factory);
19
+ } else {
20
+ // no AMD; invoke directly
21
+ factory( (typeof(jQuery) != 'undefined') ? jQuery : window.Zepto );
22
+ }
23
+ }
24
+
25
+ (function($) {
26
+ "use strict";
27
+
28
+ /*
29
+ Usage Note:
30
+ -----------
31
+ Do not use both ajaxSubmit and ajaxForm on the same form. These
32
+ functions are mutually exclusive. Use ajaxSubmit if you want
33
+ to bind your own submit handler to the form. For example,
34
+
35
+ $(document).ready(function() {
36
+ $('#myForm').on('submit', function(e) {
37
+ e.preventDefault(); // <-- important
38
+ $(this).ajaxSubmit({
39
+ target: '#output'
40
+ });
41
+ });
42
+ });
43
+
44
+ Use ajaxForm when you want the plugin to manage all the event binding
45
+ for you. For example,
46
+
47
+ $(document).ready(function() {
48
+ $('#myForm').ajaxForm({
49
+ target: '#output'
50
+ });
51
+ });
52
+
53
+ You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
54
+ form does not have to exist when you invoke ajaxForm:
55
+
56
+ $('#myForm').ajaxForm({
57
+ delegation: true,
58
+ target: '#output'
59
+ });
60
+
61
+ When using ajaxForm, the ajaxSubmit function will be invoked for you
62
+ at the appropriate time.
63
+ */
64
+
65
+ /**
66
+ * Feature detection
67
+ */
68
+ var feature = {};
69
+ feature.fileapi = $("<input type='file'/>").get(0).files !== undefined;
70
+ feature.formdata = window.FormData !== undefined;
71
+
72
+ var hasProp = !!$.fn.prop;
73
+
74
+ // attr2 uses prop when it can but checks the return type for
75
+ // an expected string. this accounts for the case where a form
76
+ // contains inputs with names like "action" or "method"; in those
77
+ // cases "prop" returns the element
78
+ $.fn.attr2 = function() {
79
+ if ( ! hasProp ) {
80
+ return this.attr.apply(this, arguments);
81
+ }
82
+ var val = this.prop.apply(this, arguments);
83
+ if ( ( val && val.jquery ) || typeof val === 'string' ) {
84
+ return val;
85
+ }
86
+ return this.attr.apply(this, arguments);
87
+ };
88
+
89
+ /**
90
+ * ajaxSubmit() provides a mechanism for immediately submitting
91
+ * an HTML form using AJAX.
92
+ */
93
+ $.fn.ajaxSubmit = function(options) {
94
+ /*jshint scripturl:true */
95
+
96
+ // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
97
+ if (!this.length) {
98
+ log('ajaxSubmit: skipping submit process - no element selected');
99
+ return this;
100
+ }
101
+
102
+ var method, action, url, $form = this;
103
+
104
+ if (typeof options == 'function') {
105
+ options = { success: options };
106
+ }
107
+ else if ( options === undefined ) {
108
+ options = {};
109
+ }
110
+
111
+ method = options.type || this.attr2('method');
112
+ action = options.url || this.attr2('action');
113
+
114
+ url = (typeof action === 'string') ? $.trim(action) : '';
115
+ url = url || window.location.href || '';
116
+ if (url) {
117
+ // clean url (don't include hash vaue)
118
+ url = (url.match(/^([^#]+)/)||[])[1];
119
+ }
120
+
121
+ options = $.extend(true, {
122
+ url: url,
123
+ success: $.ajaxSettings.success,
124
+ type: method || $.ajaxSettings.type,
125
+ iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
126
+ }, options);
127
+
128
+ // hook for manipulating the form data before it is extracted;
129
+ // convenient for use with rich editors like tinyMCE or FCKEditor
130
+ var veto = {};
131
+ this.trigger('form-pre-serialize', [this, options, veto]);
132
+ if (veto.veto) {
133
+ log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
134
+ return this;
135
+ }
136
+
137
+ // provide opportunity to alter form data before it is serialized
138
+ if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
139
+ log('ajaxSubmit: submit aborted via beforeSerialize callback');
140
+ return this;
141
+ }
142
+
143
+ var traditional = options.traditional;
144
+ if ( traditional === undefined ) {
145
+ traditional = $.ajaxSettings.traditional;
146
+ }
147
+
148
+ var elements = [];
149
+ var qx, a = this.formToArray(options.semantic, elements);
150
+ if (options.data) {
151
+ options.extraData = options.data;
152
+ qx = $.param(options.data, traditional);
153
+ }
154
+
155
+ // give pre-submit callback an opportunity to abort the submit
156
+ if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
157
+ log('ajaxSubmit: submit aborted via beforeSubmit callback');
158
+ return this;
159
+ }
160
+
161
+ // fire vetoable 'validate' event
162
+ this.trigger('form-submit-validate', [a, this, options, veto]);
163
+ if (veto.veto) {
164
+ log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
165
+ return this;
166
+ }
167
+
168
+ var q = $.param(a, traditional);
169
+ if (qx) {
170
+ q = ( q ? (q + '&' + qx) : qx );
171
+ }
172
+ if (options.type.toUpperCase() == 'GET') {
173
+ options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
174
+ options.data = null; // data is null for 'get'
175
+ }
176
+ else {
177
+ options.data = q; // data is the query string for 'post'
178
+ }
179
+
180
+ var callbacks = [];
181
+ if (options.resetForm) {
182
+ callbacks.push(function() { $form.resetForm(); });
183
+ }
184
+ if (options.clearForm) {
185
+ callbacks.push(function() { $form.clearForm(options.includeHidden); });
186
+ }
187
+
188
+ // perform a load on the target only if dataType is not provided
189
+ if (!options.dataType && options.target) {
190
+ var oldSuccess = options.success || function(){};
191
+ callbacks.push(function(data) {
192
+ var fn = options.replaceTarget ? 'replaceWith' : 'html';
193
+ $(options.target)[fn](data).each(oldSuccess, arguments);
194
+ });
195
+ }
196
+ else if (options.success) {
197
+ callbacks.push(options.success);
198
+ }
199
+
200
+ options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
201
+ var context = options.context || this ; // jQuery 1.4+ supports scope context
202
+ for (var i=0, max=callbacks.length; i < max; i++) {
203
+ callbacks[i].apply(context, [data, status, xhr || $form, $form]);
204
+ }
205
+ };
206
+
207
+ if (options.error) {
208
+ var oldError = options.error;
209
+ options.error = function(xhr, status, error) {
210
+ var context = options.context || this;
211
+ oldError.apply(context, [xhr, status, error, $form]);
212
+ };
213
+ }
214
+
215
+ if (options.complete) {
216
+ var oldComplete = options.complete;
217
+ options.complete = function(xhr, status) {
218
+ var context = options.context || this;
219
+ oldComplete.apply(context, [xhr, status, $form]);
220
+ };
221
+ }
222
+
223
+ // are there files to upload?
224
+
225
+ // [value] (issue #113), also see comment:
226
+ // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219
227
+ var fileInputs = $('input[type=file]:enabled', this).filter(function() { return $(this).val() !== ''; });
228
+
229
+ var hasFileInputs = fileInputs.length > 0;
230
+ var mp = 'multipart/form-data';
231
+ var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
232
+
233
+ var fileAPI = feature.fileapi && feature.formdata;
234
+ log("fileAPI :" + fileAPI);
235
+ var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;
236
+
237
+ var jqxhr;
238
+
239
+ // options.iframe allows user to force iframe mode
240
+ // 06-NOV-09: now defaulting to iframe mode if file input is detected
241
+ if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
242
+ // hack to fix Safari hang (thanks to Tim Molendijk for this)
243
+ // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
244
+ if (options.closeKeepAlive) {
245
+ $.get(options.closeKeepAlive, function() {
246
+ jqxhr = fileUploadIframe(a);
247
+ });
248
+ }
249
+ else {
250
+ jqxhr = fileUploadIframe(a);
251
+ }
252
+ }
253
+ else if ((hasFileInputs || multipart) && fileAPI) {
254
+ jqxhr = fileUploadXhr(a);
255
+ }
256
+ else {
257
+ jqxhr = $.ajax(options);
258
+ }
259
+
260
+ $form.removeData('jqxhr').data('jqxhr', jqxhr);
261
+
262
+ // clear element array
263
+ for (var k=0; k < elements.length; k++) {
264
+ elements[k] = null;
265
+ }
266
+
267
+ // fire 'notify' event
268
+ this.trigger('form-submit-notify', [this, options]);
269
+ return this;
270
+
271
+ // utility fn for deep serialization
272
+ function deepSerialize(extraData){
273
+ var serialized = $.param(extraData, options.traditional).split('&');
274
+ var len = serialized.length;
275
+ var result = [];
276
+ var i, part;
277
+ for (i=0; i < len; i++) {
278
+ // #252; undo param space replacement
279
+ serialized[i] = serialized[i].replace(/\+/g,' ');
280
+ part = serialized[i].split('=');
281
+ // #278; use array instead of object storage, favoring array serializations
282
+ result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]);
283
+ }
284
+ return result;
285
+ }
286
+
287
+ // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
288
+ function fileUploadXhr(a) {
289
+ var formdata = new FormData();
290
+
291
+ for (var i=0; i < a.length; i++) {
292
+ formdata.append(a[i].name, a[i].value);
293
+ }
294
+
295
+ if (options.extraData) {
296
+ var serializedData = deepSerialize(options.extraData);
297
+ for (i=0; i < serializedData.length; i++) {
298
+ if (serializedData[i]) {
299
+ formdata.append(serializedData[i][0], serializedData[i][1]);
300
+ }
301
+ }
302
+ }
303
+
304
+ options.data = null;
305
+
306
+ var s = $.extend(true, {}, $.ajaxSettings, options, {
307
+ contentType: false,
308
+ processData: false,
309
+ cache: false,
310
+ type: method || 'POST'
311
+ });
312
+
313
+ if (options.uploadProgress) {
314
+ // workaround because jqXHR does not expose upload property
315
+ s.xhr = function() {
316
+ var xhr = $.ajaxSettings.xhr();
317
+ if (xhr.upload) {
318
+ xhr.upload.addEventListener('progress', function(event) {
319
+ var percent = 0;
320
+ var position = event.loaded || event.position; /*event.position is deprecated*/
321
+ var total = event.total;
322
+ if (event.lengthComputable) {
323
+ percent = Math.ceil(position / total * 100);
324
+ }
325
+ options.uploadProgress(event, position, total, percent);
326
+ }, false);
327
+ }
328
+ return xhr;
329
+ };
330
+ }
331
+
332
+ s.data = null;
333
+ var beforeSend = s.beforeSend;
334
+ s.beforeSend = function(xhr, o) {
335
+ //Send FormData() provided by user
336
+ if (options.formData) {
337
+ o.data = options.formData;
338
+ }
339
+ else {
340
+ o.data = formdata;
341
+ }
342
+ if(beforeSend) {
343
+ beforeSend.call(this, xhr, o);
344
+ }
345
+ };
346
+ return $.ajax(s);
347
+ }
348
+
349
+ // private function for handling file uploads (hat tip to YAHOO!)
350
+ function fileUploadIframe(a) {
351
+ var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
352
+ var deferred = $.Deferred();
353
+
354
+ // #341
355
+ deferred.abort = function(status) {
356
+ xhr.abort(status);
357
+ };
358
+
359
+ if (a) {
360
+ // ensure that every serialized input is still enabled
361
+ for (i=0; i < elements.length; i++) {
362
+ el = $(elements[i]);
363
+ if ( hasProp ) {
364
+ el.prop('disabled', false);
365
+ }
366
+ else {
367
+ el.removeAttr('disabled');
368
+ }
369
+ }
370
+ }
371
+
372
+ s = $.extend(true, {}, $.ajaxSettings, options);
373
+ s.context = s.context || s;
374
+ id = 'jqFormIO' + (new Date().getTime());
375
+ if (s.iframeTarget) {
376
+ $io = $(s.iframeTarget);
377
+ n = $io.attr2('name');
378
+ if (!n) {
379
+ $io.attr2('name', id);
380
+ }
381
+ else {
382
+ id = n;
383
+ }
384
+ }
385
+ else {
386
+ $io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />');
387
+ $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
388
+ }
389
+ io = $io[0];
390
+
391
+
392
+ xhr = { // mock object
393
+ aborted: 0,
394
+ responseText: null,
395
+ responseXML: null,
396
+ status: 0,
397
+ statusText: 'n/a',
398
+ getAllResponseHeaders: function() {},
399
+ getResponseHeader: function() {},
400
+ setRequestHeader: function() {},
401
+ abort: function(status) {
402
+ var e = (status === 'timeout' ? 'timeout' : 'aborted');
403
+ log('aborting upload... ' + e);
404
+ this.aborted = 1;
405
+
406
+ try { // #214, #257
407
+ if (io.contentWindow.document.execCommand) {
408
+ io.contentWindow.document.execCommand('Stop');
409
+ }
410
+ }
411
+ catch(ignore) {}
412
+
413
+ $io.attr('src', s.iframeSrc); // abort op in progress
414
+ xhr.error = e;
415
+ if (s.error) {
416
+ s.error.call(s.context, xhr, e, status);
417
+ }
418
+ if (g) {
419
+ $.event.trigger("ajaxError", [xhr, s, e]);
420
+ }
421
+ if (s.complete) {
422
+ s.complete.call(s.context, xhr, e);
423
+ }
424
+ }
425
+ };
426
+
427
+ g = s.global;
428
+ // trigger ajax global events so that activity/block indicators work like normal
429
+ if (g && 0 === $.active++) {
430
+ $.event.trigger("ajaxStart");
431
+ }
432
+ if (g) {
433
+ $.event.trigger("ajaxSend", [xhr, s]);
434
+ }
435
+
436
+ if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
437
+ if (s.global) {
438
+ $.active--;
439
+ }
440
+ deferred.reject();
441
+ return deferred;
442
+ }
443
+ if (xhr.aborted) {
444
+ deferred.reject();
445
+ return deferred;
446
+ }
447
+
448
+ // add submitting element to data if we know it
449
+ sub = form.clk;
450
+ if (sub) {
451
+ n = sub.name;
452
+ if (n && !sub.disabled) {
453
+ s.extraData = s.extraData || {};
454
+ s.extraData[n] = sub.value;
455
+ if (sub.type == "image") {
456
+ s.extraData[n+'.x'] = form.clk_x;
457
+ s.extraData[n+'.y'] = form.clk_y;
458
+ }
459
+ }
460
+ }
461
+
462
+ var CLIENT_TIMEOUT_ABORT = 1;
463
+ var SERVER_ABORT = 2;
464
+
465
+ function getDoc(frame) {
466
+ /* it looks like contentWindow or contentDocument do not
467
+ * carry the protocol property in ie8, when running under ssl
468
+ * frame.document is the only valid response document, since
469
+ * the protocol is know but not on the other two objects. strange?
470
+ * "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy
471
+ */
472
+
473
+ var doc = null;
474
+
475
+ // IE8 cascading access check
476
+ try {
477
+ if (frame.contentWindow) {
478
+ doc = frame.contentWindow.document;
479
+ }
480
+ } catch(err) {
481
+ // IE8 access denied under ssl & missing protocol
482
+ log('cannot get iframe.contentWindow document: ' + err);
483
+ }
484
+
485
+ if (doc) { // successful getting content
486
+ return doc;
487
+ }
488
+
489
+ try { // simply checking may throw in ie8 under ssl or mismatched protocol
490
+ doc = frame.contentDocument ? frame.contentDocument : frame.document;
491
+ } catch(err) {
492
+ // last attempt
493
+ log('cannot get iframe.contentDocument: ' + err);
494
+ doc = frame.document;
495
+ }
496
+ return doc;
497
+ }
498
+
499
+ // Rails CSRF hack (thanks to Yvan Barthelemy)
500
+ var csrf_token = $('meta[name=csrf-token]').attr('content');
501
+ var csrf_param = $('meta[name=csrf-param]').attr('content');
502
+ if (csrf_param && csrf_token) {
503
+ s.extraData = s.extraData || {};
504
+ s.extraData[csrf_param] = csrf_token;
505
+ }
506
+
507
+ // take a breath so that pending repaints get some cpu time before the upload starts
508
+ function doSubmit() {
509
+ // make sure form attrs are set
510
+ var t = $form.attr2('target'),
511
+ a = $form.attr2('action'),
512
+ mp = 'multipart/form-data',
513
+ et = $form.attr('enctype') || $form.attr('encoding') || mp;
514
+
515
+ // update form attrs in IE friendly way
516
+ form.setAttribute('target',id);
517
+ if (!method || /post/i.test(method) ) {
518
+ form.setAttribute('method', 'POST');
519
+ }
520
+ if (a != s.url) {
521
+ form.setAttribute('action', s.url);
522
+ }
523
+
524
+ // ie borks in some cases when setting encoding
525
+ if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
526
+ $form.attr({
527
+ encoding: 'multipart/form-data',
528
+ enctype: 'multipart/form-data'
529
+ });
530
+ }
531
+
532
+ // support timout
533
+ if (s.timeout) {
534
+ timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
535
+ }
536
+
537
+ // look for server aborts
538
+ function checkState() {
539
+ try {
540
+ var state = getDoc(io).readyState;
541
+ log('state = ' + state);
542
+ if (state && state.toLowerCase() == 'uninitialized') {
543
+ setTimeout(checkState,50);
544
+ }
545
+ }
546
+ catch(e) {
547
+ log('Server abort: ' , e, ' (', e.name, ')');
548
+ cb(SERVER_ABORT);
549
+ if (timeoutHandle) {
550
+ clearTimeout(timeoutHandle);
551
+ }
552
+ timeoutHandle = undefined;
553
+ }
554
+ }
555
+
556
+ // add "extra" data to form if provided in options
557
+ var extraInputs = [];
558
+ try {
559
+ if (s.extraData) {
560
+ for (var n in s.extraData) {
561
+ if (s.extraData.hasOwnProperty(n)) {
562
+ // if using the $.param format that allows for multiple values with the same name
563
+ if($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
564
+ extraInputs.push(
565
+ $('<input type="hidden" name="'+s.extraData[n].name+'">').val(s.extraData[n].value)
566
+ .appendTo(form)[0]);
567
+ } else {
568
+ extraInputs.push(
569
+ $('<input type="hidden" name="'+n+'">').val(s.extraData[n])
570
+ .appendTo(form)[0]);
571
+ }
572
+ }
573
+ }
574
+ }
575
+
576
+ if (!s.iframeTarget) {
577
+ // add iframe to doc and submit the form
578
+ $io.appendTo('body');
579
+ }
580
+ if (io.attachEvent) {
581
+ io.attachEvent('onload', cb);
582
+ }
583
+ else {
584
+ io.addEventListener('load', cb, false);
585
+ }
586
+ setTimeout(checkState,15);
587
+
588
+ try {
589
+ form.submit();
590
+ } catch(err) {
591
+ // just in case form has element with name/id of 'submit'
592
+ var submitFn = document.createElement('form').submit;
593
+ submitFn.apply(form);
594
+ }
595
+ }
596
+ finally {
597
+ // reset attrs and remove "extra" input elements
598
+ form.setAttribute('action',a);
599
+ form.setAttribute('enctype', et); // #380
600
+ if(t) {
601
+ form.setAttribute('target', t);
602
+ } else {
603
+ $form.removeAttr('target');
604
+ }
605
+ $(extraInputs).remove();
606
+ }
607
+ }
608
+
609
+ if (s.forceSync) {
610
+ doSubmit();
611
+ }
612
+ else {
613
+ setTimeout(doSubmit, 10); // this lets dom updates render
614
+ }
615
+
616
+ var data, doc, domCheckCount = 50, callbackProcessed;
617
+
618
+ function cb(e) {
619
+ if (xhr.aborted || callbackProcessed) {
620
+ return;
621
+ }
622
+
623
+ doc = getDoc(io);
624
+ if(!doc) {
625
+ log('cannot access response document');
626
+ e = SERVER_ABORT;
627
+ }
628
+ if (e === CLIENT_TIMEOUT_ABORT && xhr) {
629
+ xhr.abort('timeout');
630
+ deferred.reject(xhr, 'timeout');
631
+ return;
632
+ }
633
+ else if (e == SERVER_ABORT && xhr) {
634
+ xhr.abort('server abort');
635
+ deferred.reject(xhr, 'error', 'server abort');
636
+ return;
637
+ }
638
+
639
+ if (!doc || doc.location.href == s.iframeSrc) {
640
+ // response not received yet
641
+ if (!timedOut) {
642
+ return;
643
+ }
644
+ }
645
+ if (io.detachEvent) {
646
+ io.detachEvent('onload', cb);
647
+ }
648
+ else {
649
+ io.removeEventListener('load', cb, false);
650
+ }
651
+
652
+ var status = 'success', errMsg;
653
+ try {
654
+ if (timedOut) {
655
+ throw 'timeout';
656
+ }
657
+
658
+ var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
659
+ log('isXml='+isXml);
660
+ if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) {
661
+ if (--domCheckCount) {
662
+ // in some browsers (Opera) the iframe DOM is not always traversable when
663
+ // the onload callback fires, so we loop a bit to accommodate
664
+ log('requeing onLoad callback, DOM not available');
665
+ setTimeout(cb, 250);
666
+ return;
667
+ }
668
+ // let this fall through because server response could be an empty document
669
+ //log('Could not access iframe DOM after mutiple tries.');
670
+ //throw 'DOMException: not available';
671
+ }
672
+
673
+ //log('response detected');
674
+ var docRoot = doc.body ? doc.body : doc.documentElement;
675
+ xhr.responseText = docRoot ? docRoot.innerHTML : null;
676
+ xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
677
+ if (isXml) {
678
+ s.dataType = 'xml';
679
+ }
680
+ xhr.getResponseHeader = function(header){
681
+ var headers = {'content-type': s.dataType};
682
+ return headers[header.toLowerCase()];
683
+ };
684
+ // support for XHR 'status' & 'statusText' emulation :
685
+ if (docRoot) {
686
+ xhr.status = Number( docRoot.getAttribute('status') ) || xhr.status;
687
+ xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
688
+ }
689
+
690
+ var dt = (s.dataType || '').toLowerCase();
691
+ var scr = /(json|script|text)/.test(dt);
692
+ if (scr || s.textarea) {
693
+ // see if user embedded response in textarea
694
+ var ta = doc.getElementsByTagName('textarea')[0];
695
+ if (ta) {
696
+ xhr.responseText = ta.value;
697
+ // support for XHR 'status' & 'statusText' emulation :
698
+ xhr.status = Number( ta.getAttribute('status') ) || xhr.status;
699
+ xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
700
+ }
701
+ else if (scr) {
702
+ // account for browsers injecting pre around json response
703
+ var pre = doc.getElementsByTagName('pre')[0];
704
+ var b = doc.getElementsByTagName('body')[0];
705
+ if (pre) {
706
+ xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;
707
+ }
708
+ else if (b) {
709
+ xhr.responseText = b.textContent ? b.textContent : b.innerText;
710
+ }
711
+ }
712
+ }
713
+ else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) {
714
+ xhr.responseXML = toXml(xhr.responseText);
715
+ }
716
+
717
+ try {
718
+ data = httpData(xhr, dt, s);
719
+ }
720
+ catch (err) {
721
+ status = 'parsererror';
722
+ xhr.error = errMsg = (err || status);
723
+ }
724
+ }
725
+ catch (err) {
726
+ log('error caught: ',err);
727
+ status = 'error';
728
+ xhr.error = errMsg = (err || status);
729
+ }
730
+
731
+ if (xhr.aborted) {
732
+ log('upload aborted');
733
+ status = null;
734
+ }
735
+
736
+ if (xhr.status) { // we've set xhr.status
737
+ status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error';
738
+ }
739
+
740
+ // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
741
+ if (status === 'success') {
742
+ if (s.success) {
743
+ s.success.call(s.context, data, 'success', xhr);
744
+ }
745
+ deferred.resolve(xhr.responseText, 'success', xhr);
746
+ if (g) {
747
+ $.event.trigger("ajaxSuccess", [xhr, s]);
748
+ }
749
+ }
750
+ else if (status) {
751
+ if (errMsg === undefined) {
752
+ errMsg = xhr.statusText;
753
+ }
754
+ if (s.error) {
755
+ s.error.call(s.context, xhr, status, errMsg);
756
+ }
757
+ deferred.reject(xhr, 'error', errMsg);
758
+ if (g) {
759
+ $.event.trigger("ajaxError", [xhr, s, errMsg]);
760
+ }
761
+ }
762
+
763
+ if (g) {
764
+ $.event.trigger("ajaxComplete", [xhr, s]);
765
+ }
766
+
767
+ if (g && ! --$.active) {
768
+ $.event.trigger("ajaxStop");
769
+ }
770
+
771
+ if (s.complete) {
772
+ s.complete.call(s.context, xhr, status);
773
+ }
774
+
775
+ callbackProcessed = true;
776
+ if (s.timeout) {
777
+ clearTimeout(timeoutHandle);
778
+ }
779
+
780
+ // clean up
781
+ setTimeout(function() {
782
+ if (!s.iframeTarget) {
783
+ $io.remove();
784
+ }
785
+ else { //adding else to clean up existing iframe response.
786
+ $io.attr('src', s.iframeSrc);
787
+ }
788
+ xhr.responseXML = null;
789
+ }, 100);
790
+ }
791
+
792
+ var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
793
+ if (window.ActiveXObject) {
794
+ doc = new ActiveXObject('Microsoft.XMLDOM');
795
+ doc.async = 'false';
796
+ doc.loadXML(s);
797
+ }
798
+ else {
799
+ doc = (new DOMParser()).parseFromString(s, 'text/xml');
800
+ }
801
+ return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
802
+ };
803
+ var parseJSON = $.parseJSON || function(s) {
804
+ /*jslint evil:true */
805
+ return window['eval']('(' + s + ')');
806
+ };
807
+
808
+ var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4
809
+
810
+ var ct = xhr.getResponseHeader('content-type') || '',
811
+ xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
812
+ data = xml ? xhr.responseXML : xhr.responseText;
813
+
814
+ if (xml && data.documentElement.nodeName === 'parsererror') {
815
+ if ($.error) {
816
+ $.error('parsererror');
817
+ }
818
+ }
819
+ if (s && s.dataFilter) {
820
+ data = s.dataFilter(data, type);
821
+ }
822
+ if (typeof data === 'string') {
823
+ if (type === 'json' || !type && ct.indexOf('json') >= 0) {
824
+ data = parseJSON(data);
825
+ } else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
826
+ $.globalEval(data);
827
+ }
828
+ }
829
+ return data;
830
+ };
831
+
832
+ return deferred;
833
+ }
834
+ };
835
+
836
+ /**
837
+ * ajaxForm() provides a mechanism for fully automating form submission.
838
+ *
839
+ * The advantages of using this method instead of ajaxSubmit() are:
840
+ *
841
+ * 1: This method will include coordinates for <input type="image" /> elements (if the element
842
+ * is used to submit the form).
843
+ * 2. This method will include the submit element's name/value data (for the element that was
844
+ * used to submit the form).
845
+ * 3. This method binds the submit() method to the form for you.
846
+ *
847
+ * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
848
+ * passes the options argument along after properly binding events for submit elements and
849
+ * the form itself.
850
+ */
851
+ $.fn.ajaxForm = function(options) {
852
+ options = options || {};
853
+ options.delegation = options.delegation && $.isFunction($.fn.on);
854
+
855
+ // in jQuery 1.3+ we can fix mistakes with the ready state
856
+ if (!options.delegation && this.length === 0) {
857
+ var o = { s: this.selector, c: this.context };
858
+ if (!$.isReady && o.s) {
859
+ log('DOM not ready, queuing ajaxForm');
860
+ $(function() {
861
+ $(o.s,o.c).ajaxForm(options);
862
+ });
863
+ return this;
864
+ }
865
+ // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
866
+ log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
867
+ return this;
868
+ }
869
+
870
+ if ( options.delegation ) {
871
+ $(document)
872
+ .off('submit.form-plugin', this.selector, doAjaxSubmit)
873
+ .off('click.form-plugin', this.selector, captureSubmittingElement)
874
+ .on('submit.form-plugin', this.selector, options, doAjaxSubmit)
875
+ .on('click.form-plugin', this.selector, options, captureSubmittingElement);
876
+ return this;
877
+ }
878
+
879
+ return this.ajaxFormUnbind()
880
+ .bind('submit.form-plugin', options, doAjaxSubmit)
881
+ .bind('click.form-plugin', options, captureSubmittingElement);
882
+ };
883
+
884
+ // private event handlers
885
+ function doAjaxSubmit(e) {
886
+ /*jshint validthis:true */
887
+ var options = e.data;
888
+ if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
889
+ e.preventDefault();
890
+ $(e.target).ajaxSubmit(options); // #365
891
+ }
892
+ }
893
+
894
+ function captureSubmittingElement(e) {
895
+ /*jshint validthis:true */
896
+ var target = e.target;
897
+ var $el = $(target);
898
+ if (!($el.is("[type=submit],[type=image]"))) {
899
+ // is this a child element of the submit el? (ex: a span within a button)
900
+ var t = $el.closest('[type=submit]');
901
+ if (t.length === 0) {
902
+ return;
903
+ }
904
+ target = t[0];
905
+ }
906
+ var form = this;
907
+ form.clk = target;
908
+ if (target.type == 'image') {
909
+ if (e.offsetX !== undefined) {
910
+ form.clk_x = e.offsetX;
911
+ form.clk_y = e.offsetY;
912
+ } else if (typeof $.fn.offset == 'function') {
913
+ var offset = $el.offset();
914
+ form.clk_x = e.pageX - offset.left;
915
+ form.clk_y = e.pageY - offset.top;
916
+ } else {
917
+ form.clk_x = e.pageX - target.offsetLeft;
918
+ form.clk_y = e.pageY - target.offsetTop;
919
+ }
920
+ }
921
+ // clear form vars
922
+ setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
923
+ }
924
+
925
+
926
+ // ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
927
+ $.fn.ajaxFormUnbind = function() {
928
+ return this.unbind('submit.form-plugin click.form-plugin');
929
+ };
930
+
931
+ /**
932
+ * formToArray() gathers form element data into an array of objects that can
933
+ * be passed to any of the following ajax functions: $.get, $.post, or load.
934
+ * Each object in the array has both a 'name' and 'value' property. An example of
935
+ * an array for a simple login form might be:
936
+ *
937
+ * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
938
+ *
939
+ * It is this array that is passed to pre-submit callback functions provided to the
940
+ * ajaxSubmit() and ajaxForm() methods.
941
+ */
942
+ $.fn.formToArray = function(semantic, elements) {
943
+ var a = [];
944
+ if (this.length === 0) {
945
+ return a;
946
+ }
947
+
948
+ var form = this[0];
949
+ var formId = this.attr('id');
950
+ var els = semantic ? form.getElementsByTagName('*') : form.elements;
951
+ var els2;
952
+
953
+ if (els && !/MSIE [678]/.test(navigator.userAgent)) { // #390
954
+ els = $(els).get(); // convert to standard array
955
+ }
956
+
957
+ // #386; account for inputs outside the form which use the 'form' attribute
958
+ if ( formId ) {
959
+ els2 = $(':input[form=' + formId + ']').get();
960
+ if ( els2.length ) {
961
+ els = (els || []).concat(els2);
962
+ }
963
+ }
964
+
965
+ if (!els || !els.length) {
966
+ return a;
967
+ }
968
+
969
+ var i,j,n,v,el,max,jmax;
970
+ for(i=0, max=els.length; i < max; i++) {
971
+ el = els[i];
972
+ n = el.name;
973
+ if (!n || el.disabled) {
974
+ continue;
975
+ }
976
+
977
+ if (semantic && form.clk && el.type == "image") {
978
+ // handle image inputs on the fly when semantic == true
979
+ if(form.clk == el) {
980
+ a.push({name: n, value: $(el).val(), type: el.type });
981
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
982
+ }
983
+ continue;
984
+ }
985
+
986
+ v = $.fieldValue(el, true);
987
+ if (v && v.constructor == Array) {
988
+ if (elements) {
989
+ elements.push(el);
990
+ }
991
+ for(j=0, jmax=v.length; j < jmax; j++) {
992
+ a.push({name: n, value: v[j]});
993
+ }
994
+ }
995
+ else if (feature.fileapi && el.type == 'file') {
996
+ if (elements) {
997
+ elements.push(el);
998
+ }
999
+ var files = el.files;
1000
+ if (files.length) {
1001
+ for (j=0; j < files.length; j++) {
1002
+ a.push({name: n, value: files[j], type: el.type});
1003
+ }
1004
+ }
1005
+ else {
1006
+ // #180
1007
+ a.push({ name: n, value: '', type: el.type });
1008
+ }
1009
+ }
1010
+ else if (v !== null && typeof v != 'undefined') {
1011
+ if (elements) {
1012
+ elements.push(el);
1013
+ }
1014
+ a.push({name: n, value: v, type: el.type, required: el.required});
1015
+ }
1016
+ }
1017
+
1018
+ if (!semantic && form.clk) {
1019
+ // input type=='image' are not found in elements array! handle it here
1020
+ var $input = $(form.clk), input = $input[0];
1021
+ n = input.name;
1022
+ if (n && !input.disabled && input.type == 'image') {
1023
+ a.push({name: n, value: $input.val()});
1024
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
1025
+ }
1026
+ }
1027
+ return a;
1028
+ };
1029
+
1030
+ /**
1031
+ * Serializes form data into a 'submittable' string. This method will return a string
1032
+ * in the format: name1=value1&amp;name2=value2
1033
+ */
1034
+ $.fn.formSerialize = function(semantic) {
1035
+ //hand off to jQuery.param for proper encoding
1036
+ return $.param(this.formToArray(semantic));
1037
+ };
1038
+
1039
+ /**
1040
+ * Serializes all field elements in the jQuery object into a query string.
1041
+ * This method will return a string in the format: name1=value1&amp;name2=value2
1042
+ */
1043
+ $.fn.fieldSerialize = function(successful) {
1044
+ var a = [];
1045
+ this.each(function() {
1046
+ var n = this.name;
1047
+ if (!n) {
1048
+ return;
1049
+ }
1050
+ var v = $.fieldValue(this, successful);
1051
+ if (v && v.constructor == Array) {
1052
+ for (var i=0,max=v.length; i < max; i++) {
1053
+ a.push({name: n, value: v[i]});
1054
+ }
1055
+ }
1056
+ else if (v !== null && typeof v != 'undefined') {
1057
+ a.push({name: this.name, value: v});
1058
+ }
1059
+ });
1060
+ //hand off to jQuery.param for proper encoding
1061
+ return $.param(a);
1062
+ };
1063
+
1064
+ /**
1065
+ * Returns the value(s) of the element in the matched set. For example, consider the following form:
1066
+ *
1067
+ * <form><fieldset>
1068
+ * <input name="A" type="text" />
1069
+ * <input name="A" type="text" />
1070
+ * <input name="B" type="checkbox" value="B1" />
1071
+ * <input name="B" type="checkbox" value="B2"/>
1072
+ * <input name="C" type="radio" value="C1" />
1073
+ * <input name="C" type="radio" value="C2" />
1074
+ * </fieldset></form>
1075
+ *
1076
+ * var v = $('input[type=text]').fieldValue();
1077
+ * // if no values are entered into the text inputs
1078
+ * v == ['','']
1079
+ * // if values entered into the text inputs are 'foo' and 'bar'
1080
+ * v == ['foo','bar']
1081
+ *
1082
+ * var v = $('input[type=checkbox]').fieldValue();
1083
+ * // if neither checkbox is checked
1084
+ * v === undefined
1085
+ * // if both checkboxes are checked
1086
+ * v == ['B1', 'B2']
1087
+ *
1088
+ * var v = $('input[type=radio]').fieldValue();
1089
+ * // if neither radio is checked
1090
+ * v === undefined
1091
+ * // if first radio is checked
1092
+ * v == ['C1']
1093
+ *
1094
+ * The successful argument controls whether or not the field element must be 'successful'
1095
+ * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
1096
+ * The default value of the successful argument is true. If this value is false the value(s)
1097
+ * for each element is returned.
1098
+ *
1099
+ * Note: This method *always* returns an array. If no valid value can be determined the
1100
+ * array will be empty, otherwise it will contain one or more values.
1101
+ */
1102
+ $.fn.fieldValue = function(successful) {
1103
+ for (var val=[], i=0, max=this.length; i < max; i++) {
1104
+ var el = this[i];
1105
+ var v = $.fieldValue(el, successful);
1106
+ if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
1107
+ continue;
1108
+ }
1109
+ if (v.constructor == Array) {
1110
+ $.merge(val, v);
1111
+ }
1112
+ else {
1113
+ val.push(v);
1114
+ }
1115
+ }
1116
+ return val;
1117
+ };
1118
+
1119
+ /**
1120
+ * Returns the value of the field element.
1121
+ */
1122
+ $.fieldValue = function(el, successful) {
1123
+ var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
1124
+ if (successful === undefined) {
1125
+ successful = true;
1126
+ }
1127
+
1128
+ if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
1129
+ (t == 'checkbox' || t == 'radio') && !el.checked ||
1130
+ (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
1131
+ tag == 'select' && el.selectedIndex == -1)) {
1132
+ return null;
1133
+ }
1134
+
1135
+ if (tag == 'select') {
1136
+ var index = el.selectedIndex;
1137
+ if (index < 0) {
1138
+ return null;
1139
+ }
1140
+ var a = [], ops = el.options;
1141
+ var one = (t == 'select-one');
1142
+ var max = (one ? index+1 : ops.length);
1143
+ for(var i=(one ? index : 0); i < max; i++) {
1144
+ var op = ops[i];
1145
+ if (op.selected) {
1146
+ var v = op.value;
1147
+ if (!v) { // extra pain for IE...
1148
+ v = (op.attributes && op.attributes.value && !(op.attributes.value.specified)) ? op.text : op.value;
1149
+ }
1150
+ if (one) {
1151
+ return v;
1152
+ }
1153
+ a.push(v);
1154
+ }
1155
+ }
1156
+ return a;
1157
+ }
1158
+ return $(el).val();
1159
+ };
1160
+
1161
+ /**
1162
+ * Clears the form data. Takes the following actions on the form's input fields:
1163
+ * - input text fields will have their 'value' property set to the empty string
1164
+ * - select elements will have their 'selectedIndex' property set to -1
1165
+ * - checkbox and radio inputs will have their 'checked' property set to false
1166
+ * - inputs of type submit, button, reset, and hidden will *not* be effected
1167
+ * - button elements will *not* be effected
1168
+ */
1169
+ $.fn.clearForm = function(includeHidden) {
1170
+ return this.each(function() {
1171
+ $('input,select,textarea', this).clearFields(includeHidden);
1172
+ });
1173
+ };
1174
+
1175
+ /**
1176
+ * Clears the selected form elements.
1177
+ */
1178
+ $.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
1179
+ var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
1180
+ return this.each(function() {
1181
+ var t = this.type, tag = this.tagName.toLowerCase();
1182
+ if (re.test(t) || tag == 'textarea') {
1183
+ this.value = '';
1184
+ }
1185
+ else if (t == 'checkbox' || t == 'radio') {
1186
+ this.checked = false;
1187
+ }
1188
+ else if (tag == 'select') {
1189
+ this.selectedIndex = -1;
1190
+ }
1191
+ else if (t == "file") {
1192
+ if (/MSIE/.test(navigator.userAgent)) {
1193
+ $(this).replaceWith($(this).clone(true));
1194
+ } else {
1195
+ $(this).val('');
1196
+ }
1197
+ }
1198
+ else if (includeHidden) {
1199
+ // includeHidden can be the value true, or it can be a selector string
1200
+ // indicating a special test; for example:
1201
+ // $('#myForm').clearForm('.special:hidden')
1202
+ // the above would clean hidden inputs that have the class of 'special'
1203
+ if ( (includeHidden === true && /hidden/.test(t)) ||
1204
+ (typeof includeHidden == 'string' && $(this).is(includeHidden)) ) {
1205
+ this.value = '';
1206
+ }
1207
+ }
1208
+ });
1209
+ };
1210
+
1211
+ /**
1212
+ * Resets the form data. Causes all form elements to be reset to their original value.
1213
+ */
1214
+ $.fn.resetForm = function() {
1215
+ return this.each(function() {
1216
+ // guard against an input with the name of 'reset'
1217
+ // note that IE reports the reset function as an 'object'
1218
+ if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
1219
+ this.reset();
1220
+ }
1221
+ });
1222
+ };
1223
+
1224
+ /**
1225
+ * Enables or disables any matching elements.
1226
+ */
1227
+ $.fn.enable = function(b) {
1228
+ if (b === undefined) {
1229
+ b = true;
1230
+ }
1231
+ return this.each(function() {
1232
+ this.disabled = !b;
1233
+ });
1234
+ };
1235
+
1236
+ /**
1237
+ * Checks/unchecks any matching checkboxes or radio buttons and
1238
+ * selects/deselects and matching option elements.
1239
+ */
1240
+ $.fn.selected = function(select) {
1241
+ if (select === undefined) {
1242
+ select = true;
1243
+ }
1244
+ return this.each(function() {
1245
+ var t = this.type;
1246
+ if (t == 'checkbox' || t == 'radio') {
1247
+ this.checked = select;
1248
+ }
1249
+ else if (this.tagName.toLowerCase() == 'option') {
1250
+ var $sel = $(this).parent('select');
1251
+ if (select && $sel[0] && $sel[0].type == 'select-one') {
1252
+ // deselect all other options
1253
+ $sel.find('option').selected(false);
1254
+ }
1255
+ this.selected = select;
1256
+ }
1257
+ });
1258
+ };
1259
+
1260
+ // expose debug var
1261
+ $.fn.ajaxSubmit.debug = false;
1262
+
1263
+ // helper fn for console logging
1264
+ function log() {
1265
+ if (!$.fn.ajaxSubmit.debug) {
1266
+ return;
1267
+ }
1268
+ var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
1269
+ if (window.console && window.console.log) {
1270
+ window.console.log(msg);
1271
+ }
1272
+ else if (window.opera && window.opera.postError) {
1273
+ window.opera.postError(msg);
1274
+ }
1275
+ }
1276
+
1277
+ }));
1278
+
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: bducouedic
3
  Tags: audio, sound, music, background, soundtrack, background sound, background audio, background music, posts, pages
4
  Requires at least: 3.6
5
  Tested up to: 3.9
6
- Stable tag: 1.2
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate link: http://www.webartisan.ch/en/products/soundy-free/#wa_donate
@@ -11,19 +11,46 @@ Donate link: http://www.webartisan.ch/en/products/soundy-free/#wa_donate
11
  Soundy allows a page or post to play a soundtrack while it is displayed.
12
 
13
  == Description ==
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- The **Soundy** plugin allows a page or post to play a background music while it is displayed.
16
- Having a home page or any other page playing a background music greatly improves your website visitor's experience. By choosing a music in adequacy with your content, Soundy will help making your visitors immersed in your pages. Pages with a slideshow are excellent candidates for Soundy. But a lot of other page types too.
17
- Each page or post can have its own soundtrack.
18
- The soundtrack is embedded in the page by means of the HTML 5 audio tag. This way, the plugin is compatible with all modern user devices (smartphones, tablets, laptops and desktops of all vendors).
19
- A background music can be associated with all pages and posts or with individual pages or posts.
20
- A Play/Pause button can also be displayed anywhere in the pages and posts.
21
- Defaults can be set by the administrator in the settings page of the plugin.
22
- Specific post and page plugin settings can be configured by the authors in the Edit Page and Edit Post pages.
23
- In the plugin settings page, an audio track can be set per default.
24
- The audio track can be anywhere on the web as it is specified with its URL. It can also be uploaded in the media library of the WP site.
25
- A play and pause button image can be uploaded by the administrator to replace the default one and can be positioned anywhere.
26
- This Play/Pause button can be positioned in a corner of the document or in a corner of the window. It can also be positioned with a template tag typically in the document header or with a shortcode in the content.
27
  Here are examples of Soundy implementations:
28
 
29
  * Ivy & Mario's website: [www.hanstylewedding.com](http://www.hanstylewedding.com/)
@@ -38,12 +65,14 @@ You can find [Tutorial](http://www.webartisan.ch/en/products/soundy-free/#wa_tut
38
 
39
  == Installation ==
40
 
 
 
41
  * In the Admin area (the back-end) of your WordPress Web Site, go to Plugins > Add New.
42
  * Enter **Soundy** in the search field.
43
  * **Soundy Background Music** appears.
44
  * Click on "Install Now".
45
  * Click on "Activate Plugin".
46
- * To let a page or post to play a soundtrack:
47
 
48
  1. Go into the *Edit Page* or *Edit Post* tool of this page in the Admin area.
49
  1. Set the option *Enable Background Sound* to *Yes* in the Soundy meta box and update the page.
@@ -59,6 +88,8 @@ You can find [Tutorial](http://www.webartisan.ch/en/products/soundy-free/#wa_tut
59
 
60
  == Frequently Asked Questions ==
61
 
 
 
62
  1. **Why is Soundy Background Music a Must on my WordPress Website ?**
63
  Having a home page or any other page playing a background music greatly improves your website visitor's experience. By choosing a music in adequacy with your content, Soundy will help making your visitors immersed in your pages. Pages with a slideshow are excellent candidates for Soundy. But a lot of other page types too.
64
 
@@ -117,6 +148,8 @@ And this is what your theme also should do instead of loading its own old jQuery
117
 
118
  == Screenshots ==
119
 
 
 
120
  1. **Default Audio Track Settings**
121
  1. **Play/Pause Button Settings**
122
  1. **Play/Pause Button Corner Settings**
@@ -125,21 +158,35 @@ And this is what your theme also should do instead of loading its own old jQuery
125
 
126
  == Changelog ==
127
 
128
- = 1.2 =
 
 
 
 
 
 
 
 
 
 
129
  * Added Audio Volume Control for administrators in Settings > Soundy.
130
  * Added Audio Volume Control for authors in Edit Page and Edit Post Soundy meta box.
131
  * Made Admin User Interface more responsive and user friendlier.
132
 
133
- = 1.1 =
134
  * Corrected a few minor bugs
135
  * Made Soundy forms of the back-end admin section more responsive
136
  * Added possibility to disable Soundy for mobile devices. Set variable **$disable_soundy_for_mobile** to **true** in soundy.php file to disable Soundy for mobile devices.
137
 
138
- = 1.0 =
139
- * First Version
140
 
141
  == Upgrade Notice ==
142
 
 
 
 
 
143
  = 1.2 =
144
  * After having upgraded Soundy to 1.2, please clear the cache of Soundy's admin pages in your browser. The reason is that a few CSS and Javascript files have been modified and these files are typically cached by browsers.
145
 
3
  Tags: audio, sound, music, background, soundtrack, background sound, background audio, background music, posts, pages
4
  Requires at least: 3.6
5
  Tested up to: 3.9
6
+ Stable tag: 2.0
7
  License: GPL2
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate link: http://www.webartisan.ch/en/products/soundy-free/#wa_donate
11
  Soundy allows a page or post to play a soundtrack while it is displayed.
12
 
13
  == Description ==
14
+ = Description =
15
+
16
+ The **Soundy** plugin allows a page or post to play a background music while it is displayed.
17
+
18
+ Having a home page or any other page playing a background music greatly improves your website visitor's experience. By choosing a music in adequacy with your content, Soundy will help making your visitors immersed in your pages. Pages with a slideshow are excellent candidates for Soundy. But a lot of other page types too.
19
+
20
+ A Play/Pause button can be displayed anywhere in the pages and posts. Do you need a Play/Pause button that perfectly fits your website design ? Try [**Soundy PRO**](http://www.webartisan.ch/en/products/soundy-pro/) for free.
21
+
22
+ Each page or post can have its own soundtrack. The soundtrack is embedded in the page by means of the HTML 5 audio tag. This way, the plugin is compatible with all modern user devices (smartphones, tablets, laptops and desktops of all vendors).
23
+
24
+ A background music can be associated with all pages and posts or with individual pages or posts.
25
+
26
+ Defaults can be set by the administrator in the settings page of the plugin. Specific post and page plugin settings can be configured by the authors in the Edit Page and Edit Post pages. In the plugin settings page, an audio track can be set per default.
27
+
28
+ The audio track can be anywhere on the web as it is specified with its URL. It can also be uploaded in the media library of the WP site.
29
+
30
+ A play and pause button image can be uploaded by the administrator to replace the default one and can be positioned anywhere. The Play/Pause button can be positioned in any of the four corners of the HTML document or in any of the four corners of the browser window. It can also be positioned with a template tag typically in the document header or with a shortcode in the content.
31
+
32
+ = Soundy Free Version Features =
33
+
34
+ * A soundtrack can be specified by the site administrator per default for all pages and posts.
35
+ * The default soundtrack can be overriden by page and post authors with a custom one for any page or post.
36
+ * Default Play/Pause button images can be overriden by the site administrator. He can upload these images or just specify their URLs.
37
+ * Full Control for the site administrator over Play/Pause button positioning.
38
+ * Play/Pause Button Preview in the context of any page or post.
39
+ * Audio Volume Control for site administrator as well as page/post authors.
40
+ * Auto Play Option.
41
+ * Audio Loop Option.
42
+
43
+ = Soundy PRO Version Features =
44
+
45
+ * Same features as the free version.
46
+ * [**HTML5 Play/Pause Button Designer**](http://www.webartisan.ch/en/products/soundy-pro/) allowing control over:
47
+ * &nbsp;&nbsp;&nbsp;&nbsp;Button colors
48
+ * &nbsp;&nbsp;&nbsp;&nbsp;Button size
49
+ * &nbsp;&nbsp;&nbsp;&nbsp;Button outline
50
+ * &nbsp;&nbsp;&nbsp;&nbsp;Button rounding
51
+ * &nbsp;&nbsp;&nbsp;&nbsp;Button transparency
52
+ * Seamlessly integrated button designer allows the Play/Pause button to precisely and exactly fit any website design.
53
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  Here are examples of Soundy implementations:
55
 
56
  * Ivy & Mario's website: [www.hanstylewedding.com](http://www.hanstylewedding.com/)
65
 
66
  == Installation ==
67
 
68
+ = Installation =
69
+
70
  * In the Admin area (the back-end) of your WordPress Web Site, go to Plugins > Add New.
71
  * Enter **Soundy** in the search field.
72
  * **Soundy Background Music** appears.
73
  * Click on "Install Now".
74
  * Click on "Activate Plugin".
75
+ * To let a page or post play a soundtrack:
76
 
77
  1. Go into the *Edit Page* or *Edit Post* tool of this page in the Admin area.
78
  1. Set the option *Enable Background Sound* to *Yes* in the Soundy meta box and update the page.
88
 
89
  == Frequently Asked Questions ==
90
 
91
+ = Frequently Asked Questions =
92
+
93
  1. **Why is Soundy Background Music a Must on my WordPress Website ?**
94
  Having a home page or any other page playing a background music greatly improves your website visitor's experience. By choosing a music in adequacy with your content, Soundy will help making your visitors immersed in your pages. Pages with a slideshow are excellent candidates for Soundy. But a lot of other page types too.
95
 
148
 
149
  == Screenshots ==
150
 
151
+ = Screenshots =
152
+
153
  1. **Default Audio Track Settings**
154
  1. **Play/Pause Button Settings**
155
  1. **Play/Pause Button Corner Settings**
158
 
159
  == Changelog ==
160
 
161
+ = Changelog =
162
+
163
+ = 2.0&nbsp;&nbsp; - &nbsp;&nbsp;April 23rd, 2014 =
164
+ * Object Oriented Redesign of the whole plugin.
165
+ * Added Play/Pause Button Preview in Context of any Page or Post in Settings > Soundy > Play/Pause Button Tab.
166
+ * Added Play/Pause Button Preview in Context of any Page or Post in Settings > Soundy > Play/Pause Corner Position Tab.
167
+ * Added Swap Button in Settings > Soundy > Play/Pause Button Tab to swap the URLs of the normal and hover images.
168
+ * Fixed minor bug in New Page and New Post Soundy metabox.
169
+ * [**Soundy PRO**](http://www.webartisan.ch/en/products/soundy-pro/) and its HTML5 **Play/Pause Button Designer** application is now available.
170
+
171
+ = 1.2&nbsp;&nbsp; - &nbsp;&nbsp; March 17th, 2014 =
172
  * Added Audio Volume Control for administrators in Settings > Soundy.
173
  * Added Audio Volume Control for authors in Edit Page and Edit Post Soundy meta box.
174
  * Made Admin User Interface more responsive and user friendlier.
175
 
176
+ = 1.1&nbsp;&nbsp; - &nbsp;&nbsp; March 12th, 2014 =
177
  * Corrected a few minor bugs
178
  * Made Soundy forms of the back-end admin section more responsive
179
  * Added possibility to disable Soundy for mobile devices. Set variable **$disable_soundy_for_mobile** to **true** in soundy.php file to disable Soundy for mobile devices.
180
 
181
+ = 1.0&nbsp;&nbsp; - &nbsp;&nbsp; March 4th, 2014 =
182
+ * First Release
183
 
184
  == Upgrade Notice ==
185
 
186
+ = 2.0 =
187
+ * **IMPORTANT**: After having upgraded Soundy to 2.0, please clear your browser's cache. The reason is that a few CSS and Javascript files have been modified or deleted and these files are typically cached by browsers.
188
+ * [**Soundy PRO**](http://www.webartisan.ch/en/products/soundy-pro/) and its HTML5 **Play/Pause Button Designer** application is now available.
189
+
190
  = 1.2 =
191
  * After having upgraded Soundy to 1.2, please clear the cache of Soundy's admin pages in your browser. The reason is that a few CSS and Javascript files have been modified and these files are typically cached by browsers.
192
 
soundy.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  /**
3
  * @package Soundy_Background_Music
4
- * @version 1.2
5
  */
6
  /*
7
  Plugin Name: Soundy Background Music
8
- Plugin URI: http://webartisan.ch/en/products/soundy
9
  Description: This plugin allows administrators and authors to set a background sound on any post or page.
10
- Version: 1.2
11
  Author: Bertrand du Couédic
12
  Author URI: http://webartisan.ch/en/about
13
  License: GPL2
@@ -30,30 +30,40 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
 
31
  class WarSoundy
32
  {
33
- private $disable_soundy_for_mobile = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  private $user_agent_is_mobile;
35
  private $post_id;
36
- private $plugin_name;
37
- private $plugin_url;
38
- private $soundy_version = '1.2';
39
- private $enable_bg_sound = 'no';
40
- private $audio_url = '/audio/valse.mp3';
41
- private $audio_volume = '80';
42
- private $audio_title = 'Valse - Anonymous (1870)';
43
- private $autoplay = 'yes';
44
- private $loop = 'yes';
45
- private $display_play_pause = 'yes';
46
- private $pp_position = 'window';
47
- private $pp_corner = 'upper_right';
48
- private $offset_x = 35;
49
- private $offset_x_unit = 'px';
50
- private $offset_y = 35;
51
- private $offset_y_unit = 'px';
52
- private $play_button_url = '/images/buttons/48x48/play-square-grey.png';
53
- private $play_hover_url = '/images/buttons/48x48/play-square-blue.png';
54
- private $pause_button_url = '/images/buttons/48x48/pause-square-grey.png';
55
- private $pause_hover_url = '/images/buttons/48x48/pause-square-blue.png';
56
- private $button_dimensions = '48x48';
57
 
58
  private $units = array(
59
  'px' => '(pixels)',
@@ -64,24 +74,12 @@ class WarSoundy
64
  );
65
 
66
  public function __construct()
67
- {
68
- $soundy_version = get_option( 'war_soundy_version' );
69
- if( $soundy_version != $this->soundy_version )
70
- {
71
- update_option( 'war_soundy_version', $this->soundy_version );
72
-
73
- $volume = get_option( 'war_soundy_audio_volume' );
74
- if( $volume == '' )
75
- {
76
- add_option( 'war_soundy_audio_volume', $this->audio_volume );
77
- }
78
- }
79
-
80
  $this->user_agent_is_mobile = $this->check_user_agent( 'mobile' );
81
 
82
- $plugin_path = dirname( __FILE__ );
83
- $this->plugin_name = substr( $plugin_path, strrpos( $plugin_path, '/' ) + 1 );
84
- $this->plugin_url = WP_PLUGIN_URL . '/' . $this->plugin_name;
85
 
86
  $this->audio_url = $this->plugin_url . $this->audio_url;
87
  $this->play_button_url = $this->plugin_url . $this->play_button_url;
@@ -97,8 +95,11 @@ class WarSoundy
97
  add_action( 'admin_menu', array( $this, 'add_plugin_settings_menu' ) );
98
  add_action( 'admin_init', array( $this, 'register_settings' ) );
99
 
100
- $plugin = plugin_basename( __FILE__ );
101
- add_filter("plugin_action_links_$plugin", array( $this, 'plugin_settings_link' ) );
 
 
 
102
 
103
  $uri = $_SERVER[ 'REQUEST_URI' ];
104
  $is_edit_post = ( strpos( $uri, '/wp-admin/post.php' ) == 0 ) ||
@@ -107,7 +108,8 @@ class WarSoundy
107
  if( ( isset( $_GET['page'] ) && ( $_GET['page'] == 'soundy' ) ) || $is_edit_post )
108
  {
109
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
110
- add_filter( 'get_media_item_args', array( $this, 'get_media_item_args' ) );
 
111
  }
112
 
113
  if( $is_edit_post )
@@ -118,33 +120,85 @@ class WarSoundy
118
  }
119
  else
120
  {
121
- wp_register_style( 'soundy', $this->plugin_url . '/css/style-front-end.css' );
122
- wp_enqueue_style( 'soundy');
123
  add_action( 'wp_head', array( $this, 'insert_audio' ) );
124
  add_shortcode( 'soundy', array( $this, 'soundy_shortcode' ) );
125
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  }
127
 
128
  public function activate()
129
  {
130
- add_option( 'war_soundy_version', $this->soundy_version );
131
- add_option( 'war_soundy_enable_bg_sound', $this->enable_bg_sound );
132
- add_option( 'war_soundy_audio_file_url', $this->audio_url );
133
- add_option( 'war_soundy_audio_volume', $this->audio_volume );
134
- add_option( 'war_soundy_audio_title', $this->audio_title );
135
- add_option( 'war_soundy_autoplay', $this->autoplay );
136
- add_option( 'war_soundy_loop', $this->loop );
137
- add_option( 'war_soundy_display_play_pause', $this->display_play_pause );
138
- add_option( 'war_soundy_url_play_button', $this->play_button_url );
139
- add_option( 'war_soundy_url_play_hover', $this->play_hover_url );
140
- add_option( 'war_soundy_url_pause_button', $this->pause_button_url );
141
- add_option( 'war_soundy_url_pause_hover', $this->pause_hover_url );
142
- add_option( 'war_soundy_pp_position', $this->pp_position );
143
- add_option( 'war_soundy_pp_corner', $this->pp_corner );
144
- add_option( 'war_soundy_offset_x', $this->offset_x );
145
- add_option( 'war_soundy_offset_x_unit', $this->offset_x_unit );
146
- add_option( 'war_soundy_offset_y', $this->offset_y );
147
- add_option( 'war_soundy_offset_y_unit', $this->offset_y_unit );
 
 
148
  }
149
 
150
  public function deactivate()
@@ -152,8 +206,10 @@ class WarSoundy
152
  }
153
 
154
  public function add_plugin_settings_menu()
155
- {
156
- add_options_page( 'Soundy', 'Soundy', 'manage_options', 'soundy', array( $this, 'create_plugin_settings_page' ) );
 
 
157
  }
158
 
159
  public function create_plugin_settings_page()
@@ -168,6 +224,7 @@ class WarSoundy
168
 
169
  public function get_media_item_args( $args )
170
  {
 
171
  $args[ 'send' ] = true;
172
  return $args;
173
  }
@@ -196,35 +253,89 @@ class WarSoundy
196
  $this->plugin_url . '/js/jquery-ui-1.10.4/jquery.ui.slider.js' );
197
  */
198
 
199
- wp_register_script( 'button-upload',
200
- $this->plugin_url . '/js/back-end.js', array('jquery','media-upload','thickbox') );
201
 
202
- wp_enqueue_script( 'jquery');
203
- wp_enqueue_script( 'jquery-ui-core');
204
- wp_enqueue_script( 'jquery-ui-widget');
205
- wp_enqueue_script( 'jquery-ui-mouse');
206
- wp_enqueue_script( 'jquery-ui-tabs');
207
- wp_enqueue_script( 'jquery-ui-slider');
208
-
209
- wp_enqueue_script( 'media-upload');
210
- wp_enqueue_script( 'thickbox');
211
- wp_enqueue_script( 'button-upload');
212
 
213
  wp_register_style( 'jquery-ui', $this->plugin_url . '/css/jquery-ui-1.10.4/jquery-ui.css' );
214
  wp_register_style( 'soundy', $this->plugin_url . '/css/style-back-end.css' );
 
 
 
 
 
 
 
215
 
216
- wp_enqueue_style( 'jquery-ui');
217
- wp_enqueue_style( 'thickbox');
218
- wp_enqueue_style( 'soundy');
219
  }
220
 
221
- public function plugin_settings_link( $links )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  {
223
  $settings_link = '<a href="options-general.php?page=soundy">Settings</a>';
224
  array_unshift( $links, $settings_link );
225
  return $links;
226
  }
227
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  public function get_audio_type_from_URL( $url )
229
  {
230
  $file_extension = pathinfo( $url, PATHINFO_EXTENSION );
@@ -286,7 +397,7 @@ class WarSoundy
286
  array( $this, 'display_settings_section_audio_track_header' ),
287
  'soundy'
288
  );
289
-
290
  register_setting( 'war_soundy', 'war_soundy_enable_bg_sound' );
291
  add_settings_field(
292
  'war_soundy_enable_bg_sound',
@@ -359,11 +470,11 @@ class WarSoundy
359
  'soundy'
360
  );
361
 
362
- register_setting( 'war_soundy', 'war_soundy_display_play_pause' );
363
  add_settings_field(
364
- 'war_soundy_display_play_pause',
365
- 'Display Play/Pause Button',
366
- array( $this, 'add_settings_field_display_play_pause_button' ),
367
  'soundy',
368
  'war_soundy_settings_section_play_pause_button'
369
  );
@@ -371,7 +482,7 @@ class WarSoundy
371
  register_setting( 'war_soundy', 'war_soundy_url_play_button', array( $this, 'do_sanitize_field' ) );
372
  add_settings_field(
373
  'war_soundy_url_play_button',
374
- 'Play Button Image URL',
375
  array( $this, 'add_settings_field_url_pp_button' ),
376
  'soundy',
377
  'war_soundy_settings_section_play_pause_button',
@@ -381,7 +492,7 @@ class WarSoundy
381
  register_setting( 'war_soundy', 'war_soundy_url_play_hover', array( $this, 'do_sanitize_field' ) );
382
  add_settings_field(
383
  'war_soundy_url_play_hover',
384
- 'Play Hover Image URL',
385
  array( $this, 'add_settings_field_url_pp_button' ),
386
  'soundy',
387
  'war_soundy_settings_section_play_pause_button',
@@ -391,7 +502,7 @@ class WarSoundy
391
  register_setting( 'war_soundy', 'war_soundy_url_pause_button', array( $this, 'do_sanitize_field' ) );
392
  add_settings_field(
393
  'war_soundy_url_pause_button',
394
- 'Pause Button Image URL',
395
  array( $this, 'add_settings_field_url_pp_button' ),
396
  'soundy',
397
  'war_soundy_settings_section_play_pause_button',
@@ -401,20 +512,49 @@ class WarSoundy
401
  register_setting( 'war_soundy', 'war_soundy_url_pause_hover', array( $this, 'do_sanitize_field' ) );
402
  add_settings_field(
403
  'war_soundy_url_pause_hover',
404
- 'Pause Hover Image URL',
405
  array( $this, 'add_settings_field_url_pp_button' ),
406
  'soundy',
407
  'war_soundy_settings_section_play_pause_button',
408
  array( 'pause_hover' )
409
  );
410
 
411
- add_settings_field(
 
 
 
 
 
 
 
 
 
 
 
412
  'war_soundy_reset_default_buttons',
413
  'Default Buttons',
414
  array( $this, 'add_settings_field_default_buttons' ),
415
- 'soundy',
416
  'war_soundy_settings_section_play_pause_button',
417
  array( 'pause_hover' )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  );
419
  }
420
 
@@ -456,6 +596,14 @@ class WarSoundy
456
  'soundy',
457
  'war_soundy_settings_section_play_pause_position_corner'
458
  );
 
 
 
 
 
 
 
 
459
  }
460
 
461
  public function add_settings_section_play_pause_position_static()
@@ -498,12 +646,12 @@ class WarSoundy
498
  {
499
  echo '';
500
  }
501
-
502
- public function display_settings_section_play_pause_position_static_header()
503
  {
504
- echo '';
505
  }
506
-
507
  public function add_settings_field_enable_bg_sound( $args )
508
  {
509
  ?>
@@ -559,29 +707,26 @@ class WarSoundy
559
  $file_type = pathinfo( $file_url, PATHINFO_EXTENSION );
560
  }
561
  ?>
562
- <script>
563
- war_bindMediaUploader( 'war_soundy_audio_file_url', 'war_audio_library_button', 'audio' );
564
- </script>
565
- <input id="war_audio_library_button"
566
- type="button"
567
- value="Media Library"
568
- class="war_soundy" />
569
- <br>
570
  <input id="war_soundy_audio_file_url"
571
  name="war_soundy_audio_file_url"
572
  type="text"
573
  value="<?php echo $file_url; ?>"
574
- class="war_soundy_txt_input"
575
- onchange="war_audioUrlChanged( this );" />
576
- <audio id="war_soundy_audio_player"
577
- class="war_soundy"
578
- controls
579
- style="margin-right: 10px;">
580
- <source id="war_soundy_audio_player_source"
581
- src="<?php echo $file_url; ?>"
582
- type="audio/<?php echo $file_type; ?>">
583
- </audio>
584
- <?php
 
 
 
 
 
585
  }
586
 
587
  public function add_settings_field_audio_volume( $args )
@@ -631,28 +776,36 @@ class WarSoundy
631
 
632
  public function add_settings_field_default_audio( $args )
633
  {
634
- $default_url = $this->audio_url;
635
- $default_title = str_replace( "&#039;", "\&#039;", $this->audio_title );
636
- $default_volume = $this->audio_volume;
637
  ?>
638
- <input id="war_audio_default_button"
639
- type="button"
640
- value="Reset"
641
- onclick="war_setDefaultAudio( '<?php echo $default_url; ?>',
642
- '<?php echo $default_title; ?>',
643
- <?php echo $default_volume; ?> );"
644
- class="war_soundy" />
645
  <?php
646
  }
647
 
648
- public function add_settings_field_display_play_pause_button( $args )
649
  {
 
 
 
 
 
650
  ?>
651
- <input type="checkbox"
652
- value="yes"
653
- name="war_soundy_display_play_pause"
654
- id="war_soundy_display_play_pause"
655
- <?php echo get_option( 'war_soundy_display_play_pause' ) == 'yes' ? ' checked' : ''; ?> />
 
 
 
 
 
 
 
 
 
 
656
  <?php
657
  }
658
 
@@ -660,85 +813,130 @@ class WarSoundy
660
  {
661
  $type = $args[ 0 ];
662
  ?>
663
- <script>
664
- war_bindMediaUploader( 'war_soundy_url_<?php echo $type; ?>',
665
- 'img_<?php echo $type; ?>_library_button', 'image' );
666
- </script>
667
- <input id="img_<?php echo $type; ?>_library_button"
668
- type="button"
669
- value="Media Library"
670
- class="war_soundy"
671
- style="margin-right: 10px; vertical-align: top;" />
672
- <img id="war_soundy_url_<?php echo $type; ?>_img"
673
- src="<?php echo get_option( "war_soundy_url_$type" ); ?>"
674
- class="war_soundy">
675
- <br>
676
  <input id="war_soundy_url_<?php echo $type; ?>"
677
  name="war_soundy_url_<?php echo $type; ?>"
678
  type="text"
679
  class="war_soundy_txt_input"
680
- value="<?php echo get_option( "war_soundy_url_$type" ); ?>"
681
- style=""
682
- onchange="war_imgUrlChanged( this );" />
683
- <?php
 
 
 
 
 
 
 
684
  }
685
 
 
 
 
 
 
 
 
 
 
686
  public function add_settings_field_default_buttons( $args )
687
  {
688
  ?>
689
- <input id="img_default_buttons"
690
- type="button"
691
- value="24x24"
692
- onclick="war_setDefaultButtons( '24x24',
693
- '<?php echo $this->button_dimensions; ?>',
694
- '<?php echo $this->play_button_url; ?>',
695
- '<?php echo $this->play_hover_url; ?>',
696
- '<?php echo $this->pause_button_url; ?>',
697
- '<?php echo $this->pause_hover_url; ?>' );"
698
- class="war_soundy"
699
- style="margin-right: 10px;" />
700
- <input id="img_default_buttons"
701
- type="button"
702
- value="32x32"
703
- onclick="war_setDefaultButtons( '32x32',
704
- '<?php echo $this->button_dimensions; ?>',
705
- '<?php echo $this->play_button_url; ?>',
706
- '<?php echo $this->play_hover_url; ?>',
707
- '<?php echo $this->pause_button_url; ?>',
708
- '<?php echo $this->pause_hover_url; ?>' );"
709
- class="war_soundy"
710
- style="margin-right: 10px;" />
711
- <input id="img_default_buttons"
712
- type="button"
713
- value="48x48"
714
- onclick="war_setDefaultButtons( '48x48',
715
- '<?php echo $this->button_dimensions; ?>',
716
- '<?php echo $this->play_button_url; ?>',
717
- '<?php echo $this->play_hover_url; ?>',
718
- '<?php echo $this->pause_button_url; ?>',
719
- '<?php echo $this->pause_hover_url; ?>' );"
720
- class="war_soundy"
721
- style="margin-right: 10px;" />
722
- <input id="img_default_buttons"
723
- type="button"
724
- value="64x64"
725
- onclick="war_setDefaultButtons( '64x64',
726
- '<?php echo $this->button_dimensions; ?>',
727
- '<?php echo $this->play_button_url; ?>',
728
- '<?php echo $this->play_hover_url; ?>',
729
- '<?php echo $this->pause_button_url; ?>',
730
- '<?php echo $this->pause_hover_url; ?>' );"
731
- class="war_soundy"
732
- style="margin-right: 10px;" />
733
  <?php
734
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
735
 
736
  public function add_settings_field_pp_position( $args )
737
  {
738
  $pp_position = get_option( 'war_soundy_pp_position' );
739
  $pp_corner = get_option( 'war_soundy_pp_corner' );
740
 
741
- $pp_comment = $pp_position == 'document' ? '(absolute position)' : '(fixed position)';
 
 
742
 
743
  $positions = array(
744
  document => 'Document',
@@ -764,14 +962,17 @@ class WarSoundy
764
  ( $corner_id == $pp_corner ? 'selected' : '' ) . '>' . $corner_desc . '</option>';
765
  }
766
  ?>
767
- <select name="war_soundy_pp_position"
768
- onchange="war_ppPositionChanged( this )">
769
  <?php echo $options_position; ?>
770
  </select>
771
- <select name="war_soundy_pp_corner">
 
 
 
 
772
  <?php echo $options_corner; ?>
773
  </select>
774
- <span id="war_soundy_pp_comment"><?php echo $pp_comment; ?></span>
775
  <?php
776
  }
777
 
@@ -798,8 +999,8 @@ class WarSoundy
798
  id="war_soundy_offset_x"
799
  value="<?php echo get_option( 'war_soundy_offset_x' ); ?>"
800
  size="4" />
801
- <select name="war_soundy_offset_x_unit"
802
- onchange="war_lengthUnitChanged( this )">
803
  <?php echo $unit_options_x; ?>
804
  </select>
805
  <span id="war_soundy_unit_comment_x"><?php echo $unit_comment_x; ?></span>
@@ -830,8 +1031,8 @@ class WarSoundy
830
  id="war_soundy_offset_y"
831
  value="<?php echo get_option( 'war_soundy_offset_y' ); ?>"
832
  size="4" />
833
- <select name="war_soundy_offset_y_unit"
834
- onchange="war_lengthUnitChanged( this )">
835
  <?php echo $unit_options_y; ?>
836
  </select>
837
  <span id="war_soundy_unit_comment_y"><?php echo $unit_comment_y; ?></span>
@@ -862,15 +1063,16 @@ class WarSoundy
862
  <p>Positioning with the [soundy button] shortcode will disable template tag and corner positioning of the Play/Pause button.</p>
863
  <p>Shortcode positioning has precedence upon template tag positioning, which has precedence upon corner positioning.</p>
864
  <p>Note that multiple inserts of the Play/Pause button are not supported.</p>
 
865
  <?php
866
  }
867
-
868
  public function add_meta_box( $post )
869
  {
870
  $screen = get_current_screen();
871
 
872
  add_meta_box( 'soundy-meta-box',
873
- 'Soundy Background',
874
  array( $this, 'render_meta_box' ),
875
  $screen->post_type,
876
  'normal',
@@ -879,7 +1081,12 @@ class WarSoundy
879
 
880
  public function get_meta_data( $meta_data_name, $can_be_default = false )
881
  {
882
- $meta_data = get_post_meta( $this->post_id, $meta_data_name, true );
 
 
 
 
 
883
 
884
  if( ( $meta_data == '' || $meta_data == 'default' ) && $can_be_default )
885
  {
@@ -889,11 +1096,6 @@ class WarSoundy
889
  {
890
  $meta_data = get_option( $meta_data_name );
891
  }
892
-
893
- if( $meta_data == 'no_value' )
894
- {
895
- $meta_data = '';
896
- }
897
 
898
  return $meta_data;
899
  }
@@ -931,160 +1133,8 @@ class WarSoundy
931
  {
932
  $audio_title_is_default = false;
933
  }
934
- ?>
935
- <script>
936
- war_bindMediaUploader( 'war_soundy_audio_file_url', 'war_audio_library_button', 'audio' );
937
- </script>
938
- <table class="form-table war_soundy">
939
- <tr>
940
- <th class="war_soundy">
941
- <label for="war_soundy_enable_bg_sound">Enable Background Sound</label>
942
- </th>
943
- <td>
944
- <input type="radio"
945
- id="war_soundy_enable_bg_sound_default"
946
- name="war_soundy_enable_bg_sound"
947
- value="default" <?php echo ( $enable_bg_sound == 'default' ? 'checked' : '' ); ?>/>
948
- <label for="war_soundy_enable_bg_sound_default" style="margin-right: 1em;">Default</label>
949
-
950
- <input type="radio"
951
- id="war_soundy_enable_bg_sound_yes"
952
- name="war_soundy_enable_bg_sound"
953
- value="yes" <?php echo ( $enable_bg_sound == 'yes' ? 'checked' : '' ); ?>/>
954
- <label for="war_soundy_enable_bg_sound_yes" style="margin-right: 1em;">Yes</label>
955
-
956
- <input type="radio"
957
- id="war_soundy_enable_bg_sound_no"
958
- name="war_soundy_enable_bg_sound"
959
- value="no" <?php echo ( $enable_bg_sound == 'no' ? 'checked' : '' ); ?>/>
960
- <label for="war_soundy_enable_bg_sound_no" style="margin-right: 1em;">No</label>
961
- </td>
962
- </tr>
963
- <tr>
964
- <th class="war_soundy">
965
- <label for="war_soundy_audio_file_url">Soundtrack</label>
966
- </th>
967
- <td>
968
- <script>war_initSoundTrack( '<?php echo $default_audio_url; ?>' );</script>
969
- <?php $this->add_field_audio_file_URL( true ); ?>
970
- </td>
971
- </tr>
972
- <tr>
973
- <th class="war_soundy">
974
- <label for="war_soundy_audio_title">Audio Volume</label>
975
- </th>
976
- <td>
977
- <script>war_initAudioVolume( true, <?php echo $default_audio_volume; ?> );</script>
978
- <div style="margin: 5px 5px 5px 0px">
979
- <input type="radio"
980
- id="war_soundy_audio_volume_default"
981
- name="war_soundy_audio_volume_def"
982
- value="default" <?php echo ( $audio_volume_is_default ? 'checked' : '' ); ?>/>
983
- <label for="war_soundy_audio_volume_default" style="margin-right: 1em;">Default</label>
984
-
985
- <input type="radio"
986
- id="war_soundy_audio_volume_custom"
987
- name="war_soundy_audio_volume_def"
988
- value="custom" <?php echo ( $audio_volume_is_default ? '' : 'checked' ); ?>/>
989
- <label for="war_soundy_audio_volume_custom" style="margin-right: 1em;">Custom</label>
990
- </div>
991
- <div id="war_soundy_audio_volume_slider" style="width: 300px; display: inline-block; margin: 0 10px 0 0;"></div>
992
- <input type="text"
993
- class="war_soundy_audio_volume"
994
- value="<?php echo $audio_volume; ?>"
995
- name="war_soundy_audio_volume"
996
- id="war_soundy_audio_volume" /> %
997
- </td>
998
- </tr>
999
- <tr>
1000
- <th class="war_soundy">
1001
- <label for="war_soundy_audio_title">Audio Title</label>
1002
- </th>
1003
- <td>
1004
- <script>war_initAudioTitle( '<?php echo $default_audio_title; ?>' );</script>
1005
- <div style="margin: 5px 5px 5px 0px">
1006
- <input type="radio"
1007
- id="war_soundy_audio_title_default"
1008
- name="war_soundy_audio_title_def"
1009
- value="default" <?php echo ( $audio_title_is_default ? 'checked' : '' ); ?>/>
1010
- <label for="war_soundy_audio_title_default" style="margin-right: 1em;">Default</label>
1011
-
1012
- <input type="radio"
1013
- id="war_soundy_audio_title_custom"
1014
- name="war_soundy_audio_title_def"
1015
- value="custom" <?php echo ( $audio_title_is_default ? '' : 'checked' ); ?>/>
1016
- <label for="war_soundy_audio_title_custom" style="margin-right: 1em;">Custom</label>
1017
- </div>
1018
- <input type="text"
1019
- class="war_soundy_txt_input"
1020
- value="<?php echo $audio_title; ?>"
1021
- name="war_soundy_audio_title"
1022
- id="war_soundy_audio_title" />
1023
- </td>
1024
- </tr>
1025
- <tr>
1026
- <th class="war_soundy">
1027
- <label for="war_soundy_autoplay">Autoplay</label>
1028
- </th>
1029
- <td>
1030
- <input type="radio"
1031
- id="war_soundy_autoplay_default"
1032
- name="war_soundy_autoplay"
1033
- value="default" <?php echo ( $autoplay == 'default' ? 'checked' : '' ); ?>/>
1034
- <label for="war_soundy_autoplay_default" style="margin-right: 1em;">Default</label>
1035
-
1036
- <input type="radio"
1037
- id="war_soundy_autoplay_yes"
1038
- name="war_soundy_autoplay"
1039
- value="yes" <?php echo ( $autoplay == 'yes' ? 'checked' : '' ); ?>/>
1040
- <label for="war_soundy_autoplay_yes" style="margin-right: 1em;">Yes</label>
1041
-
1042
- <input type="radio"
1043
- id="war_soundy_autoplay_no"
1044
- name="war_soundy_autoplay"
1045
- value="no" <?php echo ( $autoplay == 'no' ? 'checked' : '' ); ?>/>
1046
- <label for="war_soundy_autoplay_no" style="margin-right: 1em;">No</label>
1047
- </td>
1048
- </tr>
1049
- <tr>
1050
- <th class="war_soundy">
1051
- <label for="war_soundy_loop">Audio Repeat Loop</label>
1052
- </th>
1053
- <td>
1054
- <input type="radio"
1055
- id="war_soundy_loop_default"
1056
- name="war_soundy_loop"
1057
- value="default" <?php echo ( $loop == 'default' ? 'checked' : '' ); ?>/>
1058
- <label for="war_soundy_loop_default" style="margin-right: 1em;">Default</label>
1059
-
1060
- <input type="radio"
1061
- id="war_soundy_loop_yes"
1062
- name="war_soundy_loop"
1063
- value="yes" <?php echo ( $loop == 'yes' ? 'checked' : '' ); ?>/>
1064
- <label for="war_soundy_loop_yes" style="margin-right: 1em;">Yes</label>
1065
-
1066
- <input type="radio"
1067
- id="war_soundy_loop_no"
1068
- name="war_soundy_loop"
1069
- value="no" <?php echo ( $loop == 'no' ? 'checked' : '' ); ?>/>
1070
- <label for="war_soundy_loop_no" style="margin-right: 1em;">No</label>
1071
- </td>
1072
- </tr>
1073
- </table>
1074
- <!--
1075
- <script>
1076
- function war_show()
1077
- {
1078
- var src = jQuery( '#war_soundy_audio_player_source' ).attr( 'src' );
1079
- var type = jQuery( '#war_soundy_audio_player_source' ).attr( 'type' );
1080
-
1081
- alert( 'src = ' + src + ' \ntype = ' + type );
1082
- }
1083
- </script>
1084
- <h1 onclick="war_show();">CLICK</h1>
1085
- -->
1086
-
1087
- <?php
1088
  }
1089
 
1090
  public function save_post_data( $post_id )
@@ -1166,14 +1216,24 @@ class WarSoundy
1166
  public function insert_audio()
1167
  {
1168
  $this->post_id = get_the_ID();
 
 
1169
 
1170
- $enable_bg_sound = $this->get_meta_data( 'war_soundy_enable_bg_sound' );
1171
- if( $enable_bg_sound != 'yes' ) return;
1172
-
 
 
 
 
 
 
 
 
 
 
1173
  if( $this->user_agent_is_mobile && $this->disable_soundy_for_mobile ) return;
1174
-
1175
- $audio_file_url = $this->get_meta_data( 'war_soundy_audio_file_url' );
1176
- if( $audio_file_url == '' ) return;
1177
  $audio_type = $this->get_audio_type_from_URL( $audio_file_url );
1178
 
1179
  $audio_volume = $this->get_meta_data( 'war_soundy_audio_volume' ) / 100;
@@ -1188,9 +1248,9 @@ class WarSoundy
1188
 
1189
  $audio_code =
1190
 
1191
- '<div style="display: none">' .
1192
- ' <audio id="war_soundy_audio" preload="auto" ' . $auto_play . ' ' . $audio_loop . ' style="display: none;" hidden>' .
1193
- ' <source src="' . $audio_file_url . '" type="audio/' . $audio_type . '">' .
1194
  ' </audio>' .
1195
  '</div>';
1196
 
@@ -1204,111 +1264,17 @@ class WarSoundy
1204
  <link rel="prefetch" href="<?php echo $this->hover_url_play; ?>">
1205
  <link rel="prefetch" href="<?php echo $this->hover_url_pause; ?>">
1206
  <script>
1207
- var war_soundy_pp_button_is_inserted = false;
1208
-
1209
- jQuery( document ).ready( function()
1210
- {
1211
- <?php if( $pp_code != '' ): ?>
1212
- if( ! war_soundy_pp_button_is_inserted )
1213
- {
1214
- jQuery( 'body' ).append( '<?php echo $pp_code; ?>' );
1215
- war_soundy_pp_button_is_inserted = true;
1216
- }
1217
- <?php endif; ?>
1218
-
1219
- jQuery( 'body' ).append( '<?php echo $audio_code; ?>' );
1220
-
1221
- war_soundy_player = jQuery( '#war_soundy_audio' )[ 0 ];
1222
- war_soundy_audio_control = jQuery( '#war_soundy_audio_control' );
1223
-
1224
- war_soundy_player.volume = <?php echo $audio_volume; ?>;
1225
-
1226
- war_soundy_hovering = false;
1227
-
1228
- if( war_soundy_pp_button_is_inserted )
1229
- {
1230
- war_soundy_audio_control.click(
1231
- function()
1232
- {
1233
- if( war_soundy_player.paused )
1234
- {
1235
- war_soundy_player.play();
1236
- war_soundy_audio_control.attr( 'src', '<?php echo $this->hover_url_pause; ?>' );
1237
- }
1238
- else
1239
- {
1240
- war_soundy_player.pause();
1241
- war_soundy_audio_control.attr( 'src', '<?php echo $this->hover_url_play; ?>' );
1242
- }
1243
- } );
1244
-
1245
- war_soundy_audio_control.hover(
1246
- function()
1247
- {
1248
- war_soundy_hovering = true;
1249
- if( war_soundy_player.paused )
1250
- {
1251
- war_soundy_audio_control.attr( 'src', '<?php echo $this->hover_url_play; ?>' );
1252
- }
1253
- else
1254
- {
1255
- war_soundy_audio_control.attr( 'src', '<?php echo $this->hover_url_pause; ?>' );
1256
- }
1257
- },
1258
- function()
1259
- {
1260
- war_soundy_hovering = false;
1261
- if( war_soundy_player.paused )
1262
- {
1263
- jQuery( '#war_soundy_audio_control' ).attr( 'src', '<?php echo $this->button_url_play; ?>' );
1264
- }
1265
- else
1266
- {
1267
- jQuery( '#war_soundy_audio_control' ).attr( 'src', '<?php echo $this->button_url_pause; ?>' );
1268
- }
1269
- }
1270
- );
1271
-
1272
- jQuery( '#war_soundy_audio' ).bind( 'ended' , function()
1273
- {
1274
- if( war_soundy_hovering )
1275
- {
1276
- war_soundy_audio_control.attr( 'src', '<?php echo $this->hover_url_play; ?>' );
1277
- }
1278
- else
1279
- {
1280
- war_soundy_audio_control.attr( 'src', '<?php echo $this->button_url_play; ?>' );
1281
- }
1282
- } );
1283
-
1284
- jQuery( '#war_soundy_audio' ).bind( 'play' , function()
1285
- {
1286
- if( war_soundy_hovering )
1287
- {
1288
- war_soundy_audio_control.attr( 'src', '<?php echo $this->hover_url_pause; ?>' );
1289
- }
1290
- else
1291
- {
1292
- war_soundy_audio_control.attr( 'src', '<?php echo $this->button_url_pause; ?>' );
1293
- }
1294
- } );
1295
-
1296
- if( war_soundy_player.autoplay )
1297
- {
1298
- if( <?php echo $this->user_agent_is_IOS() ?> )
1299
- {
1300
- if( war_soundy_hovering )
1301
- {
1302
- war_soundy_audio_control.attr( 'src', '<?php echo $this->hover_url_play; ?>' );
1303
- }
1304
- else
1305
- {
1306
- war_soundy_audio_control.attr( 'src', '<?php echo $this->button_url_play; ?>' );
1307
- }
1308
- }
1309
- }
1310
- }
1311
- } );
1312
  </script>
1313
  <?php
1314
  }
@@ -1320,23 +1286,41 @@ class WarSoundy
1320
 
1321
  public function get_pp_button_code( $mode )
1322
  {
1323
- $display_play_pause = $this->get_meta_data( 'war_soundy_display_play_pause' );
1324
- if( $display_play_pause != 'yes' ) return '';
1325
-
1326
- $enable_bg_sound = $this->get_meta_data( 'war_soundy_enable_bg_sound' );
1327
- if( $enable_bg_sound != 'yes' ) return '';
1328
-
1329
- $this->button_url_play = get_option( 'war_soundy_url_play_button' );
1330
- $this->hover_url_play = get_option( 'war_soundy_url_play_hover' );
1331
- $this->button_url_pause = get_option( 'war_soundy_url_pause_button' );
1332
- $this->hover_url_pause = get_option( 'war_soundy_url_pause_hover' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1333
 
1334
  $button_position = get_option( 'war_soundy_pp_position' );
1335
  $position = ( $button_position == 'document' ) ? 'absolute' : 'fixed';
1336
 
1337
  if( $mode == 'corner' )
1338
  {
1339
- $button_corner = get_option( 'war_soundy_pp_corner' );
1340
  switch( $button_corner )
1341
  {
1342
  case upper_right:
@@ -1436,6 +1420,13 @@ class WarSoundy
1436
  return true;
1437
  }
1438
  }
 
 
 
 
 
 
 
1439
  return false;
1440
  }
1441
 
@@ -1465,7 +1456,7 @@ function soundy_get_button()
1465
  {
1466
  $pp_code = '<script>' .
1467
  'jQuery( "#war_soundy_audio_control" ).remove();' .
1468
- 'war_soundy_pp_button_is_inserted = true;' .
1469
  '</script>' .
1470
  $pp_code;
1471
  }
1
  <?php
2
  /**
3
  * @package Soundy_Background_Music
4
+ * @version 2.0
5
  */
6
  /*
7
  Plugin Name: Soundy Background Music
8
+ Plugin URI: http://webartisan.ch/en/products/soundy-free/
9
  Description: This plugin allows administrators and authors to set a background sound on any post or page.
10
+ Version: 2.0
11
  Author: Bertrand du Couédic
12
  Author URI: http://webartisan.ch/en/about
13
  License: GPL2
30
 
31
  class WarSoundy
32
  {
33
+ private $soundy_version = '2.0';
34
+ private $soundy_type = 'free';
35
+ private $soundy_subtype = '';
36
+ private $soundy_free_home_wp_url = 'http://wordpress.org/plugins/soundy-background-music/';
37
+ private $soundy_pro_home_url = 'http://webartisan.ch/en/products/soundy-pro/';
38
+ private $disable_soundy_for_mobile = false;
39
+ private $use_own_jquery_lib_on_front_end = true;
40
+ private $enable_bg_sound = 'no';
41
+ private $audio_url = '/audio/valse.mp3';
42
+ private $audio_volume = '80';
43
+ private $audio_title = 'Valse - Anonymous (1870)';
44
+ private $autoplay = 'yes';
45
+ private $loop = 'yes';
46
+ private $pp_images_to_use = 'default';
47
+ private $pp_position = 'window';
48
+ private $pp_corner = 'upper_right';
49
+ private $offset_x = 35;
50
+ private $offset_x_unit = 'px';
51
+ private $offset_y = 35;
52
+ private $offset_y_unit = 'px';
53
+ private $play_button_url = '/images/buttons/48x48/play-square-grey.png';
54
+ private $play_hover_url = '/images/buttons/48x48/play-square-blue.png';
55
+ private $pause_button_url = '/images/buttons/48x48/pause-square-grey.png';
56
+ private $pause_hover_url = '/images/buttons/48x48/pause-square-blue.png';
57
+ private $button_dimensions = '48x48';
58
+ private $page_preview_url = '';
59
+ private $pp_design; // WarSoundyPlayPauseDesign Object
60
  private $user_agent_is_mobile;
61
  private $post_id;
62
+
63
+ public $plugin_name;
64
+ public $plugin_url;
65
+ public $plugin_path;
66
+ public $plugin_path_file = __FILE__;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  private $units = array(
69
  'px' => '(pixels)',
74
  );
75
 
76
  public function __construct()
77
+ {
 
 
 
 
 
 
 
 
 
 
 
 
78
  $this->user_agent_is_mobile = $this->check_user_agent( 'mobile' );
79
 
80
+ $this->plugin_path = dirname( __FILE__ );
81
+ $this->plugin_name = substr( $this->plugin_path, strrpos( $this->plugin_path, '/' ) + 1 );
82
+ $this->plugin_url = WP_PLUGIN_URL . '/' . $this->plugin_name;
83
 
84
  $this->audio_url = $this->plugin_url . $this->audio_url;
85
  $this->play_button_url = $this->plugin_url . $this->play_button_url;
95
  add_action( 'admin_menu', array( $this, 'add_plugin_settings_menu' ) );
96
  add_action( 'admin_init', array( $this, 'register_settings' ) );
97
 
98
+ add_filter( 'plugin_action_links', array( $this, 'add_settings_link_to_plugins_page_soundy_entry' ) );
99
+ if( $this->soundy_type == 'free' || $this->soundy_subtype == 'trial' )
100
+ {
101
+ add_filter( 'plugin_row_meta', array( $this, 'add_pro_buy_link_to_plugins_page_soundy_entry' ), 10, 2 );
102
+ }
103
 
104
  $uri = $_SERVER[ 'REQUEST_URI' ];
105
  $is_edit_post = ( strpos( $uri, '/wp-admin/post.php' ) == 0 ) ||
108
  if( ( isset( $_GET['page'] ) && ( $_GET['page'] == 'soundy' ) ) || $is_edit_post )
109
  {
110
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
111
+ // to get 'Insert into Post' Button in Upload Dialog:
112
+ add_filter( 'get_media_item_args', array( $this, 'get_media_item_args' ) );
113
  }
114
 
115
  if( $is_edit_post )
120
  }
121
  else
122
  {
123
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_front_end' ) );
 
124
  add_action( 'wp_head', array( $this, 'insert_audio' ) );
125
  add_shortcode( 'soundy', array( $this, 'soundy_shortcode' ) );
126
  }
127
+
128
+ $soundy_type = get_option( 'war_soundy_type' );
129
+ $soundy_version = get_option( 'war_soundy_version' );
130
+ if( ( $soundy_type != $this->soundy_type ) || ( $soundy_version != $this->soundy_version ) )
131
+ {
132
+ update_option( 'war_soundy_version', $this->soundy_version );
133
+
134
+ $volume = get_option( 'war_soundy_audio_volume' );
135
+ if( $volume == '' )
136
+ {
137
+ update_option( 'war_soundy_audio_volume', $this->audio_volume );
138
+ }
139
+
140
+ $display_play_pause = get_option( 'war_soundy_display_play_pause' );
141
+ delete_option( 'war_soundy_display_play_pause' );
142
+ $pp_images_to_use = get_option( 'war_soundy_pp_images_to_use' );
143
+ if( ! $pp_images_to_use )
144
+ {
145
+ if( $display_play_pause == 'yes' || $display_play_pause == '' )
146
+ {
147
+ update_option( 'war_soundy_pp_images_to_use', 'default');
148
+ }
149
+ else if( $display_play_pause == 'no' )
150
+ {
151
+ update_option( 'war_soundy_pp_images_to_use', 'none' );
152
+ }
153
+ else
154
+ {
155
+ update_option( 'war_soundy_pp_images_to_use', 'default');
156
+ }
157
+ }
158
+
159
+ $image_play_normal = get_option( 'war_soundy_url_play_button' );
160
+ $image_play_hover = get_option( 'war_soundy_url_play_hover' );
161
+ $image_pause_normal = get_option( 'war_soundy_url_pause_button' );
162
+ $image_pause_hover = get_option( 'war_soundy_url_pause_hover' );
163
+
164
+ $image_play_normal = str_replace( 'soundy-music-pro', 'soundy-background-music', $image_play_normal );
165
+ $image_play_hover = str_replace( 'soundy-music-pro', 'soundy-background-music', $image_play_hover );
166
+ $image_pause_normal = str_replace( 'soundy-music-pro', 'soundy-background-music', $image_pause_normal );
167
+ $image_pause_hover = str_replace( 'soundy-music-pro', 'soundy-background-music', $image_pause_hover );
168
+
169
+ update_option( 'war_soundy_url_play_button', $image_play_normal );
170
+ update_option( 'war_soundy_url_play_hover', $image_play_hover );
171
+ update_option( 'war_soundy_url_pause_button', $image_pause_normal );
172
+ update_option( 'war_soundy_url_pause_hover', $image_pause_hover );
173
+
174
+ $audio_url = get_option( 'war_soundy_audio_file_url' );
175
+ $audio_url = str_replace( 'soundy-music-pro', 'soundy-background-music', $audio_url );
176
+ update_option( 'war_soundy_audio_file_url', $audio_url );
177
+ }
178
  }
179
 
180
  public function activate()
181
  {
182
+ add_option( 'war_soundy_type', $this->soundy_type );
183
+ add_option( 'war_soundy_version', $this->soundy_version );
184
+ add_option( 'war_soundy_enable_bg_sound', $this->enable_bg_sound );
185
+ add_option( 'war_soundy_audio_file_url', $this->audio_url );
186
+ add_option( 'war_soundy_audio_volume', $this->audio_volume );
187
+ add_option( 'war_soundy_audio_title', $this->audio_title );
188
+ add_option( 'war_soundy_autoplay', $this->autoplay );
189
+ add_option( 'war_soundy_loop', $this->loop );
190
+ add_option( 'war_soundy_pp_images_to_use', $this->pp_images_to_use );
191
+ add_option( 'war_soundy_url_play_button', $this->play_button_url );
192
+ add_option( 'war_soundy_url_play_hover', $this->play_hover_url );
193
+ add_option( 'war_soundy_url_pause_button', $this->pause_button_url );
194
+ add_option( 'war_soundy_url_pause_hover', $this->pause_hover_url );
195
+ add_option( 'war_soundy_pp_position', $this->pp_position );
196
+ add_option( 'war_soundy_pp_corner', $this->pp_corner );
197
+ add_option( 'war_soundy_offset_x', $this->offset_x );
198
+ add_option( 'war_soundy_offset_x_unit', $this->offset_x_unit );
199
+ add_option( 'war_soundy_offset_y', $this->offset_y );
200
+ add_option( 'war_soundy_offset_y_unit', $this->offset_y_unit );
201
+ add_option( 'war_soundy_page_preview_url', $this->page_preview_url );
202
  }
203
 
204
  public function deactivate()
206
  }
207
 
208
  public function add_plugin_settings_menu()
209
+ {
210
+ $html_page_title = 'Soundy';
211
+ $settings_entry_name = $html_page_title;
212
+ add_options_page( $html_page_title, $settings_entry_name, 'manage_options', 'soundy', array( $this, 'create_plugin_settings_page' ) );
213
  }
214
 
215
  public function create_plugin_settings_page()
224
 
225
  public function get_media_item_args( $args )
226
  {
227
+ // to get 'Insert into Post' Button in Upload Dialog:
228
  $args[ 'send' ] = true;
229
  return $args;
230
  }
253
  $this->plugin_url . '/js/jquery-ui-1.10.4/jquery.ui.slider.js' );
254
  */
255
 
256
+ wp_register_script( 'soundy-back-end', $this->plugin_url . '/js/back-end.js', array( 'jquery', 'media-upload', 'thickbox' ) );
 
257
 
258
+ wp_enqueue_script( 'jquery' );
259
+ wp_enqueue_script( 'jquery-ui-core' );
260
+ wp_enqueue_script( 'jquery-ui-widget' );
261
+ wp_enqueue_script( 'jquery-ui-mouse' );
262
+ wp_enqueue_script( 'jquery-ui-tabs' );
263
+ wp_enqueue_script( 'jquery-ui-slider' );
264
+
265
+ wp_enqueue_script( 'soundy-back-end' );
266
+ wp_enqueue_script( 'thickbox' );
267
+ wp_enqueue_script( 'button-upload' );
268
 
269
  wp_register_style( 'jquery-ui', $this->plugin_url . '/css/jquery-ui-1.10.4/jquery-ui.css' );
270
  wp_register_style( 'soundy', $this->plugin_url . '/css/style-back-end.css' );
271
+ if( $this->check_user_agent( 'firefox' ) )
272
+ {
273
+ wp_register_style( 'soundy-firefox', $this->plugin_url . '/css/style-back-end-firefox.css' );
274
+ }
275
+
276
+ wp_enqueue_style( 'soundy' );
277
+ wp_enqueue_style( 'soundy-firefox' );
278
 
279
+ wp_enqueue_style( 'wp-jquery-ui-dialog' );
280
+ wp_enqueue_style( 'jquery-ui' );
281
+ wp_enqueue_style( 'thickbox' );
282
  }
283
 
284
+ public function enqueue_scripts_front_end( $hook )
285
+ {
286
+ if( $this->use_own_jquery_lib_on_front_end )
287
+ {
288
+ wp_deregister_script( 'jquery' );
289
+ wp_register_script( 'jquery', $this->plugin_url . '/js/jquery-ui-1.10.4/jquery-1.10.2.js' );
290
+ wp_enqueue_script( 'jquery' );
291
+ }
292
+
293
+ wp_register_script( 'soundy-front-end', $this->plugin_url . '/js/front-end.js', array( 'jquery' ) );
294
+ wp_enqueue_script( 'soundy-front-end' );
295
+
296
+ wp_register_style( 'soundy', $this->plugin_url . '/css/style-front-end.css' );
297
+ wp_enqueue_style( 'soundy' );
298
+ }
299
+
300
+ public function add_settings_link_to_plugins_page_soundy_entry( $links )
301
  {
302
  $settings_link = '<a href="options-general.php?page=soundy">Settings</a>';
303
  array_unshift( $links, $settings_link );
304
  return $links;
305
  }
306
 
307
+ public function add_pro_buy_link_to_plugins_page_soundy_entry( $links, $file )
308
+ {
309
+ $plugin_name = plugin_basename( __FILE__ );
310
+
311
+ if ( strpos( $file, $plugin_name ) !== false )
312
+ {
313
+ if( $this->soundy_subtype == 'trial' )
314
+ {
315
+ $link_title = 'Upgrade to Soundy PRO';
316
+ $pro_link = '<a href="' . $this->soundy_pro_home_url . '" target="_blank" class="war_soundy_hit_link">' . $link_title . '</a>';
317
+ }
318
+ else
319
+ {
320
+ $link_title = 'Try Soundy PRO for Free';
321
+ $pro_link = '<a href="' . $this->soundy_pro_home_url . '" target="_blank" class="war_soundy_hit_link">' . $link_title . '</a>' .
322
+ ' with its Play/Pause Button Designer';
323
+ }
324
+ $link = array_shift( $links );
325
+ array_unshift( $links, $pro_link );
326
+ array_unshift( $links, $link );
327
+
328
+ if( $this->soundy_type == 'free' )
329
+ {
330
+ $free_wp_link_title = 'WordPress.org Plugin Page';
331
+ $free_wp_link = '<a href="' . $this->soundy_free_home_wp_url . '" target="_blank">' . $free_wp_link_title . '</a>';
332
+ array_push( $links, $free_wp_link );
333
+ }
334
+ }
335
+
336
+ return $links;
337
+ }
338
+
339
  public function get_audio_type_from_URL( $url )
340
  {
341
  $file_extension = pathinfo( $url, PATHINFO_EXTENSION );
397
  array( $this, 'display_settings_section_audio_track_header' ),
398
  'soundy'
399
  );
400
+
401
  register_setting( 'war_soundy', 'war_soundy_enable_bg_sound' );
402
  add_settings_field(
403
  'war_soundy_enable_bg_sound',
470
  'soundy'
471
  );
472
 
473
+ register_setting( 'war_soundy', 'war_soundy_pp_images_to_use' );
474
  add_settings_field(
475
+ 'war_soundy_pp_images_to_use',
476
+ 'Play/Pause Button Images',
477
+ array( $this, 'add_settings_field_pp_images_to_use' ),
478
  'soundy',
479
  'war_soundy_settings_section_play_pause_button'
480
  );
482
  register_setting( 'war_soundy', 'war_soundy_url_play_button', array( $this, 'do_sanitize_field' ) );
483
  add_settings_field(
484
  'war_soundy_url_play_button',
485
+ 'Play Normal URL',
486
  array( $this, 'add_settings_field_url_pp_button' ),
487
  'soundy',
488
  'war_soundy_settings_section_play_pause_button',
492
  register_setting( 'war_soundy', 'war_soundy_url_play_hover', array( $this, 'do_sanitize_field' ) );
493
  add_settings_field(
494
  'war_soundy_url_play_hover',
495
+ 'Play Hover URL',
496
  array( $this, 'add_settings_field_url_pp_button' ),
497
  'soundy',
498
  'war_soundy_settings_section_play_pause_button',
502
  register_setting( 'war_soundy', 'war_soundy_url_pause_button', array( $this, 'do_sanitize_field' ) );
503
  add_settings_field(
504
  'war_soundy_url_pause_button',
505
+ 'Pause Normal URL',
506
  array( $this, 'add_settings_field_url_pp_button' ),
507
  'soundy',
508
  'war_soundy_settings_section_play_pause_button',
512
  register_setting( 'war_soundy', 'war_soundy_url_pause_hover', array( $this, 'do_sanitize_field' ) );
513
  add_settings_field(
514
  'war_soundy_url_pause_hover',
515
+ 'Pause Hover URL',
516
  array( $this, 'add_settings_field_url_pp_button' ),
517
  'soundy',
518
  'war_soundy_settings_section_play_pause_button',
519
  array( 'pause_hover' )
520
  );
521
 
522
+ add_settings_field
523
+ (
524
+ 'war_soundy_swap_normal_hover',
525
+ 'Swap Normal &lt;-&gt; Hover',
526
+ array( $this, 'add_settings_field_swap_normal_hover' ),
527
+ 'soundy',
528
+ 'war_soundy_settings_section_play_pause_button',
529
+ array( 'pause_hover' )
530
+ );
531
+
532
+ add_settings_field
533
+ (
534
  'war_soundy_reset_default_buttons',
535
  'Default Buttons',
536
  array( $this, 'add_settings_field_default_buttons' ),
537
+ 'soundy',
538
  'war_soundy_settings_section_play_pause_button',
539
  array( 'pause_hover' )
540
+ );
541
+
542
+ add_settings_field
543
+ (
544
+ 'war_soundy_img_preview_here',
545
+ 'Button Preview',
546
+ array( $this, 'add_settings_field_img_preview_here' ),
547
+ 'soundy',
548
+ 'war_soundy_settings_section_play_pause_button'
549
+ );
550
+
551
+ add_settings_field
552
+ (
553
+ 'war_soundy_preview_in_context_default',
554
+ 'Preview in Context',
555
+ array( $this, 'add_settings_field_preview_in_context_default' ),
556
+ 'soundy',
557
+ 'war_soundy_settings_section_play_pause_button'
558
  );
559
  }
560
 
596
  'soundy',
597
  'war_soundy_settings_section_play_pause_position_corner'
598
  );
599
+
600
+ add_settings_field(
601
+ 'war_soundy_preview_in_context_position',
602
+ 'Preview in Context',
603
+ array( $this, 'add_settings_field_preview_in_context_position' ),
604
+ 'soundy',
605
+ 'war_soundy_settings_section_play_pause_position_corner'
606
+ );
607
  }
608
 
609
  public function add_settings_section_play_pause_position_static()
646
  {
647
  echo '';
648
  }
649
+
650
+ public function display_settings_section_play_pause_position_static_header()
651
  {
652
+ echo '';
653
  }
654
+
655
  public function add_settings_field_enable_bg_sound( $args )
656
  {
657
  ?>
707
  $file_type = pathinfo( $file_url, PATHINFO_EXTENSION );
708
  }
709
  ?>
 
 
 
 
 
 
 
 
710
  <input id="war_soundy_audio_file_url"
711
  name="war_soundy_audio_file_url"
712
  type="text"
713
  value="<?php echo $file_url; ?>"
714
+ class="war_soundy_txt_input" />
715
+ <br>
716
+ <div style="margin-top: 5px;">
717
+ <button id="war_audio_library_button"
718
+ type="button"
719
+ class="war_soundy" />Media Library</button>
720
+ <audio id="war_soundy_audio_player"
721
+ class="war_soundy"
722
+ controls
723
+ style="margin-right: 10px;">
724
+ <source id="war_soundy_audio_player_source"
725
+ src="<?php echo $file_url; ?>"
726
+ type="audio/<?php echo $file_type; ?>">
727
+ </audio>
728
+ </div>
729
+ <?php
730
  }
731
 
732
  public function add_settings_field_audio_volume( $args )
776
 
777
  public function add_settings_field_default_audio( $args )
778
  {
 
 
 
779
  ?>
780
+ <button id="war_audio_default_button"
781
+ type="button"
782
+ class="war_soundy" />Reset</button>
 
 
 
 
783
  <?php
784
  }
785
 
786
+ public function add_settings_field_pp_images_to_use( $args )
787
  {
788
+ $pp_images_to_use = get_option( 'war_soundy_pp_images_to_use' );
789
+ if( $pp_images_to_use == 'designer' && $this->soundy_type != 'pro' && $this->soundy_subtype != 'full' )
790
+ {
791
+ $pp_images_to_use = 'default';
792
+ }
793
  ?>
794
+ <input type="radio"
795
+ id="war_soundy_pp_images_to_use_default"
796
+ name="war_soundy_pp_images_to_use"
797
+ value="default"
798
+ style="margin: 5px 0 5px 0;" <?php echo ( $pp_images_to_use == 'default' ? 'checked' : '' ); ?>/>
799
+ <label for="war_soundy_pp_images_to_use_default"
800
+ style="margin-top: 0;">Use button images defined in this Play/Pause Button tab</label>
801
+ <br>
802
+ <input type="radio"
803
+ id="war_soundy_pp_images_to_use_none"
804
+ name="war_soundy_pp_images_to_use"
805
+ value="none"
806
+ style="margin: 5px 0 5px 0;" <?php echo ( $pp_images_to_use == 'none' ? 'checked' : '' ); ?>/>
807
+ <label for="war_soundy_pp_images_to_use_none"
808
+ style="margin-top: 0;">Do not display any Play/Pause Button</label>
809
  <?php
810
  }
811
 
813
  {
814
  $type = $args[ 0 ];
815
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
816
  <input id="war_soundy_url_<?php echo $type; ?>"
817
  name="war_soundy_url_<?php echo $type; ?>"
818
  type="text"
819
  class="war_soundy_txt_input"
820
+ value="<?php echo get_option( "war_soundy_url_$type" ); ?>" />
821
+ <div style="margin-top: 5px;">
822
+ <button id="img_<?php echo $type; ?>_library_button"
823
+ type="button"
824
+ value="Media Library"
825
+ class="war_soundy_button_media_library_pp_button" />Media Library</button>
826
+ <img id="war_soundy_url_<?php echo $type; ?>_img"
827
+ src="<?php echo get_option( "war_soundy_url_$type" ); ?>"
828
+ class="war_soundy" >
829
+ </div>
830
+ <?php
831
  }
832
 
833
+ public function add_settings_field_swap_normal_hover( $args )
834
+ {
835
+ ?>
836
+ <button id="war_soundy_button_swap_normal_hover"
837
+ type="button"
838
+ class="war_soundy">Swap</button>
839
+ <?php
840
+ }
841
+
842
  public function add_settings_field_default_buttons( $args )
843
  {
844
  ?>
845
+ <button id="button_default_buttons_24"
846
+ type="button"
847
+ value="24x24"
848
+ class="war_soundy"
849
+ style="margin-right: 10px;" />24x24</button>
850
+ <button id="button_default_buttons_32"
851
+ type="button"
852
+ value="32x32"
853
+ class="war_soundy"
854
+ style="margin-right: 10px;" />32x32</button>
855
+ <button id="button_default_buttons_48"
856
+ type="button"
857
+ value="48x48"
858
+ class="war_soundy"
859
+ style="margin-right: 10px;" />48x48</button>
860
+ <button id="button_default_buttons_64"
861
+ type="button"
862
+ value="64x64"
863
+ class="war_soundy"
864
+ style="margin-right: 10px;" />64x64</button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
865
  <?php
866
  }
867
+
868
+ public function add_settings_field_img_preview_here( $args )
869
+ {
870
+ ?>
871
+ <img id="war_soundy_img_preview_here">
872
+ <?php
873
+ }
874
+
875
+ public function add_settings_field_preview_in_context_default( $args )
876
+ {
877
+ ?>
878
+ <span id="war_soundy_page_preview_label"
879
+ class="war_soundy_page_preview_label">Page:</span>
880
+ <select id="war_soundy_page_preview_url_default"
881
+ class="war_soundy_page_preview_url">
882
+ <?php $this->add_page_preview_url_options() ?>
883
+ </select>
884
+ <br>
885
+ <button id="war_soundy_button_preview_in_context_default"
886
+ type="button"
887
+ style="margin-top: 8px;"
888
+ class="war_soundy">Preview</button>
889
+ <?php
890
+ }
891
+
892
+ public function add_settings_field_preview_in_context_position( $args )
893
+ {
894
+ ?>
895
+ <span id="war_soundy_page_preview_label"
896
+ class="war_soundy_page_preview_label">Page:</span>
897
+ <select id="war_soundy_page_preview_url_position"
898
+ class="war_soundy_page_preview_url">
899
+ <?php $this->add_page_preview_url_options() ?>
900
+ </select>
901
+ <br>
902
+ <button id="war_soundy_button_preview_in_context_position"
903
+ type="button"
904
+ style="margin-top: 8px;"
905
+ class="war_soundy">Preview</button>
906
+ <?php
907
+ }
908
+
909
+ private function add_page_preview_url_options()
910
+ {
911
+ echo '<option value="/">Select Page</option>';
912
+ $page_preview_url = get_option( 'war_soundy_page_preview_url' );
913
+ $pages = get_pages();
914
+ foreach ( $pages as $page )
915
+ {
916
+ $page_link = get_page_link( $page->ID );
917
+ $option = '<option value="' . $page_link . '"';
918
+ if( $page_link == $page_preview_url )
919
+ {
920
+ $option .= ' selected>';
921
+ }
922
+ else
923
+ {
924
+ $option .= '>';
925
+ }
926
+ $option .= $page->post_title;
927
+ $option .= '</option>';
928
+ echo $option;
929
+ }
930
+ }
931
 
932
  public function add_settings_field_pp_position( $args )
933
  {
934
  $pp_position = get_option( 'war_soundy_pp_position' );
935
  $pp_corner = get_option( 'war_soundy_pp_corner' );
936
 
937
+ $pp_comment = $pp_position == 'document' ?
938
+ '(absolute positioning: button will scroll with page content)' :
939
+ '(fixed positioning: button will NOT scroll with page content)';
940
 
941
  $positions = array(
942
  document => 'Document',
962
  ( $corner_id == $pp_corner ? 'selected' : '' ) . '>' . $corner_desc . '</option>';
963
  }
964
  ?>
965
+ <select id="war_soundy_pp_position"
966
+ name="war_soundy_pp_position">
967
  <?php echo $options_position; ?>
968
  </select>
969
+ <span id="war_soundy_pp_comment"><?php echo $pp_comment; ?></span>
970
+ <br>
971
+ <select id="war_soundy_pp_corner"
972
+ name="war_soundy_pp_corner"
973
+ style="margin-top: 8px;">
974
  <?php echo $options_corner; ?>
975
  </select>
 
976
  <?php
977
  }
978
 
999
  id="war_soundy_offset_x"
1000
  value="<?php echo get_option( 'war_soundy_offset_x' ); ?>"
1001
  size="4" />
1002
+ <select id="war_soundy_offset_x_unit"
1003
+ name="war_soundy_offset_x_unit">
1004
  <?php echo $unit_options_x; ?>
1005
  </select>
1006
  <span id="war_soundy_unit_comment_x"><?php echo $unit_comment_x; ?></span>
1031
  id="war_soundy_offset_y"
1032
  value="<?php echo get_option( 'war_soundy_offset_y' ); ?>"
1033
  size="4" />
1034
+ <select id="war_soundy_offset_y_unit"
1035
+ name="war_soundy_offset_y_unit">
1036
  <?php echo $unit_options_y; ?>
1037
  </select>
1038
  <span id="war_soundy_unit_comment_y"><?php echo $unit_comment_y; ?></span>
1063
  <p>Positioning with the [soundy button] shortcode will disable template tag and corner positioning of the Play/Pause button.</p>
1064
  <p>Shortcode positioning has precedence upon template tag positioning, which has precedence upon corner positioning.</p>
1065
  <p>Note that multiple inserts of the Play/Pause button are not supported.</p>
1066
+ <p>If you have posts using the button shortcode and these posts are bulk displayed in blog pages, you will get into troubles. A workaround to this multiple buttons issue is to limit the number of posts per blog page to 1 in the Settings &gt; Reading page in the admin area.</p>
1067
  <?php
1068
  }
1069
+
1070
  public function add_meta_box( $post )
1071
  {
1072
  $screen = get_current_screen();
1073
 
1074
  add_meta_box( 'soundy-meta-box',
1075
+ 'Soundy Background Music',
1076
  array( $this, 'render_meta_box' ),
1077
  $screen->post_type,
1078
  'normal',
1081
 
1082
  public function get_meta_data( $meta_data_name, $can_be_default = false )
1083
  {
1084
+ $meta_data = get_post_meta( $this->post_id, $meta_data_name, true );
1085
+
1086
+ if( $meta_data == 'no_value' )
1087
+ {
1088
+ $meta_data = '';
1089
+ }
1090
 
1091
  if( ( $meta_data == '' || $meta_data == 'default' ) && $can_be_default )
1092
  {
1096
  {
1097
  $meta_data = get_option( $meta_data_name );
1098
  }
 
 
 
 
 
1099
 
1100
  return $meta_data;
1101
  }
1133
  {
1134
  $audio_title_is_default = false;
1135
  }
1136
+
1137
+ include( sprintf( "%s/templates/meta-box.php", dirname( __FILE__ ) ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1138
  }
1139
 
1140
  public function save_post_data( $post_id )
1216
  public function insert_audio()
1217
  {
1218
  $this->post_id = get_the_ID();
1219
+
1220
+ $audio_file_url = $this->get_meta_data( 'war_soundy_audio_file_url' );
1221
 
1222
+ $preview = $_GET[ 'war_soundy_preview' ];
1223
+ if( $preview )
1224
+ {
1225
+ $this->preview = $preview;
1226
+ }
1227
+ else
1228
+ {
1229
+ $this->preview = 'false';
1230
+ $enable_bg_sound = $this->get_meta_data( 'war_soundy_enable_bg_sound' );
1231
+ if( $enable_bg_sound != 'yes' ) return;
1232
+ if( $audio_file_url == '' ) return;
1233
+ }
1234
+
1235
  if( $this->user_agent_is_mobile && $this->disable_soundy_for_mobile ) return;
1236
+
 
 
1237
  $audio_type = $this->get_audio_type_from_URL( $audio_file_url );
1238
 
1239
  $audio_volume = $this->get_meta_data( 'war_soundy_audio_volume' ) / 100;
1248
 
1249
  $audio_code =
1250
 
1251
+ '<div style="display: none;">' .
1252
+ ' <audio id="war_soundy_audio_player" preload="auto" ' . $auto_play . ' ' . $audio_loop . '>' .
1253
+ ' <source id="war_soundy_audio_player_source" src="' . $audio_file_url . '" type="audio/' . $audio_type . '">' .
1254
  ' </audio>' .
1255
  '</div>';
1256
 
1264
  <link rel="prefetch" href="<?php echo $this->hover_url_play; ?>">
1265
  <link rel="prefetch" href="<?php echo $this->hover_url_pause; ?>">
1266
  <script>
1267
+ var war_soundy_front_end = new war_SoundyFrontEnd(
1268
+ '<?php echo $pp_code; ?>',
1269
+ '<?php echo $audio_code; ?>',
1270
+ <?php echo $audio_volume; ?>,
1271
+ '<?php echo $this->preview; ?>',
1272
+ '<?php echo $this->button_url_play; ?>',
1273
+ '<?php echo $this->button_url_pause; ?>',
1274
+ '<?php echo $this->hover_url_play; ?>',
1275
+ '<?php echo $this->hover_url_pause; ?>',
1276
+ <?php echo $this->user_agent_is_IOS() ?>
1277
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1278
  </script>
1279
  <?php
1280
  }
1286
 
1287
  public function get_pp_button_code( $mode )
1288
  {
1289
+ if( $this->preview == 'false' )
1290
+ {
1291
+ $pp_images_to_use = $this->get_meta_data( 'war_soundy_pp_images_to_use' );
1292
+ if( $pp_images_to_use == 'designer' && $this->soundy_type != 'pro' && $this->soundy_subtype != 'full' )
1293
+ {
1294
+ $pp_images_to_use = 'default';
1295
+ }
1296
+
1297
+ if( $pp_images_to_use == 'none' ) return '';
1298
+
1299
+ $enable_bg_sound = $this->get_meta_data( 'war_soundy_enable_bg_sound' );
1300
+ if( $enable_bg_sound != 'yes' ) return '';
1301
+
1302
+ if( $pp_images_to_use == 'default' )
1303
+ {
1304
+ $this->button_url_play = get_option( 'war_soundy_url_play_button' );
1305
+ $this->hover_url_play = get_option( 'war_soundy_url_play_hover' );
1306
+ $this->button_url_pause = get_option( 'war_soundy_url_pause_button' );
1307
+ $this->hover_url_pause = get_option( 'war_soundy_url_pause_hover' );
1308
+ }
1309
+ }
1310
+ else
1311
+ {
1312
+ $this->button_url_play = '';
1313
+ $this->hover_url_play = '';
1314
+ $this->button_url_pause = '';
1315
+ $this->hover_url_pause = '';
1316
+ }
1317
 
1318
  $button_position = get_option( 'war_soundy_pp_position' );
1319
  $position = ( $button_position == 'document' ) ? 'absolute' : 'fixed';
1320
 
1321
  if( $mode == 'corner' )
1322
  {
1323
+ $button_corner = get_option( 'war_soundy_pp_corner' );
1324
  switch( $button_corner )
1325
  {
1326
  case upper_right:
1420
  return true;
1421
  }
1422
  }
1423
+ elseif( $type == 'firefox' )
1424
+ {
1425
+ if ( strpos( $user_agent, 'firefox' ) !== false )
1426
+ {
1427
+ return true;
1428
+ }
1429
+ }
1430
  return false;
1431
  }
1432
 
1456
  {
1457
  $pp_code = '<script>' .
1458
  'jQuery( "#war_soundy_audio_control" ).remove();' .
1459
+ 'war_soundy_front_end.pp_button_is_inserted = true;' .
1460
  '</script>' .
1461
  $pp_code;
1462
  }
templates/meta-box.php ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <script>
3
+ var war_soundy_admin = new war_SoundyAdmin(
4
+ 'meta_box',
5
+ {
6
+ default_audio_url: '<?php echo $default_audio_url; ?>',
7
+ default_audio_volume: '<?php echo $default_audio_volume; ?>',
8
+ default_audio_title: '<?php echo $default_audio_title; ?>'
9
+ } );
10
+ </script>
11
+ <table class="form-table war_soundy">
12
+ <tr>
13
+ <th class="war_soundy">
14
+ <label for="war_soundy_enable_bg_sound">Enable Background Sound</label>
15
+ </th>
16
+ <td>
17
+ <input type="radio"
18
+ id="war_soundy_enable_bg_sound_default"
19
+ name="war_soundy_enable_bg_sound"
20
+ value="default" <?php echo ( $enable_bg_sound == 'default' ? 'checked' : '' ); ?>/>
21
+ <label for="war_soundy_enable_bg_sound_default" style="margin-right: 1em;">Default</label>
22
+
23
+ <input type="radio"
24
+ id="war_soundy_enable_bg_sound_yes"
25
+ name="war_soundy_enable_bg_sound"
26
+ value="yes" <?php echo ( $enable_bg_sound == 'yes' ? 'checked' : '' ); ?>/>
27
+ <label for="war_soundy_enable_bg_sound_yes" style="margin-right: 1em;">Yes</label>
28
+
29
+ <input type="radio"
30
+ id="war_soundy_enable_bg_sound_no"
31
+ name="war_soundy_enable_bg_sound"
32
+ value="no" <?php echo ( $enable_bg_sound == 'no' ? 'checked' : '' ); ?>/>
33
+ <label for="war_soundy_enable_bg_sound_no" style="margin-right: 1em;">No</label>
34
+ </td>
35
+ </tr>
36
+ <tr>
37
+ <th class="war_soundy">
38
+ <label for="war_soundy_audio_file_url">Soundtrack</label>
39
+ </th>
40
+ <td>
41
+ <?php $this->add_field_audio_file_URL( true ); ?>
42
+ </td>
43
+ </tr>
44
+ <tr>
45
+ <th class="war_soundy">
46
+ <label for="war_soundy_audio_title">Audio Volume</label>
47
+ </th>
48
+ <td>
49
+ <div style="margin: 5px 5px 5px 0px">
50
+ <input type="radio"
51
+ id="war_soundy_audio_volume_default"
52
+ name="war_soundy_audio_volume_def"
53
+ value="default" <?php echo ( $audio_volume_is_default ? 'checked' : '' ); ?>/>
54
+ <label for="war_soundy_audio_volume_default" style="margin-right: 1em;">Default</label>
55
+
56
+ <input type="radio"
57
+ id="war_soundy_audio_volume_custom"
58
+ name="war_soundy_audio_volume_def"
59
+ value="custom" <?php echo ( $audio_volume_is_default ? '' : 'checked' ); ?>/>
60
+ <label for="war_soundy_audio_volume_custom" style="margin-right: 1em;">Custom</label>
61
+ </div>
62
+ <div id="war_soundy_audio_volume_slider" style="width: 300px; display: inline-block; margin: 0 10px 0 0;"></div>
63
+ <input type="text"
64
+ class="war_soundy_audio_volume"
65
+ value="<?php echo $audio_volume; ?>"
66
+ name="war_soundy_audio_volume"
67
+ id="war_soundy_audio_volume" /> %
68
+ </td>
69
+ </tr>
70
+ <tr>
71
+ <th class="war_soundy">
72
+ <label for="war_soundy_audio_title">Audio Title</label>
73
+ </th>
74
+ <td>
75
+ <div style="margin: 5px 5px 5px 0px">
76
+ <input type="radio"
77
+ id="war_soundy_audio_title_default"
78
+ name="war_soundy_audio_title_def"
79
+ value="default" <?php echo ( $audio_title_is_default ? 'checked' : '' ); ?>/>
80
+ <label for="war_soundy_audio_title_default" style="margin-right: 1em;">Default</label>
81
+
82
+ <input type="radio"
83
+ id="war_soundy_audio_title_custom"
84
+ name="war_soundy_audio_title_def"
85
+ value="custom" <?php echo ( $audio_title_is_default ? '' : 'checked' ); ?>/>
86
+ <label for="war_soundy_audio_title_custom" style="margin-right: 1em;">Custom</label>
87
+ </div>
88
+ <input type="text"
89
+ class="war_soundy_txt_input"
90
+ value="<?php echo $audio_title; ?>"
91
+ name="war_soundy_audio_title"
92
+ id="war_soundy_audio_title" />
93
+ </td>
94
+ </tr>
95
+ <tr>
96
+ <th class="war_soundy">
97
+ <label for="war_soundy_autoplay">Autoplay</label>
98
+ </th>
99
+ <td>
100
+ <input type="radio"
101
+ id="war_soundy_autoplay_default"
102
+ name="war_soundy_autoplay"
103
+ value="default" <?php echo ( $autoplay == 'default' ? 'checked' : '' ); ?>/>
104
+ <label for="war_soundy_autoplay_default" style="margin-right: 1em;">Default</label>
105
+
106
+ <input type="radio"
107
+ id="war_soundy_autoplay_yes"
108
+ name="war_soundy_autoplay"
109
+ value="yes" <?php echo ( $autoplay == 'yes' ? 'checked' : '' ); ?>/>
110
+ <label for="war_soundy_autoplay_yes" style="margin-right: 1em;">Yes</label>
111
+
112
+ <input type="radio"
113
+ id="war_soundy_autoplay_no"
114
+ name="war_soundy_autoplay"
115
+ value="no" <?php echo ( $autoplay == 'no' ? 'checked' : '' ); ?>/>
116
+ <label for="war_soundy_autoplay_no" style="margin-right: 1em;">No</label>
117
+ </td>
118
+ </tr>
119
+ <tr>
120
+ <th class="war_soundy">
121
+ <label for="war_soundy_loop">Audio Repeat Loop</label>
122
+ </th>
123
+ <td>
124
+ <input type="radio"
125
+ id="war_soundy_loop_default"
126
+ name="war_soundy_loop"
127
+ value="default" <?php echo ( $loop == 'default' ? 'checked' : '' ); ?>/>
128
+ <label for="war_soundy_loop_default" style="margin-right: 1em;">Default</label>
129
+
130
+ <input type="radio"
131
+ id="war_soundy_loop_yes"
132
+ name="war_soundy_loop"
133
+ value="yes" <?php echo ( $loop == 'yes' ? 'checked' : '' ); ?>/>
134
+ <label for="war_soundy_loop_yes" style="margin-right: 1em;">Yes</label>
135
+
136
+ <input type="radio"
137
+ id="war_soundy_loop_no"
138
+ name="war_soundy_loop"
139
+ value="no" <?php echo ( $loop == 'no' ? 'checked' : '' ); ?>/>
140
+ <label for="war_soundy_loop_no" style="margin-right: 1em;">No</label>
141
+ </td>
142
+ </tr>
143
+ </table>
144
+ <!--
145
+ <script>
146
+ function war_show()
147
+ {
148
+ var src = jQuery( '#war_soundy_audio_player_source' ).attr( 'src' );
149
+ var type = jQuery( '#war_soundy_audio_player_source' ).attr( 'type' );
150
+
151
+ alert( 'src = ' + src + ' \ntype = ' + type );
152
+ }
153
+ </script>
154
+ <h1 onclick="war_show();">CLICK</h1>
155
+ -->
templates/settings.php CHANGED
@@ -1,21 +1,43 @@
1
- <div class="wrap">
2
- <h2>Soundy Plugin Settings</h2>
 
 
 
 
 
 
 
3
 
4
- <p>All these settings are default settings for all pages and posts</p>
5
 
6
  <form method="post" action="options.php">
7
- <?php settings_fields( 'war_soundy' ); ?>
 
 
8
  <script>
9
- war_initTabs();
10
- war_initAudioVolume();
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  </script>
12
 
13
  <div id="war_soundy_tabs">
14
  <ul>
15
- <li><a href="#war_soundy_audio_track">Audio Track</a></li>
16
- <li><a href="#war_soundy_play_pause_button">Play/Pause Button</a></li>
17
- <li><a href="#war_soundy_play_pause_position_corner">Play/Pause Corner Position</a></li>
18
- <li><a href="#war_soundy_play_pause_position_static">Play/Pause Static Position</a></li>
19
  </ul>
20
  <div id="war_soundy_audio_track">
21
  <?php $this->do_settings_section( 'soundy', 'war_soundy_settings_section_audio_track' ); ?>
@@ -30,7 +52,7 @@
30
  <?php $this->do_settings_section( 'soundy', 'war_soundy_settings_section_play_pause_position_static' ); ?>
31
  </div>
32
  </div>
33
-
34
  <?php submit_button(); ?>
35
  </form>
36
  </div>
1
+ <div class="wrap">
2
+ <?php
3
+ $is_pro = 'false';
4
+ $is_trial = 'false';
5
+ $name = ' ';
6
+ $buy = '<button id="war_soundy_pro_buy" type="button" class="war_soundy" style="margin-left: 250px;">Try Soundy PRO For Free</button>';
7
+ $tip = '<span style="color: #2eaecc; margin-left: 125px;">Soundy PRO and its HTML5 Play/Pause Button Designer !</span>';
8
+ ?>
9
+ <h2>Soundy<?php echo $name; ?>Plugin Settings <?php echo $buy; ?></h2>
10
 
11
+ <p>All these settings are default settings for all pages and posts.<?php echo $tip; ?></p>
12
 
13
  <form method="post" action="options.php">
14
+ <?php
15
+ settings_fields( 'war_soundy' );
16
+ ?>
17
  <script>
18
+ var war_soundy_admin = new war_SoundyAdmin(
19
+ 'settings',
20
+ {
21
+ default_button_dimensions: '<?php echo $this->button_dimensions; ?>',
22
+ default_play_button_url: '<?php echo $this->play_button_url; ?>',
23
+ default_play_hover_url: '<?php echo $this->play_hover_url; ?>',
24
+ default_pause_button_url: '<?php echo $this->pause_button_url; ?>',
25
+ default_pause_hover_url: '<?php echo $this->pause_hover_url; ?>',
26
+ default_audio_url: '<?php echo $this->audio_url; ?>',
27
+ default_audio_title: '<?php echo str_replace( "&#039;", "\&#039;", $this->audio_title ); ?>',
28
+ default_audio_volume: '<?php echo $this->audio_volume; ?>',
29
+ is_pro: <?php echo $is_pro; ?>,
30
+ is_trial: <?php echo $is_trial; ?>,
31
+ soundy_pro_home_url: '<?php echo $this->soundy_pro_home_url; ?>'
32
+ } );
33
  </script>
34
 
35
  <div id="war_soundy_tabs">
36
  <ul>
37
+ <li><a id="war_soundy_tab_label_audio_track" href="#war_soundy_audio_track">Audio Track</a></li>
38
+ <li><a id="war_soundy_tab_label_play_pause_button" href="#war_soundy_play_pause_button">Play/Pause Button</a></li>
39
+ <li><a id="war_soundy_tab_label_play_pause_position_corner" href="#war_soundy_play_pause_position_corner">Play/Pause Corner Position</a></li>
40
+ <li><a id="war_soundy_tab_label_play_pause_position_static" href="#war_soundy_play_pause_position_static">Play/Pause Static Position</a></li>
41
  </ul>
42
  <div id="war_soundy_audio_track">
43
  <?php $this->do_settings_section( 'soundy', 'war_soundy_settings_section_audio_track' ); ?>
52
  <?php $this->do_settings_section( 'soundy', 'war_soundy_settings_section_play_pause_position_static' ); ?>
53
  </div>
54
  </div>
55
+
56
  <?php submit_button(); ?>
57
  </form>
58
  </div>