Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

account for content wrapped in <p> tags & various fixes #11

Merged
merged 1 commit into from
Feb 11, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions src/jquery.shorten.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* jQuery Shorten plugin 1.0.0
* jQuery Shorten plugin 1.1.0
*
* Copyright (c) 2013 Viral Patel
* Copyright (c) 2014 Viral Patel
* http://viralpatel.net
*
* Licensed under the MIT license:
Expand All @@ -20,11 +20,11 @@
$.fn.shorten = function (settings) {

"use strict";
if ($(this).data('jquery.shorten')){
return false;
}
$(this).data('jquery.shorten', true);
if ($(this).data('jquery.shorten')){
return false;
}
$(this).data('jquery.shorten', true);
var config = {
showChars: 100,
ellipsesText: "...",
Expand Down Expand Up @@ -124,15 +124,16 @@
}
}
}
c = bag;
c = $('<div/>').html(bag + '<span class="ellip">' + config.ellipsesText + '</span>').html();
}

var html = '<span class="shortcontent">' + c + '&nbsp;' + config.ellipsesText +
'</span><span class="allcontent">' + content +
'</span>&nbsp;&nbsp;<span><a href="javascript://nop/" class="morelink">' + config.moreText + '</a></span>';
var html = '<div class="shortcontent">' + c +
'</div><div class="allcontent">' + content +
'</div><span><a href="javascript://nop/" class="morelink">' + config.moreText + '</a></span>';

$this.html(html);
$this.find(".allcontent").hide(); // Esconde el contenido completo para todos los textos
$this.find(".allcontent").hide(); // Hide all text
$('.shortcontent p:last', $this).css('margin-bottom',0); //Remove bottom margin on last paragraph as it's likely shortened
}
});

Expand Down