MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
m
changed names due conflict in MediaWiki:Common.css
mNo edit summary
m (changed names due conflict in MediaWiki:Common.css)
Line 221: Line 221:


// JS function to truncate text of the captions used in Template:YouTube and Template:Image (when called by the template)
// JS function to truncate text of the captions used in Template:YouTube and Template:Image (when called by the template)
var thumbcaption_p=$('#thumbcaption p');
var thumbcaptiont_p=$('#thumbcaption_truncated p');
var thumbcaption=$('#thumbcaption').height();
var thumbcaptiont=$('#thumbcaption_truncated').height();
while ($(thumbcaption_p).outerHeight()>thumbcaption) {
while ($(thumbcaptiont_p).outerHeight()>thumbcaptiont) {
     $(thumbcaption_p).text(function (index, text) {
     $(thumbcaptiont_p).text(function (index, text) {
         return text.replace(/\W*\s(\S)*$/, '...');
         return text.replace(/\W*\s(\S)*$/, '...');
     });
     });
}​
}​

Navigation menu