completed site structure with categories, data count, menu and link enabling and also re organizing the pages
Conflicts: app/helpers/orbit_helper.rb
This commit is contained in:
1 parent
7f32588551
commit
2154edea9e
24 files changed
+2032
-122
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -2,26 +2,122 @@ var Items = function(){
|
||||
var i = this;
|
||||
this.initialize = function(){
|
||||
i.bindHandlers();
|
||||
i.itemQuantity();
|
||||
i.bindEditAddPageHandlers();
|
||||
}
|
||||
|
||||
this.bindHandlers = function(){
|
||||
var $openSlide = $('.open-slide'),
|
||||
$pageslideW;
|
||||
$(window).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954;
|
||||
$(window).resize(function() {
|
||||
$pageslideW = $(window).width() > 1440 ? 1024 : 954;
|
||||
$(window).resize(function() {
|
||||
$(this).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954;
|
||||
});
|
||||
$iFrame = $openSlide.filter('.view-page.open-slide');
|
||||
$iFrame.pageslide({
|
||||
W: $pageslideW,
|
||||
iframe: true
|
||||
});
|
||||
});
|
||||
$('.sortable').nestedSortable({
|
||||
handle: '.brand',
|
||||
items: 'li',
|
||||
maxLevels: 3,
|
||||
opacity: .6,
|
||||
disableNesting: 'no-nest',
|
||||
toleranceElement: '> div',
|
||||
placeholder: 'placeholder',
|
||||
startCollapsed: true,
|
||||
update: function(event, ui) {
|
||||
var parent = (ui.item.parent().closest('li').length ? ui.item.parent().closest('li') : ui.item.parent().closest('ol')),
|
||||
children = (parent.hasClass("root") ? parent.find(">li") : parent.find(">ol li")),
|
||||
children_ids = [];
|
||||
children.each(function(){
|
||||
children_ids.push($(this).attr("id"));
|
||||
})
|
||||
$.ajax({
|
||||
url : "<%= Rails.application.routes.url_helpers.pages_update_item_position_path %>",
|
||||
data : {"parent_id" : parent.attr("id"), "id" : ui.item.attr("id"),"children_ids" : children_ids},
|
||||
dataType : "json",
|
||||
type : "post"
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.itemQuantity = function(){
|
||||
|
||||
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');
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
this.reBindHandlers = function(){
|
||||
$.pageslide.close();
|
||||
window.openSlide();
|
||||
i.bindHandlers();
|
||||
}
|
||||
|
||||
this.bindEditAddPageHandlers = function(){
|
||||
var sidePanel = $(".view-page .content");
|
||||
|
||||
sidePanel.on("click","#categories_list input[type=checkbox]",function(){
|
||||
if($(this).is(":checked") && $(this).hasClass("checkbox-all")){
|
||||
$(".view-page .content #categories_list input[type=checkbox]").not($(this)).removeAttr("checked");
|
||||
}else{
|
||||
$(".view-page .content #categories_list input[type=checkbox].checkbox-all").removeAttr("checked");
|
||||
}
|
||||
})
|
||||
|
||||
sidePanel.on("click","#enable-menu .main-enable-parent",function(e){
|
||||
if(!$(this).is(":checked")){
|
||||
$(this).parent().parent().find(".main-enable-child").removeAttr("checked");
|
||||
}
|
||||
})
|
||||
|
||||
sidePanel.on("click","#enable-menu .main-enable-child",function(e){
|
||||
if(!$("input[for=checkbox_for_"+ $(this).val() +"]").is(":checked")){
|
||||
$(this).removeAttr("checked");
|
||||
}
|
||||
})
|
||||
|
||||
sidePanel.on("change","select.module_select", function(){
|
||||
var this_value = $(this).val(),
|
||||
categories_list = $("#categories_list");
|
||||
|
||||
categories_list.html("");
|
||||
if(this_value){
|
||||
$.ajax({
|
||||
url : "<%= Rails.application.routes.url_helpers.pages_get_categories_path %>",
|
||||
data : {"module" : this_value},
|
||||
type : "get",
|
||||
dataType : "json"
|
||||
}).done(function(categories){
|
||||
var controlDiv = $("<div class='controls'></div>");
|
||||
if(categories.categories.length){
|
||||
categories_list.parent().find("label.control-label").prepend("Category List :");
|
||||
var checkbox = $("<label class='checkbox'><input type='checkbox' value='all' name='page[categories][]' class='checkbox-all' /> All </label>");
|
||||
controlDiv.append(checkbox);
|
||||
}
|
||||
$.each(categories.categories,function(i,category){
|
||||
var checkbox = $("<label class='checkbox'><input type='checkbox' value='"+ category.id +"' name='page[categories][]' /> " + category.title + " </label>");
|
||||
controlDiv.append(checkbox);
|
||||
})
|
||||
categories_list.append(controlDiv);
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
i.initialize();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user