fixed all button for page settings and also filter display after page refresh
This commit is contained in:
parent
591a3e0bc4
commit
49217d4705
|
@ -541,6 +541,8 @@ function changeStatusHidden() {
|
|||
|
||||
// Document Ready
|
||||
$(function() {
|
||||
showFiltersOnPageRefresh();
|
||||
|
||||
new ini();
|
||||
$('#main-wrap').on('click', '.delete', function() {
|
||||
api.modal($(this).attr('rel'));
|
||||
|
@ -589,4 +591,35 @@ $(function() {
|
|||
}
|
||||
formTip()
|
||||
sidebarNav();
|
||||
});
|
||||
});
|
||||
|
||||
var showFiltersOnPageRefresh = function(){
|
||||
var params = getUrlVars(),
|
||||
paramfilter = params['new_filter[type]'];
|
||||
|
||||
// switch (paramfilter){
|
||||
// case "role":
|
||||
// paramfilter = "status";
|
||||
// break;
|
||||
// }
|
||||
|
||||
if( paramfilter ){
|
||||
$( "#filter" ).addClass('open');
|
||||
$( '#filter a[href="#collapse-' + paramfilter + '"]').parent().parent().addClass('active');
|
||||
$( '#filter #collapse-' + paramfilter ).addClass('in');
|
||||
}
|
||||
}
|
||||
|
||||
var getUrlVars = function(){
|
||||
var vars = [], hash;
|
||||
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||
for(var i = 0; i < hashes.length; i++){
|
||||
hash = hashes[i].split('=');
|
||||
vars.push(decodeURIComponent(hash[0]));
|
||||
vars[decodeURIComponent(hash[0])] = decodeURIComponent(hash[1]);
|
||||
}
|
||||
if(vars[0] == window.location.href){
|
||||
vars =[];
|
||||
}
|
||||
return vars;
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ function customOpenSlide() {
|
|||
} else {
|
||||
$('#pageslide form').prop('method', 'post')
|
||||
};
|
||||
_type == 'page' ? pageSetting(element.data('id'), _edit) : linkSetting(element.data('id'), _edit, pageslide);
|
||||
_type == 'page' ? pageSetting(element.data('id'), _edit, pageslide) : linkSetting(element.data('id'), _edit, pageslide);
|
||||
}
|
||||
});
|
||||
$iFrame.pageslide({
|
||||
|
@ -135,7 +135,8 @@ function iFrameContent() {
|
|||
iFrameFunction($iContents, $pc);
|
||||
});
|
||||
}
|
||||
function pageSetting(id, edit) {
|
||||
|
||||
function pageSetting(id, edit, ps) {
|
||||
$pageModule = $('#pageslide #page_module_app_id');
|
||||
$pageF2E = $('#pageslide #page_app_frontend_url');
|
||||
$pageDivF2E = $('#pageslide #front_url');
|
||||
|
@ -183,23 +184,25 @@ function pageSetting(id, edit) {
|
|||
|
||||
if(val.category.length > 0) {
|
||||
$.each(val.category, function(index, val) {
|
||||
var _arr = $.inArray($(this)[1], _selectData.module.category[1]);
|
||||
var _arr = $.inArray($(this)[1], _selectData.module.category);
|
||||
$pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
|
||||
if(!_selectData.module.category[0] && _arr !== -1) {
|
||||
if(_arr !== -1) {
|
||||
$pageCategory.find('input[type="checkbox"]').eq(index).prop('checked', true);
|
||||
}
|
||||
_selectData.module.category[0] ? $pageCategory.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
|
||||
var $all = $pageCategory.siblings('.checkbox').children('.select_all')
|
||||
_selectData.module.category.length > 1 && _selectData.module.category.length == index + 1 ? $all.prop('checked', true) : $all.prop('checked', false);
|
||||
});
|
||||
$pageCategoryGroup.show();
|
||||
}
|
||||
if(val.tags.length > 0) {
|
||||
$.each(val.tags, function(index, val) {
|
||||
var _arr = $.inArray($(this)[1], _selectData.module.tags[1]);
|
||||
var _arr = $.inArray($(this)[1], _selectData.module.tags);
|
||||
$pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
|
||||
if(!_selectData.module.tags[0] && _arr !== -1) {
|
||||
if(_arr !== -1) {
|
||||
$pageTags.find('input[type="checkbox"]').eq(index).prop('checked', true);
|
||||
}
|
||||
_selectData.module.tags[0] ? $pageTags.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
|
||||
var $all = $pageTags.siblings('.checkbox').children('.select_all')
|
||||
_selectData.module.tags.length > 1 && _selectData.module.tags.length == index + 1 ? $all.prop('checked', true) : $all.prop('checked', false);
|
||||
});
|
||||
$pageTagsGroup.show();
|
||||
}
|
||||
|
@ -397,12 +400,13 @@ $(function() {
|
|||
if(val.category.length > 0) {
|
||||
$.each(val.category, function(index, val) {
|
||||
if(val !== 0) {
|
||||
var _arr = _select ? $.inArray($(this)[1], _select.category[1]) : '';
|
||||
var _arr = _select ? $.inArray($(this)[1], _select.category) : '';
|
||||
$pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
|
||||
if(_select && !_select.category[0] && _arr !== -1) {
|
||||
if(_boolean && _arr !== -1) {
|
||||
$pageCategory.find('input[type="checkbox"]').eq(index).prop('checked', true);
|
||||
}
|
||||
_select && _val == _select.main && _select.category[0] ? $pageCategory.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
|
||||
var $all = $pageCategory.siblings('.checkbox').children('.select_all');
|
||||
_boolean && _val == _select.main && _select.category.length > 1 && _select.category.length == index + 1 ? $all.prop('checked', true) : $all.prop('checked', false);
|
||||
}
|
||||
});
|
||||
$pageCategoryGroup.show();
|
||||
|
@ -413,12 +417,13 @@ $(function() {
|
|||
if(val.tags.length > 0) {
|
||||
$.each(val.tags, function(index, val) {
|
||||
if(val !== 0) {
|
||||
var _arr = _select ? $.inArray($(this)[1], _select.tags[1]) : '';
|
||||
var _arr = _select ? $.inArray($(this)[1], _select.tags) : '';
|
||||
$pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
|
||||
if(_select && !_select.tags[0] && _arr !== -1) {
|
||||
if(_boolean && _arr !== -1) {
|
||||
$pageTags.find('input[type="checkbox"]').eq(index).prop('checked', true);
|
||||
}
|
||||
_select && _val == _select.main && _select.tags[0] ? $pageTags.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
|
||||
var $all = $pageTags.siblings('.checkbox').children('.select_all');
|
||||
_boolean && _val == _select.main && _select.tags.length > 1 && _select.tags.length == index + 1 ? $all.prop('checked', true) : $all.prop('checked', false);
|
||||
}
|
||||
});
|
||||
$pageTagsGroup.show();
|
||||
|
@ -451,12 +456,16 @@ $(function() {
|
|||
|
||||
$('#pageslide').on('change', '.checkbox-groups input', function(event) {
|
||||
var $checked = $(this);
|
||||
|
||||
if($checked.attr('type') == 'checkbox') {
|
||||
if($checked.hasClass('select_all') && $checked.prop('checked')) {
|
||||
$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 {
|
||||
if($checked.hasClass('select_all')) {
|
||||
if($checked.prop('checked')) {
|
||||
$checked.closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', true);
|
||||
} else {
|
||||
$checked.closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', false);
|
||||
}
|
||||
} else if($checked.hasClass('lang-enable')) {
|
||||
var checkboxes = $checked.closest('.groups').find('input[type="checkbox"]');
|
||||
if($checked.prop('checked')) {
|
||||
$checked.closest('.active-link').addClass('active').siblings('active-link').removeClass('active').end().find('.active-mune').slideDown(300);
|
||||
if(_status) {
|
||||
|
@ -470,6 +479,14 @@ $(function() {
|
|||
$(this).find('input:eq(0)').prop('checked', true);
|
||||
})
|
||||
}
|
||||
} else {
|
||||
var _l = $checked.closest('.groups').find('input[type="checkbox"]').length,
|
||||
_c = $checked.closest('.groups').find('input[type="checkbox"]:checked').length;
|
||||
if(_l == _c) {
|
||||
$checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', true)
|
||||
} else {
|
||||
$checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', false)
|
||||
};
|
||||
}
|
||||
return false;
|
||||
} else if($checked.attr('type') == 'radio' && !$(this).closest('div').hasClass('active-mune')) {
|
||||
|
|
|
@ -60,8 +60,8 @@ class Admin::PagesController < Admin::ItemsController
|
|||
m = {}
|
||||
m["main"] = page.module_app_id.to_s
|
||||
m["sub"] = page.app_frontend_url
|
||||
m["category"] = page.category.present? ? [0, page.category.map{|c| c.to_s}] : [1]
|
||||
m["tags"] = page.tag.present? ? [0, page.tag.map{|c| c.to_s}] : [1]
|
||||
m["category"] = page.category.present? ? page.category.map{|c| c.to_s} : []
|
||||
m["tags"] = page.tag.present? ? page.tag.map{|c| c.to_s} : []
|
||||
m["public"] = page.is_published ? 1 : 0
|
||||
m["link"] = @site_valid_locales.inject([]) do |link, locale|
|
||||
link << [locale, (page.enabled_for && page.enabled_for.include?(locale)) ? 1 : 0, (page.menu_enabled_for && page.menu_enabled_for[locale].eql?('true')) ? 1 :0]
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
<ul class="nav nav-pills filter-nav pull-right">
|
||||
<li class="accordion-group">
|
||||
<div class="accordion-heading">
|
||||
<a href="#collapse-status" data-toggle="collapse" data-parent="#filter" class="accordion-toggle">Roles</a>
|
||||
<a href="#collapse-role" data-toggle="collapse" data-parent="#filter" class="accordion-toggle">Roles</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="filter-group accordion-group">
|
||||
<div class="accordion-body collapse" id="collapse-status">
|
||||
<div class="accordion-body collapse" id="collapse-role">
|
||||
|
||||
<%= render :partial => "filter"%>
|
||||
|
||||
|
|
Loading…
Reference in New Issue