Fields v1.0.1
Fields facilitate data entry through text inputs, selects, and text areas, designed for user accuracy and form consistency. They streamline interactions, from concise inputs to extended texts, ensuring seamless data management across interfaces.
JS twinkle-select-js-v1.0.1 & twinkle-select-css-v1.0.1
Copy js and css
Bundle
Add the files downloaded to the needed bundle.
bundles.Add(new StyleBundle("~/Bundles/general-bundle-css",
"~/Content/twinkle-select-css-v1.0/twinkle-style.css"
);
bundles.Add(new Bundle("~/Bundles/general-bundle-js").Include(
"~/Scripts/ExternalLibraries/twinkle-select-js-v1.0/twinkle-select.js"
));
Trigger js
To trigger the js, make sure these functions are executed.
Example: In WelsPortal these functions are placed in the AppInit.ts file.
// Initializes all Selects with the Class 'TWselect'
$(`${element}.TWselect`).twSelect({
allowClear: false,
theme: 'partnerhub',
width: 'auto',
placeholder: 'Select Option',
minimumResultsForSearch: 10
});
$(`${element}.TWselectMultiple`).twSelect({
theme: 'partnerhub',
width: 'auto',
closeOnSelect: false,
selectAll: false,
allowClear: true,
placeholder: "Choose multiple",
minimumResultsForSearch: 10
});
// Disables translations
$('.twSelect-container, .TWselect, .twSelect-selection, .TWmultipleSelect').addClass('notranslate');
$('.twSelect-container, .TWselect, .twSelect-selection, .TWmultipleSelect').addClass('skiptranslate');
// To comply with ARIA guidelines
$('.twSelect-selection__choice, .twSelect-selection__placeholder').css('overflow', 'auto');
// The Search is within the Input instead of inside the Dropdown like the regular Select Picker
$('.TWmultipleSelect').parent().find('.twSelect-search, .twSelect-focusser').remove();
$('.TWmultipleSelect').on('twSelect:opening twSelect:closing', () => {
$('.TWmultipleSelect').parent().find('.twSelect-search, .twSelect-focusser').remove();
});
// Twinkle Fields
$('.tw-field-group').find('.tw-field-control').each(function (index, ele) {
var $ele = $(ele);
if ($ele.val() != '' || $ele.is(':selected') === true) {
$ele.parents('.tw-field-group').addClass('focused');
}
})
$('.tw-field-control').on('focus', function (e) {
$(this).parents('.tw-field-group').addClass('focused');
}).on('blur', function () {
if ($(this).val().length > 0) {
$(this).parents('.tw-field-group').addClass('focused');
} else {
$(this).parents('.tw-field-group').removeClass('focused');
}
});
$('.tw-field-control').on('change', function (e) {
if ($(this).is('select')) {
if ($(this).val() === $("option:first", $(this)).val()) {
$(this).parents('.tw-field-group').removeClass('focused');
}
else {
$(this).parents('.tw-field-group').addClass('focused');
}
}
})
//---- Twinkle Select single----
$('.TWselect').each(function () {
$(this).on("twSelect:open", function (e) {
$(this).parents('.tw-field-group').addClass('focused');
}).on("twSelect:close", function (e) {
if ($(this).find(':selected').val() === '') {
$(this).parents('.tw-field-group').removeClass('focused');
}
});
});
//---- Twinkle Select multiple----
$('.TWselectMultiple').each(function () {
$(this).on("twSelect:open", function (e) {
$(this).parents('.tw-field-group').addClass('focused');
}).on("twSelect:close", function (e) {
if ($(this).val() != '') {
$(this).parents('.tw-field-group').addClass('focused');
} else {
$(this).parents('.tw-field-group').removeClass('focused');
}
}).on("twSelect:select", function (e) {
$(this).parents('.tw-field-group').addClass('focused');
}).on("twSelect:unselect", function (e) {
$(this).parents('.tw-field-group').addClass('focused');
})
});
HTML
Make sure the HTML elements has this structure.
Examples (HTML)
Make sure the HTML elements has this structure.
Enabled
Disabled
JS Code
Herbert Cabrera
Software Developer
JS Code
Sandro Perez
Software Developer
Design
Abel Ferro
Twinkle System Designer
CDN
Raul Suarez
DevOps Engineer