PageSourceSearch

https://www.twis.org/wp-content/plugins/wpi-designer-button-shortcode/inc/front_global.js?t=151&ver=3.0.2

js twis.org collected 2026-09-24 08:54:06 UTC 5,513 bytes, 181 lines download raw bytes

1var debug_mode=1;
2;(function($){
3	$.fn.wpiDebug=function(){
4		function Debug(el){
5			this.$el=el;
6			this.mode=1;
7			this.state="";
8			this.init();	
9		};
10		Debug.prototype.init=function(){
11			this.mode=debug_mode;
12			this.setState("debug");
13		};
14		Debug.prototype.setState=function(state){
15			if(this.mode==1){
16				this.state=state;
17				console.log(this.state);
18			}
19		};		
20		return new Debug(this);
21	};
22	
23	var DEBUG=$(document).wpiDebug();
24	
25	$.fn.wpiTicker=function(options){			
26		function WPiTicker(el,options){
27			this.delay=options['delay'];
28			this.animate=options['animate'];
29			this.$el=$(el);
30			this.$items=this.$el.children();
31			this.itemFirst=this.$items.first();			
32			this.itemsLength=0;
33			this.elHeight=0;			
34			this.itemMargin=0;						
35			this.animation="";	
36			if(this.animate=="play"){
37				this.init_front();	
38			}
39		};
40		WPiTicker.prototype.init=function(){
41			DEBUG.setState("wpiTicker Init");					
42			this.parentPadding=parseInt(this.getStyle(this.$el,"padding"));	
43			this.initStyle();
44			this.setHeight();	
45			this.tickerAnimation();	
46			this.resize();	
47		};	
48		WPiTicker.prototype.init_front=function(){
49			DEBUG.setState("wpiTicker Init_front");					
50			this.parentPadding=parseInt(this.$el.css("padding"));			
51			if(!this.checkItemsLength_front()) return;	
52			this.initStyle();
53			this.setHeight();	
54			this.tickerAnimation();	
55			this.resize();
56		};		
57		WPiTicker.prototype.checkItemsLength_front=function(){	
58			this.itemsLength=this.$items.length;
59			if(this.itemsLength<=1) {
60				this.animate=false;  
61				return false;
62			}			
63			return true;
64		}			
65		WPiTicker.prototype.checkItems=function(){				
66			var length=this.$items.length;
67			this.$items.each(function(){
68				if($(this).first().text()=="") {
69					$(this).css({"display":"none"});
70					length=length-1;					
71				}else{
72					$(this).css({"display":"block"});
73				}			
74			});				
75			this.itemsLength=length;
76			if(this.itemsLength<=1){
77				this.$el.css({"overflow":"visible"});				
78			}
79			
80			DEBUG.setState("wpiTicker itemsLength"+length);
81		}
82		WPiTicker.prototype.tickerAnimation=function(){
83			if(this.animate=="stop"){
84				this.stopAnimation();				
85			}else{				
86				this.startAnimation();
87			}
88		};
89		WPiTicker.prototype.stopAnimation=function(){	
90			clearInterval(this.animation);	
91			this.$el.css({height:"auto", "padding":this.parentPadding});
92			this.$items.css({height:"auto","line-height":"auto", "padding":"0px"});
93			this.itemFirst.siblings().css({ "display":"none"});
94			this.itemMargin=0;
95			this.setMargin(this)
96		}
97		WPiTicker.prototype.startAnimation=function(){	
98			clearInterval(this.animation);					
99			this.checkItems();	
100			this.setTicker();
101			var self=this;	
102			this.animation=setInterval(function(){self.setMargin(self);}, this.delay);
103		}		
104		WPiTicker.prototype.setTicker=function(){	
105			this.$el.css({"height":this.elHeight,"padding":"0px"});
106      		this.$items.css({"height":this.elHeight});	
107			this.$items.children().css({"line-height":"1.2em", "display": "inline-block","vertical-align": "middle"});
108			this.totalMargin=this.elHeight*(this.itemsLength-1);			
109		};
110		WPiTicker.prototype.setHeight=function(){	
111			var self=this;
112			var maxHeight=0;
113			this.$items.css({"height":"auto","line-height":"auto","padding":this.parentPadding});			
114			this.$items.each(function(){
115				var height=($(this).outerHeight()*(1))+20;
116				if(height>maxHeight) maxHeight=height;	
117				DEBUG.setState("setHeight maxHeight: "+maxHeight+" parentPadding: "+$(this).css("padding")+" height: "+height );
118			});
119			
120			this.elHeight=maxHeight;			
121			
122		};
123		WPiTicker.prototype.setMargin=function(self){			
124			self.itemFirst.css({"margin-top":self.itemMargin});
125			self.itemMargin=self.itemMargin-self.elHeight;
126			if (self.itemMargin<(self.totalMargin*-1)){self.itemMargin=0;}			
127		};
128		WPiTicker.prototype.resize=function(){
129			var self=this;
130			var elHeight=this.elHeight;
131			$(window).resize(function(event){
132				self.setHeight();
133				self.tickerAnimation();				
134			}).trigger("resize");			
135		};		
136		WPiTicker.prototype.update=function(args){				
137			var defaults={parentPadding:0, animate:"stop"};
138			args=$.extend(defaults,args);
139			this.animate=args["animate"];
140			this.parentPadding=parseInt(args["parentPadding"]);
141			this.setHeight();	
142			this.tickerAnimation();
143			DEBUG.setState("wpiTicker animate: "+this.animate+" parentPadding: "+this.parentPadding);					
144		};		
145		WPiTicker.prototype.initStyle=function(){	
146			this.itemFirst.css({display:"block",transition:"margin-top 0.3s ease-in-out"});	
147			this.$el.css({position:"relative", overflow:"hidden"});			
148		}	
149		WPiTicker.prototype.getStyle=function($el, s){	
150			var styleVal="";			
151			var st=$el.attr("style").replace(" ","");			
152			var split=st.split(";");
153			var styles={};
154			
155			$.each(split, function(key,val){ 				
156				var spil=val.split(":");  				
157				if(spil[1]!=""){						
158					var k=spil[0].replace(" ","");				
159					if(k==s){						
160						styleVal=spil[1];	
161						return true;
162					}       
163				}
164			}); 
165			DEBUG.setState("wpiTicker padding"+styleVal);
166			return styleVal;
167		}
168		
169		var defaults={store:false,animate:"stop", delay:2500};
170		var options=$.extend(defaults, options);
171		if(options['store']==true){
172			return new WPiTicker(this,options);		
173		}else{
174			return this.each(function(){
175				new WPiTicker(this,options);
176			});
177		}
178	}
179	
180		  
181})(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.