From edab76b274e6a1c9844ec2ad097f7a077fdf8ab8 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 18 Apr 2012 16:55:43 +0530 Subject: [PATCH] knowledge base cleanup --- css/all-app.css | 2 - css/all-web.css | 2 - .../page/kb_common/kb_common.js | 91 ++++++++++--------- .../page/question_view/question_view.html | 21 ++--- .../page/question_view/question_view.js | 21 +++-- .../page/questions/questions.html | 4 +- .../page/questions/questions.js | 5 +- erpnext/startup/startup.css | 1 - .../doctype/about_us_settings/template.html | 13 +-- erpnext/website/doctype/blog/template.html | 8 +- .../doctype/contact_us_settings/template.html | 12 +-- .../website/doctype/web_page/template.html | 15 +-- erpnext/website/page/blog/blog.html | 10 +- erpnext/website/page/blog/blog.js | 2 +- js/all-app.js | 6 +- js/all-web.js | 6 +- 16 files changed, 110 insertions(+), 109 deletions(-) diff --git a/css/all-app.css b/css/all-app.css index d267c9b789..c42f3706eb 100644 --- a/css/all-app.css +++ b/css/all-app.css @@ -1735,7 +1735,6 @@ body { h1, h2, h3, h4, h5 { font-family: "Helvetica Neue", Helvetica, "Helvetica Neue", sans-serif; - font-weight: normal; margin-top: 0.2em; } @@ -3571,7 +3570,6 @@ div.appframe-toolbar { */ h1, h2, h3, h4, h5 { font-family: "Helvetica Neue", "Open Sans", Helvetica, sans-serif; - font-weight: normal; margin-top: 0.2em; } diff --git a/css/all-web.css b/css/all-web.css index c16a8e8e9b..416e9022e0 100644 --- a/css/all-web.css +++ b/css/all-web.css @@ -1215,7 +1215,6 @@ body { h1, h2, h3, h4, h5 { font-family: "Helvetica Neue", Helvetica, "Helvetica Neue", sans-serif; - font-weight: normal; margin-top: 0.2em; } @@ -1888,7 +1887,6 @@ div.appframe-toolbar { */ h1, h2, h3, h4, h5 { font-family: "Helvetica Neue", "Open Sans", Helvetica, sans-serif; - font-weight: normal; margin-top: 0.2em; } diff --git a/erpnext/knowledge_base/page/kb_common/kb_common.js b/erpnext/knowledge_base/page/kb_common/kb_common.js index a734f65ed9..fd570ec8bd 100644 --- a/erpnext/knowledge_base/page/kb_common/kb_common.js +++ b/erpnext/knowledge_base/page/kb_common/kb_common.js @@ -116,59 +116,68 @@ EditableText = function(args) { $.extend(this, args); var me = this; - this.wrapper = $a(me.parent, 'div'); - this.display = $a(me.wrapper, 'div', me.disp_class, '', me.text); - this.input = $a(me.wrapper, 'textarea', me.inp_class, {display:'none'}); + me.$w = $(repl('
\ +
\ + [edit]\ +
\ +
Formatted as markdown
\ + \ + Cancel\ +
', args)).appendTo(me.parent); - var div = $a(me.wrapper, 'div', '', {marginTop:'5px', height:'23px'}); - - // edit text - this.edit_btn = $a(div, 'a', '', {cursor:'pointer'}, '[edit]'); - - this.edit_btn.onclick = function() { - me.input.value = me.display.innerHTML; - me.show_as_input(); + this.set_display = function(txt) { + me.$w.find('.ed-text-display').html(wn.markdown(txt)); + me.text = txt; } + this.set_display(me.text); + + if(me.height) me.$w.find('.ed-text-input').css('height', me.height); + + // edit + me.$w.find('.ed-text-edit').click(function() { + me.$w.find('.ed-text-input').val(me.text); + me.show_as_input(); + }) + // save button - save the new text - // check if text is written - this.save_btn = $btn(div, 'Save', function() { - var v = me.rich_text ? wn.tinymce.get_value(me.input) : me.input.value; - if(!v) { - msgprint('Please write something!'); - return; + me.$w.find('.ed-text-save').click( + function() { + var v = me.$w.find('.ed-text-input').val(); + // check if text is written + if(!v) { + msgprint('Please write something!'); + return; + } + var btn = this; + $(btn).set_working(); + $c_page('knowledge_base', 'question_view', 'update_item', { + dt: me.dt, dn: me.dn, fn: me.fieldname, text: v + }, + function(r) { + $(btn).done_working(); + if(r.exc) {msgprint(r.exc); return; } + me.set_display(v); + me.show_as_text(); + }); } - me.save_btn.set_working(); - $c_page('knowledge_base', 'question_view', 'update_item', { - dt: me.dt, dn: me.dn, fn: me.fieldname, text: v - }, - function(r, rt) { - me.save_btn.done_working(); - if(r.exc) {msgprint(r.exc); return; } - me.display.innerHTML = v; - me.show_as_text(); - }); - }, {display: 'none'}); + ) + // cancel button - this.cancel_btn = $a(div, 'span', 'link_type', {color: '#555', display:'none'}, 'Cancel', {marginLeft:'7px'}); - this.cancel_btn.onclick = function() { + me.$w.find('.ed-text-cancel').click(function() { me.show_as_text(); - } + }) this.show_as_text = function() { - $ds(me.display); $ds(me.edit_btn); - if(me.rich_text) - wn.tinymce.remove(me.input); - $dh(me.input); $dh(me.save_btn); $dh(me.cancel_btn); - + me.$w.find('.ed-text-display, .ed-text-edit').toggle(true); + me.$w.find('.ed-text-input, .ed-text-save, .ed-text-cancel, .help').toggle(false); } this.show_as_input = function() { - $ds(me.input); $ds(me.save_btn); $ds(me.cancel_btn); - $dh(me.edit_btn); $dh(me.display); - if(me.rich_text) - wn.tinymce.add_simple(me.input, '300px'); - } + me.$w.find('.ed-text-display, .ed-text-edit').toggle(false); + me.$w.find('.ed-text-input, .ed-text-save, .ed-text-cancel, .help').toggle(true); + } } \ No newline at end of file diff --git a/erpnext/knowledge_base/page/question_view/question_view.html b/erpnext/knowledge_base/page/question_view/question_view.html index 9939332e32..521244599e 100644 --- a/erpnext/knowledge_base/page/question_view/question_view.html +++ b/erpnext/knowledge_base/page/question_view/question_view.html @@ -1,13 +1,12 @@ -
- × -

Knowledge Base

-
-

← Back to Questions

-
+
+
+
+
+
+
+
+
+ +
-
-
-
- -
\ No newline at end of file diff --git a/erpnext/knowledge_base/page/question_view/question_view.js b/erpnext/knowledge_base/page/question_view/question_view.js index 879ee7912e..e0dd1920aa 100644 --- a/erpnext/knowledge_base/page/question_view/question_view.js +++ b/erpnext/knowledge_base/page/question_view/question_view.js @@ -15,6 +15,9 @@ // along with this program. If not, see . pscript['onload_question-view'] = function(wrapper) { + wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe')); + wrapper.appframe.title('Knowledge Base'); + wrapper.add_answer_area = $('.add-answer-area').get(0); } @@ -71,12 +74,10 @@ KBQuestionView = function(w, qid, qtext) { // add a link to open add answer this.make_answer_box_link = function() { - $('.add-answer-link').html('').find('button').click( - function() { - $(this).toggle(false); - me.make_answer_box(); - }); + wn.pages['question-view'].appframe.add_button('Add your answer', function() { + $(this).toggle(false); + me.make_answer_box(); + }, 'icon-plus'); } // answer box @@ -130,9 +131,10 @@ KBAnswerList = function(args) { $.extend(this, args); this.make_list = function() { - + wn.pages['question-view'].appframe.clear_buttons(); this.list = new wn.ui.Listing({ parent: me.parent, + appframe: wn.pages['question-view'].appframe, as_dict: 1, no_result_message: 'No answers yet, be the first one to answer!', render_row: function(body, data) { @@ -143,8 +145,7 @@ KBAnswerList = function(args) { +"t2.last_name, t1.modified from tabAnswer t1, tabProfile t2 " +"where question='%(qid)s' and t1.owner = t2.name " +"order by t1.points desc, t1.modified desc", {qid: me.qid}) - }, - title: 'Answers' + } }); this.list.run(); @@ -169,7 +170,7 @@ KBAnswer = function(body, data, ans_list) { text: data.answer, inp_class: 'qv-ans-input', disp_class: 'qv-ans-text', - rich_text: 1 + height: '300px' }); $(edtxt.wrapper).addClass('well'); diff --git a/erpnext/knowledge_base/page/questions/questions.html b/erpnext/knowledge_base/page/questions/questions.html index c76f4902bb..1085b7555a 100644 --- a/erpnext/knowledge_base/page/questions/questions.html +++ b/erpnext/knowledge_base/page/questions/questions.html @@ -1,8 +1,6 @@
+
- × -

Knowledge Base

-
diff --git a/erpnext/knowledge_base/page/questions/questions.js b/erpnext/knowledge_base/page/questions/questions.js index 6b0ca25079..c2fe1910eb 100644 --- a/erpnext/knowledge_base/page/questions/questions.js +++ b/erpnext/knowledge_base/page/questions/questions.js @@ -17,6 +17,9 @@ pscript.onload_questions = function(wrapper) { body = $(wrapper).find('.layout-main-section').get(0); + wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.layout-appframe')); + wrapper.appframe.title('Knowledge Base'); + // kb var kb = new KnowledgeBase(body); @@ -60,7 +63,7 @@ function KnowledgeBase(w) { if(this.search.value==$(this.search).attr('default_text')) { msgprint('Please enter some text'); return; } - this.suggest(); + this.add_question([]); } // suggest a few users who can answer diff --git a/erpnext/startup/startup.css b/erpnext/startup/startup.css index 79ce027e37..bd21144ec6 100644 --- a/erpnext/startup/startup.css +++ b/erpnext/startup/startup.css @@ -1,6 +1,5 @@ h1, h2, h3, h4, h5 { font-family: "Helvetica Neue", "Open Sans", Helvetica, sans-serif; - font-weight: normal; margin-top: 0.2em; } diff --git a/erpnext/website/doctype/about_us_settings/template.html b/erpnext/website/doctype/about_us_settings/template.html index 864fb65506..404ebe922b 100644 --- a/erpnext/website/doctype/about_us_settings/template.html +++ b/erpnext/website/doctype/about_us_settings/template.html @@ -1,9 +1,10 @@ -
+
- {% if doc.headline %} -

{{ doc.headline }}

- {% endif %} -
+
+ {% if doc.headline %} +

{{ doc.headline }}

+ {% endif %} + {{ doc.main_section_html }} {% if doc.about_team %} @@ -28,7 +29,7 @@ {% endif %}
-
+
{{ doc.side_section_html }}
diff --git a/erpnext/website/doctype/blog/template.html b/erpnext/website/doctype/blog/template.html index 1b81fe2d90..467f30169f 100644 --- a/erpnext/website/doctype/blog/template.html +++ b/erpnext/website/doctype/blog/template.html @@ -1,13 +1,13 @@ -
+
-

Blog

-
+
+

Blog

{{ doc.title }}

By {{ doc.full_name }} on {{ doc.updated }}

{{ doc.content_html }}
-
+

All Blogs

Subscribe

diff --git a/erpnext/website/doctype/contact_us_settings/template.html b/erpnext/website/doctype/contact_us_settings/template.html index 6453784b7f..508b534a89 100644 --- a/erpnext/website/doctype/contact_us_settings/template.html +++ b/erpnext/website/doctype/contact_us_settings/template.html @@ -1,9 +1,9 @@ -

+
- {% if doc.headline %} -

{{ doc.headline }}

- {% endif %} -
+
+ {% if doc.headline %} +

{{ doc.headline }}

+ {% endif %}

@@ -16,7 +16,7 @@
{{ doc.main_section_html }}
-
+
{{ doc.side_section_html }}
diff --git a/erpnext/website/doctype/web_page/template.html b/erpnext/website/doctype/web_page/template.html index e6f071d0a7..2c92a25e99 100644 --- a/erpnext/website/doctype/web_page/template.html +++ b/erpnext/website/doctype/web_page/template.html @@ -1,26 +1,21 @@ -
+
- {% if doc.head_section and doc.layout=='Two column with header' %} -
- {{ doc.head_section_html }} -
- {% endif %} {% if doc.layout.startswith('Two column') %} -
+
+ {% else %} +
{% endif %} {{ doc.main_section_html }} {% if doc.next_page_html %} {{ doc.next_page_html }} {% endif %} - {% if doc.layout.startswith('Two column') %}
- {% endif %} {% if doc.layout.startswith('Two column') %} -
+
{{ doc.side_section_html }} {% if doc.see_also %}
diff --git a/erpnext/website/page/blog/blog.html b/erpnext/website/page/blog/blog.html index 79ea7f0f1f..ffb81280a4 100644 --- a/erpnext/website/page/blog/blog.html +++ b/erpnext/website/page/blog/blog.html @@ -1,10 +1,10 @@ -
+
-

Blog

-
-
+
+

Blog

+
-
+