PageSourceSearch

https://www.shn.ch/themes/custom/shn/libraries/jquery.dotdotdot.min.js?tlvx62

js shn.ch collected 2026-09-24 20:29:29 UTC 6,238 bytes, 13 lines download raw bytes

1/*
2 *	jQuery dotdotdot 3.2.2
3 *	@requires jQuery 1.7.0 or later
4 *
5 *	dotdotdot.frebsite.nl
6 *
7 *	Copyright (c) Fred Heusschen
8 *	www.frebsite.nl
9 *
10 *	License: CC-BY-NC-4.0
11 *	http://creativecommons.org/licenses/by-nc/4.0/
12 */
13!function(t){"use strict";var e,i,n,s,o="dotdotdot",r="3.2.2";t[o]&&t[o].version>r||(t[o]=function(t,e){this.$dot=t,this.api=["getInstance","truncate","restore","destroy","watch","unwatch"],this.opts=e;var i=this.$dot.data(o);return i&&i.destroy(),this.init(),this.truncate(),this.opts.watch&&this.watch(),this},t[o].version=r,t[o].uniqueId=0,t[o].defaults={ellipsis:"… ",callback:function(t){},truncate:"word",tolerance:0,keep:null,watch:"window",height:null},t[o].prototype={init:function(){this.watchTimeout=null,this.watchInterval=null,this.uniqueId=t[o].uniqueId++,this.originalStyle=this.$dot.attr("style")||"",this.originalContent=this._getOriginalContent(),"break-word"!==this.$dot.css("word-wrap")&&this.$dot.css("word-wrap","break-word"),"nowrap"===this.$dot.css("white-space")&&this.$dot.css("white-space","normal"),null===this.opts.height&&(this.opts.height=this._getMaxHeight()),"string"==typeof this.opts.ellipsis&&(this.opts.ellipsis=document.createTextNode(this.opts.ellipsis))},getInstance:function(){return this},truncate:function(){this.$inner=this.$dot.wrapInner("<div />").children().css({display:"block",height:"auto",width:"auto",border:"none",padding:0,margin:0}),this.$inner.empty().append(this.originalContent.clone(!0)),this.maxHeight=this._getMaxHeight();var t=!1;return this._fits()||(t=!0,this._truncateToNode(this.$inner[0])),this.$dot[t?"addClass":"removeClass"](e.truncated),this.$inner.replaceWith(this.$inner.contents()),this.$inner=null,this.opts.callback.call(this.$dot[0],t),t},restore:function(){this.unwatch(),this.$dot.empty().append(this.originalContent).attr("style",this.originalStyle).removeClass(e.truncated)},destroy:function(){this.restore(),this.$dot.data(o,null)},watch:function(){var t=this;this.unwatch();var e={};"window"==this.opts.watch?s.on(n.resize+t.uniqueId,function(i){t.watchTimeout&&clearTimeout(t.watchTimeout),t.watchTimeout=setTimeout(function(){e=t._watchSizes(e,s,"width","height")},100)}):this.watchInterval=setInterval(function(){e=t._watchSizes(e,t.$dot,"innerWidth","innerHeight")},500)},unwatch:function(){s.off(n.resize+this.uniqueId),this.watchInterval&&clearInterval(this.watchInterval),this.watchTimeout&&clearTimeout(this.watchTimeout)},_api:function(){var e=this,i={};return t.each(this.api,function(t){var n=this;i[n]=function(){var t=e[n].apply(e,arguments);return void 0===t?i:t}}),i},_truncateToNode:function(i){var n=[],s=[];if(t(i).contents().each(function(){var i=t(this);if(!i.hasClass(e.keep)){var o=document.createComment("");i.replaceWith(o),s.push(this),n.push(o)}}),s.length){for(var o=0;o<s.length;o++){t(n[o]).replaceWith(s[o]),t(s[o]).append(this.opts.ellipsis);var r=this._fits();if(t(this.opts.ellipsis,s[o]).remove(),!r){if("node"==this.opts.truncate&&o>1)return void t(s[o-2]).remove();break}}for(var h=o;h<n.length;h++)t(n[h]).remove();var a=s[Math.max(0,Math.min(o,s.length-1))];if(1==a.nodeType){var d=t("<"+a.nodeName+" />");d.append(this.opts.ellipsis),t(a).replaceWith(d),this._fits()?d.replaceWith(a):(d.remove(),a=s[Math.max(0,o-1)])}1==a.nodeType?this._truncateToNode(a):this._truncateToWord(a)}},_truncateToWord:function(t){for(var e=t,i=this,n=this.__getTextContent(e),s=-1!==n.indexOf(" ")?" ":" ",o=n.split(s),r="",h=o.length;h>=0;h--)if(r=o.slice(0,h).join(s),i.__setTextContent(e,i._addEllipsis(r)),i._fits()){"letter"==i.opts.truncate&&(i.__setTextContent(e,o.slice(0,h+1).join(s)),i._truncateToLetter(e));break}},_truncateToLetter:function(t){for(var e=this,i=this.__getTextContent(t).split(""),n="",s=i.length;s>=0&&(!(n=i.slice(0,s).join("")).length||(e.__setTextContent(t,e._addEllipsis(n)),!e._fits()));s--);},_fits:function(){return this.$inner.innerHeight()<=this.maxHeight+this.opts.tolerance},_addEllipsis:function(e){for(var i=[" "," ",",",";",".","!","?"];t.inArray(e.slice(-1),i)>-1;)e=e.slice(0,-1);return e+=this.__getTextContent(this.opts.ellipsis)},_getOriginalContent:function(){var i=this;return this.$dot.find("script, style").addClass(e.keep),this.opts.keep&&this.$dot.find(this.opts.keep).addClass(e.keep),this.$dot.find("*").not("."+e.keep).add(this.$dot).contents().each(function(){var e=this,n=t(this);if(3==e.nodeType){if(""==t.trim(i.__getTextContent(e))){if(n.parent().is("table, thead, tbody, tfoot, tr, dl, ul, ol, video"))return void n.remove();if(n.prev().is("div, p, table, td, td, dt, dd, li"))return void n.remove();if(n.next().is("div, p, table, td, td, dt, dd, li"))return void n.remove();if(!n.prev().length)return void n.remove();if(!n.next().length)return void n.remove()}}else 8==e.nodeType&&n.remove()}),this.$dot.contents()},_getMaxHeight:function(){if("number"==typeof this.opts.height)return this.opts.height;for(var t=["maxHeight","height"],e=0,i=0;i<t.length;i++)if("px"==(e=window.getComputedStyle(this.$dot[0])[t[i]]).slice(-2)){e=parseFloat(e);break}t=[];switch(this.$dot.css("boxSizing")){case"border-box":t.push("borderTopWidth"),t.push("borderBottomWidth");case"padding-box":t.push("paddingTop"),t.push("paddingBottom")}for(i=0;i<t.length;i++){var n=window.getComputedStyle(this.$dot[0])[t[i]];"px"==n.slice(-2)&&(e-=parseFloat(n))}return Math.max(e,0)}
13,_watchSizes:function(t,e,i,n){if(this.$dot.is(":visible")){var s={width:e[i](),height:e[n]()};return t.width==s.width&&t.height==s.height||this.truncate(),s}return t},__getTextContent:function(t){for(var e=["nodeValue","textContent","innerText"],i=0;i<e.length;i++)if("string"==typeof t[e[i]])return t[e[i]];return""},__setTextContent:function(t,e){for(var i=["nodeValue","textContent","innerText"],n=0;n<i.length;n++)t[i[n]]=e}},t.fn[o]=function(r){return function(){s=t(window);e={};i={};n={};t.each([e,i,n],function(t,e){e.add=function(t){for(var i=0,n=(t=t.split(" ")).length;i<n;i++)e[t[i]]=e.ddd(t[i])}});e.ddd=function(t){return"ddd-"+t};e.add("truncated keep");i.ddd=function(t){return"ddd-"+t};n.ddd=function(t){return t+".ddd"};n.add("resize");(function(){})}(),r=t.extend(!0,{},t[o].defaults,r),this.each(function(){t(this).data(o,new t[o](t(this),r)._api())})})}(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.