- var $item = $link.wrap('<li><span /></li>').parent().parent();
-
- if (id) {
- $item.attr('id', id);
- }
- if (accesskey) {
- $link.attr('accesskey', accesskey);
- tooltip += ' [' + accesskey + ']';
- }
- if (tooltip) {
- $link.attr('title', tooltip);
- }
- if (accesskey && tooltip) {
- this.updateTooltipAccessKeys($link);
- }
-
- // Append using DOM-element passing
- if (nextnode && nextnode.parentNode == $ul.get(0)) {
- $(nextnode).before($item);
- } else {
- // If the jQuery selector isn't found within the <ul>, just append it at the end
- if ($ul.find(nextnode).length === 0) {
- $ul.append($item);
+
+ // Some skins don't have portlets
+ // Just add it to the bottom of their 'sidebar' element ignoring the specified portlet target
+ switch (skin) {
+ case 'standard' :
+ case 'cologneblue' :
+ $("#quickbar").append($link.after('<br />'));
+ return $link.get(0);
+ case 'nostalgia' :
+ $("#searchform").before($link).before(' | ');
+ return $link.get(0);
+ default : // chick, modern, monobook, myskin, simple, vector...
+
+ var $portlet = $('#' + portlet);
+ if ($portlet.length === 0) {
+ return null;
+ }
+ var $ul = $portlet.find('ul').eq(0);
+ if ($ul.length === 0) {
+ if ($portlet.find('div').length === 0) {
+ $portlet.append('<ul />');
+ } else {
+ $portlet.find('div').eq(-1).append('<ul />');
+ }
+ $ul = $portlet.find('ul').eq(0);
+ }
+ if ($ul.length === 0) {
+ return null;
+ }
+
+ // unhide portlet if it was hidden before
+ $portlet.removeClass('emptyPortlet');
+
+ var $item = $link.wrap('<li><span /></li>').parent().parent();
+
+ if (id) {
+ $item.attr('id', id);
+ }
+ if (accesskey) {
+ $link.attr('accesskey', accesskey);
+ tooltip += ' [' + accesskey + ']';
+ }
+ if (tooltip) {
+ $link.attr('title', tooltip);
+ }
+ if (accesskey && tooltip) {
+ this.updateTooltipAccessKeys($link);
+ }
+
+ // Append using DOM-element passing
+ if (nextnode && nextnode.parentNode == $ul.get(0)) {
+ $(nextnode).before($item);