Created
November 20, 2013 04:46
-
-
Save jaseclamp/7557878 to your computer and use it in GitHub Desktop.
Updated mx_cloner for expressionengine to work with zenbu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function set_sections() | |
{ | |
$EE =& get_instance(); | |
$out = '<script type="text/javascript" charset="utf-8">$("#accessoryTabs a.mx_cloner").parent().remove();'; | |
//changed this line to activate cloner with zenbu | |
if ($EE->input->get('module') == 'zenbu' && $EE->input->get('M') == 'show_module_cp' && $EE->input->get('C') == 'addons_modules') { | |
$out .=' | |
//changed selector to ensure cloner link is shown on rows in entries table | |
$("table.resultTable tbody tr").live("mouseenter", function() { | |
_prev = $(this).children("td:nth-child(2)").html(); | |
_prev_id = $(this).children("td:nth-child(2)"); | |
_href = $(this).children("td:nth-child(2)").next().children("a:first").attr("href")+"&clone=y&use_autosave=n"; | |
_clone_link = " <a onclick=\'javascript:mx_cloner(\""+_href+"\");\' class=\'clone_btn\' style=\‘position: absolute; margin-top: -6px;\’><img src=\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAALCAMAAACecocUAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG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QNOLltGEQYWPjVRRjYdGVMGawYGRU4VBnZze1FGQwFBJS5RTg55fiVmbQFjQzVzJhBgJWBpABXEwgYABmWzOAABtEXJORkdFKACDAAMyMDeP1g+KEAAAAAElFTkSuQmCC\' style=\'cursor:hand;cursor: pointer;padding:0px;margin:0px\' alt=\'Clone it\' title=\'Clone it\'></a>"; | |
$(this).children("td:nth-child(2)").html(_clone_link); | |
}); | |
function mx_cloner(link){ | |
location.href= link; | |
return true; | |
} | |
//changed this also to ensure the cloner link is removed on mouse leave when using zenbu | |
$("table.resultTable tbody tr").live("mouseleave", function() { | |
$(_prev_id).html(_prev); | |
}); | |
'; | |
}; | |
$EE->lang->loadfile('mx_cloner'); | |
if ($EE->input->get('clone') == 'y') { | |
$out .= '$("input[name=\'entry_id\']").val(""); | |
EE.publish.which="new"; | |
$(".contents .heading").html("<h2>" + "'.$EE->lang->line('clone_entry').'" + "</h2>"); | |
if (typeof EE.publish.autosave != "undefined" ) { | |
delete EE.publish.autosave; | |
}; | |
$("input[name=\'nsm_better_meta__meta[0][id]\']").val(""); | |
'; | |
}; | |
$out .= ' | |
</script>'; | |
$this->sections[] = $out; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
is it ok if I will use this code for next MX Cloner update?