1/*! 2 * jQuery.Elimore 3 * http://github.com/luftinur/jquery.elimore 4 * -------------------------------------------------------------------------- 5 * Copyright (c) 2018 Lufti Nurfahmi (@luftinur) 6 * Dual licensed under the MIT and GPL licenses: 7 * http://www.opensource.org/licenses/mit-license.php 8 * http://www.gnu.org/licenses/gpl.html 9 * 10 * Create Ellipsis Of Text 11 * Change Log add options data url 12 */ 13if (typeof Object.create !== 'function') { 14 Object.create = function (obj) { 15 function _O() { }; 16 _O.prototype = obj; 17 return new _O(); 18 19 } 20 21} 22; (function ($, window, document, undefined) { 23 'use strict'; 24 25 var _Elimore = { 26 init: function (options, el) { 27 var self = this; 28 self.el = el; 29 self.$el = $(el); 30 // Store the length text of each element; 31 self.$lengthtext = self.$el.text().length; 32 self.options = $.extend({}, $.fn.elimore.options, options); 33 34 35 // Check The Length Text 36 if (self.$lengthtext >= self.options.maxLength) { 37 self.ellipsis(); 38 } else { 39 return self; 40 } 41 42 43 }, 44 ellipsis: function () { 45 46 var self = this; 47 48 //self.$elimore_toggle = $("._elimore_toggle"); 49 50 if (self.options.dataUrl) { 51 52 var fullTxt = self.$el.text(), 53 text_one = fullTxt.substr(0, self.options.maxLength), 54 dataUrl = self.$el.data("url"); 55 56 console.log(dataUrl); 57 var more_btn = '<a href="' + dataUrl + '">' + self.options.moreText + '</a>'; 58 59 self.$el.html(""); 60 61 self.$el.append(text_one + more_btn); 62 63 } else { 64 65 var fullTxt = self.$el.text(), 66 text_one = fullTxt.substr(0, self.options.maxLength), 67 text_two = fullTxt.substr(self.options.maxLength, self.$lengthtext); 68 69 var more_btn = '<a href="javascript:;" class="elimore_show">' + self.options.moreText + '</a>', 70 less_btn = '<a href="javascript:;" class="elimore_hide" style="display:none;">' + self.options.lessText + '</a>'; 71 72 if (self.options.showOnly) { 73 less_btn = ''; 74 } 75 76 self.$el.html(""); 77 if(self.options.trimOnly){ 78 self.$el.append(text_one); 79 }else{ 80 self.$el.append(text_one + '<span class="elimore_trim" style="display:none">' + text_two + '</span>' + more_btn + less_btn); 81 } 82 83 84 self._toggle_ellipsis(); 85 86 } 87 88 89 90 91 }, 92 _toggle_ellipsis: function () { 93 var self = this; 94 95 self.$show_btn = self.$el.children().find("a.elimore_show"); 96 97 // Toggle Show Hide For Ellipsis Text 98 self.$el.on("click", ".elimore_show", function () { 99 self.$el.children().toggle(); 100 }); 101 self.$el.on("click", ".elimore_hide", function () { 102 self.$el.children().toggle(); 103 }); 104 } 105 106 } 107 108 $.fn.elimore = function (options) { 109 return this.each(function () { 110 var em = Object.create(_Elimore); 111 em.init(options, this); 112 }); 113 }; 114 115 $.fn.elimore.options = { 116 maxLength: 250, 117 moreText: "Read More", 118 lessText: "Read Less", 119 showOnly: false, 120 dataUrl: false, 121 trimOnly : false 122 }; 123 124 125})(jQuery, window, document); 126
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.