// Items Quantity function itemsQuantity() { var $sortable = $('.sortable'), $host = $sortable.children('.navbar').eq(0), $navbar = $('.sortable li').children('.navbar'), $quantity = $sortable.find('li').length; $host.find('.badge').text($quantity); $navbar.each(function(i) { if($navbar.eq(i).next('ol').length>0) { var $amount = $navbar.eq(i).next('ol').find('li').length; $navbar.eq(i).find('.badge').text($amount); }else{ $navbar.eq(i).find('.badge').text('0'); } $navbar.eq(i).find('.badge').text()>0 ? $navbar.eq(i).find('.badge').addClass('badge-info'):$navbar.eq(i).find('.badge').removeClass('badge-info'); }) } function tip() { if(!$.support.touch) { $('.tip').tooltip({ position: { my: "center bottom-4", at: "center top", } }); }; } function touchSupport() { if($.support.touch) { $('.item-menu').css({ 'display': 'inline-block' }) } } function customOpenSlide() { var $openSlide = $('.open-slide'), $pageslideW; $(window).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954; $(window).resize(function() { $(this).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954; }); $noiFrame = $openSlide.not('.view-page'); $iFrame = $openSlide.filter('.view-page.open-slide'); $noiFrame.pageslide({ W: 314, openFn: function(pageslide, element) { element.addClass('active') .closest('.item-menu') .css('display', 'inline-block') .closest('.navbar-inner') .addClass('active'); }, closeFn: function(pageslide, element) { $('.item-menu').removeAttr('style'); element.removeClass('active') .closest('.navbar-inner') .removeClass('active'); }, loadComplete: function(pageslide, element) { $openSlide.removeClass('active'); $('.navbar-inner').removeClass('active'); $('.item-menu').removeAttr('style'); element.addClass('active') .closest('.item-menu') .css('display', 'inline-block') .closest('.navbar-inner') .addClass('active'); var _id = element.data('id'), _type = element.hasClass('page') ? 'page' : 'link', _edit = element.hasClass('edit') ? true : false; if(_id !== 'new') { $('#pageslide form').attr({ 'action': $('#pageslide form').attr('action') + '/' + _id, 'id': 'edit_' + _type + '_' + _id }); }; _type == 'page' ? pageSetting(element.data('id'), _edit) : ''; } }); $iFrame.pageslide({ W: $pageslideW, iframe: true, openFn: function(pageslide, element) { element.addClass('active') .closest('.item-menu') .css('display', 'inline-block') .closest('.navbar-inner') .addClass('active'); }, closeFn: function(pageslide, element) { $('.item-menu').removeAttr('style'); element.removeClass('active') .closest('.navbar-inner') .removeClass('active'); $('#main-wrap').css('width', 'auto') }, loadComplete: function(pageslide, element) { $openSlide.removeClass('active'); $('.navbar-inner').removeClass('active'); $('.item-menu').removeAttr('style'); element.addClass('active') .closest('.item-menu') .css('display', 'inline-block') .closest('.navbar-inner') .addClass('active'); pageslide.find('.content').css('padding', 0); } }); } function pageSetting(id, edit) { $pageModule = $('#page_module_app_id'), $pageF2E = $('#page_app_frontend_url'), $pageDesign = $('#page_design'), $pageTheme = $('#page_theme_id'), $pageCategory = $('#page-category'), $pageTags = $('#page-tags'); if(edit) { $.ajax({ url: 'page-setting.json', type: 'POST', contentType: "application/json; charset=utf-8", dataType: 'json', data: '{"id": ' + id + '}', cache: false, }) .done(function(data) { _selectData = data; $.each(_pageData.design, function(index, val) { $pageDesign.append(''); if(val.main[1] == _selectData.design.main) { $.each(val.sub, function(index, val) { $pageTheme.append('') }); }; }); $.each(_pageData.module, function(index, val) { $pageModule.append(''); if(val.main[1] == _selectData.module.main) { $.each(val.sub, function(index, val) { $pageF2E.append('') }); $.each(val.category, function(index, val) { var _arr = $.inArray($(this)[1], _selectData.module.category[1]); $pageCategory.append(''); if(!_selectData.module.category[0] && _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) : ''; }); $.each(val.tags, function(index, val) { var _arr = $.inArray($(this)[1], _selectData.module.tags[1]); $pageTags.append(''); if(!_selectData.module.tags[0] && _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) : ''; }); }; }); changeSetting(true); }) .fail(function(jqXHR, textStatus) { console.log(jqXHR.status, textStatus) var $errorMsg = '
Sorry! Something is wrong