PageSourceSearch

https://tve.com.br/matriz_common/versions/2.1.5/js/procergs/matriz.global.ui.js?2.1.5.161.6+1

js tve.com.br collected 2026-09-26 11:23:09 UTC 15,720 bytes, 382 lines download raw bytes

1jQuery(function ($) {
2    matriz.ui = matriz.ui || {};
3    matriz.ui.init = {
4        beforeunload: function () {
5            $("form[data-matriz-warn-onunload]").each(function (index, el) {
6                var $form = $(el);
7                $form.data("serialized-form", $form.serialize());
8                window.onbeforeunload = function (e) {
9                    e = e || window.event;
10                    e.preventDefault();
11                    if ($form.data("serialized-form") !== $form.serialize()) {
12                        var mensagem = "Qualquer informação não salva será perdida. Deseja prosseguir?";
13                        e.returnValue = mensagem;
14                        return mensagem;
15                    } else {
16                        delete e['returnValue'];
17                    }
18                };
19            });
20        },
21        datepicker: function ($el) {
22            if (!($el instanceof jQuery)) {
23                $el = $(".input-group.date");
24            }
25
26            var language = "pt-BR";
27            if (matriz.global.theme.uri !== "/themes/admin") {
28                language = $("html").attr("lang");
29            }
30
31            //inicializa o datepicker
32            //http://eternicode.github.io/bootstrap-datepicker
33            $el.datepicker({
34                autoclose: true,
35                language: language,
36                keyboardNavigation: false,
37                forceParse: false,
38                todayHighlight: true,
39                orientation: "top auto"
40            }).on("changeDate", function () {
41
42            });
43        },
44        geolocation: function () {
45            matriz.geolocation.init();
46        },
47        loading: function () {
48            matriz.ui.loading.init();
49        },
50        mask: function () {
51            $("[data-mask]").each(function () {
52                var mask = $(this).attr("data-mask");
53                var pattern = $(this).attr("data-pattern");
54                if (typeof pattern === 'undefined') {
55                    $(this).mask(mask);
56                } else {
57                    $(this).mask(mask, {'translation': {P: {pattern: pattern}}});
58                }
59            });
60        },
61        //Inicializa bootstrap-maxlength (http://mimo84.github.io/bootstrap-maxlength/)
62        maxlength: function (selector, options) {
63            if (!options) {
64                options = {
65                    alwaysShow: true,
66                    warningClass: "matriz__counter-ok",
67                    limitReachedClass: "matriz__counter-limit",
68                    twoCharLinebreak: false
69                };
70            }
71            if (selector) {
72                $(selector).maxlength(options);
73            } else {
74                $('.form-group input.form-control[maxlength]').maxlength(options);
75                $('.form-group textarea.form-control[maxlength]').maxlength(options);
76            }
77        },
78        combobox: function () {
79            var $matrizUiCombobox = $('select.matriz-ui-combobox');
80            $matrizUiCombobox.selectpicker();
81            $matrizUiCombobox.filter('[required]').addClass('matriz-ui-combobox-required').css("display", "inline-block");
82        },
83        tabs: function () {
84            //desabilitando clique nas abas com <li  class="disabled">
85            $("ul.nav-tabs li.disabled a").off("click");
86            $("ul.nav-tabs li.disabled a").on("click", function (e) {
87                return false;
88            });
89        },
90        searchbox: function () {
91            $("#formBuscaNav [name='search']").on("click", function (e) {
92                $searchText = $(this);
93                $searchText.get(0).setSelectionRange(0, $searchText.val().length);
94            });
95        },
96        tristatecheckbox: function ($selector) {
97            matriz.ui.tristatecheckbox.init($selector);
98        },
99        modal: function ($container)
100        {
101            matriz.ui.init.datepicker();
102            matriz.ui.init.mask();
103            matriz.ui.init.maxlength();
104            matriz.ui.init.combobox();
105            matriz.ui.init.tabs();
106            //matriz.ui.init.geolocation();
107            //matriz.ui.loading.init();
108        },
109        notImplementedActions: function () {
110            /**
111             * Código removido, uma vez que o atributo "data-matriz-not-implemented-action"
112             * não é mais usado e o uso do DOMSubTreeModification estva causando
113             * lentidão na execução do script 
114             */
115        },
116        player: function () {
117            $(".matriz-media-player").each(function () {
118                $(this).matrizMediaPlayer();
119            });
120        },
121        components: function () {
122            matriz.ui.component.Manager.init();
123        },
124        void: function () {
125            $("[data-matriz-void]").on("click", function (e) {
126                e.preventDefault();
127            });
128        },
129        blueimp: function() {
130            preparaBlueImpLightbox(".artigo__ilustracao", "#galeria-lightbox");
131            preparaBlueImpLightbox(".artigo__ilustracao--esquerda", "#galeria-lightbox");
132            preparaBlueImpLightbox(".artigo__ilustracao--direita", "#galeria-lightbox");
133            preparaBlueImpLightbox(".artigo__ilustracao--carousel .owl-carousel", "#galeria-lightbox");
134            // prepara o lightbox para conteudolistaimagem
135            preparaBlueImpLightbox(".thumbs-gallery", "#galeria-lightbox");
136            // prepara o lightbox para carrousel de galerias de imagem thumb
137            preparaBlueImpLightbox(".conteudoimagem-mini-galeria", "#galeria-lightbox");
138        },
139        owl: function() {
140            $(".textmidia-image-carousel, .conteudovideo-mini-galeria, .conteudoimagem-mini-galeria").each((function(k, e) {
141                preparaOWL(e);
142            }).bind(this));
143        },
144        common: function () {
145            matriz.ui.init.datepicker();
146            matriz.ui.init.mask();
147            matriz.ui.init.maxlength();
148            matriz.ui.init.combobox();
149            matriz.ui.init.tabs();
150            matriz.ui.init.loading();
151            matriz.ui.init.player();
152            matriz.ui.init.components();
153            matriz.ui.init.void();
154        },
155        all: function () {
156            // matriz.ui.init.beforeunload();
157            matriz.ui.init.datepicker();
158            matriz.ui.init.geolocation();
159            matriz.ui.init.mask();
160            matriz.ui.init.maxlength();
161            matriz.ui.init.combobox();
162            matriz.ui.init.tabs();
163            matriz.ui.init.searchbox();
164            matriz.ui.init.loading();
165            matriz.ui.init.notImplementedActions();
166            matriz.ui.init.player();
167            matriz.ui.init.components();
168            matriz.ui.init.void();
169            matriz.common.events.trigger("matriz.ui.init.all");
170        }
171    };
172
173    matriz.ui.geolocation = {};
174    matriz.ui.geolocation.getGeoObjectByName = function (name, obj) {
175        if (name) {
176            var nameParts = name.split("."), len = nameParts.length, tmpobj = obj;
177            for (var i = 0; i < len; i++) {
178                if (!tmpobj[nameParts[i]]) {
179                    tmpobj[nameParts[i]] = {};
180                }
181                tmpobj = tmpobj[nameParts[i]];
182            }
183            return tmpobj;
184        }
185    };
186
187    matriz.ui.geolocation.init = function ()
188    {
189        //tratamento para select
190        $("select").each(function () {
191            var $el = $(this);
192            matriz.common.events.on("matriz.externalapis.google.maps.ready", function () {
193                var geolocalizacaoName = $el.attr("data-matriz-geolocation-value");
194                var geolocalizacaoValue = matriz.ui.geolocation.getGeoObjectByName(geolocalizacaoName, matriz.geolocation.data);
195                if (geolocalizacaoName && geolocalizacaoValue) {
196                    $el.children("[value='" + geolocalizacaoValue + "']").attr("selected", true);
197                }
198            });
199        });
200
201        //tratamento para textbox, hidden, radio e checkbox
202        $("input").each(function () {
203            var geolocalizacaoName = $(this).attr("data-matriz-geolocation-value");
204            if (geolocalizacaoName && matriz.geolocation.data[geolocalizacaoName])
205            {
206                switch ($(this).attr("type"))
207                {
208                    case "checkbox":
209                    case "radio":
210                        if ($(this).val() === matriz.geolocation.data[geolocalizacaoName])
211                            $(this).attr("checked", "checked");
212                        break;
213                    case "text":
214                    case "hidden":
215                        $(this).val(matriz.geolocation.data[geolocalizacaoName]);
216                        break;
217                }
218            }
219        });
220        $('.matriz-ui-combobox').selectpicker("refresh");
221    };
222
223    matriz.ui.loading = {};
224    matriz.ui.loading.init = function ()
225    {
226        $('#modalLoading').hide();
227        $('#modalLoading').modal({backdrop: "static", show: false});
228    };
229    matriz.ui.loading.modal = {};
230    matriz.ui.loading.modal.show = function ()
231    {
232        $('#modalLoading').show();
233    };
234    matriz.ui.loading.modal.hide = function ()
235    {
236        $('#modalLoading').hide();
237    };
238    matriz.ui.loading.element = {};
239    matriz.ui.loading.element.show = function (el, keepChildrenShowing) {
240        if (!keepChildrenShowing) {
241            el.children().hide();
242        }
243        el.append($("<div></div>").addClass("matriz-loading-clock"));
244    };
245    matriz.ui.loading.element.hide = function (el, keepChildrenHidden) {
246        if (!keepChildrenHidden) {
247            el.children().show();
248        }
249        el.find(".matriz-loading-clock").remove();
250    };
251    matriz.ui.loading.element.showSlide = function (el, keepChildrenShowing, direction, duration = 400) {
252        if (!keepChildrenShowing) {
253            if (direction === undefined) {
254                el.children().show();
255            } else {
256                el.children().show("slide", { direction: direction }, duration);
257            }
258        }
259    };
260    matriz.ui.loading.element.hideSlide = function (el, keepChildrenShowing, direction, duration = 400) {
261        if (!keepChildrenShowing) {
262            if (direction === undefined) {
263                el.children().hide();
264            } else {
265                el.children().hide("slide", { direction: direction }, duration);
266            }
267        }
268    };
269    matriz.ui.loadImage = function (imgsrc) {
270        var deferred = $.Deferred();
271        var img = new Image();
272        img.addEventListener("load", function () {
273            deferred.resolve(img);
274        });
275        img.addEventListener("error", function () {
276            deferred.reject(new Error("O endereço ".concat(imgsrc).concat(" parece não conter uma imagem válida.")));
277        });
278        img.src = imgsrc;
279        return deferred.promise();
280    };
281
282    matriz.ui.textsearch = {
283        init: function (searchboxSelector, trsSelector) {
284            $(searchboxSelector).keyup(function () {
285                var inputTextValue = $(this).val().toLowerCase();
286                $(trsSelector).each(function () {
287                    var encontrou = false;
288                    $(this).find("td").each(function () {
289                        if ($(this).text().toLowerCase().indexOf(inputTextValue) > -1) {
290                            encontrou = true;
291                        }
292                    });
293                    if (!encontrou) {
294                        $(this).hide();
295                    } else {
296                        $(this).show();
297                    }
298                });
299            });
300        }
301    };
302
303    function preparaOWL(container) {
304        $(container).owlCarousel({
305            items: 4, //10 items above 1000px browser width
306            itemsDesktop: [1200, 3], //5 items between 1200px and 901px
307            itemsDesktopSmall: [900, 3], // between 900px and 601px
308            itemsTablet: [600, 2], //2 items between 600 and 480
309            itemsMobile: [479, 1], // 1 item between 479 and 0
310            pagination: false
311        });
312        var owl = $(container).data('owlCarousel');
313        $(container).parent().find(".next").click(function() {
314            owl.next();
315        });
316        $(container).parent().find(".prev").click(function() {
317            owl.prev();
318        });
319    };
320
321    function preparaBlueImpLightbox(seletor, container, callback) {
322        $(seletor).each(function() {
323            if ($(container).length === 0) {
324                container = container.concat($(this).attr("id"));
325            }
326            $(this).on("click", function(event) {
327                if (["img", "a"].indexOf(event.target.tagName.toLowerCase()) !== -1) {
328                    event = event || window.event;
329                    var target = event.target || event.srcElement;
330                    var link = target.src ? target.parentNode : target;
331                    var options = {
332                        hidePageScrollbars: false,
333                        container: container,
334                        index: link,
335                        event: event,
336                        preloadRange: 1,
337                        continuous: false,
338                        onslide: function(index, slide) {
339                            if (callback instanceof Function) {
340                                callback.call(this, index, slide);
341                            }
342
343                            var titulo = this.list[index].getAttribute('title');
344                            if (!titulo) {
345                                titulo = this.list[index].getAttribute('data-legenda');
346                            }
347                            var node_titulo = this.container.find(".
347imagem-detalhe__titulo");
348                            $(node_titulo).html(titulo);
349                            var node_link = $(this.container.find(".imagem-detalhe__link")).find("a");
350                            if (node_link) {
351                                var urlAmigavel = this.list[index].getAttribute("data-urlamigavel");
352                                if (urlAmigavel) {
353                                    $(node_link).attr("href", urlAmigavel);
354                                } else {
355                                    node_link.remove();
356                                }
357                            }
358                            var credito = this.list[index].getAttribute("data-credito");
359                            var node_credito = this.container.find(".imagem-detalhe__credito");
360                            if (credito) {
361                                var label_credito = this.list[index].getAttribute("data-label-credito");
362                                $(node_credito).html(label_credito + credito);
363                            } else {
364                                $(node_credito).html("");
365                            }
366                        }
367                    };
368
369                    var elements = this.getElementsByTagName('a');
370
371                    var itens = [];
372                    for(var i = 0; i < elements.length; i++) {
373                        itens.push(elements[i]);
374                    }
375
376                    window.v = blueimp.Gallery(itens, options);
377                }
378            });
379        });
380    };
381
382});

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.