2013-07-02 08:46:44 +00:00
|
|
|
// 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'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2013-10-16 13:53:29 +00:00
|
|
|
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) {
|
2013-10-20 12:54:23 +00:00
|
|
|
$('.item-menu').removeAttr('style');
|
2013-10-16 13:53:29 +00:00
|
|
|
element.removeClass('active')
|
|
|
|
.closest('.navbar-inner')
|
|
|
|
.removeClass('active');
|
|
|
|
},
|
|
|
|
loadComplete: function(pageslide, element) {
|
|
|
|
$openSlide.removeClass('active');
|
|
|
|
$('.navbar-inner').removeClass('active');
|
2013-10-20 12:54:23 +00:00
|
|
|
$('.item-menu').removeAttr('style');
|
|
|
|
element.addClass('active')
|
|
|
|
.closest('.item-menu')
|
|
|
|
.css('display', 'inline-block')
|
|
|
|
.closest('.navbar-inner')
|
|
|
|
.addClass('active');
|
2013-10-23 07:51:49 +00:00
|
|
|
_type = element.hasClass('page') ? 'page' : 'link';
|
2013-10-16 13:53:29 +00:00
|
|
|
var _id = element.data('id'),
|
2013-10-23 07:51:49 +00:00
|
|
|
_parent = element.data('parent'),
|
2013-10-16 13:53:29 +00:00
|
|
|
_edit = element.hasClass('edit') ? true : false;
|
2013-10-23 07:51:49 +00:00
|
|
|
$('#pageslide .parent').val(_parent);
|
2013-10-16 13:53:29 +00:00
|
|
|
if(_id !== 'new') {
|
|
|
|
$('#pageslide form').attr({
|
|
|
|
'action': $('#pageslide form').attr('action') + '/' + _id,
|
2013-10-23 07:51:49 +00:00
|
|
|
'id': 'edit_' + _type + '_' + _id,
|
|
|
|
'method': 'put'
|
2013-10-16 13:53:29 +00:00
|
|
|
});
|
2013-10-23 07:51:49 +00:00
|
|
|
setForm(element.data('form'));
|
|
|
|
} else {
|
|
|
|
$('#pageslide form').prop('method', 'post')
|
2013-10-16 13:53:29 +00:00
|
|
|
};
|
2013-10-23 07:51:49 +00:00
|
|
|
_type == 'page' ? pageSetting(element.data('id'), _edit) : linkSetting(element.data('id'), _edit);
|
2013-10-16 13:53:29 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$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) {
|
2013-10-20 12:54:23 +00:00
|
|
|
$('.item-menu').removeAttr('style');
|
2013-10-16 13:53:29 +00:00
|
|
|
element.removeClass('active')
|
|
|
|
.closest('.navbar-inner')
|
|
|
|
.removeClass('active');
|
|
|
|
$('#main-wrap').css('width', 'auto')
|
|
|
|
},
|
|
|
|
loadComplete: function(pageslide, element) {
|
|
|
|
$openSlide.removeClass('active');
|
|
|
|
$('.navbar-inner').removeClass('active');
|
2013-10-20 12:54:23 +00:00
|
|
|
$('.item-menu').removeAttr('style');
|
|
|
|
element.addClass('active')
|
|
|
|
.closest('.item-menu')
|
|
|
|
.css('display', 'inline-block')
|
|
|
|
.closest('.navbar-inner')
|
|
|
|
.addClass('active');
|
2013-10-16 13:53:29 +00:00
|
|
|
pageslide.find('.content').css('padding', 0);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function pageSetting(id, edit) {
|
2013-10-23 07:51:49 +00:00
|
|
|
$pageModule = $('#pageslide #page_module_app_id');
|
|
|
|
$pageF2E = $('#pageslide #page_app_frontend_url');
|
|
|
|
$pageDivF2E = $('#pageslide #front_url');
|
|
|
|
$pageDesign = $('#pageslide #page_design');
|
|
|
|
$pageTheme = $('#pageslide #page_theme_id');
|
|
|
|
$pageCategory = $('#pageslide #page-category');
|
|
|
|
$pageCategoryGroup = $('#pageslide #page-category-groups');
|
|
|
|
$pageTags = $('#pageslide #page-tags');
|
|
|
|
$pageTagsGroup = $('#pageslide #page-tags-groups');
|
|
|
|
$pagePublishedTrue = $('#pageslide #page_is_published_true');
|
|
|
|
$pageCount = $('#pageslide #page_count');
|
|
|
|
$pageDivCount = $('#pageslide #front_count');
|
|
|
|
_status = edit;
|
|
|
|
_ID = id;
|
|
|
|
if(_status) {
|
2013-10-16 13:53:29 +00:00
|
|
|
$.ajax({
|
2013-10-23 07:51:49 +00:00
|
|
|
url: "<%= Rails.application.routes.url_helpers.get_page_setting_json_admin_pages_path %>",
|
2013-10-16 13:53:29 +00:00
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
dataType: 'json',
|
2013-10-23 07:51:49 +00:00
|
|
|
data: {id: id},
|
2013-10-16 13:53:29 +00:00
|
|
|
cache: false,
|
|
|
|
})
|
|
|
|
.done(function(data) {
|
2013-10-23 07:51:49 +00:00
|
|
|
_boolean = true;
|
2013-10-16 13:53:29 +00:00
|
|
|
_selectData = data;
|
|
|
|
$.each(_pageData.design, function(index, val) {
|
|
|
|
$pageDesign.append('<option value="' + val.main[1] + '" ' + (val.main[1] == _selectData.design.main ? 'selected="selected"' : '') + '>' + val.main[0] + '</option>');
|
|
|
|
if(val.main[1] == _selectData.design.main) {
|
|
|
|
$.each(val.sub, function(index, val) {
|
|
|
|
$pageTheme.append('<option value="' + $(this)[1] + '" ' + ($(this)[1] == _selectData.design.sub ? 'selected="selected"' : '') + '>' + $(this)[0]+ '</option>')
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
2013-10-23 07:51:49 +00:00
|
|
|
$pageModule.append('<option/>');
|
2013-10-16 13:53:29 +00:00
|
|
|
$.each(_pageData.module, function(index, val) {
|
|
|
|
$pageModule.append('<option value="' + val.main[1] + '" ' + (val.main[1] == _selectData.module.main ? 'selected="selected"' : '') + '>' + val.main[0] + '</option>');
|
2013-10-23 07:51:49 +00:00
|
|
|
if(_selectData.module.main && val.main[1] == _selectData.module.main) {
|
|
|
|
$pageDivF2E.show();
|
2013-10-16 13:53:29 +00:00
|
|
|
$.each(val.sub, function(index, val) {
|
|
|
|
$pageF2E.append('<option value="' + $(this)[1] + '" ' + ($(this)[1] == _selectData.module.sub ? 'selected="selected"' : '') + '>' + $(this)[0]+ '</option>')
|
|
|
|
});
|
2013-10-23 07:51:49 +00:00
|
|
|
$.each(val.count, function(index, val) {
|
|
|
|
$pageCount.append('<option value="' + val + '" ' + (val == _selectData.module.count ? 'selected="selected"' : '') + '>' + val+ '</option>');
|
2013-10-16 13:53:29 +00:00
|
|
|
});
|
2013-10-23 07:51:49 +00:00
|
|
|
$pageDivCount.show();
|
|
|
|
|
|
|
|
if(val.category.length > 0) {
|
|
|
|
$.each(val.category, function(index, val) {
|
|
|
|
var _arr = $.inArray($(this)[1], _selectData.module.category[1]);
|
|
|
|
$pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
|
|
|
|
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) : '';
|
|
|
|
});
|
|
|
|
$pageCategoryGroup.show();
|
|
|
|
}
|
|
|
|
if(val.category.length > 0) {
|
|
|
|
$.each(val.tags, function(index, val) {
|
|
|
|
var _arr = $.inArray($(this)[1], _selectData.module.tags[1]);
|
|
|
|
$pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
|
|
|
|
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) : '';
|
|
|
|
});
|
|
|
|
$pageTagsGroup.show();
|
|
|
|
}
|
2013-10-16 13:53:29 +00:00
|
|
|
};
|
|
|
|
});
|
2013-10-23 07:51:49 +00:00
|
|
|
_selectData.module.public ? $pagePublishedTrue.prop('checked', true) : $pagePublishedTrue.prop('checked', false);
|
|
|
|
$.each(_selectData.module.link, function(index, val) {
|
|
|
|
if(val[1]) {
|
|
|
|
$('#pageslide .active-link.' + val[0]).find('input[type="checkbox"]').prop('checked', true).end().find('.active-mune').slideDown(300);
|
|
|
|
$('#pageslide .active-link.' + val[0]).find('input[type="radio"]').eq(val[2]).prop('checked', true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
changeSetting(id);
|
|
|
|
$('#pageslide').find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
|
2013-10-16 13:53:29 +00:00
|
|
|
})
|
|
|
|
.fail(function(jqXHR, textStatus) {
|
|
|
|
console.log(jqXHR.status, textStatus)
|
2013-10-20 12:54:23 +00:00
|
|
|
var $errorMsg = '<div class="error-cover"><div class="msg"><i class="icons-warning"></i><p>Sorry! Something is wrong</p></div></div>'
|
2013-10-16 13:53:29 +00:00
|
|
|
$('#pageslide .view-page').append($errorMsg);
|
|
|
|
});
|
|
|
|
} else {
|
2013-10-23 07:51:49 +00:00
|
|
|
_boolean = false;
|
2013-10-16 13:53:29 +00:00
|
|
|
$.each(_pageData.design, function(index, val) {
|
2013-10-23 07:51:49 +00:00
|
|
|
$pageDesign.append('<option value="' + val.main[1] + '" ' + (val.main[2] ? 'selected="selected"' : '') + '>' + val.main[0] + '</option>');
|
|
|
|
if(val.main[2]) {
|
2013-10-16 13:53:29 +00:00
|
|
|
$.each(val.sub, function(index, val) {
|
|
|
|
$pageTheme.append('<option value="' + $(this)[1] + '">' + $(this)[0]+ '</option>')
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|
2013-10-23 07:51:49 +00:00
|
|
|
$pageModule.append('<option/>');
|
2013-10-16 13:53:29 +00:00
|
|
|
$.each(_pageData.module, function(index, val) {
|
|
|
|
$pageModule.append('<option value="' + val.main[1] + '">' + val.main[0] + '</option>');
|
|
|
|
});
|
2013-10-23 07:51:49 +00:00
|
|
|
changeSetting(id);
|
2013-10-16 13:53:29 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-10-23 07:51:49 +00:00
|
|
|
function linkSetting(id, edit) {
|
|
|
|
$linkKey = $('#pageslide .link-key');
|
|
|
|
$linkUrl = $('#pageslide .link-url');
|
|
|
|
$linkTitle = $('#pageslide .link-title'),
|
|
|
|
$linkPublishedTrue = $('#link_is_published_true');
|
|
|
|
_status = edit;
|
|
|
|
if(_status) {
|
|
|
|
$.ajax({
|
|
|
|
url: 'link-setting.json',
|
|
|
|
type: 'POST',
|
|
|
|
contentType: "application/json; charset=utf-8",
|
|
|
|
dataType: 'json',
|
|
|
|
data: '{"id": ' + id + '}',
|
|
|
|
cache: false,
|
|
|
|
})
|
|
|
|
.done(function(data) {
|
|
|
|
_linkData = data;
|
|
|
|
$linkKey.val(data.key);
|
|
|
|
$.each(data.url, function(index, val) {
|
|
|
|
$linkUrl.eq(index).val(val)
|
|
|
|
});
|
|
|
|
$.each(data.title, function(index, val) {
|
|
|
|
$linkTitle.eq(index).val(val)
|
|
|
|
});
|
|
|
|
data.public ? $linkPublishedTrue.prop('checked', true) : $linkPublishedTrue.prop('checked', false);
|
|
|
|
$linkPublishedTrue.prop('checked') ? $('.link-options').slideDown(300) : $('.link-options').slideUp(300);
|
|
|
|
$.each(data.link, function(index, val) {
|
|
|
|
if(val[0]) {
|
|
|
|
$('.active-link').eq(index).find('input[type="checkbox"]').prop('checked', true).end().find('.active-mune').slideDown(300);
|
|
|
|
val[1] == 1 ? $('.active-link').eq(index).find('input[type="radio"]').eq(val[1]).prop('checked', true) : $('.active-link').eq(index).find('input[type="radio"]').eq(val[1]).prop('checked', true);
|
2013-10-16 13:53:29 +00:00
|
|
|
};
|
|
|
|
});
|
2013-10-23 07:51:49 +00:00
|
|
|
$('#pageslide').find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
|
|
|
|
})
|
|
|
|
.fail(function(jqXHR, textStatus) {
|
|
|
|
console.log(jqXHR.status, textStatus)
|
|
|
|
var $errorMsg = '<div class="error-cover"><div class="msg"><i class="icons-warning"></i><p>Sorry! Something is wrong</p></div></div>'
|
|
|
|
$('#pageslide .view-page').append($errorMsg);
|
2013-10-16 13:53:29 +00:00
|
|
|
});
|
2013-10-23 07:51:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function changeSetting(id) {
|
|
|
|
getView(id);
|
|
|
|
$pagePublishedTrue.prop('checked') ? $('.link-options').slideDown(300) : $('.link-options').slideUp(300);
|
2013-10-16 13:53:29 +00:00
|
|
|
}
|
2013-10-23 07:51:49 +00:00
|
|
|
|
2013-10-16 13:53:29 +00:00
|
|
|
function getPageData() {
|
2013-10-23 07:51:49 +00:00
|
|
|
$.getJSON("<%= Rails.application.routes.url_helpers.get_page_design_module_json_admin_items_path %>").done(function(data) {
|
2013-10-16 13:53:29 +00:00
|
|
|
_pageData = data;
|
|
|
|
});
|
|
|
|
}
|
2013-10-23 07:51:49 +00:00
|
|
|
function getView(id) {
|
|
|
|
var _data = {};
|
|
|
|
_data.val = $('#pageslide #page_app_frontend_url option:selected').val();
|
|
|
|
_data.id = id;
|
|
|
|
$.ajax({
|
|
|
|
url: "<%#= Rails.application.routes.url_helpers.get_display_style_admin_pages_path %>",
|
|
|
|
dataType: "html",
|
|
|
|
data: _data,
|
|
|
|
contentType: "application/html; charset=utf-8",
|
|
|
|
cache: false,
|
|
|
|
});
|
|
|
|
}
|
2013-07-02 08:46:44 +00:00
|
|
|
|
2013-10-23 07:51:49 +00:00
|
|
|
$(function() {
|
|
|
|
$pageModule = null,
|
|
|
|
$pageF2E = null,
|
|
|
|
$pageDivF2E = null,
|
|
|
|
$pageDesign = null,
|
|
|
|
$pageTheme = null,
|
|
|
|
$pageCategory = null,
|
|
|
|
$pageCategoryGroup = null,
|
|
|
|
$pageTags = null,
|
|
|
|
$pageTagsGroup = null,
|
|
|
|
$pagePublishedTrue = null,
|
|
|
|
$pageCount = null,
|
|
|
|
$pageDivCount = null,
|
|
|
|
$linkKey = null,
|
|
|
|
$linkUrl = null,
|
|
|
|
$linkTitle = null,
|
|
|
|
$linkPublishedTrue = null,
|
|
|
|
_boolean = null,
|
|
|
|
_ID = null,
|
|
|
|
_type = null,
|
|
|
|
_status = null,
|
|
|
|
_pageData = null,
|
|
|
|
_selectData = null,
|
|
|
|
_linkData = null;
|
2013-07-02 08:46:44 +00:00
|
|
|
$('.sortable').nestedSortable({
|
|
|
|
handle: '.brand',
|
|
|
|
items: 'li',
|
|
|
|
maxLevels: 3,
|
|
|
|
opacity: .6,
|
|
|
|
toleranceElement: '> div',
|
|
|
|
placeholder: 'placeholder',
|
|
|
|
startCollapsed: true,
|
|
|
|
disableNesting: 'no-nest',
|
2013-10-07 07:52:10 +00:00
|
|
|
update: function(event, ui) {
|
2013-10-08 04:33:24 +00:00
|
|
|
var position = null;
|
|
|
|
if($(ui.item).closest('ol').hasClass('item-groups')) {
|
|
|
|
position = $(ui.item).index() - 1;
|
|
|
|
} else {
|
|
|
|
position = $(ui.item).index();
|
|
|
|
};
|
2013-10-23 07:51:49 +00:00
|
|
|
$.post("<%= Rails.application.routes.url_helpers.update_position_admin_items_path %>", { id: ui.item.attr('id'), parent_id: (ui.item.parent().closest('li').attr('id') || ui.item.parent().closest('ol').attr('id')), position: position } );
|
2013-07-02 08:46:44 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
$(".sortable").delegate(".brand, .delete", clickEvent, function(e){
|
|
|
|
if($(this).hasClass('delete')) {
|
|
|
|
$target = $(this);
|
|
|
|
$('#dialog a.delete-item').attr("href", $(this).attr("rel"));
|
|
|
|
$('#dialog').modal('show');
|
|
|
|
} else {
|
|
|
|
if($(this).closest('li').children('ol').length > 0){
|
|
|
|
$(this).closest('li').toggleClass('collapsed');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
2013-10-23 07:51:49 +00:00
|
|
|
$("#dialog").on('show', function (e) {
|
|
|
|
$(this).find('.delete-item').on(clickEvent, function() {
|
|
|
|
$target.parents('.navbar').parent('li').remove();
|
|
|
|
$('ol').not('.sortable').each(function() {
|
|
|
|
if($(this).children('li').index() == -1) {
|
|
|
|
$(this).remove();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
itemsQuantity();
|
|
|
|
$('#dialog').modal('hide');
|
|
|
|
e.preventDefault();
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#pageslide').on('change', '.change', function(event) {
|
|
|
|
var _data, _select, _subData, $subSelete;
|
|
|
|
if(event.target.id !== 'page_app_frontend_url') {
|
|
|
|
if(event.target.id == 'page_design') {
|
|
|
|
_data = _pageData.design;
|
|
|
|
_select = _boolean ? _selectData.design : null;
|
|
|
|
_subData = 'template';
|
|
|
|
$subSelete = $('#pageslide #page_theme_id');
|
|
|
|
} else {
|
|
|
|
_data = _pageData.module;
|
|
|
|
_select = _boolean ? _selectData.module : null;
|
|
|
|
_subData = 'module';
|
|
|
|
$subSelete = $('#pageslide #page_app_frontend_url');
|
|
|
|
};
|
|
|
|
$(this).children("option:selected").each(function () {
|
|
|
|
var _val = $(this).val();
|
|
|
|
$subSelete.empty();
|
|
|
|
if(_val) {
|
|
|
|
$.each(_data, function(index, val) {
|
|
|
|
if(_val == val.main[1]) {
|
|
|
|
$pageDivF2E.show();
|
|
|
|
$.each(val.sub, function(index, val) {
|
|
|
|
var _selected = _select && $(this)[1] == _select.sub ? 'selected="selected"' : '';
|
|
|
|
$subSelete.append('<option value="' + $(this)[1] + '" ' + _selected + '>' + $(this)[0] + '</option>');
|
|
|
|
});
|
|
|
|
$.each(val.count, function(index, val) {
|
|
|
|
$pageCount.append('<option value="' + val + '" ' + (_select.main == _val && val == _selectData.module.count ? 'selected="selected"' : '') + '>' + val+ '</option>');
|
|
|
|
});
|
|
|
|
$pageDivCount.show();
|
|
|
|
|
|
|
|
if(event.target.id == 'page_module_app_id') {
|
|
|
|
if(val.category.length > 0) {
|
|
|
|
$.each(val.category, function(index, val) {
|
|
|
|
if(val !== 0) {
|
|
|
|
var _arr = _select ? $.inArray($(this)[1], _select.category[1]) : '';
|
|
|
|
$pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
|
|
|
|
if(_select && !_select.category[0] && _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) : '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$pageCategoryGroup.show();
|
|
|
|
} else {
|
|
|
|
$pageCategory.empty();
|
|
|
|
$pageCategoryGroup.hide();
|
|
|
|
}
|
|
|
|
if(val.tags.length > 0) {
|
|
|
|
$.each(val.tags, function(index, val) {
|
|
|
|
if(val !== 0) {
|
|
|
|
var _arr = _select ? $.inArray($(this)[1], _select.tags[1]) : '';
|
|
|
|
$pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
|
|
|
|
if(_select && !_select.tags[0] && _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) : '';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$pageTagsGroup.show();
|
|
|
|
} else {
|
|
|
|
$pageTags.empty();
|
|
|
|
$pageTagsGroup.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
$pageCategory.empty();
|
|
|
|
$pageCategoryGroup.hide();
|
|
|
|
$pageTags.empty();
|
|
|
|
$pageTagsGroup.hide();
|
|
|
|
$pageF2E.empty();
|
|
|
|
$pageDivF2E.hide();
|
|
|
|
$pageCount.empty();
|
|
|
|
$pageDivCount.hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
getView(_ID);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
2013-07-02 08:46:44 +00:00
|
|
|
|
2013-10-23 07:51:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
$('#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.prop('checked')) {
|
|
|
|
$checked.closest('.active-link').addClass('active').siblings('active-link').removeClass('active').end().find('.active-mune').slideDown(300);
|
|
|
|
if(_status) {
|
|
|
|
var _index = $checked.closest('.link-options').find('.active').index() - 1,
|
|
|
|
_index = _type == 'page' ? _selectData.module.link[_index][1] : _linkData.link[_index][1] ;
|
|
|
|
$checked.closest('.active-link').find('.active-mune input').eq(_index).prop('checked', true);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$('.active-link').removeClass('active');
|
|
|
|
$checked.closest('.active-link').find('.active-mune').slideUp(300, function() {
|
|
|
|
$(this).find('input:eq(0)').prop('checked', true);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} else if($checked.attr('type') == 'radio' && !$(this).closest('div').hasClass('active-mune')) {
|
|
|
|
$('#pageslide #page_is_published_true').prop('checked') || $('#pageslide #link_is_published_true').prop('checked') ? $('.link-options').slideDown(300) : $('.link-options').slideUp(300);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
2013-07-02 08:46:44 +00:00
|
|
|
tip();
|
|
|
|
touchSupport()
|
|
|
|
itemsQuantity();
|
2013-10-16 13:53:29 +00:00
|
|
|
getPageData();
|
2013-07-02 08:46:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function reloadStructure(){
|
|
|
|
$.pageslide.close();
|
2013-10-16 13:53:29 +00:00
|
|
|
customOpenSlide();
|
2013-07-02 08:46:44 +00:00
|
|
|
tip();
|
|
|
|
touchSupport()
|
|
|
|
itemsQuantity();
|
|
|
|
};
|