Post by Retread on Nov 2, 2020 19:37:47 GMT -8
Theme Selector (basic edition) Version 0.0.4 Beta
A convenient way for a user to select their theme with a minimum amount of clicking and scrolling. No setup or settings by the plugin installer or member are required. Just install and go.
Places an Icon on the PBN bar. Clicking the icon will take the member directly to a modified version of their Edit Profile Settings page.
From there, the user can select any theme for which they have permission, then with a single click of the button, save the selected theme and view the theme without leaving the Theme Selector page.
After that, they can navigate away from the page using the forum Navigation Menu or Navigation Tree.
Many thanks to Yogi B (yogib) and Chris (horace) for their assistance.
This plugin is editable.
Direct link to the Library Item
www.proboards.com/library/plugins/item/2098
Edit: The plugin has been accepted so the link is now valid. However, you might prefer to navigate via the Admin panel in your forum ...
Admin Home> Plugins> Plugin Library
... that way you will be able to install it directly on your forum rather than downloading then importing.
Admin Home> Plugins> Plugin Library
... that way you will be able to install it directly on your forum rather than downloading then importing.
Second Edit
There are compatibility issues with this plugin and User Theme Display. To correct that, from your Admin panel, navigate:
Admin Home> Plugins> Forum Plugins and click the Build tab.
Click on User Theme Display
Click on the Components tab.
REPLACE the entire contents in text area with this:
//All Your Base Are Belong To User Theme Display//
// This version is compatible with Theme Selector and also eliminates an unnecessary alert //
var utdprevtheme = ""
$(document).ready(function() {
/* Modifcation to Inhibit unnecessary intearctions on the Settings page.*/
if(window.location.href.indexOf('settings') >= 0) {
return;
}
if(window.location.href.indexOf('avatar') >= 0) {
return;
}
/* End of modification */
utdprevtheme = $('.theme-chooser').val()
utdload();
})
function utdload() {
var user = pb.data('user').id;
var theme = pb.data('user').theme_id
var key = pb.plugin.key('theme_display').get(user)
if(key != theme) {
utdupdate();
}
if(pb.plugin.get('user_theme_display').settings.who_can_see_this == 'members' && proboards.data('user').id == 0) //no guests
return;
if(pb.plugin.get('user_theme_display').settings.who_can_see_this == 'staff' && !proboards.data('user').is_staff) //only staff
return;
if(pb.plugin.get('user_theme_display').settings.who_can_see_this == 'admin' && user != 1) //only main admin
return;
utdapply();
pb.events.on('afterSearch', function() {
utdapply()
//runs after search because ajax won't fire if already searched previously
})
$(document).ajaxComplete(function(event, xhr, settings) {
utdapply()
//runs on all ajax calls, safety function prevents extra calls
});
pb.events.on('pageChange', function() {
utdapply()
//runs on pagechange because ajax won't fire if page loaded previously
})
$('.theme-chooser').change(function() {
utdupdate()
})
}
function utdapply() {
var user = proboards.data('page').member
var themetext = ''
if(user != undefined) {
var key = pb.plugin.key('theme_display').get(user.id)
if(key == undefined) {
themetext = 'Theme Unsaved'
} else {
var ui = pb.plugin.get('user_theme_display').settings.themes
for(a = 0; a < ui.length; a++) {
if(key == ui[a].select_theme_to_record)
if(ui[a].text_you_want_displayed != '') {
themetext = ui[a].text_you_want_displayed
}
else {
themetext = '<td>' + pb.plugin.get('user_theme_display').settings.theme_heading + '</td><td><span>' + pb.plugin.get('user_theme_display').settings.themes[a].theme_display_name + '</span></td>'
}
}
}
if(themetext == '')
themetext = 'Hidden Theme' //Not in settings
if($('.form_user_status #center-column .headings:first').length)
if(parseInt(pb.plugin.get('user_theme_display').settings.add_to_user_profile)) //on off profile
if(!$('.utdcss').length)
$('.form_user_status #center-column .headings:first').parent().parent().append('<tr class="utdcss">' + themetext + '</tr>') //profile
}
if(parseInt(pb.plugin.get('user_theme_display').settings.append_to_mini_profile)) //on off mini profile
if(!$('.utdprevention').length) //don't do twice
for(propertys in pb.data('proboards.post')) {
if($('#post-' + propertys + ' .user-link').attr('href') != undefined) {
var profiletarget = utdprofiletarget(propertys)
$('#post-' + propertys + ' ' + profiletarget).prepend(utdminiprofile(propertys))
}
}
if(parseInt(pb.plugin.get('user_theme_display').settings.add_a_members_column)) //on off mini profile
if(document.location.pathname.split('/')[1] == 'members') //auto load
{
if(!$('.utdtheme').length)
$('.content.cap-bottom .list .head .date-registered').before('<th class="utdtheme sortable" style="width:15%">' + pb.plugin.get('user_theme_display').settings.theme_heading.replace(':', '') + '</th>')
if(!$('.utdajaxprevention').length)
$('.content.cap-bottom .list .list-content tr').each(function(b) {
$(this).find('td.date-registered').before('<td>' + utdmemberadd($(this).attr('id').replace('member-', '')) + '</td>')
})
}
}
function utdprofiletarget(post) {
var user = $('#post-' + post + ' .user-link').attr('href')
var themetext = ''
if(user == undefined)
return ''
user = user.replace('/user/', '')
if(user == undefined)
return '.mini-profile .info'
var key = pb.plugin.key('theme_display').get(user)
if(key == undefined) {
return '.mini-profile .info'
} else {
var ui = pb.plugin.get('user_theme_display').settings.themes
for(a = 0; a < ui.length; a++) {
if(key == ui[a].select_theme_to_record)
if(ui[a].custom_miniprofile_target != '')
return '' + ui[a].custom_miniprofile_target
}
}
return '.mini-profile .info'
}
function utdminiprofile(post) {
var user = $('#post-' + post + ' .user-link').attr('href')
var themetext = ''
if(user == undefined)
return ''
user = user.replace('/user/', '')
if(user == undefined)
return 'Cannot Find User Link'
var key = pb.plugin.key('theme_display').get(user)
if(key == undefined) {
themetext = 'Theme Unsaved'
} else {
var ui = pb.plugin.get('user_theme_display').settings.themes
for(a = 0; a < ui.length; a++) {
if(key == ui[a].select_theme_to_record)
if(ui[a].text_you_want_displayed != '') {
themetext = ui[a].text_you_want_displayed
}
else {
themetext = '<td>' + pb.plugin.get('user_theme_display').settings.theme_heading + ' </td><td><span>' + pb.plugin.get('user_theme_display').settings.themes[a].theme_display_name + '</span></td>'
}
}
}
if(themetext == '')
themetext = 'Hidden Theme'
return '<span class="utdprevention utdcss">' + themetext + '</span><br>'
}
function utdmemberadd(user) {
var themetext = ''
if(user == undefined)
return 'Cannot Find User Link'
var key = pb.plugin.key('theme_display').get(user)
if(key == undefined) {
themetext = 'Theme Unsaved'
} else {
var ui = pb.plugin.get('user_theme_display').settings.themes
for(a = 0; a < ui.length; a++) {
if(key == ui[a].select_theme_to_record)
if(ui[a].text_you_want_displayed != '') {
themetext = ui[a].text_you_want_displayed.match(/<span[^>]*>[^>]*<\/span>/)
}
else {
themetext = ui[a].theme_display_name
}
}
}
if(themetext == '')
themetext = 'Hidden Theme'
return '<span class="utdajaxprevention utdcss">' + themetext + '</span>'
}
function utdupdate() {
if(pb.data('user').id == 0 || window.location.href.indexOf('preview_theme') != -1)
return
proboards.dialog("utdpopup", {
title: "Save Data",
open: function(event, ui) {
$(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
},
modal: true,
width: 300,
height: 200,
resizable: false,
autoOpen: true,
draggable: false,
closeOnEscape: false,
buttons: [{
text: "Save",
click: function() {
utdsavekey($(this))
}
},
{
text: "Cancel",
click: function() {
$(this).dialog('close');
$('.theme-chooser').val(utdprevtheme) //revert to previous theme selection
}
}
]
});
if(proboards.data('route').name == 'edit_user_settings') {
$('#utdpopup').html('Click save to confirm your chosen theme.');
return
}
$('#utdpopup').html('Click save to update your profile data. After you save, this popup will not appear again. If you ignore this popup, it will appear again on your next page.')
}
function utdsavekey(thisdialog) {
if(proboards.data('route').name == 'edit_user_settings') {
pb.plugin.key('theme_display').set({
object_id: proboards.data('user').id,
value: parseFloat($('.theme-chooser').val()),
success: function() {
thisdialog.dialog('close');
pb.loading(true);
$('input[value="Save Account Settings"]').click()
},
error: function(error) {}
})
return;
}
pb.plugin.key('theme_display').set({
object_id: proboards.data('user').id,
value: proboards.data('user').theme_id,
success: function() {
thisdialog.dialog('close');
//pb.window.alert('Saved Successfully')
},
error: function(error) {}
})
//first time set
}
Click the Save Changes button.