PageSourceSearch

https://bildungszentrum-singen.de/global_js/veranst/wco.morelesstoggler.js

js bildungszentrum-singen.de collected 2026-10-04 17:03:42 UTC 6,134 bytes, 172 lines download raw bytes

1/**
2 * Togglt Inhalte mit mehr/weniger
3 * ANKR/26.07.2013
4 */
5(function($){
6	
7	function WcoMoreLessToggler(){
8	
9		var proto = {
10			
11			'defaults': {'moreButtonText': 'm',
12						'lessButtonText': 'l'},
13			'settings': {},
14			
15			'_fnLoad': function(nElem, opts) {
16				this.settings = $.extend(this.defaults, opts);
17				var that = this;	
18				$('.create-more-less-text-toggler').each(function() {
19					that._fnCreateTextToggleBox($(this));
20				});
21				$('.create-more-less-toggler').each(function() {
22					that._fnCreateToggleBox($(this));
23				});
24				$('.create-more-less-toggler-accordion').each(function() {
25					that._fnCreateAccordionToggleBox($(this));
26				});
27			},
28			
29			'_fnCreateAccordionToggleBox': function($nBox) {
30				var $nMoreContent = $nBox.find('.v-detail-more-content');
31				if($nMoreContent.hasClass('v-detail-more-content') && $nMoreContent.children().length>0) {
32					$nBox.addClass("v-detail-more-less-toggle-box");
33					$nBox.find('.v-detail-box-title').append(this._fnCreateTextToggleBoxToggler());
34					this._fnAddToggleBoxListeners($nBox);
35				}
36				
37			},
38			
39			'_fnCreateToggleBox': function($nBox) {
40				var $nMoreContent = $nBox.find('.v-detail-more-content');
41				if($nMoreContent.hasClass('v-detail-more-content') && $nMoreContent.children().length>0) {
42					$nBox.addClass("v-detail-more-less-toggle-box");
43					//$nMoreContent.prepend($nBox.find('.v-detail-less-content').html());
44					$nMoreContent.prepend($nBox.find('.v-detail-less-content').children().clone(true))
45					$nBox.append(this._fnCreateTextToggleBoxToggler());
46					this._fnAddToggleBoxListeners($nBox);
47				}
48				
49			},
50			
51			//var lessContent = beschreibungT.substring(0, 150) + '...';	
52			/*var lessContent = document.createElement("div");
53			Cutter.run($nTmp.context, lessContent, 10);	*/	
54			'_fnCreateTextToggleBox': function($nBox) {
55				var $nTmp = $(document.createElement("div")).html($nBox.find('.v-detail-more-content').html());
56				$nTmp.find(".media-container-div").empty();
57				$nTmp.find(".veranst-bilder-container").empty();
58				var beschreibungT = $.trim($nTmp.text());
59				if(beschreibungT.length>150) {
60					$nBox.addClass("v-detail-more-less-toggle-box");
61					var lessContent = this._fnCutHTMLContent($nTmp.html(), 150);
62					var $nLessContainer = $(document.createElement("div")).addClass("v-detail-less-content").html(lessContent);	
63					$nBox.prepend($nLessContainer);
64					$nBox.append(this._fnCreateTextToggleBoxToggler());
65					this._fnAddToggleBoxListeners($nBox);
66				}
67			},
68			
69			/**
70			 * Kuerzt HTML auf x Zeichen
71			 */
72			'_fnCutHTMLContent': function(html, count) {
73				var ret = '';
74				var that = this;
75				var length = 0;
76				if(typeof html == 'string') {
77					var $tmp = $(document.createElement("div")).html(html);
78				} else {
79					var $tmp = $(html);
80				}
81				$tmp.contents().each(function() {
82					if(length>=count) {
83						return false;
84					} else {
85						var content = '';
86						if($(this).contents().length>0) {
87							content = that._fnCutHTMLContent(this, (count-length));
88						} else {
89							content = $(this).text();
90						}
91						if($.trim(content).length>0) {
92							content = ' '+content;
93							length += $.trim(content).length;
94							if(length>=(count+3)) {
95								content = content.substring(0, count)+'...';
96							} else if($.trim(ret).length>0){
97								var $parentBlock = $(this).parent('h1,h2,h3,h4,h5,h6,div,p').not('.is-used');	
98								if($parentBlock.text().length>0) {
99									$parentBlock.addClass('is-used');
100									length += 20;
101									content = ' <br />'+content;
102									//content = content+' <br />';
103								} else if($(this).is('h1,h2,h3,h4,h5,h6,div,p,li')) {
104									length += 20;
105									content = ' <br />'+content;
106								}
107							}
108							ret += content;
109						} 
110					}
111				});
112				return ret;
113			},
114			
115			'_fnCreateTextToggleBoxContainer': function($nMoreContent, $nLessContent) {
116				var $nToggler = this._fnCreateTextToggleBoxToggler();
117				var $nContainer = $(document.createElement("div"));
118				$nContainer.append($nLessContent);
119				$nContainer.append($nMoreContent);
120				$nContainer.append($nToggler);
121				return $nContainer;
122			},
123			
124			'_fnCreateTextToggleBoxToggler': function() {
125				var $nToggler = $(document.createElement("button")).addClass('v-detail-more-less-toggler v-detail-more').attr("type", "button").html(this.settings.moreButtonText);
126				return $nToggler;
127			},
128			
129			'_fnAddToggleBoxListeners': function($nBox) {
130				var that = this;
131				$nBox.find(".v-detail-more-less-toggler").click(function() {
132					that._fnOnToggle($(this), $nBox);
133				});
134			},
135			
136			'_fnOnToggle': function($nToggler, $nParentBox) {
137				var $nLessContent = $nParentBox.find(".v-detail-less-content");
138				if($nToggler.hasClass("v-detail-more")) {
139					if($nLessContent.hasClass('v-detail-less-content')) {
140						$nLessContent.slideUp(400, function() {
141							$nParentBox.find(".v-detail-more-content").slideDown(400, function() {
142								$nParentBox.find(".v-detail-more-content").find('div').trigger('wcomorelesstoggler.show');
143							});
144						});
145					} else {
146						$nParentBox.find(".v-detail-more-content").slideDown(400, function() {
147							$nParentBox.find(".v-detail-more-content").find('div').trigger('wcomorelesstoggler.show');
148						})
149					}
150					$nToggler.removeClass("v-detail-more").addClass("v-detail-less").html(this.settings.lessButtonText);
151				} else {
152					$nParentBox.find(".v-detail-more-content").slideUp(400, function() {
153						if($nLessContent.hasClass('v-detail-less-content')) {
154							$nLessContent.slideDown(400, function() {
155								$nLessContent.find('div').trigger('wcomorelesstoggler.show');
156							});
157						}
158					});
159					$nToggler.removeClass("v-detail-less").addClass("v-detail-more").html(this.settings.moreButtonText);
160				}
161			}
162		};
163		
164		$.extend(WcoMoreLessToggler.prototype, proto);
165	};
166	
167	$.fn.wcomorelesstoggler = function(opts){
168		var kc = new WcoMoreLessToggler();
169		kc._fnLoad(this, opts);
170	};
171	
172})(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.