jQuery(document).ready(function() {
"use strict";
/* Custom select design */
jQuery('.dtstaff-drop-down').append('
');
jQuery('.dtstaff-drop-down').append('');
jQuery('.dtstaff-drop-down select option').each(function() {
var bg = jQuery(this).css('background-image');
var text = jQuery(this).text();
var pos = text.indexOf("-");
var res1 = text.substring(0, pos);
var res2 = text.substring(pos+1);
jQuery('.select-list').append('' + res1 + ' ' + res2 + '');
});
jQuery('.dtstaff-drop-down .button').html('' + jQuery('.dtstaff-drop-down select').find(':selected').text() + '' + 'Arrow');
jQuery('.dtstaff-drop-down ul li').each(function() {
if (jQuery(this).find('span').text() == jQuery('.dtstaff-drop-down select').find(':selected').text()) {
jQuery(this).addClass('active');
}
});
jQuery('.dtstaff-drop-down .select-list').on('click', 'li', function() {
var dd_text = jQuery(this).find('span.staff-role').text();
var dd_img = jQuery(this).find('span:first').css('background-image');
var dd_val = jQuery(this).find('span:first').attr('value');
jQuery('.dtstaff-drop-down .button').html('' + '' + dd_text + '' + 'Arrow');
jQuery('.dtstaff-drop-down .select-list span').parent().removeClass('active');
jQuery(this).parent().addClass('active');
jQuery('.dtstaff-drop-down select.dt-select-staff').val( dd_val );
jQuery('.dtstaff-drop-down .select-list li').slideUp();
});
jQuery('.dtstaff-drop-down .button').on('click','a.select-list-link', function()
{
jQuery('.dtstaff-drop-down ul li').slideToggle();
});
/* End */
});
function doRegenerateSelect() {
jQuery('.dtstaff-drop-down .button').html('');
jQuery('.select-list').html('');
jQuery('.dtstaff-drop-down select option').each(function() {
var bg = jQuery(this).css('background-image');
var text = jQuery(this).text();
var pos = text.indexOf("-");
var res1 = text.substring(0, pos);
var res2 = text.substring(pos+1);
jQuery('.select-list').append('' + res1 + ' ' + res2 + '');
});
jQuery('.dtstaff-drop-down .button').html('' + jQuery('.dtstaff-drop-down select').find(':selected').text() + '' + 'Arrow');
jQuery('.dtstaff-drop-down ul li').each(function() {
if (jQuery(this).find('span').text() == jQuery('.dtstaff-drop-down select').find(':selected').text()) {
jQuery(this).addClass('active');
}
});
}