Community Central
Community Central
No edit summary
m (→‎top: Collas(ible|ed) => mw-collaps(ible|ed).)
Tag: apiedit
 
(4 intermediate revisions by 3 users not shown)
Line 9: Line 9:
 
http://images2.wikia.nocookie.net/monsterwars/images/e/ed/Search-switch.gif
 
http://images2.wikia.nocookie.net/monsterwars/images/e/ed/Search-switch.gif
   
Here's the js:
+
Here's the js:
{|class="collapsible collapsed"
+
{|class="mw-collapsible mw-collapsed"
 
!
 
!
 
|-
 
|-
Line 167: Line 167:
   
 
::This seems to work just fine for me -- [[User:Sam Wang|Sam Wang]] ({{#ifexist: Message Wall:Sam Wang | [[Message Wall:Sam Wang|wall]] | [[User talk:Sam Wang|talk]] }}) 04:55, August 5, 2012 (UTC)
 
::This seems to work just fine for me -- [[User:Sam Wang|Sam Wang]] ({{#ifexist: Message Wall:Sam Wang | [[Message Wall:Sam Wang|wall]] | [[User talk:Sam Wang|talk]] }}) 04:55, August 5, 2012 (UTC)
  +
  +
'''Comment''' - Change the two occurrences of the following lines:
  +
<pre>
  +
if (settings & 1) { $go_button.after($original_search_button); }
  +
else { $original_search_button.after($go_button); }
  +
</pre>
  +
To:
  +
<pre>
  +
if (settings & 1) {
  +
$go_button.show();
  +
$original_search_button.hide();
  +
}
  +
else {
  +
$original_search_button.show();
  +
$go_button.hide();
  +
}
  +
</pre>
  +
And to allow for the additional space with one less button, remove <code>$options_button.outerWidth(true)</code> in the <code>$search_text.css</code> block, <code>.width</code> line. As for changing the color for the Base64 colors, just upload them to a [http://www.dailycoding.com/Utils/Converter/ImageToBase64.aspx Image to Base64] converter (the arrow/dots only). {{Signatures/Ryan_PM}} 20:20, August 5, 2012 (UTC)
  +
  +
:Jens Ingels: modifying the search feature wiki-wide like this is a [[Terms of Use]] violation. Refer to [[User_blog:Daniel_Baran/Search_Developments:_Big_Picture|this Staff blog]], specifically the notice at the very bottom under '''Policy note'''. If you are making this as a user script for just yourself or that has to be manually installed by individual users, that's fine. But if this is being applied in MediaWiki:Common.js or MediaWiki:Wikia.js, it's a TOU violation and staff would ask you to remove it if they knew about it. {{User:Mathmagician/sig|21:23 UTC|Sun|05 August 2012}}
  +
The bug seems only to apear when your wiki has an black navheader. When your search image is black the dot will not recolor with it.
  +
  +
Thx all for the info it worked. I just finished the code on one of my wikias: [http://monsterwars.wikia.com/wiki/MediaWiki:Common.js/Search_Fix.js].
  +
  +
Also thx for the info of the policy note. I didn't known an search extension is ilegal. They should add an note of it in the dev.wikia. --[[User:Jens Ingels|Jens Ingels]] ([[User talk:Jens Ingels|talk]]) 18:24, August 6, 2012 (UTC)
  +
  +
Fast question, is the dev wikia from wikia itself? I currently post it on the talk with the go extension. I think it's usefull also for other users.

Latest revision as of 21:01, 18 October 2016

Forums: Index Support Requests Search Fix.js edite
Fandom's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.
Archive
Note: This topic has been unedited for 2738 days. It is considered archived - the discussion is over. Information in this thread may be out of date. Do not add to unless it really needs a response.

I'm back with another problem. I want to change the textcolors off this buttoms to back like the searchbuttom is now:
Searchfix.png

Any idea how to do this. The js works with an save system. And I also want to try to hide the buttom. Here's an photoshop result how it want it to be:
Search-switch.gif

Here's the js:

/*global $, skin */
/*jslint devel: true, browser: true, indent: 2, plusplus: true, bitwise: true, white: true */

(function () {
  'use strict';
  var jq_go = function () {
    if (skin !== 'oasis') { return; }
    var
      get_cookie = function () {
        var i, c, cl = document.cookie.split(';');
        for (i = 0; i < cl.length; i++) {
          c = $.trim(cl[i]);
          if (c.indexOf('search_fix=') === 0) { return parseInt(c.substring(11), 10) || 0; }
        }
        return 1;
      },
      set_cookie = function (val) {
        var date = new Date();
        date.setTime(date.getTime() + (20 * 365 * 30 * 24 * 60 * 60 * 1000));
        date = date.toGMTString();
        document.cookie = 'search_fix=' + val + '; expires=' + date + '; domain=.wikia.com; path=/';
        return val;
      },
      loc = (
        $('#WikiaRail #WikiaSearch').size() ? 0 : (
          $('#WikiHeader #WikiaSearch').size() ? 1 : (
            $('#WikiaArticle .WikiaSearch').size() ? 2 : (
              $('#WikiaPageHeader #WikiaSearch').size() ? 3 : 0
            )
          )
        )
      ),//0=rail, 1=recentchanges, 2=wikia "thing", 3=main page
      settings = get_cookie(),
      $wikia_search = $('form#WikiaSearch, form.WikiaSearch').first(),
      $original_search_button = $wikia_search.find('button.wikia-button:first'),
      $go_button = $original_search_button.clone(),
      $options_button = $original_search_button.clone().attr('type', 'button'),
      $search_text = $wikia_search.find('input[name="search"]'),
      go_button_arrow = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAQCAYAAAD52jQlAAAAAXNSR0IArs4c6QAAAFNJREFUOMtjYBgs4P///2fwyTNSYiAjI6MJVQwlxmBGagQBusGM1ApbZIMZqRlpMIMZiYlNUgAjI6MJEy2SHO28P2giiupJiuqJn5hsSpMChSYAAGM0M6CqfzSlAAAAAElFTkSuQmCC',
      options_button_dots = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAYAAAAmlE46AAAAAXNSR0IArs4c6QAAAB5JREFUKM9jYBgFo2CkgP///5/5////GWL5THR3IQCrQha54XKThQAAAABJRU5ErkJggg==';
    if ($wikia_search.size() < 1) { return; }

    /*adding buttons*/
    $original_search_button.after($options_button).before($go_button);
    $go_button.add($options_button).find('img')
      .removeClass('sprite search')
      .attr('alt', function (i) { return ['Go', 'Options'][i]; })
      .attr('src', function (i) { return [go_button_arrow, options_button_dots][i]; })
      .add($original_search_button.find('img'))
      .height(16).width(function (i) { return [21, 21, 10][i]; })
      .parent().css('margin', '0px 1px');
    $go_button.css('right', '+=' + ($original_search_button.outerWidth(true) + $options_button.outerWidth(true)));
    $original_search_button.css('right', '+=' + $options_button.outerWidth(true));
    $search_text.css('margin-right', '-=6')
      .width($search_text.width() - ($original_search_button.outerWidth(true) + $options_button.outerWidth(true)));

    if (settings & 1) { $go_button.after($original_search_button); }
    else { $original_search_button.after($go_button); }

    /*removing auto complete*/
    $(document).ready(function () { if (settings & 4) { $.loadJQueryAutocomplete = function () { }; } });


    /*events*/
    $go_button.click(function () {
      $wikia_search.attr('target', get_cookie() & 2 ? '_blank' : '_self');
      $wikia_search.find('input[name="fulltext"], input[name="go"]').remove();
      $wikia_search.append($('<input />', {'type': 'hidden', 'name': 'go', 'value': 'Go'}));
      $wikia_search.submit();
      return false;
    });
    $original_search_button.click(function () {
      $wikia_search.attr('target', get_cookie() & 2 ? '_blank' : '_self');
      $wikia_search.find('input[name="fulltext"], input[name="go"]').remove();
      $wikia_search.append($('<input />', {'type': 'hidden', 'name': 'fulltext', 'value': 'Search'}));
      $wikia_search.submit();
      return false;
    });
    $options_button.click(function () {
      var check_settings = function (name, num) {
        if (settings & num) { $('#search_fix_opt_' + name).attr('checked', 'checked'); }
        else { $('#search_fix_opt_' + name).removeAttr('checked'); }
      };
      if ($('#search_fix_options').size() < 1) {
        $wikia_search.after(
          $('<section />', {'id': 'search_fix_options'})
            .css({
              'background': '#FFFFFF',
              'border': '1px solid #CCCCCC',
              'box-shadow': '0px 2px 5px 0px #E0E0E0',
              'display': 'none',
              'line-height': '1.5em',
              'margin-bottom': '10px',
              'max-width': '282px',
              'padding': '8px',
              'position': (loc === 0 ? 'relative' : 'absolute'),
              'right': (loc === 0 ? 0 : 10) + 'px',
              'top': (loc === 1 ? 83 : (loc === 3 ? 38 : (loc === 2 ? 85 : 0))) + 'px'
            })
            .append(
              'What to use when you press Enter:',
              $('<br />'),
              $('<input />', {'type': 'radio', 'id': 'search_fix_opt_search', 'value': '0', 'name': 'search_fix_default_button', 'checked': 'checked'}),
              'Search',
              $('<br />'),
              $('<input />', {'type': 'radio', 'id': 'search_fix_opt_go',  'value': '1', 'name': 'search_fix_default_button'}),
              'Go',
              $('<br />'),
              $('<br />'),
              $('<input />', {'type': 'checkbox', 'value': '1', 'id': 'search_fix_opt_new_window', 'name': 'search_fix_new_window'}),
              'Open all searches in a new window',
              $('<br />'),
              $('<input />', {'type': 'checkbox', 'value': '1', 'id': 'search_fix_opt_acomplete', 'name': 'search_fix_acomplete'}),
              'Disable wikia autocomplete (for future pages)',
              $('<button />', {'id': 'search_fix_options_save', 'value': '1', 'name': 'search_fix_new_window'})
                .text('Save')
                .css({'top': '30%', 'right': '18px', 'position': 'absolute'})
                .click(function () {
                  settings = set_cookie(
                    parseInt($('#search_fix_options input[name="search_fix_default_button"]:checked').val(), 10) +
                      ($('#search_fix_opt_new_window').is(':checked') ? 2 : 0) +
                      ($('#search_fix_opt_acomplete').is(':checked') ? 4 : 0)
                  );
                  $('#search_fix_options').slideUp('fast');
                  if (settings & 1) { $go_button.after($original_search_button); }
                  else { $original_search_button.after($go_button); }
                })
            )
        );
      }
      settings = get_cookie();
      $('#' + (settings & 1 ? 'search_fix_opt_go' : 'search_fix_opt_search')).click();
      check_settings('new_window', 2);
      check_settings('acomplete', 4);
      check_settings('cat', 8);

      $('#search_fix_options').slideToggle('fast');
      return false;
    });
  },
  jq_wait = function jq_wait() {
    if (typeof window.jQuery === 'undefined') { setTimeout(jq_wait, 100); }
    else { $(document).ready(jq_go); }
  };
  jq_wait();
}());

Any idea how to do this? The progress need to stay afther an save like it is now. --Jens Ingels (talk) 16:20, August 3, 2012 (UTC)

What do you mean by "how to do this"? -- Sam Wang (wall) 04:53, August 5, 2012 (UTC)
This seems to work just fine for me -- Sam Wang (wall) 04:55, August 5, 2012 (UTC)

Comment - Change the two occurrences of the following lines:

if (settings & 1) { $go_button.after($original_search_button); }
else { $original_search_button.after($go_button); }

To:

if (settings & 1) {
    $go_button.show();
    $original_search_button.hide();
}
else {
    $original_search_button.show();
    $go_button.hide();
}

And to allow for the additional space with one less button, remove $options_button.outerWidth(true) in the $search_text.css block, .width line. As for changing the color for the Base64 colors, just upload them to a Image to Base64 converter (the arrow/dots only). Ryan PM

20:20, August 5, 2012 (UTC)
Jens Ingels: modifying the search feature wiki-wide like this is a Terms of Use violation. Refer to this Staff blog, specifically the notice at the very bottom under Policy note. If you are making this as a user script for just yourself or that has to be manually installed by individual users, that's fine. But if this is being applied in MediaWiki:Common.js or MediaWiki:Wikia.js, it's a TOU violation and staff would ask you to remove it if they knew about it. 20px_Rin_Tohsaka_Avatar.png Mathmagician ƒ(♫) 21:23 UTC, Sun, 05 August 2012

The bug seems only to apear when your wiki has an black navheader. When your search image is black the dot will not recolor with it.

Thx all for the info it worked. I just finished the code on one of my wikias: [1].

Also thx for the info of the policy note. I didn't known an search extension is ilegal. They should add an note of it in the dev.wikia. --Jens Ingels (talk) 18:24, August 6, 2012 (UTC)

Fast question, is the dev wikia from wikia itself? I currently post it on the talk with the go extension. I think it's usefull also for other users.