PageSourceSearch

https://marcoballetta.com/wp-content/plugins/soundy-background-music/js/front-end.js?ver=7.1.2

js marcoballetta.com collected 2026-10-06 13:15:24 UTC 13,630 bytes, 383 lines download raw bytes

1function war_SoundyFrontEnd( args )
2{
3	var _this = this;
4
5	_this.pp_code                 = args.pp_code;
6	_this.audio_code              = args.audio_code;
7	_this.audio_volume            = args.audio_volume;
8	_this.preview                 = args.preview;
9	_this.button_url_play_normal  = args.button_url_play_normal;
10	_this.button_url_pause_normal = args.button_url_pause_normal;
11	_this.button_url_play_hover   = args.button_url_play_hover;
12	_this.button_url_pause_hover  = args.button_url_pause_hover;
13	_this.user_agent_is_IOS       = args.user_agent_is_IOS;
14
15	_this.hovering                = false;
16
17    jQuery.noConflict();
18	jQuery( document ).ready( function()
19	{
20        if( _this.pp_code )
21        {
22            if( ! jQuery( '.war_soundy_audio_control.war_soundy_pp_corner' ).length )
23            {
24                jQuery( 'body' ).append( _this.pp_code );
25            }
26        }
27
28        if( ! jQuery( '#war_soundy_audio_player' ).length )
29        {
30            jQuery( 'body' ).append( _this.audio_code );
31        }
32
33		_this.audio_control = jQuery( '.war_soundy_audio_control' );
34		_this.audio_player  = jQuery( '#war_soundy_audio_player' );
35		_this.audio_player_element  = _this.audio_player[ 0 ];
36
37		_this.audio_player_element.volume = _this.audio_volume;
38
39		if( _this.preview != 'false' )
40		{
41			// Workaround for the preview player hanging:
42			var opener_player = window.opener.jQuery( '#war_soundy_audio_player' )[ 0 ];
43			opener_player.play();
44			opener_player.pause();
45
46            _this.button_url_play_normal  = window.opener.jQuery( '#war_soundy_url_play_button' ).val();
47            _this.button_url_pause_normal = window.opener.jQuery( '#war_soundy_url_pause_button' ).val();
48            _this.button_url_play_hover   = window.opener.jQuery( '#war_soundy_url_play_hover' ).val();
49            _this.button_url_pause_hover  = window.opener.jQuery( '#war_soundy_url_pause_hover' ).val();
50
51			if( _this.audio_player_element.autoplay )
52			{
53				_this.audio_player_element.load();
54				_this.audio_player_element.play();
55				_this.audio_control.attr( 'src', _this.button_url_pause_normal );
56			}
57			else
58			{
59				_this.audio_control.attr( 'src', _this.button_url_play_normal );
60			}
61			
62			var position = window.opener.jQuery( '#war_soundy_pp_position' ).children( 'option:selected' ).val();
63			if( position == 'document' )
64			{
65				_this.audio_control.css( 'position', 'absolute' );
66			}
67			else
68			{
69				_this.audio_control.css( 'position', 'fixed' );
70			}
71
72			var pp_corner = window.opener.jQuery( '#war_soundy_pp_corner' ).children( 'option:selected' ).val();
73			var offset_x  = window.opener.jQuery( '#war_soundy_offset_x' ).val() + window.opener.jQuery( '#war_soundy_offset_x_unit' ).val();
74			var offset_y  = window.opener.jQuery( '#war_soundy_offset_y' ).val() + window.opener.jQuery( '#war_soundy_offset_y_unit' ).val();
75			switch( pp_corner )
76			{
77				case 'upper_right': 
78					_this.audio_control.css( 'top',    offset_y );
79					_this.audio_control.css( 'right',  offset_x );
80					_this.audio_control.css( 'bottom', '' );
81					_this.audio_control.css( 'left',   '' );
82					break;
83				case 'upper_left': 
84					_this.audio_control.css( 'top',    offset_y );
85					_this.audio_control.css( 'right',  '' );
86					_this.audio_control.css( 'bottom', '' );
87					_this.audio_control.css( 'left',   offset_x );
88					break;
89				case 'bottom_right': 
90					_this.audio_control.css( 'top',    '' );
91					_this.audio_control.css( 'right',  offset_x );
92					_this.audio_control.css( 'bottom', offset_y );
93					_this.audio_control.css( 'left',   '' );
94					break;
95				case 'bottom_left': 
96					_this.audio_control.css( 'top',    '' );
97					_this.audio_control.css( 'right',  '' );
98					_this.audio_control.css( 'bottom', offset_y );
99					_this.audio_control.css( 'left',   offset_x );
100					break;
101			}
102		}
103
104        _this.initPPButtonAudio();
105
106        _this.audio_control.load( function()
107        {
108            _this.initPPButtonLayout();
109
110            jQuery( window ).resize( function()
111            {
112                _this.initPPButtonLayout();
113            } );
114        } );
115	} );
116}
117
118war_SoundyFrontEnd.prototype.animateVolume = function( audio_player_element, new_volume )
119{
120	var _this = this;
121	
122	var volume = audio_player_element.volume;
123	
124	function iterateVolume()
125	{
126		var volume_diff = Math.abs( volume - new_volume );
127		if( volume_diff > 0.1 && volume < new_volume )
128		{
129			volume += 0.1;
130		}
131		else if( volume_diff > 0.1 && volume > new_volume )
132		{
133			volume -= 0.1;
134		}
135		else
136		{
137			clearInterval( interval_id );
138			return;
139		}
140		audio_player_element.volume = volume;
141	}
142	
143	var interval_id = setInterval( iterateVolume, 400 );
144}
145
146war_SoundyFrontEnd.prototype.initPPButtonAudio = function()
147{
148    var _this = this;
149
150    if( _this.audio_player_element.paused )
151    {
152        _this.audio_control.attr( 'src', _this.button_url_play_normal );
153    }
154    else
155    {
156        _this.audio_control.attr( 'src', _this.button_url_pause_normal );
157    }
158
159    _this.audio_control.click(
160        function()
161        {
162            if( _this.audio_player_element.paused )
163            {
164                _this.audio_player_element.play();
165                _this.audio_control.attr( 'src', _this.button_url_pause_hover );
166            }
167            else
168            {
169                _this.audio_player_element.pause();
170                _this.audio_control.attr( 'src', _this.button_url_play_hover );
171            }
172        } );
173
174    _this.audio_control.hover(
175        function()
176        {
177            _this.hovering = true;
178            if( _this.audio_player_element.paused )
179            {
180                _this.audio_control.attr( 'src', _this.button_url_play_hover );
181            }
182            else
183            {
184                _this.audio_control.attr( 'src', _this.button_url_pause_hover );
185            }
186        },
187        function()
188        {
189            _this.hovering = false;
190            if( _this.audio_player_element.paused )
191            {
192                _this.audio_control.attr( 'src', _this.button_url_play_normal );
193            }
194            else
195            {
196                _this.audio_control.attr( 'src', _this.button_url_pause_normal );
197            }
198        }
199    );
200
201    _this.audio_player.bind( 'ended' , function()
202    {
203        if( _this.hovering )
204        {
205            _this.audio_control.attr( 'src', _this.button_url_play_hover );
206        }
207        else
208        {
209            _this.audio_control.attr( 'src', _this.button_url_play_normal );
210        }
211    } );
212
213    _this.audio_player.bind( 'play' , function()
214    {
215        if( _this.hovering )
216        {
217            _this.audio_control.attr( 'src', _this.button_url_pause_hover );
218        }
219        else
220        {
221            _this.audio_control.attr( 'src', _this.button_url_pause_normal );
222        }
223    } );
224
225    if( _this.audio_player_element.autoplay )
226    {
227        if( _this.user_agent_is_IOS )
228        {
229            if( _this.hovering )
230            {
231                _this.audio_control.attr( 'src', _this.button_url_play_hover );
232            }
233            else
234            {
235                _this.audio_control.attr( 'src', _this.button_url_play_normal );
236            }
237        }
238    }
239}
240
241war_SoundyFrontEnd.prototype.initPPButtonLayout = function()
242{
243    var _this = this;
244
245    if( ! _this.audio_control.length ) return;
246
247    if( _this.is_audio_control_width_and_height_set == null )
248    {
249        _this.button_width  = _this.audio_control.prop( 'width' );
250        if( _this.button_width == 0 ) return;
251
252        _this.button_height = _this.audio_control.prop( 'height' );
253        _this.button_aspect_ratio = _this.button_height / _this.button_width;
254
255        _this.is_audio_control_width_and_height_set = true;
256    }
257
258    if( war_soundy_responsive_mode != 'none' )
259    {
260        var window_width = jQuery( window ).width();
261
262        switch( war_soundy_button_corner )
263        {
264            case 'upper_right':
265            default:
266                var prop_x = 'right';
267                var prop_y = 'top';
268                break;
269            case 'upper_left':
270                var prop_x = 'left';
271                var prop_y = 'top';
272                break;
273            case 'bottom_right':
274                var prop_x = 'right';
275                var prop_y = 'bottom';
276                break;
277            case 'bottom_left':
278                var prop_x = 'left';
279                var prop_y = 'bottom';
280                break;
281        }
282
283        if( war_soundy_responsive_mode == 'table' )
284        {
285            for( var index in war_soundy_responsive_table_rows )
286            {
287                var row = war_soundy_responsive_table_rows[ index ];
288                if( row.button_width != -1 )
289                {
290                    if( row.window_width_min != -1 && row.window_width_max != -1 )
291                    {
292                        if( row.window_width_min <= window_width && window_width <= row.window_width_max )
293                        {
294                            _this.audio_control.css( 'width', row.button_width );
295                            _this.audio_control.css( 'height', Math.round( row.button_width * _this.button_aspect_ratio ) );
296                        }
297                    }
298                    else if( row.window_width_min != -1 )
299                    {
300                        if( row.window_width_min <= window_width )
301                        {
302                            _this.audio_control.css( 'width', row.button_width );
303                            _this.audio_control.css( 'height', Math.round( row.button_width * _this.button_aspect_ratio ) );
304                        }
305                    }
306                    else if( row.window_width_max != -1 )
307                    {
308                        if( window_width <= row.window_width_max )
309                        {
310                            _this.audio_control.css( 'width', row.button_width );
311                            _this.audio_control.css( 'height', Math.round( row.button_width * _this.button_aspect_ratio ) );
312                        }
313                    }
314                }
315            }
316
317            if( jQuery( '.war_soundy_audio_control.war_soundy_pp_corner' ).length )
318            {
319                for( var index in war_soundy_responsive_table_rows )
320                {
321                    var row = war_soundy_responsive_table_rows[ index ];
322                    if( row.offset_x != -1 || row.offset_y != -1 )
323                    {
324                        if( row.window_width_min != -1 && row.window_width_max != -1 )
325                        {
326                            if( row.window_width_min <= window_width && window_width <= row.window_width_max )
327                            {
328                                if( row.offset_x != -1 ) jQuery( '.war_soundy_audio_control.war_soundy_pp_corner' ).css( prop_x, row.offset_x );
329                                if( row.offset_y != -1 ) jQuery( '.war_soundy_audio_control.war_soundy_pp_corner' ).css( prop_y, row.offset_y );
330                            }
331                        }
332                        else if( row.window_width_min != -1 )
333                        {
334                            if( row.window_width_min <= window_width )
335                            {
336                                if( row.offset_x != -1 ) jQuery( '.war_soundy_audio_control.war_soundy_pp_corner' ).css( prop_x, row.offset_x );
337                                if( row.offset_y != -1 ) jQuery( '.war_soundy_audio_control.war_soundy_pp_corner' ).css( prop_y, row.offset_y );
338                            }
339                        }
340                        else if( row.window_width_max != -1 )
341                        {
342                            if( window_width <= row.window_width_max )
343                            {
344                                if( row.offset_x != -1 ) jQuery( '.war_soundy_audio_control.war_soundy_pp_corner' ).css( prop_x, row.offset_x );
345                                if( row.offset_y != -1 ) jQuery( '.war_soundy_audio_control.war_soundy_pp_corner' ).css( prop_y, row.offset_y );
346                            }
347                        }
348                    }
349                }
350            }
351        }
352        else // if( war_soundy_responsive_mode == 'scale' )
353        {
354            var scale_factor = ( window_width * 0.7 / war_soundy_responsive_reference_window_width ) + 0.3;
355
356            var responsive_button_width = Math.round( _this.button_width * scale_factor );
357            _this.audio_control.width( responsive_button_width );
358            _this.audio_control.height( Math.round( responsive_button_width * _this.button_aspect_ratio ) );
359
360            var jquery_corner_button = jQuery( '.war_soundy_audio_control.war_soundy_pp_corner' );
361            if( jquery_corner_button.length )
362            {
363                if( _this.is_button_offsets_set == null )
364                {
365                    _this.button_offset_x = jquery_corner_button.css( prop_x );
366                    _this.button_offset_y = jquery_corner_button.css( prop_y );
367
368                    _this.is_button_offsets_set = true;
369                }
370
371                var offset_x = _this.button_offset_x;
372                offset_x = offset_x.replace( 'px', '' );
373                var offset_y = _this.button_offset_y;
374                offset_y = offset_y.replace( 'px', '' );
375                var responsive_offset_x = Math.round( offset_x * scale_factor );
376                var responsive_offset_y = Math.round( offset_y * scale_factor );
377
378                jquery_corner_button.css( prop_x, responsive_offset_x );
379                jquery_corner_button.css( prop_y, responsive_offset_y );
380            }
381        }
382    }
383}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.