PageSourceSearch

https://gigisplayhouse.org/wp-content/plugins/google-language-translator/js/scripts.js?ver=7.0.1

js gigisplayhouse.org collected 2026-09-24 08:52:04 UTC 11,945 bytes, 335 lines download raw bytes

1/* wrapper for doGTranslate function from https://gtranslate.com */
2function doGoogleLanguageTranslator(lang_pair) {
3    if(window.glt_request_uri)
4        return true;
5
6    doGTranslate(lang_pair);
7}
8
9jQuery(document).ready(function($) {
10  $('#glt-translate-trigger,#glt-translate-trigger font').toolbar({
11    content: '#flags',
12    position: 'top',
13    hideOnClick: true,
14    event: 'click',
15    style: 'primary'
16  });
17
18  $('#glt-translate-trigger').on('toolbarItemClick',function(event) {
19    $(this).removeClass('pressed');
20  });
21});
22
23/**
24 * Toolbar.js
25 *
26 * @fileoverview  jQuery plugin that creates tooltip style toolbars.
27 * @link          http://paulkinzett.github.com/toolbar/
28 * @author        Paul Kinzett (http://kinzett.co.nz/)
29 * @version       1.1.0
30 * @requires      jQuery 1.7+
31 *
32 * @license jQuery Toolbar Plugin v1.1.0
33 * http://paulkinzett.github.com/toolbar/
34 * Copyright 2013 - 2015 Paul Kinzett (http://kinzett.co.nz/)
35 * Released under the MIT license.
36 * <https://raw.github.com/paulkinzett/toolbar/master/LICENSE.txt>
37 */
38
39if ( typeof Object.create !== 'function' ) {
40    Object.create = function( obj ) {
41        function F() {}
42        F.prototype = obj;
43        return new F();
44    };
45}
46
47(function( $, window, document, undefined ) {
48
49    var ToolBar = {
50        init: function( options, elem ) {
51            var self = this;
52            self.elem = elem;
53            self.$elem = $( elem );
54            self.options = $.extend( {}, $.fn.toolbar.options, options );
55            self.metadata = self.$elem.data();
56            self.overrideOptions();
57            self.toolbar = $('<div class="tool-container" />')
58                .addClass('tool-'+self.options.position)
59                .addClass('toolbar-'+self.options.style)
60                .append('<div class="tool-items" />')
61                .append('<div class="arrow" />')
62                .appendTo('body')
63                .css('opacity', 0)
64                .hide();
65            self.toolbar_arrow = self.toolbar.find('.arrow');
66            self.initializeToolbar();
67        },
68
69        overrideOptions: function() {
70            var self = this;
71
72            $.each( self.options, function( $option ) {
73                if (typeof(self.$elem.data('toolbar-'+$option)) != "undefined") {
74                    self.options[$option] = self.$elem.data('toolbar-'+$option);
75                }
76            });
77        },
78
79        initializeToolbar: function() {
80            var self = this;
81            self.populateContent();
82            self.setTrigger();
83            self.toolbarWidth = self.toolbar.width();
84        },
85
86        setTrigger: function() {
87            var self = this;
88
89            if (self.options.event == 'onload') {
90                $(window).load(function(event) {
91                    event.preventDefault();
92                    self.show();
93                });
94            }
95
96            if (self.options.event == 'click') {
97                self.$elem.on('click', function(event) {
98                    event.preventDefault();
99                    if(self.$elem.hasClass('pressed')) {
100                        self.hide();
101                    } else {
102                        self.show();
103                    }
104                });
105
106                if (self.options.hideOnClick) {
107                    $('html').on("click.toolbar", function ( event ) {
108                        if (event.target != self.elem &&
109                            self.$elem.has(event.target).length === 0 &&
110                            self.toolbar.has(event.target).length === 0 &&
111                            self.toolbar.is(":visible")) {
112                            self.hide();
113                        }
114                    });
115                }
116            }
117
118            if (self.options.hover) {
119                var moveTime;
120
121                function decideTimeout () {
122                    if (self.$elem.hasClass('pressed')) {
123                        moveTime = setTimeout(function() {
124                            self.hide();
125                        }, 150);
126                    } else {
127                        clearTimeout(moveTime);
128                    };
129                };
130
131                self.$elem.on({
132                    mouseenter: function(event) {
133                        if (self.$elem.hasClass('pressed')) {
134                            clearTimeout(moveTime);
135                        } else {
136                            self.show();
137                        }
138                    }
139                });
140
141                self.$elem.parent().on({
142                    mouseleave: function(event){ decideTimeout(); }
143                });
144
145                $('.tool-container').on({
146                    mouseenter: function(event){ clearTimeout(moveTime); },
147                    mouseleave: function(event){ decideTimeout(); }
148                });
149            }
150
151            $(window).resize(function( event ) {
152                event.stopPropagation();
153
154                if ( self.toolbar.is(":visible") ) {
155                    self.toolbarCss = self.getCoordinates(self.options.position, 20);
156                    self.collisionDetection();
157                    self.toolbar.css( self.toolbarCss );
158                    self.toolbar_arrow.css( self.arrowCss );
159                }
160            });
161        },
162
163        populateContent: function() {
164            var self = this;
165            var location = self.toolbar.find('.tool-items');
166            var content = $(self.options.content).clone( true ).find('a').addClass('tool-item');
167
168            location.html(content);
169            location.find('.tool-item').on('click', function(event) {
170                if(typeof window.glt_request_uri == 'undefined')
171                    event.preventDefault();
172                self.$elem.trigger('toolbarItemClick', this);
173            });
174        },
175
176        calculatePosition: function() {
177            var self = this;
178                self.arrowCss = {};
179                self.toolbarCss = self.getCoordinates(self.options.position, self.options.adjustment);
180                self.toolbarCss.position = 'fixed';
181                self.toolbarCss.zIndex = self.options.zIndex;
182                self.collisionDetection();
183                self.toolbar.css(self.toolbarCss);
184                self.toolbar_arrow.css(self.arrowCss);
185        },
186
187        getCoordinates: function( position, adjustment ) {
188            var self = this;
189
190            self.coordinates = self.$elem.offset();
191
192            if (self.options.adjustment && self.options.adjustment[self.options.position]) {
193                adjustment = self.options.adjustment[self.options.position] + adjustment;
194            }
195
196            switch(self.options.position) {
197                case 'top':
198                    return {
199                        left: self.coordinates.left-(self.toolbar.width()/2)+(self.$elem.outerWidth()/2),
200                        top: self.coordinates.top-self.$elem.outerHeight()-adjustment,
201                        right: 'auto'
202                    };
203
204                case 'left':
205                    return {
206                        left: self.coordinates.left-(self.toolbar.width()/2)-(self.$elem.outerWidth()/2)-adjustment,
207                        top: self.coordinates.top-(self.toolbar.height()/2)+(self.$elem.outerHeight()/2),
208                        right: 'auto'
209                    };
210
211                case 'right':
212                    return {
213                        left: self.coordinates.left+(self.toolbar.width()/2)+(self.$elem.outerWidth()/2)+adjustment,
214                        top: self.coordinates.top-(self.toolbar.height()/2)+(self.$elem.outerHeight()/2),
215                        right: 'auto'
216                    };
217
218                case 'bottom':
219                    return {
220                        left: self.coordinates.left-(self.toolbar.width()/2)+(self.$elem.outerWidth()/2),
221                        top: self.coordinates.top+self.$elem.outerHeight()+adjustment,
222                        right: 'auto'
223                    };
224            }
225        },
226
227        collisionDetection: function() {
228            var self = this;
229            var edgeOffset = 20;
230
231            if(self.options.position == 'top' || self.options.position == 'bottom') {
232                self.arrowCss = {left: '50%', right: '50%'};
233                if( self.toolbarCss.left < edgeOffset ) {
234                    self.toolbarCss.left = edgeOffset;
235                    self.arrowCss.left = self.$elem.offset().left + self.$elem.width()/2-(edgeOffset);
236                }
237
238                else if(($(window).width() - (self.toolbarCss.left + self.toolbarWidth)) < edgeOffset) {
239                    self.toolbarCss.right = edgeOffset;
240                    self.toolbarCss.left = 'auto';
241                    self.arrowCss.left = 'auto';
242                    self.arrowCss.right = ($(window).width()-self.$elem.offset().left)-(self.$elem.width()/2)-(edgeOffset)-5;
243                }
244            }
245        },
246
247        show: function() {
248            var self = this;
249            self.$elem.addClass('pressed');
250            self.calculatePosition();
251            self.toolbar.show().css({'opacity': 1}).addClass('animate-'+self.options.animation);
252            self.$elem.trigger('toolbarShown');
253
254            // lazy load library
255            var e = document.querySelector('#google_language_translator');
256            if(e)
257                e.dispatchEvent(new FocusEvent('focusin', {bubbles: true}));
258        },
259
260        hide: function() {
261            var self = this;
262            var animation = {'opacity': 0};
263            self.$elem.removeClass('pressed');
264            switch(self.options.position) {
265                case 'top':
266                    animation.top = '+=20';
267                    break;
268                case 'left':
269                    animation.left = '+=20';
270                    break;
271                case 'right':
272                    animation.left = '-=20';
273                    break;
274                case 'bottom':
275                    animation.top = '-=20';
276                    break;
277            }
278            self.toolbar.animate(animation, 200, function() {
279                self.toolbar.hide();
280            });
281            self.$elem.trigger('toolbarHidden');
282        },
283
284        getToolbarElement: function () {
285            return this.toolbar.find('.tool-items');
286        }
287    };
288
289    $.fn.toolbar = function( options ) {
290        if ($.isPlainObject( options )) {
291            return this.each(function() {
292                var toolbarObj = Object.create( ToolBar );
293                toolbarObj.init( options, this );
294                $(this).data('toolbarObj', toolbarObj);
295            });
296        } else if ( typeof options === 'string' && options.indexOf('_') !== 0 ) {
297            var toolbarObj = $(this).data('toolbarObj');
298            var method = toolbarObj[options];
299            return method.apply(toolbarObj, $.makeArray(arguments).slice(1));
300        }
301    };
302
303    $.fn.toolbar.options = {
304        content: '#myContent',
305        position: 'top',
306        hideOnClick: false,
307        zIndex: 120,
308        hover: false,
309        style: 'default',
310        animation: 'standard',
311        adjustment: 10
312    };
313}) ( jQuery, window, document );
314
315jQuery(function($) {
316  $('#flags a, a.single-language, .tool-items a').each(function() {
317    $(this).attr('data-lang', $(this).attr('title'));
318  });
319
320  $(document.body).on("click", "a.flag", function() {
321    if($(this).attr("href") === "#")
322        event.preventDefault();
323    var lang_text = $(this).attr('data-lang');
324    var default_lang = window.glt_default_lang || window.gtranslateSettings?.default_language || 'en';
325    var lang_prefix = $(this).attr("class").split(" ")[2];
326    doGoogleLanguageTranslator(default_lang + "|" + lang_prefix);
327    $(".tool-container").hide();
328  });
329
330  if(window.glt_request_uri) {
331    $('#google_language_translator select').on('change', function() {
332        doGLTTranslate($(this).val());
333    })
334  }
335});

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.