From 6252c13ec850b564f9fcec3060b9fa88b440b263 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 7 Aug 2012 12:53:49 +0530 Subject: [PATCH] added code style and mardown in todo --- erpnext/utilities/page/kb_common/kb_common.js | 2 +- erpnext/utilities/page/questions/questions.py | 2 +- erpnext/utilities/page/todo/todo.js | 6 ++++-- erpnext/utilities/page/todo/todo.py | 1 + public/css/all-app.css | 20 ++++++++++++++++++- public/css/all-web.css | 20 ++++++++++++++++++- public/js/all-app.js | 2 +- public/js/kb_common.js | 3 +-- 8 files changed, 47 insertions(+), 9 deletions(-) diff --git a/erpnext/utilities/page/kb_common/kb_common.js b/erpnext/utilities/page/kb_common/kb_common.js index a135612d7e..9d6b7e8e0b 100644 --- a/erpnext/utilities/page/kb_common/kb_common.js +++ b/erpnext/utilities/page/kb_common/kb_common.js @@ -93,7 +93,7 @@ EditableText = function(args) {
\ [edit]\ \ -

Formatted as
Formatted as
markdown
\ \ Cancel\ diff --git a/erpnext/utilities/page/questions/questions.py b/erpnext/utilities/page/questions/questions.py index bd9efc7385..7420d5f8c9 100644 --- a/erpnext/utilities/page/questions/questions.py +++ b/erpnext/utilities/page/questions/questions.py @@ -49,7 +49,7 @@ def add_question(arg): from webnotes.model.doc import Document d = Document('Question') - d.question = args['question'].title() + d.question = args['question'] d.points = 1 d.save(1) diff --git a/erpnext/utilities/page/todo/todo.js b/erpnext/utilities/page/todo/todo.js index 786e757e29..1ab8982778 100644 --- a/erpnext/utilities/page/todo/todo.js +++ b/erpnext/utilities/page/todo/todo.js @@ -89,7 +89,7 @@ erpnext.todo.ToDoItem = Class.extend({ } if(!todo.description) todo.description = ''; - todo.desc = todo.description.replace(/\n/g, "
"); + todo.desc = wn.markdown(todo.description); $(parent_list).append(repl('\
\ @@ -145,7 +145,9 @@ erpnext.todo.make_dialog = function(det) { title: 'To Do', fields: [ {fieldtype:'Date', fieldname:'date', label:'Event Date', reqd:1}, - {fieldtype:'Text', fieldname:'description', label:'Description', reqd:1}, + {fieldtype:'Text', fieldname:'description', label:'Description', + reqd:1, description:'Use markdown to \ + format content'}, {fieldtype:'Check', fieldname:'checked', label:'Completed'}, {fieldtype:'Select', fieldname:'priority', label:'Priority', reqd:1, 'options':['Medium','High','Low'].join('\n')}, {fieldtype:'Button', fieldname:'save', label:'Save'} diff --git a/erpnext/utilities/page/todo/todo.py b/erpnext/utilities/page/todo/todo.py index 1b54478eca..05c695d248 100644 --- a/erpnext/utilities/page/todo/todo.py +++ b/erpnext/utilities/page/todo/todo.py @@ -28,6 +28,7 @@ def get(arg=None): @webnotes.whitelist() def edit(arg=None): + import markdown2 args = webnotes.form_dict d = Document('ToDo', args.get('name') or None) diff --git a/public/css/all-app.css b/public/css/all-app.css index ecdbe652f9..f120a8bd73 100644 --- a/public/css/all-app.css +++ b/public/css/all-app.css @@ -1969,7 +1969,25 @@ span, div, td, input, textarea, button, select { } -pre { margin: 0px; padding: 0px; } +pre { + background-color: #F5F5F5; + border: 1px solid rgba(0, 0, 0, 0.15); + border-radius: 4px 4px 4px 4px; + display: block; + font-size: 12.025px; + line-height: 18px; + margin: 0 0 15px; + padding: 8.5px; + white-space: pre-wrap; + word-wrap: break-word; +} + +code, pre { + border-radius: 3px 3px 3px 3px; + color: #333333; + font-family: Menlo,Monaco,Consolas,"Courier New",monospace; + font-size: 12px; +} button { margin: 2px; margin-left: 0px; } diff --git a/public/css/all-web.css b/public/css/all-web.css index 332471b01b..b27a7dac47 100644 --- a/public/css/all-web.css +++ b/public/css/all-web.css @@ -1830,7 +1830,25 @@ span, div, td, input, textarea, button, select { } -pre { margin: 0px; padding: 0px; } +pre { + background-color: #F5F5F5; + border: 1px solid rgba(0, 0, 0, 0.15); + border-radius: 4px 4px 4px 4px; + display: block; + font-size: 12.025px; + line-height: 18px; + margin: 0 0 15px; + padding: 8.5px; + white-space: pre-wrap; + word-wrap: break-word; +} + +code, pre { + border-radius: 3px 3px 3px 3px; + color: #333333; + font-family: Menlo,Monaco,Consolas,"Courier New",monospace; + font-size: 12px; +} button { margin: 2px; margin-left: 0px; } diff --git a/public/js/all-app.js b/public/js/all-app.js index 6d6c820aa4..0620d3b0d6 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -1895,7 +1895,7 @@ 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;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:'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:"js/lib/tiny_mce_33/custom_content.css",oninit:function(){me.init_editor();}});this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{$(me.input).val(v);}} +_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:'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:"js/lib/tiny_mce_33/custom_content.css?q=1",oninit:function(){me.init_editor();}});this.input.set_input=function(v){if(me.editor){me.editor.setContent(v);}else{$(me.input).val(v);}} this.input.onchange=function(){me.set(me.editor.getContent());me.run_trigger();} this.get_value=function(){return me.editor.getContent();}}else{wn.require('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('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('js/lib/ace/mode-javascript.js');var JavascriptMode=require("ace/mode/javascript").Mode;me.editor.getSession().setMode(new JavascriptMode());} diff --git a/public/js/kb_common.js b/public/js/kb_common.js index d478cac368..bbd57f10e6 100644 --- a/public/js/kb_common.js +++ b/public/js/kb_common.js @@ -6,8 +6,7 @@ KBItemToolbar=function(args,kb){$.extend(this,args);var me=this;this.make=functi this.make_tags();this.setup_del();} this.make_timestamp=function(){this.line1.innerHTML=repl('By %(name)s | %(when)s',{name:wn.utils.full_name(this.det.first_name,this.det.last_name),when:wn.datetime.comment_when(this.det.modified)});if(has_common(user_roles,['Administrator','System Manager'])){this.line1.innerHTML+=' | delete';}} -this.make_answers=function(){if(this.doctype=='Question') -this.line1.innerHTML+=' | '+this.det.answers+' answers'} +this.make_answers=function(){if(this.doctype=='Question'){if(this.det.answers==0){this.line1.innerHTML+=' | no answers';}else if(this.det.answers==1){this.line1.innerHTML+=' | 1 answer';}else{this.line1.innerHTML+=' | '+this.det.answers+' answers';}}} this.make_tags=function(){this.line1.innerHTML+=' | ' this.tags_area=$a(this.line1,'span','kb-tags') this.tags=new TagList(this.tags_area,this.det._user_tags&&(this.det._user_tags.split(',')),this.doctype,this.det.name,0,kb.set_tag_filter)}