MediaWiki:Common.js: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
(After messing around and trying to implement this using pure CSS, it'll be easy to use some JS alongside the CSS...)
mNo edit summary
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 gtcp=$('#gallerythumb_caption p');
var thumbcaption_p=$('#thumbcaption p');
var gtcdivh=$('#gallerythumb_caption').height();
var thumbcaption=$('#thumbcaption').height();
while ($(gtcp).outerHeight()>gtcdivh) {
while ($(thumbcaption_p).outerHeight()>thumbcaption) {
     $(gtcp).text(function (index, text) {
     $(thumbcaption_p).text(function (index, text) {
         return text.replace(/\W*\s(\S)*$/, '...');
         return text.replace(/\W*\s(\S)*$/, '...');
     });
     });
}​
}​

Navigation menu