diff --git a/app/assets/javascripts/basic/orbit_js_1.0.1.js b/app/assets/javascripts/basic/orbit_js_1.0.1.js index 9626619ba..f57a8b50b 100644 --- a/app/assets/javascripts/basic/orbit_js_1.0.1.js +++ b/app/assets/javascripts/basic/orbit_js_1.0.1.js @@ -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(); -}); \ No newline at end of file +}); + +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; +} diff --git a/app/assets/javascripts/lib/items/items.js.erb b/app/assets/javascripts/lib/items/items.js.erb index 47b46b45f..c88c95ddc 100644 --- a/app/assets/javascripts/lib/items/items.js.erb +++ b/app/assets/javascripts/lib/items/items.js.erb @@ -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(''); - 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(''); - 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(''); - 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(''); - 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')) { diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index 320b8e9aa..c515655e7 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -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] diff --git a/app/views/admin/users_new_interface/index.html.erb b/app/views/admin/users_new_interface/index.html.erb index b72e62d41..ee33c881d 100644 --- a/app/views/admin/users_new_interface/index.html.erb +++ b/app/views/admin/users_new_interface/index.html.erb @@ -24,12 +24,12 @@