From c9977ae7d90c5baf765552f1273f4fa7fb956391 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 12 Mar 2013 11:48:23 +0530 Subject: [PATCH] added text coloring options for website --- .../style_settings/custom_template.css | 26 ++++++++++-------- .../doctype/style_settings/style_settings.js | 7 ++--- .../doctype/style_settings/style_settings.py | 15 +++++++++++ .../doctype/style_settings/style_settings.txt | 27 +++++++++++++++---- 4 files changed, 56 insertions(+), 19 deletions(-) diff --git a/website/doctype/style_settings/custom_template.css b/website/doctype/style_settings/custom_template.css index 00c02bb2b3..24353f97e0 100644 --- a/website/doctype/style_settings/custom_template.css +++ b/website/doctype/style_settings/custom_template.css @@ -14,11 +14,14 @@ body { {% if doc.font or doc.google_web_font_for_text %} font-family: '{{ doc.google_web_font_for_text or doc.font }}', 'Helvetica Neue', Arial, Sans !important; {% endif %} -{% if doc.font_size %} - font-size: {{ doc.font_size }} !important; -{% endif %} + {% if doc.font_size %}font-size: {{ doc.font_size }} !important;{% endif %} + {% if doc.page_text %}color: #{{ doc.page_text }};{% endif %} } +{% if doc.page_links %}a, a:hover { + color: #{{ doc.page_links }}; +}{% endif %} + {% if doc.font_size %} .small { font-size: {{ doc.small_font_size }} !important; @@ -29,16 +32,17 @@ div.outer { background-color: #{{ doc.page_background or "fff" }}; } -{% if doc.google_web_font_for_heading or doc.heading_font %} -h1, h2, h3, h4, h5 { +{% if doc.google_web_font_for_heading or doc.heading_font %}h1, h2, h3, h4, h5 { font-family: '{{ doc.google_web_font_for_heading or doc.heading_font }}', 'Helvetica Neue', Arial !important; -} -{% endif %} -{% if doc.heading_text_style %} -h1, h2, h3, h4, h5 { +}{% endif %} + +{% if doc.heading_text_style %}h1, h2, h3, h4, h5 { text-transform: {{ doc.heading_text_style }}; -} -{% endif %} +}{% endif %} + +{% if doc.page_headings %}h1, h2, h3, h4, h5 { + color: #{{ doc.page_headings }}; +}{% endif %} {% if doc.page_border %} /* Page Border*/ diff --git a/website/doctype/style_settings/style_settings.js b/website/doctype/style_settings/style_settings.js index e8ee908799..54c4f08511 100644 --- a/website/doctype/style_settings/style_settings.js +++ b/website/doctype/style_settings/style_settings.js @@ -17,8 +17,9 @@ cur_frm.cscript.onload_post_render = function() { wn.require('lib/public/js/lib/jscolor/jscolor.js'); - cur_frm.fields_dict.background_color.input.className = 'color'; - cur_frm.fields_dict.page_background.input.className = 'color'; - cur_frm.fields_dict.top_bar_background.input.className = 'color'; + $.each(["background_color", "page_background", "page_text", "page_links", + "top_bar_background", "top_bar_foreground", "page_headings"], function(i, v) { + cur_frm.fields_dict[v].input.className = 'color'; + }) jscolor.bind(); } \ No newline at end of file diff --git a/website/doctype/style_settings/style_settings.py b/website/doctype/style_settings/style_settings.py index ba003ae594..bf46afb97d 100644 --- a/website/doctype/style_settings/style_settings.py +++ b/website/doctype/style_settings/style_settings.py @@ -15,7 +15,10 @@ # along with this program. If not, see . from __future__ import unicode_literals +import webnotes + from webnotes.utils import cint, cstr +from webnotes import _ class DocType: def __init__(self, d, dl): @@ -26,6 +29,8 @@ class DocType: from jinja2 import Template import os + self.validate_colors() + with open(os.path.join( os.path.dirname(os.path.abspath(__file__)), 'custom_template.css'), 'r') as f: @@ -47,6 +52,16 @@ class DocType: if f in self.doc.fields: del self.doc.fields[f] + def validate_colors(self): + if self.doc.page_background==self.doc.page_text: + webnotes.msgprint(_("Page text and background is same color. Please change."), + raise_exception=1) + + if self.doc.top_bar_background==self.doc.top_bar_foreground: + webnotes.msgprint(_("Top Bar text and background is same color. Please change."), + raise_exception=1) + + def prepare(self): if not self.doc.font_size: self.doc.font_size = '13px' diff --git a/website/doctype/style_settings/style_settings.txt b/website/doctype/style_settings/style_settings.txt index e58ae09e95..fbb4c422f6 100644 --- a/website/doctype/style_settings/style_settings.txt +++ b/website/doctype/style_settings/style_settings.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-25 11:35:10", + "creation": "2013-03-08 11:36:53", "docstatus": 0, - "modified": "2013-03-08 09:58:49", + "modified": "2013-03-12 11:34:32", "modified_by": "Administrator", "owner": "Administrator" }, @@ -65,6 +65,24 @@ "fieldtype": "Data", "label": "Page Background" }, + { + "doctype": "DocField", + "fieldname": "page_headings", + "fieldtype": "Data", + "label": "Page Headings" + }, + { + "doctype": "DocField", + "fieldname": "page_text", + "fieldtype": "Data", + "label": "Page Text" + }, + { + "doctype": "DocField", + "fieldname": "page_links", + "fieldtype": "Data", + "label": "Page Links" + }, { "doctype": "DocField", "fieldname": "page_border", @@ -88,9 +106,8 @@ "description": "000 is black, fff is white", "doctype": "DocField", "fieldname": "top_bar_foreground", - "fieldtype": "Select", - "label": "Top Bar Foreground", - "options": "000\nFFF" + "fieldtype": "Data", + "label": "Top Bar Text" }, { "doctype": "DocField",