From dcfdfc317c1fafe30fad7e839a4aca502e7d9479 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 25 Apr 2012 18:24:44 +0530 Subject: [PATCH] fixes to website module and fixed rename and double column bugs --- css/all-app.css | 9 +-- css/all-web.css | 31 +++------ erpnext/website/css/website.css | 22 ++----- .../style_settings/custom_template.css | 1 + .../doctype/style_settings/style_settings.py | 2 + .../doctype/style_settings/style_settings.txt | 44 ++++++++++--- .../website/doctype/web_page/template.html | 2 +- erpnext/website/doctype/web_page/web_page.js | 20 +++++- erpnext/website/doctype/web_page/web_page.py | 8 +++ erpnext/website/doctype/web_page/web_page.txt | 63 +++++++++++-------- js/all-app.js | 5 +- js/all-web.js | 2 +- 12 files changed, 128 insertions(+), 81 deletions(-) diff --git a/css/all-app.css b/css/all-app.css index ff022b795f..21cf8fb041 100644 --- a/css/all-app.css +++ b/css/all-app.css @@ -1923,9 +1923,9 @@ div.std-footer-item { } .layout_wrapper, .layout-wrapper { - -moz-box-shadow: 0px 0px 6px rgba(0,0,0,0.3); - -webkit-box-shadow: 0px 0px 6px rgba(0,0,0,0.3); - box-shadow: 0px 0px 6px rgba(0,0,0,0.3); + -moz-box-shadow: 0px 0px 9px rgba(0,0,0,0.5); + -webkit-box-shadow: 0px 0px 9px rgba(0,0,0,0.5); + box-shadow: 0px 0px 9px rgba(0,0,0,0.5); background-color: #fff; padding: 15px; -webkit-border-radius: 5px; @@ -1945,7 +1945,8 @@ div.std-footer-item { } .layout-main { - padding: 15px; + padding: 15px; + background-color: #fff; } .layout-main-section { diff --git a/css/all-web.css b/css/all-web.css index 146d478211..8ac14cb716 100644 --- a/css/all-web.css +++ b/css/all-web.css @@ -1403,9 +1403,9 @@ div.std-footer-item { } .layout_wrapper, .layout-wrapper { - -moz-box-shadow: 0px 0px 6px rgba(0,0,0,0.3); - -webkit-box-shadow: 0px 0px 6px rgba(0,0,0,0.3); - box-shadow: 0px 0px 6px rgba(0,0,0,0.3); + -moz-box-shadow: 0px 0px 9px rgba(0,0,0,0.5); + -webkit-box-shadow: 0px 0px 9px rgba(0,0,0,0.5); + box-shadow: 0px 0px 9px rgba(0,0,0,0.5); background-color: #fff; padding: 15px; -webkit-border-radius: 5px; @@ -1425,7 +1425,8 @@ div.std-footer-item { } .layout-main { - padding: 15px; + padding: 15px; + background-color: #fff; } .layout-main-section { @@ -1946,8 +1947,8 @@ div#body_div, header .container, .content, #opened-page-selector, footer { width: 900px; } -.layout_wrapper { - padding: 27px; +div#body_div { + margin-top: 90px; } p, li { @@ -1965,10 +1966,6 @@ pre { margin-bottom: 9px; } -.web-content input[type="text"], .web-content input[type="password"], .web-content select { - min-width: 180px; -} - .web-head-section { margin-bottom: 20px } @@ -1991,6 +1988,7 @@ pre { .web-page-status { padding: 7px; + margin-top: -20px; color: #777; clear: both; text-align: right; @@ -2021,20 +2019,12 @@ footer { } .web-footer div, .web-footer a { - font-size: 11px; + font-size: 14px; } .web-footer-menu { margin-bottom: 7px; } -footer a, footer a:visited { - color: #777; -} - -footer a:hover { - background-color: #777; - color: #fff; -} .web-footer-menu ul { list-style: none; @@ -2080,9 +2070,8 @@ footer a:hover { } .two-column { - width: 40%; + width: 50%; float: left; - padding: 5%; } .clear { diff --git a/erpnext/website/css/website.css b/erpnext/website/css/website.css index 1fd0bb055c..ad8702ab47 100644 --- a/erpnext/website/css/website.css +++ b/erpnext/website/css/website.css @@ -2,8 +2,8 @@ div#body_div, header .container, .content, #opened-page-selector, footer { width: 900px; } -.layout_wrapper { - padding: 27px; +div#body_div { + margin-top: 90px; } p, li { @@ -21,10 +21,6 @@ pre { margin-bottom: 9px; } -.web-content input[type="text"], .web-content input[type="password"], .web-content select { - min-width: 180px; -} - .web-head-section { margin-bottom: 20px } @@ -47,6 +43,7 @@ pre { .web-page-status { padding: 7px; + margin-top: -20px; color: #777; clear: both; text-align: right; @@ -77,20 +74,12 @@ footer { } .web-footer div, .web-footer a { - font-size: 11px; + font-size: 14px; } .web-footer-menu { margin-bottom: 7px; } -footer a, footer a:visited { - color: #777; -} - -footer a:hover { - background-color: #777; - color: #fff; -} .web-footer-menu ul { list-style: none; @@ -136,9 +125,8 @@ footer a:hover { } .two-column { - width: 40%; + width: 50%; float: left; - padding: 5%; } .clear { diff --git a/erpnext/website/doctype/style_settings/custom_template.css b/erpnext/website/doctype/style_settings/custom_template.css index 72c15a1929..8c987f87a5 100644 --- a/erpnext/website/doctype/style_settings/custom_template.css +++ b/erpnext/website/doctype/style_settings/custom_template.css @@ -3,6 +3,7 @@ body { background: url("files/{{ doc.background_image }}") repeat; {% elif doc.background_color %} background-color: #{{ doc.background_color }}; + background-image: none; {% endif %} {% if doc.font %} font-family: '{{ doc.font }}', Verdana, Sans !important; diff --git a/erpnext/website/doctype/style_settings/style_settings.py b/erpnext/website/doctype/style_settings/style_settings.py index 282cd93fd4..db26a15e80 100644 --- a/erpnext/website/doctype/style_settings/style_settings.py +++ b/erpnext/website/doctype/style_settings/style_settings.py @@ -28,6 +28,8 @@ class DocType: self.doc.small_font_size = str(int(self.doc.font_size[:-2])-2) + 'px' self.doc.custom_css = temp.render(doc = self.doc) + if self.doc.add_css: + self.doc.custom_css += '\n\n/* User CSS */\n\n' + self.doc.add_css from webnotes.session_cache import clear_cache clear_cache('Guest') diff --git a/erpnext/website/doctype/style_settings/style_settings.txt b/erpnext/website/doctype/style_settings/style_settings.txt index b87a02c15f..dd962d5459 100644 --- a/erpnext/website/doctype/style_settings/style_settings.txt +++ b/erpnext/website/doctype/style_settings/style_settings.txt @@ -5,7 +5,7 @@ { 'creation': '2012-04-02 16:02:43', 'docstatus': 0, - 'modified': '2012-04-16 13:36:48', + 'modified': '2012-04-25 10:00:35', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -23,7 +23,7 @@ 'name': '__common__', 'section_style': u'Simple', 'show_in_menu': 0, - 'version': 19 + 'version': 23 }, # These values are common for all DocField @@ -89,6 +89,27 @@ 'permlevel': 0 }, + # DocField + { + 'colour': u'White:FFF', + 'description': u'Select a white footer foreground color if you have a dark background', + 'doctype': u'DocField', + 'fieldname': u'footer_font_color', + 'fieldtype': u'Select', + 'label': u'Footer Font Color', + 'options': u'\nwhite', + 'permlevel': 0 + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldtype': u'Column Break', + 'label': u'Fonts', + 'permlevel': 0, + 'width': u'50%' + }, + # DocField { 'doctype': u'DocField', @@ -121,13 +142,20 @@ # DocField { - 'colour': u'White:FFF', - 'description': u'Select a white footer foreground color if you have a dark background', 'doctype': u'DocField', - 'fieldname': u'footer_font_color', - 'fieldtype': u'Select', - 'label': u'Footer Font Color', - 'options': u'\nwhite', + 'fieldtype': u'Section Break', + 'label': u'CSS', + 'permlevel': 0 + }, + + # DocField + { + 'colour': u'White:FFF', + 'description': u'add your own CSS (careful!)', + 'doctype': u'DocField', + 'fieldname': u'add_css', + 'fieldtype': u'Code', + 'label': u'Add CSS', 'permlevel': 0 }, diff --git a/erpnext/website/doctype/web_page/template.html b/erpnext/website/doctype/web_page/template.html index 2c92a25e99..471c95c94a 100644 --- a/erpnext/website/doctype/web_page/template.html +++ b/erpnext/website/doctype/web_page/template.html @@ -1,5 +1,5 @@
-
{% if doc.layout.startswith('Two column') %} diff --git a/erpnext/website/doctype/web_page/web_page.js b/erpnext/website/doctype/web_page/web_page.js index 442907512a..0b7b78da59 100644 --- a/erpnext/website/doctype/web_page/web_page.js +++ b/erpnext/website/doctype/web_page/web_page.js @@ -1,15 +1,33 @@ $.extend(cur_frm.cscript, { layout: function(doc) { if(!doc.layout) doc.layout = 'Two column with header' - hide_field(['head_section', 'side_section']); + hide_field(['head_section', 'side_section', 'javascript', 'css']); if(doc.layout=='Two column with header') { unhide_field(['head_section', 'side_section']); } if(doc.layout=='Two column') { unhide_field('side_section'); } + if(doc.insert_code) { + if(!doc.javascript) { + doc.javascript = 'wn.pages["'+doc.name+'"].onload = function(wrapper) { }'; + } + unhide_field('javascript'); + } + if(doc.insert_style) { + if(!doc.css) { + doc.css = '#page-'+doc.name+' { }'; + } + unhide_field('css'); + } }, refresh: function(doc) { cur_frm.cscript.layout(doc); + }, + insert_style: function() { + cur_frm.cscript.layout(doc); + }, + insert_code: function() { + cur_frm.cscript.layout(doc); } }) \ No newline at end of file diff --git a/erpnext/website/doctype/web_page/web_page.py b/erpnext/website/doctype/web_page/web_page.py index 6b0f074ecc..ff8a9049ac 100644 --- a/erpnext/website/doctype/web_page/web_page.py +++ b/erpnext/website/doctype/web_page/web_page.py @@ -44,6 +44,14 @@ class DocType: with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f: p.content = Template(f.read()).render(doc=self.doc) + p.title = self.doc.title + + if self.doc.insert_code: + p.script = self.doc.javascript + + if self.doc.insert_style: + p.style = self.doc.css + p.save() website.utils.add_guest_access_to_page(p.name) diff --git a/erpnext/website/doctype/web_page/web_page.txt b/erpnext/website/doctype/web_page/web_page.txt index 7c155d788c..fb6febdbc7 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-10 10:41:00', + 'modified': '2012-04-25 16:03:57', 'modified_by': u'Administrator', 'owner': u'Administrator' }, @@ -22,7 +22,7 @@ 'name': '__common__', 'section_style': u'Simple', 'show_in_menu': 0, - 'version': 11 + 'version': 16 }, # These values are common for all DocField @@ -85,15 +85,6 @@ 'reqd': 1 }, - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'layout', - 'fieldtype': u'Select', - 'label': u'Layout', - 'options': u'Two column with header\nTwo column\nSingle column' - }, - # DocField { 'doctype': u'DocField', @@ -105,10 +96,10 @@ # DocField { 'doctype': u'DocField', - 'fieldname': u'text_align', + 'fieldname': u'layout', 'fieldtype': u'Select', - 'label': u'Text Align', - 'options': u'Left\nCenter\nRight' + 'label': u'Layout', + 'options': u'Two column with header\nTwo column\nSingle column' }, # DocField @@ -158,29 +149,49 @@ 'doctype': u'DocField', 'fieldname': u'sb2', 'fieldtype': u'Section Break', - 'label': u'Links' + 'label': u'More' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'text_align', + 'fieldtype': u'Select', + 'label': u'Text Align', + 'options': u'Left\nCenter\nRight' }, # DocField { 'colour': u'White:FFF', - 'description': u'Link for next page appears at the bottom of the page', 'doctype': u'DocField', - 'fieldname': u'next_page', - 'fieldtype': u'Link', - 'label': u'Next Page', - 'options': u'Page' + 'fieldname': u'insert_code', + 'fieldtype': u'Check', + 'label': u'Insert Code' }, # DocField { - 'colour': u'White:FFF', - 'description': u'Related pages appear on the right side of the link and are linked both ways.', 'doctype': u'DocField', - 'fieldname': u'related_pages', - 'fieldtype': u'Table', - 'label': u'Related Pages', - 'options': u'Related Page' + 'fieldname': u'javascript', + 'fieldtype': u'Code', + 'label': u'Javascript' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'insert_style', + 'fieldtype': u'Check', + 'label': u'Insert Style' + }, + + # DocField + { + 'doctype': u'DocField', + 'fieldname': u'css', + 'fieldtype': u'Code', + 'label': u'CSS' }, # DocField diff --git a/js/all-app.js b/js/all-app.js index beca5f6fb7..bec4220647 100644 --- a/js/all-app.js +++ b/js/all-app.js @@ -353,7 +353,7 @@ if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.field /* * lib/js/wn/views/container.js */ -wn.provide('wn.pages');wn.provide('wn.views');wn.views.Container=Class.extend({init:function(){this.container=$('#body_div').get(0);this.page=null;this.pagewidth=$('#body_div').width();this.pagemargin=50;},add_page:function(label,onshow,onhide){var page=$('
').appendTo(this.container).get(0);if(onshow) +wn.provide('wn.pages');wn.provide('wn.views');wn.views.Container=Class.extend({init:function(){this.container=$('#body_div').get(0);this.page=null;this.pagewidth=$('#body_div').width();this.pagemargin=50;},add_page:function(label,onshow,onhide){var page=$('
').attr('id',"page-"+label).appendTo(this.container).get(0);if(onshow) $(page).bind('show',onshow);if(onshow) $(page).bind('hide',onhide);page.label=label;wn.pages[label]=page;return page;},change_to:function(label){if(this.page&&this.page.label==label){return;} var me=this;if(label.tagName){var page=label;}else{var page=wn.pages[label];} @@ -1710,7 +1710,8 @@ _f.Frm.prototype.email_doc=function(){if(!_e.dialog)_e.make();sel=this.print_sel c.appendChild(this.print_sel);c.cur_sel=this.print_sel;_e.dialog.widgets['Send With Attachments'].checked=0;if(cur_frm.doc.file_list){$ds(_e.dialog.rows['Send With Attachments']);}else{$dh(_e.dialog.rows['Send With Attachments']);} _e.dialog.widgets['Subject'].value=get_doctype_label(this.meta.name)+': '+this.docname;_e.dialog.show();} _f.Frm.prototype.rename_notify=function(dt,old,name){this.is_editable[name]=this.is_editable[old];delete this.is_editable[old];if(this.docname==old) -this.docname=name;if(this&&this.opendocs[old]){local_dt[dt][name]=local_dt[dt][old];local_dt[dt][old]=null;} +this.docname=name;else +return;if(this&&this.opendocs[old]){local_dt[dt][name]=local_dt[dt][old];local_dt[dt][old]=null;} delete this.opendocs[old];this.opendocs[name]=true;wn.re_route[window.location.hash]='Form/'+encodeURIComponent(this.doctype)+'/'+encodeURIComponent(name);wn.set_route('Form',this.doctype,name);} _f.Frm.prototype.setup_meta=function(){this.meta=get_local('DocType',this.doctype);this.perm=get_perm(this.doctype);if(this.meta.istable){this.meta.in_dialog=1} this.setup_print();} diff --git a/js/all-web.js b/js/all-web.js index 1e0a54189e..6ec421e218 100644 --- a/js/all-web.js +++ b/js/all-web.js @@ -240,7 +240,7 @@ if(wn.model.no_value_type.indexOf(df.fieldtype)==-1&&!me.fields_by_name[df.field /* * lib/js/wn/views/container.js */ -wn.provide('wn.pages');wn.provide('wn.views');wn.views.Container=Class.extend({init:function(){this.container=$('#body_div').get(0);this.page=null;this.pagewidth=$('#body_div').width();this.pagemargin=50;},add_page:function(label,onshow,onhide){var page=$('
').appendTo(this.container).get(0);if(onshow) +wn.provide('wn.pages');wn.provide('wn.views');wn.views.Container=Class.extend({init:function(){this.container=$('#body_div').get(0);this.page=null;this.pagewidth=$('#body_div').width();this.pagemargin=50;},add_page:function(label,onshow,onhide){var page=$('
').attr('id',"page-"+label).appendTo(this.container).get(0);if(onshow) $(page).bind('show',onshow);if(onshow) $(page).bind('hide',onhide);page.label=label;wn.pages[label]=page;return page;},change_to:function(label){if(this.page&&this.page.label==label){return;} var me=this;if(label.tagName){var page=label;}else{var page=wn.pages[label];}