{% macro modal_ace_edit_head(acedata) %} {% endmacro %} {% macro modal_ace_edit_button(acedate) %} {{ acedate["buttontext"] }} {% endmacro %} {% macro modal_ace_edit_body(acedate) %}
{% endmacro %} {% macro modal_ace_edit_jsfooter(acedata) %} {% for acekey in acedata %} var {{ acedata[acekey]["editorvar"] }} = ace.edit("{{ acedata[acekey]["textidstring"] }}"); //$(document).ready( function() { {{ acedata[acekey]["editorvar"] }}.setValue($("#{{ acedata[acekey]["contentid"] }}").val(),1); {{ acedata[acekey]["varstring"] }}={{ acedata[acekey]["editorvar"] }}.getValue(); //}); {{ acedata[acekey]["editorvar"] }}.setTheme({{ acedata[acekey]["textidstring"] }}currenttheme); {{ acedata[acekey]["editorvar"] }}.getSession().setMode("ace/mode/yaml"); {{ acedata[acekey]["editorvar"] }}.getSession().setTabSize(2); {{ acedata[acekey]["editorvar"] }}.getSession().setUseSoftTabs(true); {{ acedata[acekey]["editorvar"] }}.resize(true); {{ acedata[acekey]["editorvar"] }}.setShowPrintMargin(false); //editor.scrollToLine(300, true, true, function () {}); //editor.gotoLine(300, 10, true); //editor.getSession().foldAll(0,100); //window.setTimeout(function() { editor.getSession().foldAll();editor.getSession().unfold(2000,3000); }, 100); $("#{{ acedata[acekey]["textidstring"] }}undo").click(function(){ {{ acedata[acekey]["editorvar"] }}.undo();{{ acedata[acekey]["editorvar"] }}.focus();}); $("#{{ acedata[acekey]["textidstring"] }}redo").click(function(){ {{ acedata[acekey]["editorvar"] }}.redo();{{ acedata[acekey]["editorvar"] }}.focus();}); $("#{{ acedata[acekey]["textidstring"] }}expand").click(function(){ {{ acedata[acekey]["editorvar"] }}.getSession().unfold();{{ acedata[acekey]["editorvar"] }}.focus();}); $("#{{ acedata[acekey]["textidstring"] }}collapse").click(function(){ {{ acedata[acekey]["editorvar"] }}.getSession().foldAll();{{ acedata[acekey]["editorvar"] }}.focus();}); //$("#yamleditslpitview").click(function(){editor.getSession().setSplits(2);}); $("#{{ acedata[acekey]["textidstring"] }}zoomin").click(function(){ {{ acedata[acekey]["textidstring"] }}fontsize++;document.getElementById('{{ acedata[acekey]["textidstring"] }}').style.fontSize={{ acedata[acekey]["textidstring"] }}fontsize+'px';{{ acedata[acekey]["editorvar"] }}.focus();}); $("#{{ acedata[acekey]["textidstring"] }}zoomout").click(function(){ {{ acedata[acekey]["textidstring"] }}fontsize--;document.getElementById('{{ acedata[acekey]["textidstring"] }}').style.fontSize={{ acedata[acekey]["textidstring"] }}fontsize+'px';{{ acedata[acekey]["editorvar"] }}.focus();}); $("#{{ acedata[acekey]["textidstring"] }}-optioninvisibles").click(function(){ {{ acedata[acekey]["editorvar"] }}.setShowInvisibles(! {{ acedata[acekey]["editorvar"] }}.getShowInvisibles()); updateaceoption{{ acedata[acekey]["textidstring"] }}(); }); $("#{{ acedata[acekey]["textidstring"] }}-optionintendguides").click(function(){ {{ acedata[acekey]["editorvar"] }}.setDisplayIndentGuides(! {{ acedata[acekey]["editorvar"] }}.getDisplayIndentGuides()); updateaceoption{{ acedata[acekey]["textidstring"] }}(); }); $("#{{ acedata[acekey]["textidstring"] }}-optiongutter").click(function(){ {{ acedata[acekey]["editorvar"] }}.renderer.setShowGutter(! {{ acedata[acekey]["editorvar"] }}.renderer.getShowGutter()); updateaceoption{{ acedata[acekey]["textidstring"] }}(); }); $("#{{ acedata[acekey]["textidstring"] }}-optionwrapoff").click(function(){ {{ acedata[acekey]["editorvar"] }}.setOption("wrap", "off"); updateaceoption{{ acedata[acekey]["textidstring"] }}(); }); $("#{{ acedata[acekey]["textidstring"] }}-optionwrapfree").click(function(){ {{ acedata[acekey]["editorvar"] }}.setOption("wrap", "free"); updateaceoption{{ acedata[acekey]["textidstring"] }}(); }); $(".{{ acedata[acekey]["textidstring"] }}-optionwrapNUM").click(function(x){ {{ acedata[acekey]["editorvar"] }}.setOption("wrap", parseInt($(x.target).text().replace(new RegExp("[^0-9]", "g"), ""))); updateaceoption{{ acedata[acekey]["textidstring"] }}();}); $(".{{ acedata[acekey]["textidstring"] }}-optionsettheme").click(function(x){ {{ acedata[acekey]["textidstring"] }}currenttheme="ace/theme/"+$(x.target).text().trim() {{ acedata[acekey]["editorvar"] }}.setTheme({{ acedata[acekey]["textidstring"] }}currenttheme); updateaceoption{{ acedata[acekey]["textidstring"] }}();}); $(".{{ acedata[acekey]["textidstring"] }}-optionsettheme").hover(function(x){ {{ acedata[acekey]["editorvar"] }}.setTheme("ace/theme/"+$(x.target).text().trim());},function(x){ {{ acedata[acekey]["editorvar"] }}.setTheme({{ acedata[acekey]["textidstring"] }}currenttheme);}); function updateaceoption{{ acedata[acekey]["textidstring"] }}(){ if ({{ acedata[acekey]["editorvar"] }}.getShowInvisibles()){$("#{{ acedata[acekey]["textidstring"] }}-optioninvisibles span").removeClass("hidden");}else{$("#{{ acedata[acekey]["textidstring"] }}-optioninvisibles span").addClass("hidden");} if ({{ acedata[acekey]["editorvar"] }}.getDisplayIndentGuides()){$("#{{ acedata[acekey]["textidstring"] }}-optionintendguides span").removeClass("hidden");}else{$("#{{ acedata[acekey]["textidstring"] }}-optionintendguides span").addClass("hidden");} if ({{ acedata[acekey]["editorvar"] }}.renderer.getShowGutter()){$("#{{ acedata[acekey]["textidstring"] }}-optiongutter span").removeClass("hidden");}else{$("#{{ acedata[acekey]["textidstring"] }}-optiongutter span").addClass("hidden");} if ({{ acedata[acekey]["editorvar"] }}.getOption("wrap")=="off"){$("#{{ acedata[acekey]["textidstring"] }}-optionwrapoff span").removeClass("hidden");}else{$("#{{ acedata[acekey]["textidstring"] }}-optionwrapoff span").addClass("hidden");} if ({{ acedata[acekey]["editorvar"] }}.getOption("wrap")=="free"){$("#{{ acedata[acekey]["textidstring"] }}-optionwrapfree span").removeClass("hidden");}else{$("#{{ acedata[acekey]["textidstring"] }}-optionwrapfree span").addClass("hidden");} $( ".{{ acedata[acekey]["textidstring"] }}-optionwrapNUM" ).each(function(i, obj) { if ({{ acedata[acekey]["editorvar"] }}.getOption("wrap")==parseInt($(obj).text().replace(new RegExp("[^0-9]", "g"), ""))) {$(obj).find("span").removeClass("hidden"); }else{$(obj).find("span").addClass("hidden");} }); } updateaceoption{{ acedata[acekey]["textidstring"] }}(); $("#{{ acedata[acekey]["textidstring"] }}save").click(function(){ {{ acedata[acekey]["varstring"] }}={{ acedata[acekey]["editorvar"] }}.getValue(); {{ acedata[acekey]["editorvar"] }}.focus(); $("body").trigger("ace-{{ acedata[acekey]["textidstring"] }}-post-save"); }); $("#{{ acedata[acekey]["textidstring"] }}reset").click(function(){ tmpline={{ acedata[acekey]["editorvar"] }}.selection.getCursor().row; tmpcol={{ acedata[acekey]["editorvar"] }}.selection.getCursor().column; {{ acedata[acekey]["editorvar"] }}.setValue({{ acedata[acekey]["varstring"] }},1);{{ acedata[acekey]["editorvar"] }}.gotoLine(tmpline+1,tmpcol);{{ acedata[acekey]["editorvar"] }}.scrollToLine(tmpline+1, true, true, function () {});{{ acedata[acekey]["editorvar"] }}.focus();}); {% endfor %} function resizeAce() { var h = window.innerHeight; if (h > 360) { {% for acekey in acedata %} $('#{{ acedata[acekey]["textidstring"] }}').css('height', (h - 300).toString() + 'px'); {% endfor %} } }; $(window).on('resize', function () { resizeAce(); }); resizeAce(); {% endmacro %}