all problem fixed for all categories and tags in plugin widget
This commit is contained in:
parent
1febd0bdac
commit
9428171859
|
@ -107,15 +107,18 @@ $(function() {
|
|||
}
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$('#module_widget').on('change', '.checkbox-groups input', function(event) {
|
||||
var $checked = $(this);
|
||||
if($checked.attr('type') == 'checkbox') {
|
||||
if($checked.hasClass('select_all') && $checked.prop('checked')) {
|
||||
if($checked.hasClass('select_all')) {
|
||||
if($checked.prop('checked')){
|
||||
$checked.closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', true);
|
||||
$checked.closest('.checkbox').siblings('.groups').find("input[type=hidden]").removeAttr('name');
|
||||
}else{
|
||||
$checked.closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', false);
|
||||
} else if($checked.prop('checked') && !$checked.hasClass('lang-enable')) {
|
||||
$checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', false);
|
||||
} else {
|
||||
$checked.closest('.checkbox').siblings('.groups').find("input[type=hidden]").attr('name', 'page_part['+$checked.closest('.checkbox-groups').data('for')+'][]');
|
||||
}
|
||||
} else if($checked.hasClass('lang-enable')) {
|
||||
if($checked.prop('checked')) {
|
||||
$checked.closest('.active-link').addClass('active').siblings('active-link').removeClass('active').end().find('.active-mune').slideDown(300);
|
||||
if(_status) {
|
||||
|
@ -129,6 +132,19 @@ $(function() {
|
|||
$(this).find('input:eq(0)').prop('checked', true);
|
||||
})
|
||||
}
|
||||
} else {
|
||||
var checkboxes_size = $checked.closest('.groups').find("input[type=checkbox]").length,
|
||||
checked_size = $checked.closest('.groups').find("input:checked").length;
|
||||
if(checkboxes_size == checked_size)
|
||||
$checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', true);
|
||||
else
|
||||
$checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', false);
|
||||
|
||||
if(checked_size == 0)
|
||||
$checked.closest('.groups').find("input[type=hidden]").attr('name', 'page['+$checked.closest('.checkbox-groups').data('for')+'][]');
|
||||
else
|
||||
$checked.closest('.groups').find("input[type=hidden]").removeAttr('name');
|
||||
|
||||
}
|
||||
return false;
|
||||
} else if($checked.attr('type') == 'radio' && !$(this).closest('div').hasClass('active-mune')) {
|
||||
|
|
|
@ -97,25 +97,26 @@
|
|||
<%= f.select :widget_path, @widget_paths, {}, selected: (@part.widget_path rescue nil), class: "input-xlarge change" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group input-content checkbox-groups <%= 'hide' if @module_app_categories.blank? %>" id="page-category-groups">
|
||||
<div class="control-group input-content checkbox-groups <%= 'hide' if @module_app_categories.blank? %>" id="page-category-groups" data-for="category">
|
||||
<%= f.label :categories, t(:categories), class: "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= content_tag :label, class: "checkbox" do %>
|
||||
<%= check_box_tag nil, nil, false, class: "select_all" %> <%= t(:all) %>
|
||||
<%= check_box_tag nil, nil, (@part.category.size == @module_app_categories.size ? true : false), class: "select_all" %> <%= t(:all) %>
|
||||
<% end %>
|
||||
<div class="groups" id="page-category">
|
||||
<%= content_tag_for(:label, @module_app_categories, class: "checkbox inline") do |category|%>
|
||||
<%= check_box_tag("page_part[category][]", category.id, (@part.category.include?(category.id.to_s) rescue false) ) %>
|
||||
<%= category.title %>
|
||||
<% end if @module_app_categories %>
|
||||
<input type="hidden" value>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group input-content checkbox-groups <%= 'hide' if @module_app_tags.blank? %>" id="page-tags-groups">
|
||||
<div class="control-group input-content checkbox-groups <%= 'hide' if @module_app_tags.blank? %>" id="page-tags-groups" data-for="tag">
|
||||
<%= f.label :tags, t(:tags), class: "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= content_tag :label, class: "checkbox" do %>
|
||||
<%= check_box_tag nil, nil, true, class: "select_all" %> <%= t(:all) %>
|
||||
<%= check_box_tag nil, nil, (@part.tag.size == @module_app_tags.size ? true : false), class: "select_all" %> <%= t(:all) %>
|
||||
<% end %>
|
||||
<div class="groups" id="page-tags">
|
||||
<%= content_tag_for(:label, @module_app_tags, class: "checkbox inline") do |tag|%>
|
||||
|
@ -162,8 +163,8 @@
|
|||
</script>
|
||||
<script>
|
||||
function toggleChecked(status) {
|
||||
$(".checkbox").each( function() {
|
||||
$(this).attr("checked",status);
|
||||
})
|
||||
$(".checkbox").each( function() {
|
||||
$(this).attr("checked",status);
|
||||
})
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue