Commit bc12cb2f authored by Sebastien Robin's avatar Sebastien Robin

erp5_ace_editor: allow to have different modes, use python by default to keep compatibility

parent 915ee2fb
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># For backward compatibility, make sure to use python as default mode\n
mode = "python"\n
portal_type = context.getPortalType()\n
if portal_type == "Web Page":\n
mode = "html"\n
elif portal_type == "Web Script":\n
mode = "javascript"\n
elif portal_type == "Web Style":\n
mode = "css"\n
return mode\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getAceEditorMode</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
<tal:block tal:define=\'site_root python: here.getWebSiteValue() or here.getPortalObject();\n <tal:block tal:define=\'site_root python: here.getWebSiteValue() or here.getPortalObject();\n
portal_url python: site_root.absolute_url();\n portal_url python: site_root.absolute_url();\n
div_id string:${id}_ace;\n div_id string:${id}_ace;\n
mode python: here.Base_getAceEditorMode();\n
container_div_id string:${div_id}_container;\n container_div_id string:${div_id}_container;\n
\'>\n \'>\n
<style type="text/css">\n <style type="text/css">\n
...@@ -173,7 +174,7 @@ ...@@ -173,7 +174,7 @@
<script type="text/javascript"\n <script type="text/javascript"\n
tal:attributes="src string:${portal_url}/ace/ace.js"></script>\n tal:attributes="src string:${portal_url}/ace/ace.js"></script>\n
<script type="text/javascript"\n <script type="text/javascript"\n
tal:attributes="src string:${portal_url}/ace/mode-python.js"></script>\n tal:attributes="src string:${portal_url}/ace/mode-${mode}.js"></script>\n
<script type="text/javascript"\n <script type="text/javascript"\n
tal:attributes="src string:${portal_url}/ace/ext-settings_menu.js"></script>\n tal:attributes="src string:${portal_url}/ace/ext-settings_menu.js"></script>\n
<script type="text/javascript"\n <script type="text/javascript"\n
...@@ -185,6 +186,7 @@ ...@@ -185,6 +186,7 @@
tal:content="structure string:\n tal:content="structure string:\n
ace_editor_container_div = null;\n ace_editor_container_div = null;\n
ace_editor = null;\n ace_editor = null;\n
var mode = \'${mode}\';\n
\n \n
function maximizeFullscreenRemoveSaveMessage() {\n function maximizeFullscreenRemoveSaveMessage() {\n
$(\'.ace_editor_maximize_fullscreen_message\').remove();\n $(\'.ace_editor_maximize_fullscreen_message\').remove();\n
...@@ -385,7 +387,7 @@ ...@@ -385,7 +387,7 @@
$.ajax({type: \'GET\',\n $.ajax({type: \'GET\',\n
async: false,\n async: false,\n
url: \'Component_getErrorWarningMessageDictAsJson\',\n url: \'Component_getErrorWarningMessageDictAsJson\',\n
success: getErrorWarningMessageDictHandler});\n success: getErrorWarningMessageDictHandler})\n
}\n }\n
\n \n
window.onload = function() {\n window.onload = function() {\n
...@@ -410,8 +412,8 @@ ...@@ -410,8 +412,8 @@
\n \n
ace_editor.resize(true);\n ace_editor.resize(true);\n
\n \n
var PythonMode = require(\'ace/mode/python\').Mode;\n var Mode = require(\'ace/mode/\' + mode).Mode;\n
ace_editor.getSession().setMode(new PythonMode());\n ace_editor.getSession().setMode(new Mode());\n
ace_editor.getSession().setUseSoftTabs(true);\n ace_editor.getSession().setUseSoftTabs(true);\n
ace_editor.getSession().setTabSize(2);\n ace_editor.getSession().setTabSize(2);\n
\n \n
...@@ -441,13 +443,17 @@ ...@@ -441,13 +443,17 @@
}, 500);\n }, 500);\n
}\n }\n
\n \n
if (mode === \'python\') {\n
checkPythonSourceCode();\n checkPythonSourceCode();\n
}\n
\n \n
var textarea = $(\'#${id}\');\n var textarea = $(\'#${id}\');\n
ace_editor.getSession().on(\'change\', function() {\n ace_editor.getSession().on(\'change\', function() {\n
changed = true; // This is the dirty flag for onbeforeunload warning in erp5.js\n changed = true; // This is the dirty flag for onbeforeunload warning in erp5.js\n
textarea.val(ace_editor.getSession().getValue());\n textarea.val(ace_editor.getSession().getValue());\n
if (mode === \'python\') {\n
checkPythonSourceCode();\n checkPythonSourceCode();\n
}\n
});\n });\n
\n \n
/* Only display the source code saving button if the main save button is\n /* Only display the source code saving button if the main save button is\n
......
21 22
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment