added code style and mardown in todo

This commit is contained in:
Rushabh Mehta 2012-08-07 12:53:49 +05:30
parent e6ecb06001
commit 6252c13ec8
8 changed files with 47 additions and 9 deletions

View File

@ -93,7 +93,7 @@ EditableText = function(args) {
<div class="ed-text-display %(disp_class)s"></div>\ <div class="ed-text-display %(disp_class)s"></div>\
<a class="ed-text-edit" style="cursor: pointer; float: right; margin-top: -16px;">[edit]</a>\ <a class="ed-text-edit" style="cursor: pointer; float: right; margin-top: -16px;">[edit]</a>\
<textarea class="ed-text-input %(inp_class)s hide"></textarea>\ <textarea class="ed-text-input %(inp_class)s hide"></textarea>\
<div class="help hide"><br>Formatted as <a href="http://en.wikipedia.org/wiki/Markdown#Syntax_examples"\ <div class="help hide"><br>Formatted as <a href="#markdown-reference"\
target="_blank">markdown</a></div>\ target="_blank">markdown</a></div>\
<button class="btn btn-small btn-info hide ed-text-save">Save</button>\ <button class="btn btn-small btn-info hide ed-text-save">Save</button>\
<a class="ed-text-cancel hide" style="cursor: pointer;">Cancel</a>\ <a class="ed-text-cancel hide" style="cursor: pointer;">Cancel</a>\

View File

@ -49,7 +49,7 @@ def add_question(arg):
from webnotes.model.doc import Document from webnotes.model.doc import Document
d = Document('Question') d = Document('Question')
d.question = args['question'].title() d.question = args['question']
d.points = 1 d.points = 1
d.save(1) d.save(1)

View File

@ -89,7 +89,7 @@ erpnext.todo.ToDoItem = Class.extend({
} }
if(!todo.description) todo.description = ''; if(!todo.description) todo.description = '';
todo.desc = todo.description.replace(/\n/g, "<br>"); todo.desc = wn.markdown(todo.description);
$(parent_list).append(repl('\ $(parent_list).append(repl('\
<div class="todoitem">\ <div class="todoitem">\
@ -145,7 +145,9 @@ erpnext.todo.make_dialog = function(det) {
title: 'To Do', title: 'To Do',
fields: [ fields: [
{fieldtype:'Date', fieldname:'date', label:'Event Date', reqd:1}, {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 <a href="#markdown-reference">markdown</a> to \
format content'},
{fieldtype:'Check', fieldname:'checked', label:'Completed'}, {fieldtype:'Check', fieldname:'checked', label:'Completed'},
{fieldtype:'Select', fieldname:'priority', label:'Priority', reqd:1, 'options':['Medium','High','Low'].join('\n')}, {fieldtype:'Select', fieldname:'priority', label:'Priority', reqd:1, 'options':['Medium','High','Low'].join('\n')},
{fieldtype:'Button', fieldname:'save', label:'Save'} {fieldtype:'Button', fieldname:'save', label:'Save'}

View File

@ -28,6 +28,7 @@ def get(arg=None):
@webnotes.whitelist() @webnotes.whitelist()
def edit(arg=None): def edit(arg=None):
import markdown2
args = webnotes.form_dict args = webnotes.form_dict
d = Document('ToDo', args.get('name') or None) d = Document('ToDo', args.get('name') or None)

View File

@ -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; } button { margin: 2px; margin-left: 0px; }

View File

@ -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; } button { margin: 2px; margin-left: 0px; }

View File

@ -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(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();} if(st=='Write'){this.grid.show();}else if(st=='Read'){this.grid.show();}else{this.grid.hide();}
this.grid.refresh();} 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.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());} 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());} 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());}

View File

@ -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_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+=' | <a style="cursor:pointer;"\ 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+=' | <a style="cursor:pointer;"\
class="del-link">delete</a>';}} class="del-link">delete</a>';}}
this.make_answers=function(){if(this.doctype=='Question') 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.line1.innerHTML+=' | '+this.det.answers+' answers'}
this.make_tags=function(){this.line1.innerHTML+=' | ' this.make_tags=function(){this.line1.innerHTML+=' | '
this.tags_area=$a(this.line1,'span','kb-tags') 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)} 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)}