ソースを参照

moved frappe-web.min.js to head section, cleanup in comments and web-form css

version-14
Anand Doshi 10年前
コミット
3ae69187f4
6個のファイルの変更77行の追加73行の削除
  1. +0
    -1
      frappe/hooks.py
  2. +2
    -2
      frappe/public/css/website.css
  3. +2
    -2
      frappe/public/less/website.less
  4. +9
    -5
      frappe/templates/base.html
  5. +10
    -8
      frappe/templates/generators/web_form.html
  6. +54
    -55
      frappe/templates/includes/comments/comments.html

+ 0
- 1
frappe/hooks.py ファイルの表示

@@ -30,7 +30,6 @@ app_include_css = [
]

web_include_js = [
"assets/js/frappe-web.min.js",
"website_script.js"
]



+ 2
- 2
frappe/public/css/website.css ファイルの表示

@@ -584,8 +584,8 @@ fieldset {
padding: 15px;
border-bottom: 1px solid #d1d8dd;
}
.add-comment-section {
padding-top: 15px;
.blog-comment-row:last-child {
margin-bottom: 30px;
}
textarea {
resize: vertical;


+ 2
- 2
frappe/public/less/website.less ファイルの表示

@@ -266,8 +266,8 @@ fieldset {
border-bottom: 1px solid @border-color;
}

.add-comment-section {
padding-top: 15px;
.blog-comment-row:last-child {
margin-bottom: 30px;
}

textarea {


+ 9
- 5
frappe/templates/base.html ファイルの表示

@@ -8,6 +8,8 @@
<meta name="generator" content="frappe">
<script type="text/javascript"
src="/assets/frappe/js/lib/jquery/jquery.min.js"></script>
<script type="text/javascript"
src="/assets/js/frappe-web.min.js"></script>

{% block favicon %}
<link rel="shortcut icon"
@@ -89,22 +91,24 @@
</div>
</div>
</div>

<!-- js should be loaded in body! -->
{%- for link in web_include_js %}
<script type="text/javascript" src="{{ link|with_leading_slash }}"></script>
{%- endfor -%}

{%- block script_lib %}
<script data-html-block="script_lib" data-path="{{ name }}">
{%- if script_lib is defined -%}{{ script_lib }}{%- endif -%}
</script>
{%- endblock -%}

{%- block script %}
<script data-html-block="script">
{%- if script is defined -%}{{ script }}{%- endif -%}
</script>
{%- endblock %}

{%- block script_lib %}
<script data-html-block="script_lib" data-path="{{ name }}">
{%- if script_lib is defined -%}{{ script_lib }}{%- endif -%}
</script>
{%- endblock -%}
{%- block body_include %}{{ body_include or "" }}{% endblock -%}
</body>
</html>

+ 10
- 8
frappe/templates/generators/web_form.html ファイルの表示

@@ -13,17 +13,19 @@
{% endif %}
</div>
{% if login_required and frappe.user=="Guest" %}
<div class="text-muted">
{{ _("Please login to create a new {0}").format(_(doc_type)) }}
<div class="login-required">
<div class="text-muted">
{{ _("Please login to create a new {0}").format(_(doc_type)) }}
</div>
<p>
<a href="/login?redirect-to=/{{ pathname }}" class="btn btn-primary">
{{ _("Login") }}
</a>
</p>
</div>
<p>
<a href="/login?redirect-to=/{{ pathname }}" class="btn btn-primary">
{{ _("Login") }}
</a>
</p>
{% elif (login_required and allow_multiple and not params.name and not params.new) %}
<p>
<a href="{{ pathname }}?new=1" class="btn btn-primary">
<a href="{{ pathname }}?new=1" class="btn btn-primary btn-new">
{{ _("New {0}").format(_(doc_type)) }}
</a>
</p>


+ 54
- 55
frappe/templates/includes/comments/comments.html ファイルの表示

@@ -14,7 +14,7 @@
{% if login_required and frappe.user=="Guest" %}
<div class="text-muted"><a href="/login?redirect-to={{ pathname }}">{{ _("Login to comment") }}</a></div>
{% else %}
<p><a class="add-comment">{{ _("Add Comment") }}</a></p>
<a class="add-comment">{{ _("Add Comment") }}</a>
<div style="display: none;" id="comment-form">
<p>{{ _("Add Comment") }}</p>
<div class="alert" style="display:none;"></div>
@@ -40,65 +40,64 @@
{% endif %}
</div>
<script>
frappe.ready(function() {
console.log("ready!");
var n_comments = $(".comment-row").length;
frappe.ready(function() {
var n_comments = $(".comment-row").length;

if(n_comments) {
$(".no_comment").toggle(false);
}
if(n_comments > 50) {
$(".add-comment").toggle(false)
.parent().append("<div class='text-muted'>Comments are closed.</div>")
}
$(".add-comment").click(function() {
$(this).toggle(false);
$("#comment-form").toggle();

$("[name='comment_by']").val(getCookie("user_id") || "");
$("[name='comment_by_fullname']").val(getCookie("full_name") || "");
$("#comment-form textarea").val("");
})
$("#submit-comment").click(function() {
var args = {
comment_by_fullname: $("[name='comment_by_fullname']").val(),
comment_by: $("[name='comment_by']").val(),
comment: $("[name='comment']").val(),
comment_doctype: "{{ doctype }}",
comment_docname: "{{ name }}",
comment_type: "Comment",
page_name: "{{ pathname }}",
if(n_comments) {
$(".no_comment").toggle(false);
}

if(!args.comment_by_fullname || !args.comment_by || !args.comment) {
frappe.msgprint("All fields are necessary to submit the comment.")
return false;
if(n_comments > 50) {
$(".add-comment").toggle(false)
.parent().append("<div class='text-muted'>Comments are closed.</div>")
}
$(".add-comment").click(function() {
$(this).toggle(false);
$("#comment-form").toggle();

if (!valid_email(args.comment_by)) {
frappe.msgprint("Please enter a valid email address.");
return false;
}
$("[name='comment_by']").val(getCookie("user_id") || "");
$("[name='comment_by_fullname']").val(getCookie("full_name") || "");
$("#comment-form textarea").val("");
})
$("#submit-comment").click(function() {
var args = {
comment_by_fullname: $("[name='comment_by_fullname']").val(),
comment_by: $("[name='comment_by']").val(),
comment: $("[name='comment']").val(),
comment_doctype: "{{ doctype }}",
comment_docname: "{{ name }}",
comment_type: "Comment",
page_name: "{{ pathname }}",
}

frappe.call({
btn: this,
type: "POST",
method: "frappe.templates.includes.comments.comments.add_comment",
args: args,
callback: function(r) {
if(r.exc) {
if(r._server_messages)
frappe.msgprint(r._server_messages);
} else {
$(r.message).appendTo("#comment-list");
$(".no-comment, .add-comment").toggle(false);
$("#comment-form")
.replaceWith("<div class='alert alert-success'>Thank you for your comment!</div>")
}
if(!args.comment_by_fullname || !args.comment_by || !args.comment) {
frappe.msgprint("All fields are necessary to submit the comment.")
return false;
}

if (!valid_email(args.comment_by)) {
frappe.msgprint("Please enter a valid email address.");
return false;
}
})

return false;
})
})
frappe.call({
btn: this,
type: "POST",
method: "frappe.templates.includes.comments.comments.add_comment",
args: args,
callback: function(r) {
if(r.exc) {
if(r._server_messages)
frappe.msgprint(r._server_messages);
} else {
$(r.message).appendTo("#comment-list");
$(".no-comment, .add-comment").toggle(false);
$("#comment-form")
.replaceWith('<div class="text-muted">Thank you for your comment!</div>')
}
}
})

return false;
})
});
</script>

読み込み中…
キャンセル
保存