PageSourceSearch

https://true.ag/wp-content/plugins/google-language-translator-premium/js/scripts.js?ver=5.0.44

js true.ag collected 2026-10-07 20:00:21 UTC 17,213 bytes, 518 lines download raw bytes

1jQuery(document).ready(function($) {
2  $("#language.auto-language-translation .selected").click (function(event) {
3	event.preventDefault();
4    $("#language.auto-language-translation .option").slideToggle(); 
5  });
6  
7  $("#language.manual-language-translation .selected").click (function(event) {
8	event.preventDefault();
9	$("#language.manual-language-translation .option").slideToggle();
10  });
11
12  $("#language.auto-language-translation .option").click (function(event) {
13	//event.preventDefault();
14	$(this).slideToggle();
15  });
16				
17  $("#language.auto-language-translation .option").mouseleave (function() {
18	$(this).slideUp();
19  });
20
21  $("#language.auto-language-translation .switcher").mouseleave (function() { 
22    $("#language.auto-language-translation .option").slideUp();
23  });
24				
25  $("#language.auto-language-translation .switcher").mouseleave (function() {
26    $("#language.auto-language-translation .option").slideUp();
27  });
28});
29
30//Floating Widget
31jQuery(document).ready(function($) {	
32  $('#glt-translate-trigger.toolbar-click,#glt-translate-trigger.toolbar-click font').toolbar({
33    content: '#flags', 
34    position: 'top', 
35    hideOnClick: true, 
36    event: 'click',
37    style: 'primary',
38  });
39	
40  $('#glt-translate-trigger.toolbar-onload,#glt-translate-trigger.toolbar-onload font').toolbar({
41    content: '#flags', 
42    position: 'top', 
43    event: 'onload',
44    style: 'primary',
45  });
46
47  $('#glt-translate-trigger.toolbar-click').on('toolbarItemClick',function(event) {
48    $(this).removeClass('pressed');
49  });
50}); //jQuery
51
52/**
53 * Toolbar.js
54 *
55 * @fileoverview  jQuery plugin that creates tooltip style toolbars.
56 * @link          http://paulkinzett.github.com/toolbar/
57 * @author        Paul Kinzett (http://kinzett.co.nz/)
58 * @version       1.1.0
59 * @requires      jQuery 1.7+
60 *
61 * @license jQuery Toolbar Plugin v1.1.0
62 * http://paulkinzett.github.com/toolbar/
63 * Copyright 2013 - 2015 Paul Kinzett (http://kinzett.co.nz/)
64 * Released under the MIT license.
65 * <https://raw.github.com/paulkinzett/toolbar/master/LICENSE.txt>
66 */
67
68if ( typeof Object.create !== 'function' ) {
69    Object.create = function( obj ) {
70        function F() {}
71        F.prototype = obj;
72        return new F();
73    };
74}
75
76(function( $, window, document, undefined ) {
77
78    var ToolBar = {
79        init: function( options, elem ) {
80            var self = this;
81            self.elem = elem;
82            self.$elem = $( elem );
83            self.options = $.extend( {}, $.fn.toolbar.options, options );
84            self.metadata = self.$elem.data();
85            self.overrideOptions();
86            self.toolbar = $('<div class="tool-container" />')
87                .addClass('tool-'+self.options.position)
88                .addClass('toolbar-'+self.options.style)
89                .append('<div class="tool-items" />')
90                .append('<div class="arrow" />')
91                .appendTo('body')
92                .css('opacity', 0)
93                .hide();
94            self.toolbar_arrow = self.toolbar.find('.arrow');
95            self.initializeToolbar();
96        },
97
98        overrideOptions: function() {
99            var self = this;
100
101            $.each( self.options, function( $option ) {
102                if (typeof(self.$elem.data('toolbar-'+$option)) != "undefined") {
103                    self.options[$option] = self.$elem.data('toolbar-'+$option);
104                }
105            });
106        },
107
108        initializeToolbar: function() {
109            var self = this;
110            self.populateContent();
111            self.setTrigger();
112            self.toolbarWidth = self.toolbar.width();
113        },
114
115        setTrigger: function() {
116            var self = this;
117			
118			if (self.options.event == 'onload') {
119                $(window).load(function(event) {
120                    event.preventDefault();
121                    self.show();
122                });
123			}
124
125            if (self.options.event == 'click') {
126                self.$elem.on('click', function(event) {
127                    event.preventDefault();
128                    if(self.$elem.hasClass('pressed')) {
129                        self.hide();
130                    } else {
131                        self.show();
132                    }
133                });
134
135                if (self.options.hideOnClick) {
136                    $('html').on("click.toolbar", function ( event ) {
137                        if (event.target != self.elem &&
138                            self.$elem.has(event.target).length === 0 &&
139                            self.toolbar.has(event.target).length === 0 &&
140                            self.toolbar.is(":visible")) {
141                            self.hide();
142                        }
143                    });
144                }
145            }
146
147            if (self.options.hover) {
148                var moveTime;
149
150                function decideTimeout () {
151                    if (self.$elem.hasClass('pressed')) {
152                        moveTime = setTimeout(function() {
153                            self.hide();
154                        }, 150);
155                    } else {
156                        clearTimeout(moveTime);
157                    };
158                };
159
160                self.$elem.on({
161                    mouseenter: function(event) {
162                        if (self.$elem.hasClass('pressed')) {
163                            clearTimeout(moveTime);
164                        } else {
165                            self.show();
166                        }
167                    }
168                });
169
170                self.$elem.parent().on({
171                    mouseleave: function(event){ decideTimeout(); }
172                });
173
174                $('.tool-container').on({
175                    mouseenter: function(event){ clearTimeout(moveTime); },
176                    mouseleave: function(event){ decideTimeout(); }
177                });
178            }
179
180            $(window).resize(function( event ) {
181                event.stopPropagation();
182
183                if ( self.toolbar.is(":visible") ) {
184                    self.toolbarCss = self.getCoordinates(self.options.position, 20);
185                    self.collisionDetection();
186                    self.toolbar.css( self.toolbarCss );
187                    self.toolbar_arrow.css( self.arrowCss );
188                }
189            });
190        },
191
192        populateContent: function() {
193            var self = this;
194            var location = self.toolbar.find('.tool-items');
195            var content = $(self.options.content).clone( true ).find('a').addClass('tool-item');
196
197            location.html(content);
198            location.find('.tool-item').on('click', function(event) {
199                event.preventDefault();
200                self.$elem.trigger('toolbarItemClick', this);
201            });
202        },
203
204        calculatePosition: function() {
205            var self = this;
206                self.arrowCss = {};
207                self.toolbarCss = self.getCoordinates(self.options.position, self.options.adjustment);
208                self.toolbarCss.position = 'fixed';
209                self.toolbarCss.zIndex = self.options.zIndex;
210                self.collisionDetection();
211                self.toolbar.css(self.toolbarCss);
212                self.toolbar_arrow.css(self.arrowCss);
213        },
214
215        getCoordinates: function( position, adjustment ) {
216            var self = this;
217
218            self.coordinates = self.$elem.offset();
219
220            if (self.options.adjustment && self.options.adjustment[self.options.position]) {
221                adjustment = self.options.adjustment[self.options.position] + adjustment;
222            }
223
224            switch(self.options.position) {
225                case 'top':
226                    return {
227                        left: self.coordinates.left-(self.toolbar.width()/2)+(self.$elem.outerWidth()/2),
228                        top: self.coordinates.top-self.$elem.outerHeight()-adjustment,
229                        right: 'auto'
230                    };
231
232                case 'left':
233                    return {
234                        left: self.coordinates.left-(self.toolbar.width()/2)-(self.$elem.outerWidth()/2)-adjustment,
235                        top: self.coordinates.top-(self.toolbar.height()/2)+(self.$elem.outerHeight()/2),
236                        right: 'auto'
237                    };
238
239                case 'right':
240                    return {
241                        left: self.coordinates.left+(self.toolbar.width()/2)+(self.$elem.outerWidth()/2)+adjustment,
242                        top: self.coordinates.top-(self.toolbar.height()/2)+(self.$elem.outerHeight()/2),
243                        right: 'auto'
244                    };
245
246                case 'bottom':
247                    return {
248                        left: self.coordinates.left-(self.toolbar.width()/2)+(self.$elem.outerWidth()/2),
249                        top: self.coordinates.top+self.$elem.outerHeight()+adjustment,
250                        right: 'auto'
251                    };
252            }
253        },
254
255        collisionDetection: function() {
256            var self = this;
257            var edgeOffset = 20;
258
259            if(self.options.position == 'top' || self.options.position == 'bottom') {
260                self.arrowCss = {left: '50%', right: '50%'};
261                if( self.toolbarCss.left < edgeOffset ) {
262                    self.toolbarCss.left = edgeOffset;
263                    self.arrowCss.left = self.$elem.offset().left + self.$elem.width()/2-(edgeOffset);
264                }
265
266                else if(($(window).width() - (self.toolbarCss.left + self.toolbarWidth)) < edgeOffset) {
267                    self.toolbarCss.right = edgeOffset;
268                    self.toolbarCss.left = 'auto';
269                    self.arrowCss.left = 'auto';
270                    self.arrowCss.right = ($(window).width()-self.$elem.offset().left)-(self.$elem.width()/2)-(edgeOffset)-5;
271                }
272            }
273        },
274
275        show: function() {
276            var self = this;
277            self.$elem.addClass('pressed');
278            self.calculatePosition();
279            self.toolbar.show().css({'opacity': 1}).addClass('animate-'+self.options.animation);
280            self.$elem.trigger('toolbarShown');
281        },
282		
283		hide: function() {
284            var self = this;
285            var animation = {'opacity': 0};
286            self.$elem.removeClass('pressed');
287            switch(self.options.position) {
288                case 'top':
289                    animation.top = '+=20';
290                    break;
291                case 'left':
292                    animation.left = '+=20';
293                    break;
294                case 'right':
295                    animation.left = '-=20';
296                    break;
297                case 'bottom':
298                    animation.top = '-=20';
299                    break;
300            }
301            self.toolbar.animate(animation, 200, function() {
302                self.toolbar.hide();
303            });
304            self.$elem.trigger('toolbarHidden');
305        },
306
307        getToolbarElement: function () {
308            return this.toolbar.find('.tool-items');
309        }
310    };
311
312    $.fn.toolbar = function( options ) {
313        if ($.isPlainObject( options )) {
314            return this.each(function() {
315                var toolbarObj = Object.create( ToolBar );
316                toolbarObj.init( options, this );
317                $(this).data('toolbarObj', toolbarObj);
318            });
319        } else if ( typeof options === 'string' && options.indexOf('_') !== 0 ) {
320            var toolbarObj = $(this).data('toolbarObj');
321            var method = toolbarObj[options];
322            return method.apply(toolbarObj, $.makeArray(arguments).slice(1));
323        }
324    };
325
326    $.fn.toolbar.options = {
327        content: '#myContent',
328        position: 'top',
329        hideOnClick: false,
330        zIndex: 120,
331        hover: false,
332        style: 'default',
333        animation: 'standard',
334        adjustment: 10
335    };
336}) ( jQuery, window, document );
337
338
339
340/*!
341 * jQuery Cookie Plugin v1.4.1
342 * https://github.com/carhartl/jquery-cookie
343 *
344 * Copyright 2013 Klaus Hartl
345 * Released under the MIT license
346 */
347(function (factory) {
348	if (typeof define === 'function' && define.amd) {
349		// AMD
350		define(['jquery'], factory);
351	} else if (typeof exports === 'object') {
352		// CommonJS
353		factory(require('jquery'));
354	} else {
355		// Browser globals
356		factory(jQuery);
357	}
358}(function ($) {
359
360	var pluses = /\+/g;
361
362	function encode(s) {
363		return config.raw ? s : encodeURIComponent(s);
364	}
365
366	function decode(s) {
367		return config.raw ? s : decodeURIComponent(s);
368	}
369
370	function stringifyCookieValue(value) {
371		return encode(config.json ? JSON.stringify(value) : String(value));
372	}
373
374	function parseCookieValue(s) {
375		if (s.indexOf('"') === 0) {
376			// This is a quoted cookie as according to RFC2068, unescape...
377			s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
378		}
379
380		try {
381			// Replace server-side written pluses with spaces.
382			// If we can't decode the cookie, ignore it, it's unusable.
383			// If we can't parse the cookie, ignore it, it's unusable.
384			s = decodeURIComponent(s.replace(pluses, ' '));
385			return config.json ? JSON.parse(s) : s;
386		} catch(e) {}
387	}
388
389	function read(s, converter) {
390		var value = config.raw ? s : parseCookieValue(s);
391		return $.isFunction(converter) ? converter(value) : value;
392	}
393
394	var config = $.cookie = function (key, value, options) {
395
396		// Write
397
398		if (value !== undefined && !$.isFunction(value)) {
399			options = $.extend({}, config.defaults, options);
400
401			if (typeof options.expires === 'number') {
402				var days = options.expires, t = options.expires = new Date();
403				t.setTime(+t + days * 864e+5);
404			}
405
406			return (document.cookie = [
407				encode(key), '=', stringifyCookieValue(value),
408				options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
409				options.path    ? '; path=' + options.path : '',
410				options.domain  ? '; domain=' + options.domain : '',
411				options.secure  ? '; secure' : ''
412			].join(''));
413		}
414
415		// Read
416
417		var result = key ? undefined : {};
418
419		// To prevent the for loop in the first place assign an empty array
420		// in case there are no cookies at all. Also prevents odd result when
421		// calling $.cookie().
422		var cookies = document.cookie ? document.cookie.split('; ') : [];
423
424		for (var i = 0, l = cookies.length; i < l; i++) {
425			var parts = cookies[i].split('=');
426			var name = decode(parts.shift());
427			var cookie = parts.join('=');
428
429			if (key && key === name) {
430				// If second argument (value) is a function it's a converter...
431				result = read(cookie, value);
432				break;
433			}
434
435			// Prevent storing a cookie that we couldn't decode.
436			if (!key && (cookie = read(cookie)) !== undefined) {
437				result[name] = cookie;
438			}
439		}
440
441		return result;
442	};
443
444	config.defaults = {};
445
446	$.removeCookie = function (key, options) {
447		if ($.cookie(key) === undefined) {
448			return false;
449		}
450
451		// Must not alter options, thus extending a fresh object...
452		$.cookie(key, '', $.extend({}, options, { expires: -1 }));
453		return !$.cookie(key);
454	};
455
456}));
457
458
459
460/*-------------------------------------------------------------------------------*
461 * Script for onClick trigger functionality used by flag images
462 * Script modified from original GTranslate plugin created by Edvard Ananyan at http://edo.webmaster.am
463 * GTranslate Free Version is licensed under GNU/GPL license
464 *-------------------------------------------------------------------------------*/
465
466/* <![CDATA[ */
467function GLTFireEvent(lang_pair, lang_dest) {
468    try {
469        if (document.createEvent) {
470            var event = document.createEvent("HTMLEvents");
471            event.initEvent(lang_dest, true, true);
472            lang_pair.dispatchEvent(event)
473        } else {
474            var event = document.createEventObject();
475            lang_pair.fireEvent('on' + lang_dest, event)
476        }
477    } catch (e) {}
478}
479
480function doGoogleLanguageTranslator(lang_pair) {
481    if (lang_pair.value) lang_pair = lang_pair.value;
482    if (lang_pair == '') return;
483    var lang_dest = lang_pair.split('|')[1];
484    var event =  '';
485    var classic = jQuery('.goog-te-combo');
486    var simple = jQuery('.goog-te-menu-frame:first');
487    var simpleValue = simple.contents().find('.goog-te-menu2-item span.text:contains('+lang_text+')'); 
488    
489    if (classic.length == 0) {
490      for (var i = 0; i < simple.length; i++) {
491        event = simple[i];
492        //alert('Simple is active.');
493      }
494    } else {
495      for (var i = 0; i < classic.length; i++) {
496        event = classic[i]; 
497        //alert('Classic is active.');
498      }
499    }
500    if (document.getElementById('google_language_translator') != null) {
501      if (classic.length != 0) {
502        if (lang_prefix != default_lang) {
503          event.value = lang_dest;
504          GLTFireEvent(event, 'change');
505        } else {
506          jQuery('.goog-te-banner-frame:first').contents().find('.goog-close-link').get(0).click();
507        }
508      } else {
509        event.value = lang_dest; 
510        if (lang_prefix != default_lang) {
511          simpleValue.click(); 
512        } else {
513          //jQuery('.goog-te-banner-frame:first').contents().find('.goog-close-link').get(0).click();
514        }       
515      }  
516    }
517}
518/* ]]> */

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.