PageSourceSearch

https://clearbuildingmanagement.com/wp-content/plugins/ultimate-floating-widgets/public/js/script.js?ver=3.1

js clearbuildingmanagement.com collected 2026-09-26 19:58:39 UTC 15,749 bytes, 483 lines download raw bytes

1(function($){
2$(document).ready(function(){
3    
4    var init = function(){
5        
6        window.ufw_wrap_auto = {};
7        
8        $('.ufw_wrap').each(function(){
9            
10            var id = $(this).attr('id');
11            var auto_trigger = $(this).attr('data-auto-trigger');
12            var auto_trigger_device = $(this).attr('data-auto-trigger-device');
13            var auto_close = $(this).attr('data-auto-close');
14            var auto_close_time = $(this).attr('data-auto-close-time');
15            var btn_reveal = $(this).attr('data-btn-reveal');
16            var devices = $(this).attr('data-devices');
17            var save_state = $(this).attr('data-save');
18
19            window.ufw_wrap_auto[id] = {
20                'status': $(this).hasClass('ufw_wb_opened') ? 'opened' : 'closed',
21                'save_state': (typeof save_state !== 'undefined') ? save_state : false,
22                'open_at': (typeof auto_trigger !== 'undefined') ? auto_trigger : false,
23                'close_at': (typeof auto_close !== 'undefined') ? auto_close : false,
24                'close_time': (typeof auto_close_time !== 'undefined') ? auto_close_time : false,
25                'close_timeout': false,
26                'btn_reveal': (typeof btn_reveal !== 'undefined') ? btn_reveal : false,
27                'btn_status': 'hidden',
28                'auto_trigger_device': (typeof auto_trigger_device !== 'undefined') ? auto_trigger_device : 'all',
29            };
30
31            var hidden = init_display($(this), auto_trigger, devices);
32
33            if(hidden){
34                return;
35            }else{
36                $(this).removeClass('ufw_wb_hidden');
37            }
38
39            var $btn = $(this).find('.ufw_btn');
40            show_hide_btn($btn, 'show');
41
42            if($(this).hasClass('ufw_wb_opened')){
43                adjust_size($(this));
44                $(this).find('.ufw_wb').css('display', 'block');
45                do_auto_close_time($(this), 'start');
46            }
47
48            if(window.ufw_wrap_auto[id]['close_time']){
49                $(this).on('mouseenter', function(){
50                    do_auto_close_time($(this), 'stop')
51                });
52                $(this).on('mouseleave', function(){
53                    do_auto_close_time($(this), 'start')
54                });
55            }
56
57        });
58        
59        position_popups();
60
61        on_scroll(0, 0);
62
63        window.UFW = api();
64
65    }
66    
67    var api = function(){
68        
69        return {
70            'open': function(id){
71                var $wrap = $('#ufw_' + id);
72                if($wrap.length == 0){
73                    return false;
74                }else{
75                    open_close_wb($wrap, 'open', 'manual');
76                    return $wrap;
77                }
78            },
79            'close': function(id){
80                var $wrap = $('#ufw_' + id);
81                if($wrap.length == 0){
82                    return false;
83                }else{
84                    open_close_wb($wrap, 'close', 'manual');
85                    return $wrap;
86                }
87            },
88            'toggle': function(id){
89                var $wrap = $('#ufw_' + id);
90                if($wrap.length == 0){
91                    return false;
92                }else{
93                    open_close_wb($wrap, 'toggle', 'manual');
94                    return $wrap;
95                }
96            }
97        };
98    }
99
100    var open_close_wb = function($wrap, action='toggle', by='auto'){
101        
102        var id = $wrap.attr('id');
103        var $wb = $wrap.find('.ufw_wb');
104        var open_anim = 'animate__animated animate__' + $wrap.attr('data-open-anim');
105        var close_anim = 'animate__animated animate__' + $wrap.attr('data-close-anim');
106        
107        var open_class = 'ufw_wb_opened';
108        var close_class = 'ufw_wb_closed';
109        
110        var $close_btn = $wrap.find('.ufw_close_btn');
111
112        if($wrap.hasClass(open_class) && (action == 'close' || action == 'toggle')){
113            
114            if(close_anim.includes('none')){
115                $wb.hide(0, function(){
116                    after_open_close($wb, true);
117                });
118            }else{
119                $wb.removeClass(open_anim);
120                $wb.addClass(close_anim);
121            }
122            
123            $wrap.addClass(close_class);
124            $wrap.removeClass(open_class);
125            
126            $close_btn.fadeOut();
127
128            window.ufw_wrap_auto[id]['status'] = 'closed';
129
130            if(by == 'manual'){
131                $wrap.data('closed_manually', true);
132                if(window.ufw_wrap_auto[id]['save_state'] !== false){
133                    set_cookie('ufw_status_' + id, 'closed', window.ufw_wrap_auto[id]['save_state']);
134                }
135            }
136
137        }else if($wrap.hasClass(close_class) && (action == 'open' || action == 'toggle')){
138            
139            if(by == 'auto' && $wrap.data('closed_manually')){
140                return;
141            }
142
143            $wb.show();
144
145            if(!open_anim.includes('none')){
146                $wb.removeClass(close_anim);
147                $wb.addClass(open_anim);
148            }
149            
150            adjust_size($wrap);
151            
152            $wrap.removeClass(close_class);
153            $wrap.addClass(open_class);
154            
155            $close_btn.fadeIn();
156
157            window.ufw_wrap_auto[id]['status'] = 'opened';
158
159            if(by == 'manual'){
160                if(window.ufw_wrap_auto[id]['save_state'] !== false){
161                    set_cookie('ufw_status_' + id, 'opened', window.ufw_wrap_auto[id]['save_state']);
162                }
163            }
164
165            do_auto_close_time($wrap, 'start');
166
167        }
168        
169    }
170    
171    var show_hide_btn = function($btn, action='show'){
172        
173        if($btn.length == 0){
174            return;
175        }
176
177        var id = $btn.closest('.ufw_wrap').attr('id');
178        var btn_status = window.ufw_wrap_auto[id]['btn_status'];
179
180        if(action == 'show' && btn_status == 'hidden'){
181            $btn.fadeIn();
182            window.ufw_wrap_auto[id]['btn_status'] = 'visible';
183        }
184        
185        if(action == 'hide' && btn_status == 'visible'){
186            $btn.fadeOut();
187            window.ufw_wrap_auto[id]['btn_status'] = 'hidden';
188        }
189        
190        position_popups();
191
192    }
193    
194    var on_scroll = function(at, scrolled){
195        
196        for (var id in window.ufw_wrap_auto) {
197            if (window.ufw_wrap_auto.hasOwnProperty(id)){
198                
199                var open_at = window.ufw_wrap_auto[id]['open_at'];
200                var close_at = window.ufw_wrap_auto[id]['close_at'];
201                var cur_status = window.ufw_wrap_auto[id]['status'];
202                var btn_reveal = window.ufw_wrap_auto[id]['btn_reveal'];
203                var btn_status = window.ufw_wrap_auto[id]['btn_status'];
204                var auto_trigger_device = window.ufw_wrap_auto[id]['auto_trigger_device'];
205                
206                var $wrap = $('#'+id);
207                var $btn = $wrap.find('.ufw_btn');
208                
209                if(open_at !== false){
210                    if(at > open_at && cur_status == 'closed'){
211                        if(close_at === false || (close_at !== false && at < close_at)){
212                            if(auto_trigger_device == 'all' 
213                                || (auto_trigger_device == 'desktop' && !is_mobile()) 
214                                || (auto_trigger_device == 'mobile' && is_mobile())
215                            ){
216                                open_close_wb($wrap, 'open');
217                            }
218                        }
219                    }
220                    else if(at < open_at && cur_status == 'opened'){
221                        open_close_wb($wrap, 'close');
222                    }
223                }
224                
225                if(close_at !== false){
226                    if(at > close_at){
227                        open_close_wb($wrap, 'close');
228                    }
229                }
230
231                if(btn_reveal !== false){
232                    if(!btn_reveal.includes('-')){
233                        btn_reveal = btn_reveal + '-101';
234                    }
235                    var br_split = btn_reveal.split('-');
236
237                    if((at >= br_split[0] && at <= br_split[1]) && btn_status == 'hidden'){
238                        show_hide_btn($btn, 'show');
239                    }else if((at <= br_split[0] || at >= br_split[1]) && btn_status == 'visible' && cur_status != 'opened'){
240                        show_hide_btn($btn, 'hide');
241                        open_close_wb($wrap, 'close');
242                    }
243                }
244                
245            }
246        }
247        
248    }
249
250    var position_popups = function(){
251        
252        postion_popup('.ufw_pp.ufw_p_br', 'right');
253        postion_popup('.ufw_pp.ufw_p_bl', 'left');
254        postion_popup('.ufw_pp.ufw_p_tr', 'right');
255        postion_popup('.ufw_pp.ufw_p_tl', 'left');
256        
257    }
258    
259    var postion_popup = function(wb, position){
260        
261        var btn_offset = 16;
262        
263        $(wb).each(function(){
264            
265            if(typeof $(this).attr('data-hidden') !== 'undefined'){
266                return;
267            }
268
269            $(this).css(position, btn_offset + 'px');
270            
271            var $btn = $(this).find('.ufw_btn');
272            var btn_width = $btn.outerWidth();
273            
274            btn_offset += btn_width + btn_offset;
275            
276        });
277    }
278    
279    var adjust_size = function($wrap){
280
281        var $wb = $wrap.find('.ufw_wb');
282        var is_popup = $wrap.hasClass('ufw_pp');
283        var size = $wrap.attr('data-size').split('*');
284
285        $wrap.outerWidth(size[0]);
286
287        if(typeof $wb.data('orig-width') === 'undefined'){
288            $wb.data('orig-width', $wb.outerWidth());
289        }
290
291        if(typeof $wb.data('orig-height') === 'undefined'){
292            $wb.data('orig-height', $wb.outerHeight());
293        }
294
295        var orig_width = $wb.data('orig-width');
296        var orig_height = $wb.data('orig-height');
297        var width_pad = is_popup ? 50 : 0;
298
299        // Set width (both popup and flyout)
300        if(orig_width + width_pad > document.body.clientWidth){
301            $wrap.outerWidth(document.body.clientWidth - width_pad);
302        }else{
303            $wrap.outerWidth(orig_width);
304        }
305
306        // Set height (only popup)
307        if(is_popup){
308            if( orig_height + 100 > window.innerHeight ){
309                $wb.outerHeight(window.innerHeight - 100);
310            }else{
311                $wb.outerHeight(orig_height);
312            }
313        }
314
315    }
316
317    var remove_animate_class = function($ele){
318        $ele.removeClass(function(index, className){
319            return (className.match (/(^|\s)animate__\S+/g) || []).join(' ');
320        });
321    }
322
323    var after_open_close = function($wb, no_anim=false){
324        var $wrap = $wb.closest('.ufw_wrap');
325        if($wrap.hasClass('ufw_wb_closed') || no_anim){
326            $wb.hide();
327            $wrap.width('auto');
328        }
329        remove_animate_class($wb);
330    }
331
332    var do_auto_close_time = function($wrap, action){
333
334        var id = $wrap.attr('id');
335        var auto_close_time = window.ufw_wrap_auto[id]['close_time'] * 1000;
336
337        if(!auto_close_time){
338            return;
339        }
340
341        if(action == 'stop'){
342            if(window.ufw_wrap_auto[id]['close_timeout']){
343                clearTimeout(window.ufw_wrap_auto[id]['close_timeout']);
344                window.ufw_wrap_auto[id]['close_timeout'] = false;
345            }
346        }
347
348        if(action == 'start' && window.ufw_wrap_auto[id]['status'] == 'opened'){
349            window.ufw_wrap_auto[id]['close_timeout'] = setTimeout(function(){
350                open_close_wb($wrap, 'close', 'auto');
351                clearTimeout(window.ufw_wrap_auto[id]['close_timeout']);
352                window.ufw_wrap_auto[id]['close_timeout'] = false;
353            }, auto_close_time);
354        }
355
356    }
357
358    var is_mobile = function(){
359        return /Mobi|Android/i.test(navigator.userAgent);
360    }
361
362    var set_cookie = function(name, value, days){
363
364        var expires = '';
365
366        if (days != 0) {
367            var date = new Date();
368            date.setTime(date.getTime() + (days*24*60*60*1000));
369            expires = '; expires=' + date.toUTCString();
370        }
371
372        document.cookie = name + '=' + (value || '') + expires + '; path=/';
373
374    }
375
376    var get_cookie = function(name){
377
378        var name_eq = name + '=';
379        var ca = document.cookie.split(';');
380
381        for(var i=0; i < ca.length; i++) {
382            var c = ca[i];
383            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
384            if (c.indexOf(name_eq) == 0) return c.substring(name_eq.length, c.length);
385        }
386
387        return null;
388
389    }
390
391    var init_display = function($ele, auto_trigger, devices){
392
393        if(devices == 'mobile_only' && !is_mobile()){
394            $ele.hide();
395            return true; // Stay hidden
396        }
397
398        if(devices == 'desktop_only' && is_mobile()){
399            $ele.hide();
400            return true;
401        }
402
403        if(typeof auto_trigger !== 'undefined'){ // Auto trigger is set
404            return false;
405        }
406
407        var id = $ele.attr('id');
408        var todo = false;
409
410        if( ( is_mobile() && $ele.attr( 'data-init-m' ) == 'opened' )
411        || ( !is_mobile() && $ele.attr( 'data-init-d' ) == 'opened' ) ){
412            todo = 'open';
413        }
414
415        if(window.ufw_wrap_auto[id]['save_state'] !== false){
416            var cookie_status = get_cookie('ufw_status_' + id);
417
418            if(cookie_status == 'opened'){
419                todo = 'open';
420            }
421    
422            if(cookie_status == 'closed'){
423                todo = 'close';
424            }
425        }
426
427        if(todo){
428            if(todo == 'open'){
429                setTimeout(function(){
430                    open_close_wb($ele, 'open', 'auto');
431                }, 500);
432            }else{
433                $ele.removeClass( 'ufw_wb_opened' );
434                $ele.addClass( 'ufw_wb_closed' );
435                window.ufw_wrap_auto[id]['status'] = 'closed';
436            }
437        }
438
439        return false;
440
441    }
442
443    $('.ufw_wb').on( 'transitionend animationend', function(){
444        after_open_close($(this));
445    });
446    
447    $('.ufw_btn').on( 'click', function(e){
448        e.preventDefault();
449        $wrap = $(this).closest('.ufw_wrap');
450        open_close_wb($wrap, 'toggle', 'manual');
451    });
452    
453    $('.ufw_btn').on( 'animationend', function(){
454        remove_animate_class($(this));
455    });
456
457    $('.ufw_close_btn').on('click', function(e){
458        e.preventDefault();
459        $wrap = $(this).closest('.ufw_wrap');
460        open_close_wb($wrap, 'toggle', 'manual');
461    });
462
463    $(window).scroll(function(){
464        
465        var at = ($(window).scrollTop() / ($(document).height() - $(window).height())) * 100;
466        var scrolled = $(window).scrollTop();
467        
468        on_scroll(at, scrolled);
469        
470    });
471    
472    $(document).keyup(function(e){
473        if (e.keyCode === 27){
474            $('.ufw_wrap').each(function(){
475                open_close_wb($(this), 'close');
476            });
477        }
478    });
479    
480    init();
481    
482});
483})( jQuery );

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.