PageSourceSearch

https://clearcommodity.net/plugins/system/t4/themes/base/js/base.js?ff768f

js clearcommodity.net collected 2026-10-02 15:32:31 UTC 9,062 bytes, 242 lines download raw bytes

1jQuery(document).ready(function($) {
2   
3    /**
4     *monitor the element scroll to add class into body for style effect later
5     */
6    $(window).ready(function() {
7        if (
8            "IntersectionObserver" in window &&
9            "IntersectionObserverEntry" in window &&
10            "intersectionRatio" in window.IntersectionObserverEntry.prototype
11        ) {
12            var options = {
13                root: null,
14                rootMargin: '0px',
15                threshold: 0
16            };
17            var sections = document.querySelectorAll(".t4-section");
18            var maxIdx = 0;
19            var sticky = document.querySelectorAll(".t4-sticky");
20
21            function isValid(el) {
22                return el.offsetTop < window.innerHeight && el.offsetTop + el.offsetHeight < window.innerHeight + 200;
23            }
24
25            function doChange(changes, observer) {
26                changes.forEach( function(change){
27                    var clientRect = change.boundingClientRect,
28                        target = change.target;
29
30                    if (clientRect.top <= -clientRect.height) {
31                        document.body.setAttribute('data-top-' + target.id, 'over');
32                        document.body.classList.add('top-away');
33
34                    } else {
35                        document.body.setAttribute('data-top-' + target.id, 'under');
36                        document.body.classList.remove('top-away');
37                    }
38
39                })
40            }
41
42            var observer = new IntersectionObserver(doChange, options);
43
44            for(var i=0; i<sections.length; i++) {
45                var el = sections[i];
46                if (isValid(el)) {
47                    el.idx = i;
48                    observer.observe(el);
49                } else {
50                    maxIdx = i - 1;
51                    break;
52                }
53            }
54            var top = 0;
55            var zindex = 300;
56            for(var i=0; i<sticky.length; i++) {
57                var elSk = sticky[i];
58                top += elSk.offsetHeight;
59                if(typeof sticky[i+1] != 'undefined'){
60                    $(elSk).css({'z-index':zindex});
61                    zindex -= 1;
62                    $(sticky[i+1]).css({top:top,'z-index':zindex});
63                }
64                
65            }
66            // monitor not at top
67            var options2 = {
68                root: null,
69                rootMargin: '0px',
70                threshold: 0
71            };
72            function doChange2(changes) {
73                var clientRect = changes[0].boundingClientRect;
74                if (clientRect.top <= -100) {
75                    document.body.classList.add('not-at-top');
76                } else {
77                    document.body.classList.remove('not-at-top');
78                }
79            }
80            var observer2 = new IntersectionObserver(doChange2, options2);
81            var anchorEl = $('<a name="top-anchor">').prependTo('.t4-content-inner');
82            if(anchorEl.get(0)) observer2.observe(anchorEl.get(0));
83
84        }
85    });
86    
87    //check anchor link on menu scroll smoothly
88    $(document).on('click', 'a[href^="#"]', function (event) {
89        event.preventDefault();
90        if($(this).data('slide')) return;
91        if(['tab'].indexOf($(this).data('toggle')) > -1) return;
92        if(['tab'].indexOf($(this).attr('data-bs-toggle')) > -1) return;
93        var el = '';
94        if($($.attr(this, 'href')).length){
95            var el = $.attr(this, 'href');
96        }else if($('[name="' + $.attr(this, 'href').substr(1) + '"]').length){
97            var el = '[name="' + $.attr(this, 'href').substr(1) + '"]';
98        }else{
99            return;
100        }
101        if($('body').hasClass('has-offcanvas--visible')){
102            $('.js-offcanvas-close').trigger('click');
103        }
104        $('html, body').animate({
105            scrollTop: $(el).offset().top
106        }, 500);
107    });
108
109    $('li.nav-item.dropdown').on('hidden.bs.dropdown', function(e) {
110        $(this).find('.show').removeClass('show');
111    });
112
113    /**
114     * Back-to-top action: scroll back to top
115     */
116    $('body').on('click','#back-to-top',function() {
117        $('body,html,.t4-content').animate({
118            scrollTop : 0
119        }, 500);
120        return false;
121    });
122    
123    $(document).find('.t4-content').on("scroll",function (event) {
124        var scroll = $('.t4-content').scrollTop();
125        localStorage.setItem("page_scroll", scroll);
126       
127    });
128});
129// Add missing Mootools when Bootstrap is loaded
130(function($)
131{
132    $(document).ready(function(){
133        var bootstrapLoaded = (typeof $().carousel == 'function');
134        var mootoolsLoaded = (typeof MooTools != 'undefined');
135        if (bootstrapLoaded && mootoolsLoaded) {
136            Element.implement({
137                hide: function () {
138                    return this;
139                },
140                show: function (v) {
141                    return this;
142                },
143                slide: function (v) {
144                    return this;
145                }
146            });
147        }
148    });
149    function refreshCurrentPage () {
150        var page = window.location.href;
151        var cur  = localStorage.getItem('page');
152        if(cur == page){
153            return true;
154        }
155        return false;
156    }
157    
158
159    window.onload = function () {
160        var check  = refreshCurrentPage();
161        localStorage.setItem("page",window.location.href);
162        if(document.getElementsByClassName("t4-content").length){
163            if (check) {
164                var match = localStorage.getItem("page_scroll");
165                document.getElementsByClassName("t4-content")[0].scrollTop = match;
166            }else{
167                document.getElementsByClassName("t4-content")[0].scrollTop = 0;
168            }
169        }
170    }
171    //add version to js
172    var Joomla = window.Joomla || {};
173    Joomla.version = $('html').hasClass('j4') ? "4" : "3";
174    if(Joomla.version == 3){
175        /**
176         * Render messages send via JSON
177         * Used by some javascripts such as validate.js
178         * PLEASE NOTE: do NOT use user supplied input in messages as potential HTML markup is NOT sanitized!
179         *
180         * @param   {object}  messages    JavaScript object containing the messages to render. Example:
181         *                              var messages = {
182         *                                  "message": ["Message one", "Message two"],
183         *                                  "error": ["Error one", "Error two"]
184         *                              };
185         * @return  {void}
186         */
187        Joomla.renderMessages = function( messages ) {
188            Joomla.removeMessages();
189
190            var messageContainer = document.getElementById( 'system-message-container' ),
191                type, typeMessages, messagesBox, title, titleWrapper, i, messageWrapper, alertClass;
192
193            for ( type in messages ) {
194                if ( !messages.hasOwnProperty( type ) ) { continue; }
195                // Array of messages of this type
196                typeMessages = messages[ type ];
197
198                // Create the alert box
199                messagesBox = document.createElement( 'div' );
200
201                // Message class
202                alertClass = (type === 'notice') ? 'alert-info' : 'alert-' + type;
203                alertClass = (type === 'message') ? 'alert-success' : alertClass;
204                alertClass = (type === 'error') ? 'alert-error alert-danger' : alertClass;
205
206                messagesBox.className = 'alert ' + alertClass;
207
208                // Close button
209                var buttonWrapper = document.createElement( 'button' );
210                buttonWrapper.setAttribute('type', 'button');
211                if($('body').hasClass('loaded-bs5')){
212                    buttonWrapper.setAttribute('data-bs-dismiss', 'alert');
213                }else{
214                    buttonWrapper.setAttribute('data-dismiss', 'alert');
215                }
216                buttonWrapper.className = 'close';
217                buttonWrapper.innerHTML = '×';
218                messagesBox.appendChild( buttonWrapper );
219
220                // Title
221                title = Joomla.JText._( type );
222
223                // Skip titles with untranslated strings
224                if ( typeof title != 'undefined' ) {
225                    titleWrapper = document.createElement( 'h4' );
226                    titleWrapper.className = 'alert-heading';
227                    titleWrapper.innerHTML = Joomla.JText._( type );
228                    messagesBox.appendChild( titleWrapper );
229                }
230
231                // Add messages to the message box
232                for ( i = typeMessages.length - 1; i >= 0; i-- ) {
233                    messageWrapper = document.createElement( 'div' );
234                    messageWrapper.innerHTML = typeMessages[ i ];
235                    messagesBox.appendChild( messageWrapper );
236                }
237
238                messageContainer.appendChild( messagesBox );
239            }
240        };
241    }
242})(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.