@@ -22,7 +22,13 @@ jQuery(function ($) { | |||||
}; | }; | ||||
$.fn.cleanHtml = function () { | $.fn.cleanHtml = function () { | ||||
var html = $(this).html(); | var html = $(this).html(); | ||||
return html && html.replace(/(<br>|\s|<div><br><\/div>| )*$/, ''); | |||||
html = html && html.replace(/(<br>|\s|<div><br><\/div>| )*$/, ''); | |||||
// remove custom typography (use CSS!) | |||||
html = html && html.replace(/(font-family|font-size|line-height):[^;]*;/g, ''); | |||||
html = html && html.replace(/<[^>]*(font=['"][^'"]*['"])>/g, function(a,b) { return a.replace(b, ''); }); | |||||
html = html && html.replace(/\s*style\s*=\s*["']\s*["']/g, ''); | |||||
return html; | |||||
}; | }; | ||||
$.fn.wysiwyg = function (userOptions) { | $.fn.wysiwyg = function (userOptions) { | ||||
var editor = this, | var editor = this, | ||||
@@ -157,7 +157,6 @@ wn.editors.BootstrapWYSIWYG = Class.extend({ | |||||
me.$textarea.val(html_beautify(me.$editor.cleanHtml())); | me.$textarea.val(html_beautify(me.$editor.cleanHtml())); | ||||
me.$parent.find(".for-rich-text").toggle(false); | me.$parent.find(".for-rich-text").toggle(false); | ||||
me.$parent.find(".for-html").toggle(true); | me.$parent.find(".for-html").toggle(true); | ||||
console.log(me.$parent.find(".btn-html")); | |||||
me.$parent.find(".btn-html").attr("disabled", "disabled"); | me.$parent.find(".btn-html").attr("disabled", "disabled"); | ||||
me.$parent.find(".btn-rich-text").attr("disabled", false); | me.$parent.find(".btn-rich-text").attr("disabled", false); | ||||
me.current_editor = me.$textarea; | me.current_editor = me.$textarea; | ||||
@@ -287,7 +287,7 @@ wn.views.ReportView = wn.ui.Listing.extend({ | |||||
method: "webnotes.client.set_value", | method: "webnotes.client.set_value", | ||||
args: { | args: { | ||||
doctype: docfield.parent, | doctype: docfield.parent, | ||||
docname: row[docfield.parent===me.doctype ? "name" : docfield.parent+":name"], | |||||
name: row[docfield.parent===me.doctype ? "name" : docfield.parent+":name"], | |||||
fieldname: docfield.fieldname, | fieldname: docfield.fieldname, | ||||
value: d.get_value(docfield.fieldname) | value: d.get_value(docfield.fieldname) | ||||
}, | }, | ||||
@@ -25,17 +25,17 @@ def get_value(doctype, fieldname, filters=None, as_dict=True, debug=False): | |||||
return webnotes.conn.get_value(doctype, json.loads(filters), fieldname, as_dict=as_dict, debug=debug) | return webnotes.conn.get_value(doctype, json.loads(filters), fieldname, as_dict=as_dict, debug=debug) | ||||
@webnotes.whitelist() | @webnotes.whitelist() | ||||
def set_value(doctype, docname, fieldname, value): | |||||
def set_value(doctype, name, fieldname, value): | |||||
if fieldname in webnotes.model.default_fields: | if fieldname in webnotes.model.default_fields: | ||||
webnotes.throw(_("Cannot edit standard fields")) | webnotes.throw(_("Cannot edit standard fields")) | ||||
doc = webnotes.conn.get_value(doctype, docname, ["parenttype", "parent"], as_dict=True) | |||||
doc = webnotes.conn.get_value(doctype, name, ["parenttype", "parent"], as_dict=True) | |||||
if doc and doc.parent: | if doc and doc.parent: | ||||
bean = webnotes.bean(doc.parenttype, doc.parent) | bean = webnotes.bean(doc.parenttype, doc.parent) | ||||
child = bean.doclist.getone({"doctype": doctype, "name": docname}) | child = bean.doclist.getone({"doctype": doctype, "name": docname}) | ||||
child.fields[fieldname] = value | child.fields[fieldname] = value | ||||
else: | else: | ||||
bean = webnotes.bean(doctype, docname) | |||||
bean = webnotes.bean(doctype, name) | |||||
bean.doc.fields[fieldname] = value | bean.doc.fields[fieldname] = value | ||||
bean.save() | bean.save() | ||||
@@ -191,4 +191,10 @@ fieldset { | |||||
display: table-cell; | display: table-cell; | ||||
vertical-align: middle; | vertical-align: middle; | ||||
text-align: center; | text-align: center; | ||||
} | |||||
.web-page-editable { | |||||
margin: -15px; | |||||
padding: 15px; | |||||
border-radius: 4px; | |||||
} | } |
@@ -3,6 +3,14 @@ | |||||
{% block content %} | {% block content %} | ||||
<div class="col-md-12" style="margin-top: 15px;"> | <div class="col-md-12" style="margin-top: 15px;"> | ||||
{% include "lib/website/doctype/website_slideshow/templates/includes/slideshow.html" %} | {% include "lib/website/doctype/website_slideshow/templates/includes/slideshow.html" %} | ||||
<div class="web-page-content"> | |||||
{{ main_section }} | {{ main_section }} | ||||
</div> | |||||
</div> | </div> | ||||
<script> | |||||
$(function() { | |||||
window.name = "{{ name }}"; | |||||
if(getCookie("full_name")) { $.get("app/js/web_page_editable.js"); }; | |||||
}) | |||||
</script> | |||||
{% endblock %} | {% endblock %} |