From 4ee56c064ed1d57e452c495ab90816742520cb30 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 2 May 2012 15:30:15 +0530 Subject: [PATCH] added ace editor --- .../home/page/attributions/attributions.html | 2 ++ erpnext/website/doctype/web_page/web_page.txt | 9 +++++++-- .../website_settings/website_settings.txt | 3 ++- js/all-app.js | 17 ++++++++++------- js/all-web.js | 3 +-- 5 files changed, 22 insertions(+), 12 deletions(-) diff --git a/erpnext/home/page/attributions/attributions.html b/erpnext/home/page/attributions/attributions.html index 72703c85e6..f76c248dd9 100644 --- a/erpnext/home/page/attributions/attributions.html +++ b/erpnext/home/page/attributions/attributions.html @@ -37,6 +37,8 @@
  • JQuery UI (datepicker, sortable)
  • TinyMCE - text editor
  • Twitter Bootstrap
  • +
  • Ace - code editor
  • +
  • Slick Grid - report grid
  • jQPlot - graphs
  • JSON2 - JSON builder, parser
  • JSColor - color picker
  • diff --git a/erpnext/website/doctype/web_page/web_page.txt b/erpnext/website/doctype/web_page/web_page.txt index f5d128005d..c40caff7de 100644 --- a/erpnext/website/doctype/web_page/web_page.txt +++ b/erpnext/website/doctype/web_page/web_page.txt @@ -5,7 +5,7 @@ { 'creation': '2012-04-02 16:02:43', 'docstatus': 0, - 'modified': '2012-04-28 10:03:45', + 'modified': '2012-05-02 15:24:31', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -22,7 +22,7 @@ 'name': '__common__', 'section_style': u'Simple', 'show_in_menu': 0, - 'version': 17 + 'version': 1 }, # These values are common for all DocField @@ -124,6 +124,7 @@ 'fieldname': u'head_section', 'fieldtype': u'Text', 'label': u'Head Section', + 'options': u'Markdown', 'permlevel': 0 }, @@ -135,6 +136,7 @@ 'fieldname': u'main_section', 'fieldtype': u'Code', 'label': u'Main Section', + 'options': u'Markdown', 'permlevel': 0 }, @@ -146,6 +148,7 @@ 'fieldname': u'side_section', 'fieldtype': u'Code', 'label': u'Side Section', + 'options': u'Markdown', 'permlevel': 0 }, @@ -186,6 +189,7 @@ 'fieldname': u'javascript', 'fieldtype': u'Code', 'label': u'Javascript', + 'options': u'Javascript', 'permlevel': 0 }, @@ -204,6 +208,7 @@ 'fieldname': u'css', 'fieldtype': u'Code', 'label': u'CSS', + 'options': u'CSS', 'permlevel': 0 }, diff --git a/erpnext/website/doctype/website_settings/website_settings.txt b/erpnext/website/doctype/website_settings/website_settings.txt index 71093dd180..cf109cfdc8 100644 --- a/erpnext/website/doctype/website_settings/website_settings.txt +++ b/erpnext/website/doctype/website_settings/website_settings.txt @@ -5,7 +5,7 @@ { 'creation': '2012-04-02 16:38:02', 'docstatus': 0, - 'modified': '2012-04-30 14:20:56', + 'modified': '2012-05-02 15:24:12', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -237,6 +237,7 @@ 'fieldname': u'startup_code', 'fieldtype': u'Code', 'label': u'Startup Code', + 'options': u'Javascript', 'permlevel': 0 } ] \ No newline at end of file diff --git a/js/all-app.js b/js/all-app.js index 74ffb18cb5..97c023e808 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -170,7 +170,7 @@ var l=items.length;for(var i=0;i0){if(this.df.allow_on_submit&&cur_fr if(this.df['default'].toLowerCase()=='no add rows'){this.grid.can_add_rows=false;}} if(st=='Write'){this.grid.show();}else if(st=='Read'){this.grid.show();}else{this.grid.hide();} this.grid.refresh();} -_f.TableField.prototype.set=function(v){};_f.TableField.prototype.set_input=function(v){};_f.CodeField=function(){};_f.CodeField.prototype=new Field();_f.CodeField.prototype.make_input=function(){var me=this;this.label_span.innerHTML=this.df.label;this.input=$a(this.input_area,'textarea','code_text',{fontSize:'12px'});this.myid=wn.dom.set_unique_id(this.input);this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{me.input.value=v;me.input.innerHTML=v;}} -this.input.onchange=function(){if(me.editor){}else{me.set(me.input.value);} -me.run_trigger();} -this.get_value=function(){if(me.editor){return me.editor.getContent();}else{return this.input.value;}} -if(this.df.fieldtype=='Text Editor'){$(me.input).tinymce({script_url:'lib/js/lib/tiny_mce_33/tiny_mce.js',theme:"advanced",plugins:"style,inlinepopups,table",extended_valid_elements:"div[id|dir|class|align|style]",width:'100%',height:'360px',theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",content_css:"lib/js/lib/tiny_mce_33/custom_content.css",oninit:function(){me.init_editor();}});}else{$y(me.input,{fontFamily:'Courier, Fixed'});}} +_f.TableField.prototype.set=function(v){};_f.TableField.prototype.set_input=function(v){};_f.CodeField=function(){};_f.CodeField.prototype=new Field();_f.CodeField.prototype.make_input=function(){var me=this;this.label_span.innerHTML=this.df.label;if(this.df.fieldtype=='Text Editor'){this.input=$a(this.input_area,'text_area','',{fontSize:'12px'});this.myid=wn.dom.set_unique_id(this.input);$(me.input).tinymce({script_url:'lib/js/lib/tiny_mce_33/tiny_mce.js',theme:"advanced",plugins:"style,inlinepopups,table",extended_valid_elements:"div[id|dir|class|align|style]",width:'100%',height:'360px',theme_advanced_buttons1:"bold,italic,underline,strikethrough,hr,|,justifyleft,justifycenter,justifyright,|,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,code,|,forecolor,backcolor,|,tablecontrols",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",content_css:"lib/js/lib/tiny_mce_33/custom_content.css",oninit:function(){me.init_editor();}});this.input.set_input=function(v){me.editor.setContent(v);} +this.input.onchange=function(){me.set(me.editor.getContent());me.run_trigger();} +this.get_value=function(){return me.editor.getContent();}}else{wn.require('lib/js/lib/ace/ace.js');$(this.input_area).css('border','1px solid #aaa');this.pre=$a(this.input_area,'pre','',{position:'relative',height:'400px',width:'100%'});this.input={};this.myid=wn.dom.set_unique_id(this.pre);this.editor=ace.edit(this.myid);if(me.df.options=='Markdown'||me.df.options=='HTML'){wn.require('lib/js/lib/ace/mode-html.js');var HTMLMode=require("ace/mode/html").Mode;me.editor.getSession().setMode(new HTMLMode());} +else if(me.df.options=='Javascript'){wn.require('lib/js/lib/ace/mode-javascript.js');var JavascriptMode=require("ace/mode/javascript").Mode;me.editor.getSession().setMode(new JavascriptMode());} +else if(me.df.options=='Python'){wn.require('lib/js/lib/ace/mode-python.js');var PythonMode=require("ace/mode/python").Mode;me.editor.getSession().setMode(new PythonMode());} +this.input.set_input=function(v){me.editor.getSession().setValue(v);} +this.input.onchange=function(){me.set(me.get_value());me.run_trigger();} +this.get_value=function(){return me.editor.getSession().getValue();} +$(this.wrapper).bind('refresh',function(){me.editor.resize();});$(cur_frm.wrapper).bind('render_complete',function(){me.editor.resize();});}} _f.CodeField.prototype.init_editor=function(){var me=this;this.editor=tinymce.get(this.myid);this.editor.onKeyUp.add(function(ed,e){me.set(ed.getContent());});this.editor.onPaste.add(function(ed,e){me.set(ed.getContent());});this.editor.onSetContent.add(function(ed,e){me.set(ed.getContent());});var c=locals[cur_frm.doctype][cur_frm.docname][this.df.fieldname];if(cur_frm&&c){this.editor.setContent(c);}} _f.CodeField.prototype.set_disp=function(val){$y(this.disp_area,{width:'90%'}) if(this.df.fieldtype=='Text Editor'){this.disp_area.innerHTML=val;}else{this.disp_area.innerHTML='';}} diff --git a/js/all-web.js b/js/all-web.js index 6dd52b3bd4..7ea4012597 100644 --- a/js/all-web.js +++ b/js/all-web.js @@ -57,7 +57,7 @@ var l=items.length;for(var i=0;i