Recent Tutorials
Who is online?
In total there are 10 users online :: 0 Registered, 0 Hidden and 10 Guests :: 2 Bots

None

[ View the whole list ]


Most users ever online was 172 on Fri 19 Feb 2016, 05:17
Keywords

How to change the default Edge theme?

View previous topic View next topic Go down

avatar
Guest
Guest
View all awards

PostGuest on Sat 24 Dec 2016, 11:38

We've got plenty of themes to chosse from, one of which is now a custom 'KLM Flying Blue' theme. Say, what if we want to have for instance the default theme switched with the KLM one? What do we need to do? If been looking for an answer in the all.js but I couldn't find it. It's probably in some of the Edge CSS somewhere. And when the KLM has been made the default theme, will it still be visible in the theme list?

@Ange Tuteur, please shed a light on this question for us, thank you.


Last edited by Samantha on Thu 29 Dec 2016, 03:51; edited 3 times in total
avatar
Ace 1
Valued Member
Title :
God of Creation
Gender : Male
Age : 17
Posts : 2092
Points : 2759
Reputation : 78
Location : druid hill Park
Language : Eng, Fr, Loud
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Sun 25 Dec 2016, 08:15

Here ya go @Samantha

Title: Default Theme Changer
Placement: All the pages
Code:
$(function() {
    var default_theme = 'Mine Shaft',
        visible_in_theme_list = true,

        option;

    (function changeDefaultTheme(theme) {
        if (!$('#fa_theme_selector > option[value="' + theme + '"]')[0]) {
            console.log('This is not a valid theme');
            return;
        }

        option = $('#fa_theme_selector > option[value="' + theme + '"]');

        $('#fa_theme_selector').val(theme).trigger('change');
        visible_in_theme_list ? option.detach().insertAfter('#fa_theme_selector > option:eq(1)') : option.remove();

        if (my_getcookie('fa_theme_color') != default_theme) my_setcookie('fa_theme_color', theme);
    })(default_theme);
});

You can change
Code:
default_theme
to your theme name (as long as it's already within the theme picker dropdown).

And if you want your theme to still be in the dropdown and show (as opposed to showing up as default theme), then don't change the
Code:
visible_in_theme_list
value.

Hope this works for ya
avatar
Guest
Guest
View all awards

PostGuest on Mon 26 Dec 2016, 21:17

Worked to near perfection, @Ace 1! TYVM! Smile However, when another theme has been chosen and the site reloads in the browser it gives me the default theme again. The cookie with the user's choice either had not been dropped or it wouldn't read it and it falls back to the default theme (the one that had been forced to be default using the script). Same thing when browsing the forums...
avatar
Ace 1
Valued Member
Title :
God of Creation
Gender : Male
Age : 17
Posts : 2092
Points : 2759
Reputation : 78
Location : druid hill Park
Language : Eng, Fr, Loud
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Mon 26 Dec 2016, 23:18

Try replacing the script with this one:

Code:
$(function() {
    var default_theme = 'Mine Shaft',
        visible_in_theme_list = true,

        current_theme = my_getcookie('fa_theme_color'),
        option;

    (current_theme == 'Select a theme' || current_theme == default_theme) && (function changeDefaultTheme(theme) {
        if (!$('#fa_theme_selector > option[value="' + theme + '"]')[0]) {
            console.log('This is not a valid theme');
            return;
        }

        option = $('#fa_theme_selector > option[value="' + theme + '"]');

        $('#fa_theme_selector').val(theme).trigger('change');
        visible_in_theme_list ? option.detach().insertAfter('#fa_theme_selector > option:eq(1)') : option.remove();

        my_setcookie('fa_theme_color', theme);
    })(default_theme);
});
avatar
Guest
Guest
View all awards

PostGuest on Tue 27 Dec 2016, 05:25

Nope, that one falls back to the default color scheme, like on FMD ...
avatar
Ace 1
Valued Member
Title :
God of Creation
Gender : Male
Age : 17
Posts : 2092
Points : 2759
Reputation : 78
Location : druid hill Park
Language : Eng, Fr, Loud
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Wed 28 Dec 2016, 07:10

@Samantha This should work.

Code:
$(function() {
    var default_theme = 'Mine Shaft',
        visible_in_theme_list = true,

        current_theme = my_getcookie('fa_theme_color'),
        option;

    (current_theme == 'Select a theme' || current_theme == default_theme) && (function changeDefaultTheme(theme) {
        if (!$('#fa_theme_selector > option[value="' + theme + '"]')[0]) {
            console.log('This is not a valid theme');
            return;
        }

        option = $('#fa_theme_selector > option[value="' + theme + '"]');

        $('#fa_theme_selector').val(theme).trigger('change');
        visible_in_theme_list ? option.detach().insertAfter('#fa_theme_selector > option:eq(1)') : option.css('display', 'none').parent().val('Default theme');

        my_setcookie('fa_theme_color', theme);

        !visible_in_theme_list && $('#fa_theme_selector').change(function() {
            if (this.value == 'Select a theme' || this.value == 'Default theme') {
                $('#fa_theme_selector').val(theme).trigger('change');
                $('#fa_theme_selector').val(!visible_in_theme_list ? 'Default theme' : theme);
            }
        });
    })(default_theme);
});
avatar
Guest
Guest
View all awards

PostGuest on Wed 28 Dec 2016, 11:23

Nope, not working again, Ken. I'm using this in All the Pages:

Code:
$(function() {
            var default_theme = 'KLM Flying Blue',
                visible_in_theme_list = true,
       
                current_theme = my_getcookie('fa_theme_color'),
                option;
       
            (current_theme == 'Select a theme' || current_theme == default_theme) && (function changeDefaultTheme(theme) {
                if (!$('#fa_theme_selector > option[value="' + theme + '"]')[0]) {
                    console.log('This is not a valid theme');
                    return;
                }
       
                option = $('#fa_theme_selector > option[value="' + theme + '"]');
       
                $('#fa_theme_selector').val(theme).trigger('change');
                visible_in_theme_list ? option.detach().insertAfter('#fa_theme_selector > option:eq(1)') : option.css('display', 'none').parent().val('Default theme');
       
                my_setcookie('fa_theme_color', theme);
       
                !visible_in_theme_list && $('#fa_theme_selector').change(function() {
                    if (this.value == 'Select a theme' || this.value == 'Default theme') {
                        $('#fa_theme_selector').val(theme).trigger('change');
                        $('#fa_theme_selector').val(!visible_in_theme_list ? 'Default theme' : theme);
                    }
                });
            })(default_theme);
        });




You can see the result for yourself on the test site. Could it be the language? Perhaps you should add some language vars ...

EDIT: I've taken the script offline again as started to annoy me lol
avatar
Ace 1
Valued Member
Title :
God of Creation
Gender : Male
Age : 17
Posts : 2092
Points : 2759
Reputation : 78
Location : druid hill Park
Language : Eng, Fr, Loud
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Wed 28 Dec 2016, 21:39

lul it was the language haha

Code:
$(function() {
  var default_theme = 'Mine Shaft',
    default_text = ['Select a theme', 'Default theme'],
    show_name = true,

    current_theme = my_getcookie('fa_theme_color'),
    option;

  (function changeDefaultTheme(theme) {
    if (!$('#fa_theme_selector > option[value="' + theme + '"]')[0]) {
      console.error(theme + ': This is not a valid theme.');
      return;
    }

    if ($('#fa_theme_selector').val() == default_text[0]) {
      $('#fa_theme_selector').val(theme).trigger('change');
      my_setcookie('fa_theme_color', theme);
    }

    option = $('#fa_theme_selector > option[value="' + theme + '"]');
    option.detach().text(show_name ? theme : default_text[1]).insertBefore('#fa_theme_selector > option:eq(0)').next().remove();

    $('#fa_theme_selector').change(function() {
      this.firstChild.textContent = show_name ? theme : default_text[1];
      if ($(this).find('option:selected').index() == 0) $('#fa_theme_selector').val(theme).val(default_text[1]);
    });
  })(default_theme);
});

Now with this code I set up some variables.

Code:
  var default_theme = 'Mine Shaft',
    default_text = ['Select a theme', 'Default theme'],
    show_name = true,

default_theme - You know what this is.
default_text - This takes two values, the first being what you normally see and the second being what the first option of the theme picker is when you don't have the default one enabled.
show_name - When this is true, the forum will show the original name of the theme. Otherwise, it will appear as "Default theme".

Let me know how this works out.
avatar
Guest
Guest
View all awards

PostGuest on Thu 29 Dec 2016, 03:49

Yeah, now it's working alright! AND I noticed some EDGE language language update errors for the themes in ALL.JS, so I had to fix them first. It said 'Kies een thema ... ...' instead of 'Kies een thema ...' in several locations in that JS.

BIG THANKS to you, @Ace 1! Good
avatar
Ace 1
Valued Member
Title :
God of Creation
Gender : Male
Age : 17
Posts : 2092
Points : 2759
Reputation : 78
Location : druid hill Park
Language : Eng, Fr, Loud
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Thu 29 Dec 2016, 07:19

Glad to help lol

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

 
Permissions in this forum:
You cannot reply to topics in this forum