User:Monster Domosed/common.js: Difference between revisionsGive feedback
No edit summary |
No edit summary |
||
| Line 36: | Line 36: | ||
function renderWidget($root, items) { | function renderWidget($root, items) { | ||
$root.empty(); | |||
items.forEach(function (item, index) { | items.forEach(function (item, index) { | ||
| Line 72: | Line 72: | ||
$li.append($titleLink).append($meta); | $li.append($titleLink).append($meta); | ||
$ | $root.append($li); | ||
}); | }); | ||
| Line 83: | Line 83: | ||
$moreLi.append($moreLink); | $moreLi.append($moreLink); | ||
$ | $root.append($moreLi); | ||
} | } | ||
| Line 110: | Line 108: | ||
function () { | function () { | ||
$root.html( | $root.html( | ||
'< | '<li class="recent-changes-error">Could not load recent changes.</li>' | ||
); | ); | ||
} | } | ||
| Line 127: | Line 125: | ||
} | } | ||
function | function getExistingPortletList() { | ||
var $portlet = $('#p-Recent_Changes, #p-RecentChanges').first(); | var $portlet = $('#p-Recent_Changes, #p-RecentChanges').first(); | ||
if (!$portlet.length) { | if (!$portlet.length) { | ||
| Line 134: | Line 131: | ||
} | } | ||
var $ | var $list = $portlet.find('.vector-menu-content-list').first(); | ||
/ | if (!$list.length) { | ||
var $content = $portlet.find('.vector-menu-content | $list = $('<ul class="vector-menu-content-list recent-changes-list"></ul>') | ||
.attr('data-limit', '4') | |||
.attr('data-refresh', '300000'); | |||
var $content = $portlet.find('.vector-menu-content').first(); | |||
if ($content.length) { | if ($content.length) { | ||
$content.append($ | $content.append($list); | ||
} else { | } else { | ||
$portlet.append($ | $portlet.append($list); | ||
} | |||
} else { | |||
$list.addClass('recent-changes-list'); | |||
if (!$list.data('limit')) { | |||
$list.attr('data-limit', '4'); | |||
} | |||
if (!$list.data('refresh')) { | |||
$list.attr('data-refresh', '300000'); | |||
} | } | ||
} | } | ||
return $ | return $list; | ||
} | } | ||
$(function () { | $(function () { | ||
var $widget = | var $widget = getExistingPortletList(); | ||
if ($widget.length) { | if ($widget.length) { | ||
initWidget($widget); | initWidget($widget); | ||