Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/ |
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/truncate.min.js |
define ("core/truncate",["jquery"],function(a){var b=function(a,b){var c=a+"",d=c.length,e=b?+b:0;if(e!=e){e=0}if(-1>=e||e>=d){return""}e=0|e;var f=c.charCodeAt(e),g,h=e+1,i=1;if(55296<=f&&56319>=f&&d>h){g=c.charCodeAt(h);if(56320<=g&&57343>=g){i=2}}return i},c=function(a){for(var c=0,d=0;d<a.length;d+=b(a,d)){c++}return c},d=function(a,c){if(!a.length){return 0}var d=0,e=0;do{d+=b(a,d);e++}while(d<a.length&&e<c);return d};a.truncate=function(b,c){return a("<div></div>").append(b).truncate(c).html()};a.fn.truncate=function(b){if(!isNaN(parseFloat(b)))b={length:b};var e=a.extend({},a.truncate.defaults,b);return this.each(function(){var b=a(this);if(e.noBreaks)b.find("br").replaceWith(" ");var f=e.ellipsis.length,g=b.text(),h=c(g),j=h-e.length+f;if(h<e.length)return;if(e.stripTags)b.text(g);if(e.words&&0<j){var k=g.slice(0,d(g,e.length-f)+1),l=k.replace(/(\s*\S+|\s)$/,""),m=c(l),n=k.match(/\s/)?!1:!0;if(e.keepFirstWord&&0===m){j=h-c(/^(\S*)/.exec(g)[0])-f}else if(n&&0===m){j=h-e.length+f}else{j=h-m-1}}if(j>h){j=h-e.length}if(0>j||!j&&!e.truncated)return;a.each(b.contents().get().reverse(),function(b,g){var h=a(g),i=h.text(),k=c(i);if(k<=j){e.truncated=!0;j-=k;h.remove();return}if(3===g.nodeType){var l=k-j;l=0<=l?d(i,l):0;a(g.splitText(l)).replaceWith(e.ellipsis);return!1}h.truncate(a.extend(e,{length:k-j+f}));return!1})})};a.truncate.defaults={stripTags:!1,words:!1,keepFirstWord:!1,noBreaks:!1,length:1/0,ellipsis:"\u2026"};return{truncate:a.truncate}}); //# sourceMappingURL=truncate.min.js.map