В uCoz стандартный вид категорий при добавлении материала реализован в виде самого простого выпадающего списка с checkbox'ами или radio-кнопками, в зависимости от того, во сколько категорий можно добавлять материал. Эту опцию можно активировать/дезактивировать в настройках моделей.
Установка:
Установка очень простая, не займет много времени.
1. Страница добавления/редактирования материалов. Вставьте следующий код после $BODY$:
Код
<script>
var config = {
'.chosen-select': {},
'.chosen-select-deselect': {
allow_single_deselect: true
},
'.chosen-select-no-single': {
disable_search_threshold: 10
},
'.chosen-select-no-results': {
no_results_text: 'Oops, nothing found!'
},
'.chosen-select-width': {
width: "95%"
}
};
$(document).ready(function() {
var str = "<option value=''></option>";
var multy1 = "";
$("input[name='ocat']").each(function() {
var typee = $(this).attr("type");
if (typee != "radio") multy1 = "multiple";
var value1 = $(this).val();
var idt = $(this).attr("id");
var che;
if ($(this).prop("checked")) che = "selected";
else che = "";
var id = idt;
var name = $("label[for='" + id + "']").html();
str = str + "<option " + che + " value='" + value1 + "'>" + name + "</option>";
});
$("#catSelector9").after("<td class='manTd2'><select id='selectchange' data-placeholder='Выберите категорию...' class='chosen-select' style='width:100%;' " + multy1 + ">" + str + "</select></td>");
$("#uCatsMenu7, #catSelector9, .u-combolist").hide();
$("#selectchange").change(function() {
$("select#selectchange option").each(function() {
var srrr = $(this).val();
var srrr2 = $(this).prop("selected");
if (srrr2) $('#cus' + srrr).prop("checked", true);
else $('#cus' + srrr).prop("checked", false);
})
});
for (var selector in config) {
$(selector).chosen(config[selector]);
}
});</script>
<script src="https://htmlstart.ucoz.net/js/chosen.jquery.min.js" type="text/javascript"> </script>
var config = {
'.chosen-select': {},
'.chosen-select-deselect': {
allow_single_deselect: true
},
'.chosen-select-no-single': {
disable_search_threshold: 10
},
'.chosen-select-no-results': {
no_results_text: 'Oops, nothing found!'
},
'.chosen-select-width': {
width: "95%"
}
};
$(document).ready(function() {
var str = "<option value=''></option>";
var multy1 = "";
$("input[name='ocat']").each(function() {
var typee = $(this).attr("type");
if (typee != "radio") multy1 = "multiple";
var value1 = $(this).val();
var idt = $(this).attr("id");
var che;
if ($(this).prop("checked")) che = "selected";
else che = "";
var id = idt;
var name = $("label[for='" + id + "']").html();
str = str + "<option " + che + " value='" + value1 + "'>" + name + "</option>";
});
$("#catSelector9").after("<td class='manTd2'><select id='selectchange' data-placeholder='Выберите категорию...' class='chosen-select' style='width:100%;' " + multy1 + ">" + str + "</select></td>");
$("#uCatsMenu7, #catSelector9, .u-combolist").hide();
$("#selectchange").change(function() {
$("select#selectchange option").each(function() {
var srrr = $(this).val();
var srrr2 = $(this).prop("selected");
if (srrr2) $('#cus' + srrr).prop("checked", true);
else $('#cus' + srrr).prop("checked", false);
})
});
for (var selector in config) {
$(selector).chosen(config[selector]);
}
});</script>
<script src="https://htmlstart.ucoz.net/js/chosen.jquery.min.js" type="text/javascript"> </script>
Код
<style>
.u-comboeditcell,
.u-combo {
border: none !important;
width: 100% !important;
}
td.manTd2 {
display: block;
}
.chosen-container {
position: relative;
display: inline-block;
vertical-align: middle;
font-size: 13px;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.chosen-container .chosen-drop {
position: absolute;
top: 100%;
left: -9999px;
z-index: 1010;
box-sizing: border-box;
width: 100%;
border: 1px solid #aaa;
border-top: 0;
background: #fff;
box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
}
.chosen-container.chosen-with-drop .chosen-drop {
left: 0;
}
.chosen-container a {
cursor: pointer;
}
.chosen-container-single .chosen-single {
position: relative;
display: block;
overflow: hidden;
padding: 0 0 0 8px;
height: 23px;
border: 1px solid #aaa;
border-radius: 5px;
background-color: #fff;
background: linear-gradient(to bottom, #fff 20%, #f6f6f6 50%, #eee 52%, #f4f4f4 100%);
background-clip: padding-box;
box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(0, 0, 0, .1);
color: #444;
text-decoration: none;
white-space: nowrap;
line-height: 24px;
}
.chosen-container-single .chosen-default {
color: #999;
}
.chosen-container-single .chosen-single span {
display: block;
overflow: hidden;
margin-right: 26px;
text-overflow: ellipsis;
white-space: nowrap;
}
.chosen-container-single .chosen-single-with-deselect span {
margin-right: 38px;
}
.chosen-container-single .chosen-single abbr {
position: absolute;
top: 6px;
right: 26px;
display: block;
width: 12px;
height: 12px;
background: url('/img/chosen-sprite.png') -42px 1px no-repeat;
font-size: 1px;
}
.chosen-container-single .chosen-single abbr:hover {
background-position: -42px -10px;
}
.chosen-container-single.chosen-disabled .chosen-single abbr:hover {
background-position: -42px -10px;
}
.chosen-container-single .chosen-single div {
position: absolute;
top: 0;
right: 0;
display: block;
width: 18px;
height: 100%;
}
.chosen-container-single .chosen-single div b {
display: block;
width: 100%;
height: 100%;
background: url('/img/chosen-sprite.png') no-repeat 0 2px;
}
.chosen-container-single .chosen-search {
position: relative;
z-index: 1010;
margin: 0;
padding: 3px 4px;
white-space: nowrap;
}
.chosen-container-single .chosen-search input[type="text"] {
box-sizing: border-box;
margin: 1px 0;
padding: 4px 20px 4px 5px;
width: 100%;
height: auto;
outline: 0;
border: 1px solid #aaa;
background: #fff url('/img/chosen-sprite.png') no-repeat 100% -20px;
font-size: 1em;
font-family: sans-serif;
line-height: normal;
border-radius: 0;
}
.chosen-container-single .chosen-drop {
margin-top: -1px;
border-radius: 0 0 4px 4px;
background-clip: padding-box;
}
.chosen-container-single.chosen-container-single-nosearch .chosen-search {
position: absolute;
left: -9999px;
}
.chosen-container .chosen-results {
position: relative;
overflow-x: hidden;
overflow-y: auto;
margin: 0 4px 4px 0;
padding: 0 0 0 4px;
max-height: 240px;
-webkit-overflow-scrolling: touch;
}
.chosen-container .chosen-results li {
display: none;
margin: 0;
padding: 5px 6px;
list-style: none;
line-height: 15px;
-webkit-touch-callout: none;
}
.chosen-container .chosen-results li.active-result {
display: list-item;
cursor: pointer;
}
.chosen-container .chosen-results li.disabled-result {
display: list-item;
color: #ccc;
cursor: default;
}
.chosen-container .chosen-results li.highlighted {
background-color: #3875d7;
background: linear-gradient(to bottom, #3875d7 20%, #2a62bc 90%);
color: #fff;
}
.chosen-container .chosen-results li.no-results {
display: list-item;
background: #f4f4f4;
}
.chosen-container .chosen-results li.group-result {
display: list-item;
font-weight: 700;
cursor: default;
}
.chosen-container-multi .chosen-choices li {
list-style: none;
}
.chosen-container-multi .chosen-choices li.search-field {
margin: 0;
padding: 0;
white-space: nowrap;
}
.chosen-container-multi .chosen-choices li.search-field input[type="text"] {
margin: 1px 0;
padding: 5px;
height: 15px;
outline: 0;
border: 0 !important;
background: transparent !important;
box-shadow: none;
color: #666;
font-size: 100%;
font-family: sans-serif;
line-height: normal;
border-radius: 0;
width: 100% !important;
}
.chosen-container-multi .chosen-choices li.search-field .default {
color: #999;
}
.chosen-container-multi .chosen-choices li.search-choice {
position: relative;
margin: 3px 0 3px 5px;
padding: 3px 20px 3px 5px;
border: 1px solid #aaa;
border-radius: 3px;
background-color: #e4e4e4;
background: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
background-clip: padding-box;
box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, .05);
color: #333;
line-height: 13px;
cursor: default;
}
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
position: absolute;
top: 4px;
right: 3px;
display: block;
width: 12px;
height: 12px;
background: url('/img/chosen-sprite.png') -42px 1px no-repeat;
font-size: 1px;
}
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
background-position: -42px -10px;
}
.chosen-container-multi .chosen-choices li.search-choice-disabled {
padding-right: 5px;
border: 1px solid #ccc;
background-color: #e4e4e4;
background: linear-gradient(to top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
color: #666;
}
.chosen-container-multi .chosen-choices li.search-choice-focus {
background: #d4d4d4;
}
.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close {
background-position: -42px -10px;
}
.chosen-container-multi .chosen-results {
margin: 0;
padding: 0;
}
.chosen-container-multi .chosen-drop .result-selected {
display: list-item;
color: #ccc;
cursor: default;
}
.chosen-container-active .chosen-single {
border: 1px solid #5897fb;
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
}
.chosen-container-active.chosen-with-drop .chosen-single {
border: 1px solid #aaa;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
background: linear-gradient(to bottom, #eee 20%, #fff 80%);
box-shadow: 0 1px 0 #fff inset;
}
.chosen-container-active.chosen-with-drop .chosen-single div {
border-left: 0;
background: transparent;
}
.chosen-container-active.chosen-with-drop .chosen-single div b {
background-position: -18px 2px;
}
.chosen-container-active .chosen-choices {
border: 1px solid #5897fb;
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
}
.chosen-container-active .chosen-choices li.search-field input[type="text"] {
color: #111 !important;
}
.chosen-disabled {
opacity: .5 !important;
cursor: default;
}
.chosen-disabled .chosen-single {
cursor: default;
}
.chosen-disabled .chosen-choices .search-choice .search-choice-close {
cursor: default;
}
/* RTL поддержка */
.chosen-rtl { text-align: right; }
.chosen-rtl .chosen-single { padding: 0 8px 0 0; overflow: visible; }
.chosen-rtl .chosen-single span { margin-right: 0; margin-left: 26px; direction: rtl; }
.chosen-rtl .chosen-single-with-deselect span { margin-left: 38px; }
.chosen-rtl .chosen-single div { right: auto; left: 3px; }
.chosen-rtl .chosen-single abbr { right: auto; left: 26px; }
.chosen-rtl .chosen-choices li { float: right; }
.chosen-rtl .chosen-choices li.search-field input[type="text"] { direction: rtl; }
.chosen-rtl .chosen-choices li.search-choice { margin: 3px 5px 3px 0; padding: 3px 5px 3px 19px; }
.chosen-rtl .chosen-choices li.search-choice .search-choice-close { right: auto; left: 4px; }
.chosen-rtl.chosen-container-single-nosearch .chosen-search,
.chosen-rtl .chosen-drop { left: 9999px; }
.chosen-rtl.chosen-container-single .chosen-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; }
.chosen-rtl .chosen-results li.group-option { padding-right: 15px; padding-left: 0; }
.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div { border-right: 0; }
.chosen-rtl .chosen-search input[type="text"] {
padding: 4px 5px 4px 20px;
background: #fff url('/img/chosen-sprite.png') no-repeat -30px -20px !important;
direction: rtl;
}
.chosen-rtl.chosen-container-single .chosen-single div b { background-position: 6px 2px; }
.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b { background-position: -12px 2px; }
</style>
.u-comboeditcell,
.u-combo {
border: none !important;
width: 100% !important;
}
td.manTd2 {
display: block;
}
.chosen-container {
position: relative;
display: inline-block;
vertical-align: middle;
font-size: 13px;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.chosen-container .chosen-drop {
position: absolute;
top: 100%;
left: -9999px;
z-index: 1010;
box-sizing: border-box;
width: 100%;
border: 1px solid #aaa;
border-top: 0;
background: #fff;
box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
}
.chosen-container.chosen-with-drop .chosen-drop {
left: 0;
}
.chosen-container a {
cursor: pointer;
}
.chosen-container-single .chosen-single {
position: relative;
display: block;
overflow: hidden;
padding: 0 0 0 8px;
height: 23px;
border: 1px solid #aaa;
border-radius: 5px;
background-color: #fff;
background: linear-gradient(to bottom, #fff 20%, #f6f6f6 50%, #eee 52%, #f4f4f4 100%);
background-clip: padding-box;
box-shadow: 0 0 3px #fff inset, 0 1px 1px rgba(0, 0, 0, .1);
color: #444;
text-decoration: none;
white-space: nowrap;
line-height: 24px;
}
.chosen-container-single .chosen-default {
color: #999;
}
.chosen-container-single .chosen-single span {
display: block;
overflow: hidden;
margin-right: 26px;
text-overflow: ellipsis;
white-space: nowrap;
}
.chosen-container-single .chosen-single-with-deselect span {
margin-right: 38px;
}
.chosen-container-single .chosen-single abbr {
position: absolute;
top: 6px;
right: 26px;
display: block;
width: 12px;
height: 12px;
background: url('/img/chosen-sprite.png') -42px 1px no-repeat;
font-size: 1px;
}
.chosen-container-single .chosen-single abbr:hover {
background-position: -42px -10px;
}
.chosen-container-single.chosen-disabled .chosen-single abbr:hover {
background-position: -42px -10px;
}
.chosen-container-single .chosen-single div {
position: absolute;
top: 0;
right: 0;
display: block;
width: 18px;
height: 100%;
}
.chosen-container-single .chosen-single div b {
display: block;
width: 100%;
height: 100%;
background: url('/img/chosen-sprite.png') no-repeat 0 2px;
}
.chosen-container-single .chosen-search {
position: relative;
z-index: 1010;
margin: 0;
padding: 3px 4px;
white-space: nowrap;
}
.chosen-container-single .chosen-search input[type="text"] {
box-sizing: border-box;
margin: 1px 0;
padding: 4px 20px 4px 5px;
width: 100%;
height: auto;
outline: 0;
border: 1px solid #aaa;
background: #fff url('/img/chosen-sprite.png') no-repeat 100% -20px;
font-size: 1em;
font-family: sans-serif;
line-height: normal;
border-radius: 0;
}
.chosen-container-single .chosen-drop {
margin-top: -1px;
border-radius: 0 0 4px 4px;
background-clip: padding-box;
}
.chosen-container-single.chosen-container-single-nosearch .chosen-search {
position: absolute;
left: -9999px;
}
.chosen-container .chosen-results {
position: relative;
overflow-x: hidden;
overflow-y: auto;
margin: 0 4px 4px 0;
padding: 0 0 0 4px;
max-height: 240px;
-webkit-overflow-scrolling: touch;
}
.chosen-container .chosen-results li {
display: none;
margin: 0;
padding: 5px 6px;
list-style: none;
line-height: 15px;
-webkit-touch-callout: none;
}
.chosen-container .chosen-results li.active-result {
display: list-item;
cursor: pointer;
}
.chosen-container .chosen-results li.disabled-result {
display: list-item;
color: #ccc;
cursor: default;
}
.chosen-container .chosen-results li.highlighted {
background-color: #3875d7;
background: linear-gradient(to bottom, #3875d7 20%, #2a62bc 90%);
color: #fff;
}
.chosen-container .chosen-results li.no-results {
display: list-item;
background: #f4f4f4;
}
.chosen-container .chosen-results li.group-result {
display: list-item;
font-weight: 700;
cursor: default;
}
.chosen-container-multi .chosen-choices li {
list-style: none;
}
.chosen-container-multi .chosen-choices li.search-field {
margin: 0;
padding: 0;
white-space: nowrap;
}
.chosen-container-multi .chosen-choices li.search-field input[type="text"] {
margin: 1px 0;
padding: 5px;
height: 15px;
outline: 0;
border: 0 !important;
background: transparent !important;
box-shadow: none;
color: #666;
font-size: 100%;
font-family: sans-serif;
line-height: normal;
border-radius: 0;
width: 100% !important;
}
.chosen-container-multi .chosen-choices li.search-field .default {
color: #999;
}
.chosen-container-multi .chosen-choices li.search-choice {
position: relative;
margin: 3px 0 3px 5px;
padding: 3px 20px 3px 5px;
border: 1px solid #aaa;
border-radius: 3px;
background-color: #e4e4e4;
background: linear-gradient(to bottom, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
background-clip: padding-box;
box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, .05);
color: #333;
line-height: 13px;
cursor: default;
}
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
position: absolute;
top: 4px;
right: 3px;
display: block;
width: 12px;
height: 12px;
background: url('/img/chosen-sprite.png') -42px 1px no-repeat;
font-size: 1px;
}
.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
background-position: -42px -10px;
}
.chosen-container-multi .chosen-choices li.search-choice-disabled {
padding-right: 5px;
border: 1px solid #ccc;
background-color: #e4e4e4;
background: linear-gradient(to top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
color: #666;
}
.chosen-container-multi .chosen-choices li.search-choice-focus {
background: #d4d4d4;
}
.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close {
background-position: -42px -10px;
}
.chosen-container-multi .chosen-results {
margin: 0;
padding: 0;
}
.chosen-container-multi .chosen-drop .result-selected {
display: list-item;
color: #ccc;
cursor: default;
}
.chosen-container-active .chosen-single {
border: 1px solid #5897fb;
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
}
.chosen-container-active.chosen-with-drop .chosen-single {
border: 1px solid #aaa;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
background: linear-gradient(to bottom, #eee 20%, #fff 80%);
box-shadow: 0 1px 0 #fff inset;
}
.chosen-container-active.chosen-with-drop .chosen-single div {
border-left: 0;
background: transparent;
}
.chosen-container-active.chosen-with-drop .chosen-single div b {
background-position: -18px 2px;
}
.chosen-container-active .chosen-choices {
border: 1px solid #5897fb;
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
}
.chosen-container-active .chosen-choices li.search-field input[type="text"] {
color: #111 !important;
}
.chosen-disabled {
opacity: .5 !important;
cursor: default;
}
.chosen-disabled .chosen-single {
cursor: default;
}
.chosen-disabled .chosen-choices .search-choice .search-choice-close {
cursor: default;
}
/* RTL поддержка */
.chosen-rtl { text-align: right; }
.chosen-rtl .chosen-single { padding: 0 8px 0 0; overflow: visible; }
.chosen-rtl .chosen-single span { margin-right: 0; margin-left: 26px; direction: rtl; }
.chosen-rtl .chosen-single-with-deselect span { margin-left: 38px; }
.chosen-rtl .chosen-single div { right: auto; left: 3px; }
.chosen-rtl .chosen-single abbr { right: auto; left: 26px; }
.chosen-rtl .chosen-choices li { float: right; }
.chosen-rtl .chosen-choices li.search-field input[type="text"] { direction: rtl; }
.chosen-rtl .chosen-choices li.search-choice { margin: 3px 5px 3px 0; padding: 3px 5px 3px 19px; }
.chosen-rtl .chosen-choices li.search-choice .search-choice-close { right: auto; left: 4px; }
.chosen-rtl.chosen-container-single-nosearch .chosen-search,
.chosen-rtl .chosen-drop { left: 9999px; }
.chosen-rtl.chosen-container-single .chosen-results { margin: 0 0 4px 4px; padding: 0 4px 0 0; }
.chosen-rtl .chosen-results li.group-option { padding-right: 15px; padding-left: 0; }
.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div { border-right: 0; }
.chosen-rtl .chosen-search input[type="text"] {
padding: 4px 5px 4px 20px;
background: #fff url('/img/chosen-sprite.png') no-repeat -30px -20px !important;
direction: rtl;
}
.chosen-rtl.chosen-container-single .chosen-single div b { background-position: 6px 2px; }
.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b { background-position: -12px 2px; }
</style>
все нужные файлы в прекрепленном архиве картинку залить в папку img если таковой нет создайте ее