PageSourceSearch

https://ten-golf.com/wp-content/themes/tengolf-child/js/modal.js?3…&ver=ae83185da5143e4ccd8605c21daf8b10

js ten-golf.com collected 2026-10-02 11:37:40 UTC 8,529 bytes, 246 lines download raw bytes

1var Modal = {
2    titleTextDefault : "Atención",
3    buttonAcceptTextDefault : "Aceptar",
4
5    closeModal : function(modal, remove, modifyZIndex, close_opaque, opaque_id) {
6        var _this = this;
7
8        remove = typeof remove === "undefined" || remove === null ? true : remove;
9        modifyZIndex = typeof modifyZIndex === "undefined" || modifyZIndex === null ? false : modifyZIndex;
10
11        var d = _this.getDimensions();
12
13        modal.animate({
14            opacity : 0,
15            top : ((d.window.height + d.scroll.top) / 2 - modal.height() / 2 - 40) + "px",
16        },{
17            duration : 200,
18            complete : function() {
19                if (modifyZIndex) {
20                    modal.css("zIndex", "-9999");
21                }
22
23                modal.hide();
24
25                if (remove) {
26                    modal.remove();
27                }
28
29                if (close_opaque) {
30                    jQuery("body").removeClass("noscroll");
31                    jQuery(".opaque[data-opaque-id='" + opaque_id + "']").remove();
32                }
33            }
34        });
35    },
36
37    getDimensions : function() {
38        var o = {
39            body : {
40                height : jQuery("body").height(),
41                width : jQuery("body").width()
42            },
43            scroll : {
44                left : jQuery(window).scrollLeft(),
45                top : jQuery(window).scrollTop()
46            },
47            window : {
48                height : jQuery(window).height(),
49                width : jQuery(window).width()
50            }
51        };
52
53        if (o.body.height >= o.window.height) {
54            o.highest = o.body.height;
55        } else {
56            o.highest = o.window.height;
57        }
58
59        if (o.body.width >= o.window.width) {
60            o.widest = o.body.width;
61        } else {
62            o.widest = o.window.width;
63        }
64
65        return o;
66    },
67
68    modal : function(config) {
69        // config es un objeto que consta de title, message, button1_text, button2_text, button1_callback, button2_callback, show_opaque, show_callback, text_align, title_uppercase
70        var _this = this;
71
72        config = typeof config === "undefined" || config === null ? {} : config;
73        title_uppercase = typeof config.title_uppercase === "undefined" || config.title_uppercase === null || jQuery.trim(config.title_uppercase) === "" ? false : config.title_uppercase;
74        title = typeof config.title === "undefined" || config.title === null ? _this.titleTextDefault : jQuery.trim(config.title);
75        message = typeof config.message === "undefined" || config.message === null || jQuery.trim(config.message) === "" ? null : jQuery.trim(config.message);
76        button1_text = typeof config.button1_text === "undefined" || config.button1_text === null || jQuery.trim(config.button1_text) === "" ? _this.buttonAcceptTextDefault : jQuery.trim(config.button1_text);
77        button2_text = typeof config.button2_text === "undefined" || config.button2_text === null || jQuery.trim(config.button2_text) === "" ? "" : jQuery.trim(config.button2_text);
78        show_opaque = typeof config.show_opaque === "undefined" || config.show_opaque === null ? true : config.show_opaque;
79        text_align = typeof config.text_align === "undefined" || config.text_align === null || jQuery.trim(config.text_align) === "" ? "center" : jQuery.trim(config.text_align);
80
81        var modal = jQuery("<div>").addClass("modal-confirm");
82        var html_title = "";
83        var html_message = "";
84        var b1 = null;
85        var b2 = null;
86        var buttons_wrapper = null;
87        var opaque_id = (new Date()).getTime();
88
89        if (title !== "") {
90            if (title_uppercase) {
91                html_title = "<div class=\"title\" style=\"text-transform: uppercase;\">" + title + "</div>";
92            } else {
93                html_title = "<div class=\"title\">" + title + "</div>";
94            }
95        }
96
97        if (message !== "") {
98            html_message = "<div class=\"message-wrapper\"><div class=\"message\" style=\"text-align: " + text_align + ";\">" + message + "</div></div>";
99        }
100
101        if (button1_text !== "" && button1_text !== "none") {
102            b1 = jQuery("<button>").attr({
103                type : "button"
104            }).addClass("btn btn-primary").html(button1_text).on("click", function(e) {
105                var _ = jQuery(this);
106                var d = _this.getDimensions();
107                var rButton1 = true;
108
109                _.addClass("loading");
110
111                if (typeof config.button1_callback === "function") {
112                    rButton1 = config.button1_callback();
113                }
114
115                if (rButton1 !== false) {
116                    _this.closeModal(_.parents(".modal-confirm"), true, false, show_opaque, opaque_id);
117                }
118
119                _.removeClass("loading");
120            });
121        }
122
123        if (button2_text !== "" && button2_text !== "none") {
124            b2 = jQuery("<button>").attr({
125                type : "button"
126            }).addClass("btn btn-secondary").html(button2_text).on("click", function(e) {
127                var _ = jQuery(this);
128                var d = _this.getDimensions();
129                var rButton2 = true;
130
131                _.addClass("loading");
132
133                if (typeof config.button2_callback === "function") {
134                    rButton2 = config.button2_callback();
135                }
136
137                if (rButton2 !== false) {
138                    _this.closeModal(_.parents(".modal-confirm"), true, false, show_opaque, opaque_id);
139                }
140
141                _.removeClass("loading");
142            });
143        }
144
145        buttons_wrapper = jQuery("<div>").addClass("buttons-wrapper");
146
147        buttons_wrapper.append(b1);
148
149        if (b2 !== null) {
150            buttons_wrapper.append(b2);
151        }
152
153        modal.attr("data-opaque", opaque_id);
154        modal.append(html_title);
155        modal.append(html_message);
156        modal.append(buttons_wrapper);
157
158        modal.appendTo("body").hide();
159        _this.openModal(modal, show_opaque, opaque_id);
160
161        if (typeof config.show_callback === "function") {
162            config.show_callback();
163        }
164
165        return opaque_id;
166    },
167
168    opaqueLayer : function(removeCallback, removeOnClick, container, opaque_id) {
169        var _this = this;
170
171        removeCallback = typeof removeCallback !== "function" ? null : removeCallback;
172        removeOnClick = typeof removeOnClick === "undefined" || removeOnClick === null ? true : removeOnClick;
173        container = typeof container === "undefined" || container === null ? null : container;
174
175        var d = _this.getDimensions();
176
177        var layer = jQuery("<div>").attr({
178            "data-opaque-id" : opaque_id
179        }).addClass("opaque").css({
180            height : d.highest + "px",
181            width : d.widest + "px"
182        }).on("click", function() {
183            if (removeOnClick) {
184                _this.removeOpaqueLayer(removeCallback);
185            }
186        });
187
188        if (container === null) {
189            jQuery("body").append(layer);
190        } else {
191            container.append(layer);
192        }
193
194        jQuery(window).on("resize", function() {
195            var d = _this.getDimensions();
196
197            layer.css({
198                height : d.highest + "px",
199                width : d.widest + "px"
200            });
201        });
202
203        jQuery("body").addClass("noscroll");
204    },
205
206    openModal : function(modal, show_opaque, opaque_id) {
207        var _this = this;
208        var d = _this.getDimensions();
209        var body = jQuery("body");
210
211        if (show_opaque) {
212            _this.opaqueLayer(null, false, null, opaque_id);
213        }
214
215        if (modal.parent() != body) {
216            modal.detach().appendTo(body);
217        }
218
219        modal.show().css({
220            left : "50%",
221            top : "48%",
222            transform : "translateX(-50%) translateY(-50%)"
223        });
224
225        window.setTimeout(function() {
226            modal.animate({
227                opacity : 1,
228                top : "50%"
229            }, {
230                duration : 300
231            });
232        }, 200);
233    },
234
235    removeOpaqueLayer : function(removeCallback) {
236        var _this = this;
237        removeCallback = typeof removeCallback !== "function" ? null : removeCallback;
238
239        if (typeof removeCallback === "function") {
240            removeCallback();
241        }
242
243        jQuery(".opaque").remove();
244        jQuery("body").removeClass("noscroll");
245    }
246};

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.