$(document).ready(function() { var bindBehaviors = function(scope) { bindOverlay(); $(".content_edit").hover( function() { $(".hover_edit").removeClass("hover_edit"); $(this).addClass("hover_edit"); var useMenu = "myMenu"; $(this).contextMenu({ menu:useMenu }, function(action, el, pos) { if(action == "edit") { var content_type = $(el).attr("rel"); var content_id = $(el).attr("id"); var col_id = $(el).attr("column"); showOverlay("content", content_type, content_id, col_id); } if(action == "logout") { $.get("/manage/logout", {}, function() { location.href=window.location.href; }); } if(action == "edit_page") { var content_id = $(el).attr("page_id"); showOverlay("page", content_id); } if(action == "edit_collections") { var content_id = $(el).attr("page_id"); showOverlay("collections", content_id); } if(action == "reorder_collections") { var content_id = $(el).attr("page_id"); showOverlay("reorder_collections", content_id); } if(action == "add_callout") { showOverlay("add_callout"); } } ); }, function () { $(".hover_edit").removeClass("hover_edit"); $(this).destroyContextMenu(); } ); } function bindOverlay(){ $("#mid-wrap, #dimmer, #close-editor").click(function(event){ if(event.target==this){ closeOverlay(); return false; } }); } function showOverlay(t,action,id,col_id){ $("#dimmer").addClass("dim").fadeTo(1,0.5).show(); $("#overlay-box").addClass("show-box").show(); $('#overlay-return').html("Loading..."); if(t == "content") { if(action != null && id != null) { $.post("/manage/edit_content_block.php",{ type:action, id: id, col:col_id },function(data){ $('#overlay-return').html(data); runMCEInit(); bindOverlay(); }); } } else if(t == "page") { if(action != null) { $.post("/manage/edit_page.php", {id:action,col:id}, function(data){ $('#overlay-return').html(data); bindOverlay(); }); } } else if(t == "collections") { if(action != null) { $.post("/manage/manage_collections.php", {id:action}, function(data){ $('#overlay-return').html(data); bindOverlay(); }); } } else if(t == "reorder_collections") { if(action != null) { $.post("/manage/reorder_callouts.php", {id:action}, function(data){ $('#overlay-return').html(data); bindOverlay(); }); } } else if(t == "add_callout") { if(action == null && id == null) { $.post("/manage/add_callout.php", {}, function(data){ $('#overlay-return').html(data); bindOverlay(); }); } } } function closeOverlay(){ $("#dimmer, #overlay-box").hide(); } bindBehaviors(); fontResizer('9px','11px','13px'); });