PageSourceSearch

https://ifidie.com/wp-content/uploads/ac_assets/uc_content_accordion/content_accordion.js?ver=2.0.15

js ifidie.com collected 2026-09-27 12:08:14 UTC 7,160 bytes, 285 lines download raw bytes

1
2function UCPostAccordion(objAccordion){
3  
4  var g_activeClass;
5  var g_dataLinkNum, g_accItem, g_scrollOffset;
6
7  //scroll func
8  function scrollToTop(){
9    var panel = jQuery(this).closest(".uc_ac_box");
10    
11    jQuery('html, body').animate({
12      scrollTop: panel.offset().top + g_scrollOffset
13    }, 400);
14  }
15  
16  /**
17  * set hash
18  */
19  function setHash(objTab){
20    
21    var isHashSet = objAccordion.data("set-hash");
22    
23    if(isHashSet == false)
24    return(false);
25    
26    var objTabDataId = objTab.parent().attr('id');
27    
28    window.location.hash = objTabDataId;    
29    
30  }
31  
32  function onItemClick(){
33    
34    var objCaption = jQuery(this);
35    var objContent = objCaption.next();
36    var objItem = objCaption.parent();
37    
38    setHash(objCaption);
39    
40    var isActive = objItem.hasClass(g_activeClass);
41    var dataCloseothers = objAccordion.data("closeothers");
42    
43    if(dataCloseothers == true){
44
45      if(isActive == true){    
46        //remove active class from clicked
47        objItem.removeClass(g_activeClass);
48        objContent.slideUp();    
49        return(false);
50      }
51       
52      var objItems = objItem.siblings();
53
54      objItems.each(function(){
55
56        var objTab = jQuery(this);
57        var isTabActive = objTab.hasClass(g_activeClass);
58     
59        //remove active class from all other tabs
60        //use carefully, not to touch inner accordion if such exists
61        if(isTabActive == true){
62          objTab.removeClass(g_activeClass);
63          objTab.find(" > .uc_content").slideUp();        
64        }
65      });      
66      
67      
68    }
69   
70    objItem.addClass(g_activeClass);
71    
72    var dataScroll = objAccordion.data('scroll');
73    
74    if (dataScroll == "desktop"){
75      if(window.matchMedia("(min-width: 1024px)").matches){
76        objContent.slideDown(scrollToTop);
77      }else{
78        objContent.slideDown();
79      }
80    }
81    
82    if (dataScroll == "mobile"){
83      if(window.matchMedia("(max-width: 1024px)").matches){
84        objContent.slideDown(scrollToTop);
85      }else{
86        objContent.slideDown();
87      }
88    }
89    
90    if (dataScroll == "desktop+mobile"){
91      objContent.slideDown(scrollToTop);
92    }
93    
94    if (dataScroll == "off"){
95      objContent.slideDown();
96    }
97    
98    return false;
99  }
100  
101  
102  function linkToSlideScroll(){ 
103    
104    jQuery('html, body').animate({
105      scrollTop: g_accItem.offset().top + g_scrollOffset
106    }, 400);
107  }
108  
109  /*
110  * check if element is in viewport
111  */
112  function isElementInViewport(objElement) {
113    
114    var elementTop = objElement.offset().top;
115    var elementBottom = elementTop + objElement.outerHeight();
116    
117    var viewportTop = jQuery(window).scrollTop();
118    var viewportBottom = viewportTop + jQuery(window).height();
119    
120    var isInViwport = elementBottom > viewportTop && elementTop < viewportBottom;
121    
122    return(isInViwport);
123  } 
124  
125  /*
126  * on trigger link click
127  */
128  function onLinkClick(e){
129    
130    var objLink = jQuery(this);
131    
132    var dataAccName = objAccordion.data('name');
133    var dataLinkName = objLink.data('name');
134    g_dataLinkNum = objLink.data('num');
135    g_accItem = objAccordion.find('.uc_ac_box .uc_trigger').eq(g_dataLinkNum - 1);
136    var accItemNumber = objAccordion.find('.uc_ac_box').length;
137    
138    
139    if(dataLinkName != dataAccName)
140    return(false);
141    
142    if(dataLinkName == undefined || g_dataLinkNum == '' || g_dataLinkNum > accItemNumber)
143    return(false);
144    
145    var accItemContent = g_accItem.next();
146    var accItemParent = g_accItem.parent();
147    var isItemParentActive = accItemParent.hasClass("uc-item-active");
148    
149    e.preventDefault();
150    
151    if(isItemParentActive == true && isElementInViewport(objAccordion) == false){
152      
153      linkToSlideScroll();
154      
155    }else if(isItemParentActive == false && isElementInViewport(objAccordion) == false){
156      
157      onItemClick();	      
158      accItemContent.slideDown(linkToSlideScroll);
159      accItemParent.addClass("uc-item-active");
160      
161    }else if(isItemParentActive == false && isElementInViewport(objAccordion) == true){
162      
163      onItemClick();	      
164      accItemContent.slideDown();
165      accItemParent.addClass("uc-item-active");
166    }
167    
168    
169  }
170  
171  /**
172  * init open links
173  */
174  function initLinks(){
175    
176    var objLinks = jQuery('.ue-link-goto-item').not(".uc-link-inited");
177    
178    if(objLinks.length == 0){
179      return(false);
180    }
181    
182    var elementName = objAccordion.data("name");
183    
184    jQuery.each(objLinks, function(index, linkElement){
185      
186      var objLink = jQuery(linkElement);      
187      var name = objLink.data("name");
188      
189      if(name != elementName)
190      return(true);
191      
192      objLink.addClass("uc-link-inited");
193      
194      objLink.on("click", onLinkClick);
195      
196    });
197    
198  }
199  
200  
201  function runPostAccordion(){
202    //init globals
203    
204    g_activeClass = "uc-item-active";    
205    g_scrollOffset = objAccordion.data('offset');
206    
207    initLinks();
208    
209    //init events    
210    objAccordion.on("click", ".uc_trigger", onItemClick);
211    objAccordion.on("ucclick", ".uc_trigger", onItemClick);
212    
213    //init hash
214    if(!window.location.hash)
215    return(false);
216        
217    //find hashed tab object
218    var objHashedTabs = jQuery('[id=' + window.location.hash + ']');
219
220    objHashedTabs.each(function(){
221
222      var objHashedTab = jQuery(this);
223
224      //find main widget wrapper of the hashed tab
225      var objHashedTabWrapper = objHashedTab.parents('.uc_material_accordion'); 
226
227      //find if main widget wrapper is inside another accordion tab
228      var objWrapperParent = objHashedTabWrapper.parents('.uc_ac_box');
229
230      //if not than trigger click on hashed tab only and move to another hashed tab object
231      //do nothing with inner accordion on this stage (if its exists)
232      if(!objWrapperParent.length){
233          
234        setTimeout(function(){
235
236          //find if tab is active
237          var isActive = objHashedTab.hasClass(g_activeClass);
238
239          if(isActive == true)
240          return(true);
241
242          objHashedTab.find(' > .uc_trigger').trigger('click');
243
244        },200);
245
246        return(true);
247      }
248      
249      //if wrapper is inside another accordion tab
250      setTimeout(function(){
251
252        //if tab is active then skip and go to another one
253        var isActive = objHashedTab.hasClass('uc-item-active');
254        
255        if(isActive == true)
256        return(true);
257
258        objHashedTab.find(' > .uc_trigger').trigger('click');
259       
260        //open parent accordion tab it wasn't open already
261        var isParentTabActive = objWrapperParent.hasClass('uc-item-active');
262
263        if(isParentTabActive == true)
264        return(true);
265
266        var objParentAccordionTab = objWrapperParent.find(' > .uc_trigger');
267        var accItemContent = objParentAccordionTab.next();
268        var accItemParent = objParentAccordionTab.parent();          
269
270        accItemContent.slideDown();
271        accItemParent.addClass("uc-item-active");
272   
273      },300);
274
275      
276    });
277
278	objAccordion.addClass('uc-inited');
279    
280  }
281  
282  if(objAccordion.hasClass('uc-inited') == false)
283  runPostAccordion();
284  
285}

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.