added ace editor
This commit is contained in:
parent
30ab0227b3
commit
4ee56c064e
@ -37,6 +37,8 @@
|
||||
<li>JQuery UI (datepicker, sortable)</li>
|
||||
<li>TinyMCE - text editor</li>
|
||||
<li>Twitter Bootstrap</li>
|
||||
<li>Ace - code editor</li>
|
||||
<li>Slick Grid - report grid</li>
|
||||
<li>jQPlot - graphs</li>
|
||||
<li>JSON2 - JSON builder, parser</li>
|
||||
<li>JSColor - color picker</li>
|
||||
|
@ -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
|
||||
},
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
]
|
@ -170,7 +170,7 @@ var l=items.length;for(var i=0;i<l;i++){var src=items[i];wn.assets.execute(src);
|
||||
/*
|
||||
* lib/js/wn/dom.js
|
||||
*/
|
||||
wn.provide('wn.dom');wn.dom={by_id:function(id){return document.getElementById(id);},eval:function(txt){if(!txt)return;var el=document.createElement('script');el.appendChild(document.createTextNode(txt));document.getElementsByTagName('head')[0].appendChild(el);},set_style:function(txt){if(!txt)return;var se=document.createElement('style');se.type="text/css";if(se.styleSheet){se.styleSheet.cssText=txt;}else{se.appendChild(document.createTextNode(txt));}
|
||||
wn.provide('wn.dom');wn.dom={id_count:0,by_id:function(id){return document.getElementById(id);},set_unique_id:function(ele){var id='unique-'+wn.dom.id_count;ele.setAttribute('id',id);wn.dom.id_count++;return id;},eval:function(txt){if(!txt)return;var el=document.createElement('script');el.appendChild(document.createTextNode(txt));document.getElementsByTagName('head')[0].appendChild(el);},set_style:function(txt){if(!txt)return;var se=document.createElement('style');se.type="text/css";if(se.styleSheet){se.styleSheet.cssText=txt;}else{se.appendChild(document.createTextNode(txt));}
|
||||
document.getElementsByTagName('head')[0].appendChild(se);},add:function(parent,newtag,className,cs,innerHTML,onclick){if(parent&&parent.substr)parent=wn.dom.by_id(parent);var c=document.createElement(newtag);if(parent)
|
||||
parent.appendChild(c);if(className){if(newtag.toLowerCase()=='img')
|
||||
c.src=className
|
||||
@ -639,7 +639,6 @@ var time_to_ampm=wn.datetime.time_to_ampm;var time_to_hhmm=wn.datetime.time_to_h
|
||||
/*
|
||||
* lib/js/legacy/utils/dom.js
|
||||
*/
|
||||
wn.dom.set_unique_id=function(ele){var id='unique-'+wn.dom.id_count;ele.setAttribute('id',id);wn.dom.id_count++;return id;}
|
||||
wn.tinymce={add_simple:function(ele,height){if(ele.myid){tinyMCE.execCommand('mceAddControl',true,ele.myid);return;}
|
||||
ele.myid=wn.dom.set_unique_id(ele);$(ele).tinymce({script_url:'lib/js/lib/tiny_mce_33/tiny_mce.js',height:height?height:'200px',theme:"advanced",theme_advanced_buttons1:"bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,link,unlink,forecolor,backcolor,code,",theme_advanced_buttons2:"",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_path:false,theme_advanced_resizing:false});},remove:function(ele){tinyMCE.execCommand('mceRemoveControl',true,ele.myid);},get_value:function(ele){return tinymce.get(ele.myid).getContent();}}
|
||||
wn.ele={link:function(args){var span=$a(args.parent,'span','link_type',args.style);span.loading_img=$a(args.parent,'img','',{margin:'0px 4px -2px 4px',display:'none'});span.loading_img.src='lib/images/ui/button-load.gif';span.innerHTML=args.label;span.user_onclick=args.onclick;span.onclick=function(){if(!this.disabled)this.user_onclick(this);}
|
||||
@ -1882,11 +1881,15 @@ if(cur_frm.editable&&cur_frm.doc.docstatus>0){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='<textarea class="code_text" readonly=1>'+val+'</textarea>';}}
|
||||
|
@ -57,7 +57,7 @@ var l=items.length;for(var i=0;i<l;i++){var src=items[i];wn.assets.execute(src);
|
||||
/*
|
||||
* lib/js/wn/dom.js
|
||||
*/
|
||||
wn.provide('wn.dom');wn.dom={by_id:function(id){return document.getElementById(id);},eval:function(txt){if(!txt)return;var el=document.createElement('script');el.appendChild(document.createTextNode(txt));document.getElementsByTagName('head')[0].appendChild(el);},set_style:function(txt){if(!txt)return;var se=document.createElement('style');se.type="text/css";if(se.styleSheet){se.styleSheet.cssText=txt;}else{se.appendChild(document.createTextNode(txt));}
|
||||
wn.provide('wn.dom');wn.dom={id_count:0,by_id:function(id){return document.getElementById(id);},set_unique_id:function(ele){var id='unique-'+wn.dom.id_count;ele.setAttribute('id',id);wn.dom.id_count++;return id;},eval:function(txt){if(!txt)return;var el=document.createElement('script');el.appendChild(document.createTextNode(txt));document.getElementsByTagName('head')[0].appendChild(el);},set_style:function(txt){if(!txt)return;var se=document.createElement('style');se.type="text/css";if(se.styleSheet){se.styleSheet.cssText=txt;}else{se.appendChild(document.createTextNode(txt));}
|
||||
document.getElementsByTagName('head')[0].appendChild(se);},add:function(parent,newtag,className,cs,innerHTML,onclick){if(parent&&parent.substr)parent=wn.dom.by_id(parent);var c=document.createElement(newtag);if(parent)
|
||||
parent.appendChild(c);if(className){if(newtag.toLowerCase()=='img')
|
||||
c.src=className
|
||||
@ -526,7 +526,6 @@ var time_to_ampm=wn.datetime.time_to_ampm;var time_to_hhmm=wn.datetime.time_to_h
|
||||
/*
|
||||
* lib/js/legacy/utils/dom.js
|
||||
*/
|
||||
wn.dom.set_unique_id=function(ele){var id='unique-'+wn.dom.id_count;ele.setAttribute('id',id);wn.dom.id_count++;return id;}
|
||||
wn.tinymce={add_simple:function(ele,height){if(ele.myid){tinyMCE.execCommand('mceAddControl',true,ele.myid);return;}
|
||||
ele.myid=wn.dom.set_unique_id(ele);$(ele).tinymce({script_url:'lib/js/lib/tiny_mce_33/tiny_mce.js',height:height?height:'200px',theme:"advanced",theme_advanced_buttons1:"bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,link,unlink,forecolor,backcolor,code,",theme_advanced_buttons2:"",theme_advanced_buttons3:"",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_path:false,theme_advanced_resizing:false});},remove:function(ele){tinyMCE.execCommand('mceRemoveControl',true,ele.myid);},get_value:function(ele){return tinymce.get(ele.myid).getContent();}}
|
||||
wn.ele={link:function(args){var span=$a(args.parent,'span','link_type',args.style);span.loading_img=$a(args.parent,'img','',{margin:'0px 4px -2px 4px',display:'none'});span.loading_img.src='lib/images/ui/button-load.gif';span.innerHTML=args.label;span.user_onclick=args.onclick;span.onclick=function(){if(!this.disabled)this.user_onclick(this);}
|
||||
|
Loading…
x
Reference in New Issue
Block a user