Fandom Developers Wiki
(→‎For blog posts: new section)
Line 144: Line 144:
   
 
::::In other words: <code>.eq(0)</code> would only be of indirect use to you. In your own code it's probably useless. But if you're interested anyway, take a look at [http://css-tricks.com/pseudo-class-selectors/ this] and [http://api.jquery.com/eq/ this] -- [[w:Message_Wall:Pecoes|peco<span style="vertical-align:-0.2em">e</span>s]] 15:27, July 08, 2012 (UTC)
 
::::In other words: <code>.eq(0)</code> would only be of indirect use to you. In your own code it's probably useless. But if you're interested anyway, take a look at [http://css-tricks.com/pseudo-class-selectors/ this] and [http://api.jquery.com/eq/ this] -- [[w:Message_Wall:Pecoes|peco<span style="vertical-align:-0.2em">e</span>s]] 15:27, July 08, 2012 (UTC)
  +
  +
== For blog posts ==
  +
  +
I need to purge blog posts to see properly their replies. I do it by entering <code>?action=purge</code> manually, but what if PurgeButton could also purge the blog posts? [[User:Cafeinlove|Cafeinlove]], 22:06, July 10, 2012 (UTC)

Revision as of 22:06, 10 July 2012

Redundant buttons

A bug for you to chew on: Use this, then go on a blog page. Redundant buttons. --Zapwire (invisible leather tardis) 14:14, December 16, 2009 (UTC) Old, as well as any wiki with SMW. Just need to have it check the current ns and not appear if it's in X. Joey (talk) 15:07, December 18, 2009 (UTC)

New profile masthead

With this edit, Monchoman45 fixed the code for the Purge button so that it would work with the new profile masthead. It worked brilliantly for a bit. But, now it seems to have stopped working in the user and usertalk namespaces again. Just wanted to alert you guys. Thanks! — SpikeToronto 05:37, August 26, 2011 (UTC)

Should be fixed. grunny:~$ 16:40, August 26, 2011 (UTC)
It works! Only, now the pulldown has a certain level of tranparency to it pulls down behind other elements. Although that may only be on pages with the new RTE activated. Thanks! — SpikeToronto 21:17, August 26, 2011 (UTC)
Update: Well, it is working great on userpages and user talkpages, and in other namespaces. However, it does not show up in subpages in the user namespace. (See here for an example.) Thanks! — SpikeToronto 07:36, August 29, 2011 (UTC)
Should be fixed. grunny:~$ 08:10, August 30, 2011 (UTC)

Localizations

Can the translations be added in a similar way to ShowHide code? leviathan_89 21:50, March 11, 2012 (UTC)

Other Languages — Chinese

"Purge" in Chinese is "刷新" -- Sam Wang (talk) 04:57, May 13, 2012 (UTC)

Small improvement

There are two things that I feel could be improved upon:

  1. The dangling "action=purge" in the URL is really annoying.
  2. This function does not purge the browser's cache.

So how about this:

function purge () {
    $.get('/index.php?title=' + encodeURIComponent(wgPageName) + '&action=purge', function () {
        location.reload(true);
    });
}

Or in full:

if( wgNamespaceNumber >= 0 && !window.PurgeButtonsLoaded && document.getElementById('control_purge') == null && wgNamespaceNumber != 500 && wgNamespaceNumber != 502 ) {
    addOnloadHook( addPurgeButton );
}
var PurgeButtonsLoaded = true; // prevent duplicate running (but not dupe buttons from outside this code)

function addPurgeButton () {
    var theText = 'Refresh'; //default text, ala SMW
    
    if( typeof PurgeButtonText == "string" ) {
        theText = PurgeButtonText;
    }

    function purge () {
        $.get('/index.php?title=' + encodeURIComponent(wgPageName) + '&action=purge', function () {
            location.reload(true);
        });
    }
    
    switch( skin ) {
        case 'answers': /* forked from monaco, close enough, pass to monaco */
        case 'awesome': /* you really shouldnt even have this value... */
        case 'monaco_old': /* really, where are you getting these skin settings from... */
        case 'monaco':
            $('#page_controls').append('<li id="control_purgebutton"><img src="/skins/common/blank.gif" class="sprite refresh" /><a id="purge" href="javascript:void(0)" title="Purge page">'+ theText + '</a></li>');
            break;


        case 'uncyclopedia': /* monobook clone, pass to monobook */
        case 'wowwiki': /* monobook clone, pass to monobook */
        case 'lostbook': /* monobook clone, pass to monobook */
        case 'monobook':
            $('#p-cactions > .pBody > ul').append('<li id="ca-purge"><a id="purge" href="javascript:void(0)" title="Purge page">'+ theText + '</a></li>');
            break;

        case 'oasis':
        case 'wikia':
            $(((wgNamespaceNumber == 2 || wgNamespaceNumber == 3) && $( '.UserProfileActionButton' ).length ? '.UserProfileActionButton' : '#WikiaPageHeader') + ' > .wikia-menu-button > ul').append('<li><a id="purge" href="javascript:void(0)" title="Purge page">'+ theText + '</a></li>');
            break;

    }
    
    $('#purge').click(purge);
}

-- pecoes 18:39, June 11, 2012 (UTC)

*bump* pecoes 05:54, June 13, 2012 (UTC) -- pecoes 09:57, June 13, 2012 (UTC)
Done. Cheers, grunny@:~$ 16:47, June 16, 2012 (UTC)
Thanks! I like how this clears the ?action=purge from the URL. That way, if I want, I can just Ctrl-F5 after. Thanks guys! — SpikeToronto 21:50, June 16, 2012 (UTC)
Actually, you don't have to Ctrl+F5 anymore. That's already included. -- pecoes 21:57, June 16, 2012 (UTC)
Perfect! Double thanks!! — SpikeToronto 22:28, June 16, 2012 (UTC)
By the way, at least in Internet Explorer, this new function is closer to Reload than Refresh. Thanks! — SpikeToronto 05:22, June 17, 2012 (UTC)

Only add to main menu button

Can the code be changed to only append Purge to the main menu button? I have created a second menu button with extra admin functions and I'm annoyed that Purge gets appended there as well since it's of class "wikia-menu-button" too. Land Raider 13:49, July 3, 2012 (UTC)

Do you have an example page? Or can you post your button's HTML and/or where it's located in the DOM? -- pecoes 14:24, July 03, 2012 (UTC)
You can probably fix this in your personal CSS. — SpikeToronto 19:32, July 4, 2012 (UTC)
Basically, I modified FastDelete tool to create a menu with FastDelete buttons instead of separate buttons (which is done by default). The menu is created with:
$( 'header.WikiaPageHeader' ).append('<nav class="wikia-menu-button"><a title="FastDelete" data-summary="Cleanup. See [[MediaWiki:Policy|Policy]] for details" data-id="fastdelete"><img class="sprite edit-pencil" width="30" height="16" src="data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D" alt="">FastDelete</a><span class="drop"><img class="chevron" src="data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D"></span><ul id="fastdelete-list" class="WikiaMenuElement"></ul></nav>');

which is the only way I found to create another menu in addition to the main (Edit/Rephrase/Delete and Purge, if installed) one. In order for the menu to actually be a

menu, it needs this 'wikia-menu-button class but PurgeButton gets appended to that menu too, then. You're saying I can fix that in my personal CSS - how can this be done? I have tried to created a new menu button class but realized that CSS apparently can't "inherit" properties of other classes, and I don't know where to steal the CSS for the standard wikia-menu-button so that I could create another class based on it. If you suggest some other fix, I'd be glad to know about it. Land Raider 15:00, July 5, 2012 (UTC)


If you use Wikia's CSS to create complex interface elements, you have to plan for side-effects. Your drop-down button is basically a hack at this point. The only real fix is to write the CSS for the nav-button yourself. You can take Wikia's CSS as a blueprint, if you like. -- pecoes 15:51, July 05, 2012 (UTC)
Where do I find Wikia's CSS which defines wikia-menu-button? Land Raider 15:05, July 6, 2012 (UTC)
What you’ve done, LandRaider, sounds very interesting. If I understand it correctly, it adds the FastDelete buttons to the edit button pulldown? Could it be made to branch out from the "delete" entry on the button? The reason I ask is that the pulldown is already long with all the options already there. Thanks! — SpikeToronto 00:24, July 6, 2012 (UTC)
No, it creates a second menu because as you said, the Edit one is already quite crowded and those buttons delete a page instantly, so caution is needed when using them and it's better to separate them from standard tools. Take a look. Land Raider 15:05, July 6, 2012 (UTC)
As a quick hack: How about adding a height property to the dropdown and setting the overflow to "hidden"?
And out of curiosity: What do those sub-buttons mean? -- pecoes 15:51, July 06, 2012 (UTC)
EDIT: Sorry I didn't see your follow-up question above: You can find the CSS for menu button by "inspecting" the element either with Firefox/Firebug or Chrome. -- pecoes 15:53, July 06, 2012 (UTC)
Sub-buttons? "Wiki" for questions that can be answered by reading the "main" wiki (game answers wikias are not contributor-powered search engines for easily accessible documented knowledge, after all!), "Opinion" for breaking the Wikia answers policy (questions which can only have answers based on personal opinion are considered out of place) and "Spec" for baseless speculation requests (inquiries about information that cannot be deduced from the topic's media - games, movies, books, etc. - and is therefore baseless speculation). Regarding inspecting, I did that already (that's how I got the code for the button on the first place), but I was too confused with the CSS, I know very little about it and JavaScript. I'll try it out soon though, thanks for your suggestion! As for the quick hack, it's a good idea but a complete abomination from my point of view, an extra level of complexity... better try creating my own button with CSS :) Land Raider 20:14, July 6, 2012 (UTC)

"better try creating my own button with CSS :)"

Absolutely :) -- pecoes 20:39, July 06, 2012 (UTC)

What about adding .eq(0) to the PurgeButton selector? CSS classes are ther to be reused. No need to reinvent the wheel, specially when he wants to have the exact same functionality of the already existing menu button. I'm too lazy at that moment to switch to the Oasis skin, but if the existing button has an ID, PurgeButton should select the menu button by the ID rather than the CSS class, to prevent this from occurring. Otherwise, better put .eq(0) to the selector --Ciencia Al Poder en WikiDex 12:15, July 7, 2012 (UTC)
Only Grunny has edit-rights for the code and he hasn't chimed in yet. -- pecoes 12:48, July 07, 2012 (UTC)
What does .eq(0) do? Also, I tried selecting by ID in my customized PurgeButton code which I imported to DAA and it didn't work, but ought to be just my lame JS skills. If this can be done, I'd be delighted. Land Raider
Cienca's suggestion was that it would be easier to modify the PurgeButton script with .eq(0) then for you to recreate the CSS from scratch. .eq(0) selects the first matching node, so attaching it to the jQuery selector would cause only the first nav of class wikia-menu-button to be retrofitted with the purge-option.
In other words: .eq(0) would only be of indirect use to you. In your own code it's probably useless. But if you're interested anyway, take a look at this and this -- pecoes 15:27, July 08, 2012 (UTC)

For blog posts

I need to purge blog posts to see properly their replies. I do it by entering ?action=purge manually, but what if PurgeButton could also purge the blog posts? Cafeinlove, 22:06, July 10, 2012 (UTC)