Provided the same treatment to the role and group forms
This commit is contained in:
64
assets/uf-tweaks/js/widgets/groups.js
Normal file
64
assets/uf-tweaks/js/widgets/groups.js
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Groups widget. Sets up dropdowns, modals, etc for a table of groups.
|
||||
*
|
||||
* This script depends on slug-override.js
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Override the admin "attachGroupForm" method for the sake of an element id override
|
||||
*/
|
||||
function attachGroupForm() {
|
||||
$("body").on('renderSuccess.ufModal', function (data) {
|
||||
var modal = $(this).ufModal('getModal');
|
||||
var form = modal.find('.js-form');
|
||||
|
||||
|
||||
/**
|
||||
* Set up modal widgets
|
||||
*/
|
||||
// Set up any widgets inside the modal
|
||||
form.find(".js-select2").select2({
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
// Auto-generate slug
|
||||
slugOverride(form, '#input-group-slug-override');
|
||||
|
||||
// Fontawesome-iconpicker
|
||||
// Starcraft icons
|
||||
var sc_icons = [{
|
||||
title: "sc sc-terran",
|
||||
searchTerms: ['starcraft', 'terran']
|
||||
},
|
||||
{
|
||||
title: "sc sc-zerg",
|
||||
searchTerms: ['starcraft', 'zerg']
|
||||
}, {
|
||||
title: "sc sc-protoss",
|
||||
searchTerms: ['starcraft', 'protoss']
|
||||
},
|
||||
]
|
||||
|
||||
$('.icp-auto').iconpicker({
|
||||
// this is a hacky way to add in our custom icons to the default FA5 icons.
|
||||
// See https://github.com/farbelous/fontawesome-iconpicker/issues/77
|
||||
icons: typeof sc_icons != 'undefined' ? $.merge(sc_icons, $.iconpicker.defaultOptions.icons) : null,
|
||||
});
|
||||
|
||||
// Set icon when changed
|
||||
form.find('input[name=icon]').on('input change', function() {
|
||||
$(this).prev(".icon-preview").find("i").removeClass().addClass($(this).val());
|
||||
});
|
||||
|
||||
$('.icp-auto').iconpicker();
|
||||
|
||||
// Set up the form for submission
|
||||
form.ufForm({
|
||||
validator: page.validators
|
||||
}).on("submitSuccess.ufForm", function() {
|
||||
// Reload page on success
|
||||
window.location.reload();
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user