2 * jQuery Shorten plugin 1.1.0
4 * Copyright (c) 2014 Viral Patel
5 * http://viralpatel.net
7 * Licensed under the MIT license:
8 * http://www.opensource.org/licenses/mit-license.php
12 ** updated by Jeff Richardson
13 ** Updated to use strict,
14 ** IE 7 has a "bug" It is returning undefined when trying to reference string characters in this format
15 ** content[i]. IE 7 allows content.charAt(i) This works fine in all modern browsers.
16 ** I've also added brackets where they weren't added just for readability (mostly for me).
20 ** largely modified by Jan Szejko
21 ** Now it doesn't shorten the text, just changes adds a class and lets CSS do the rest
25 $.fn.shorten = function(settings) {
33 onLess: function() {},
34 onMore: function() {},
40 $.extend(config, settings);
43 if ($(this).data('jquery.shorten') && !config.force) {
46 $(this).data('jquery.shorten', true);
48 $(document).off("click", '.morelink');
53 var $this = $(this), $main = $this.prev();
54 if ($main.hasClass('short')) {
55 $main.removeClass('short');
56 $this.html(config.lessText);
59 $main.addClass('short');
60 $this.html(config.moreText);
67 return this.each(function() {
69 var button = '<a href="javascript:void(0)" class="morelink">' + config.moreText + '</a></span>';
70 $this.addClass('short');