-
+
{{ item_name }}
{% if website_image %}
-
+
{% else %}
This is an auto-generated Image
{% endif %}
-
- {{ web_description_html }}
+
Product Description
+
+ {{ web_long_description or web_short_description }}
+
+ {% if obj.doclist.get({"doctype":"Item Website Specification"}) %}
+
Specifications
+
+ {% for d in obj.doclist.get(
+ {"doctype":"Item Website Specification"}) %}
+
+ {{ d.label }} |
+ {{ d.description }} |
+
+ {% endfor %}
+
+ {% endif %}
-
-
More Categories
-
-
-
Similar Products
-
-
-
{% endblock %}
\ No newline at end of file
diff --git a/website/templates/js/blog.js b/website/templates/js/blog.js
index 24cdf15ae4..43b2d70a96 100644
--- a/website/templates/js/blog.js
+++ b/website/templates/js/blog.js
@@ -15,29 +15,54 @@
// along with this program. If not, see
.
// js inside blog page
-wn.pages['{{ name }}'].onload = function(wrapper) {
- erpnext.blog_list = new wn.ui.Listing({
- parent: $(wrapper).find('#blog-list').get(0),
- method: 'website.helpers.blog.get_blog_list',
- hide_refresh: true,
- no_toolbar: true,
- render_row: function(parent, data) {
- if(!data.comments) {
- data.comment_text = 'No comments yet.'
- } else if (data.comments===1) {
- data.comment_text = '1 comment.'
+
+$(document).ready(function() {
+ // make list of blogs
+ blog.get_list();
+
+ $("#next-page").click(function() {
+ blog.get_list();
+ })
+});
+
+var blog = {
+ start: 0,
+ get_list: function() {
+ $.ajax({
+ method: "GET",
+ url: "server.py",
+ data: {
+ cmd: "website.helpers.blog.get_blog_list",
+ start: blog.start
+ },
+ dataType: "json",
+ success: function(data) {
+ blog.render(data.message);
+ }
+ });
+ },
+ render: function(data) {
+ var $wrap = $("#blog-list");
+ $.each(data, function(i, b) {
+ // comments
+ if(!b.comments) {
+ b.comment_text = 'No comments yet.'
+ } else if (b.comments===1) {
+ b.comment_text = '1 comment.'
} else {
- data.comment_text = data.comments + ' comments.'
+ b.comment_text = b.comments + ' comments.'
}
- if(data.content && data.content.length==1000) {
- data.content += repl('...
(read on)', data);
- }
- parent.innerHTML = repl('
\
+ $(repl('
\
%(comment_text)s
\
- %(content)s
', data);
- },
- page_length: 10
- });
- erpnext.blog_list.run();
+ %(content)s
\
+
Read with comments...
\
+
', b)).appendTo($wrap);
+ });
+ blog.start += data.length;
+ if(!data.length) {
+ $("#next-page").toggle(false)
+ .parent().append("
Nothing more to show.
");
+ }
+ }
}
\ No newline at end of file
diff --git a/website/templates/js/blog_page.js b/website/templates/js/blog_page.js
index 12dcac139f..2e8de7e90c 100644
--- a/website/templates/js/blog_page.js
+++ b/website/templates/js/blog_page.js
@@ -16,166 +16,61 @@
// js inside blog page
-wn.provide('erpnext.blog');
-wn.pages['{{ name }}'].onload = function(wrapper) {
- erpnext.blog.wrapper = wrapper;
+$(document).ready(function() {
+ var n_comments = $(".comment-row").length;
- // sidebar
- //erpnext.blog.render_recent_list(wrapper);
-
- // unhide no-result if no comments found
- erpnext.blog.toggle_no_result(wrapper);
-
- // bind add comment button to comment dialog
- erpnext.blog.make_comment_dialog(wrapper);
-
- // hide add comment button after 50 comments
- erpnext.blog.toggle_add_comment_btn(wrapper);
-}
-
-erpnext.blog.adjust_page_height = function(wrapper) {
- if (!wrapper) { wrapper = erpnext.blog.wrapper; }
- if (!wrapper) { return; }
-
- // adjust page height based on sidebar height
- var $main_page = $(wrapper).find('.layout-main-section');
- var $sidebar = $(wrapper).find('.layout-side-section');
- if ($sidebar.height() > $main_page.height()) {
- $main_page.height($sidebar.height());
+ if(n_comments) {
+ $(".no_comment").toggle(false);
}
-}
-
-erpnext.blog.render_recent_list = function(wrapper) {
- if (!wrapper) { wrapper = erpnext.blog.wrapper; }
- if (!wrapper) { return; }
-
- wrapper.recent_list = new wn.ui.Listing({
- parent: $(wrapper).find('.recent-posts'),
- no_toolbar: true,
- method: 'website.helpers.blog.get_recent_blog_list',
- get_args: function() {
- return { name: '{{ name }}' }
- },
- hide_refresh: true,
- render_row: function(parent, data) {
- if(data.content && data.content.length>=100) data.content += '...';
- parent.innerHTML = repl('
', data);
-
- // adjust page height depending on sidebar height
- erpnext.blog.adjust_page_height(wrapper);
- },
- page_length: 5,
- });
- wrapper.recent_list.run();
-}
-
-erpnext.blog.toggle_no_result = function(wrapper) {
- if (!wrapper) { wrapper = erpnext.blog.wrapper; }
- if (!wrapper) { return; }
-
- var $blog_comments = $(wrapper).find('.blog-comments');
- var $comment_rows = $blog_comments.find('.comment-row');
- var $no_result = $blog_comments.find('.no-result');
-
- if ($comment_rows.length == 0) {
- $no_result.removeClass('hide');
- } else {
- $no_result.addClass('hide');
+ if(n_comments > 50) {
+ $(".add-comment").toggle(false)
+ .parent().append("
Comments are closed.
")
}
-}
-
-erpnext.blog.make_comment_dialog = function(wrapper) {
- if (!wrapper) { wrapper = erpnext.blog.wrapper; }
- if (!wrapper) { return; }
-
- var $comment_btn = $(wrapper).find('button.add-comment');
-
- $comment_btn.click(function() {
- if(!erpnext.blog.comment_dialog) {
- var d = new wn.ui.Dialog({
- title: 'Add Comment',
- fields: [
- {
- fieldname: 'comment_by_fullname', label: 'Your Name',
- reqd: 1, fieldtype: 'Data'
- },
- {
- fieldname: 'comment_by', label: 'Email Id',
- reqd: 1, fieldtype: 'Data'
- },
- {
- fieldname: 'comment', label: 'Comment',
- reqd: 1, fieldtype: 'Text'
- },
- {
- fieldname: 'post_comment', label: 'Post Comment',
- fieldtype: 'Button'
- },
- ],
- });
-
- erpnext.blog.comment_dialog = d;
+ $(".add-comment").click(function() {
+ $("#comment-form").toggle();
+ $("#comment-form input, #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(),
+ cmd: "website.helpers.blog.add_comment",
+ comment_doctype: "Blog",
+ comment_docname: "{{ name }}",
+ page_name: "{{ page_name }}"
}
- erpnext.blog.comment_dialog.fields_dict.post_comment
- .input.onclick = function() {
- erpnext.blog.add_comment(wrapper);
+ $("#comment-form .alert").toggle(false);
+
+ if(!args.comment_by_fullname || !args.comment_by || !args.comment) {
+ $("#comment-form .alert")
+ .html("All fields are necessary to submit the comment.")
+ .toggle(true);
+ return false;
}
- erpnext.blog.comment_dialog.show();
- });
-
-}
-
-erpnext.blog.add_comment = function(wrapper) {
- var args = erpnext.blog.comment_dialog.get_values();
-
- if(!args) return;
-
- args.comment_doctype = 'Blog';
- args.comment_docname = '{{ name }}';
- args.page_name = '{{ page_name }}';
-
- wn.call({
- method: 'website.helpers.blog.add_comment',
- args: args,
- btn: this,
- callback: function(r) {
- if(!r.exc) {
- erpnext.blog.add_comment_to_page(wrapper, r.message);
- erpnext.blog.comment_dialog.hide();
+
+ $.ajax({
+ method: "POST",
+ url: "server.py",
+ data: args,
+ dataType: "json",
+ success: function(data) {
+ if(data.exc) {
+ $("#comment-form .alert")
+ .html(data.exc)
+ .toggle(true)
+ } else {
+ $(data.message).appendTo(".blog-comments");
+ $(".no_comment").toggle(false);
+ $(".add-comment").toggle(false);
+ $("#comment-form")
+ .replaceWith("
Thank you for your comment!
")
+ }
}
- }
- });
-}
-
-erpnext.blog.add_comment_to_page = function(wrapper, comment) {
- $blog_comments = $(wrapper).find('.blog-comments');
- $comment_rows = $blog_comments.find('.comment-row');
-
- if ($comment_rows.length) {
- $blog_comments.append(comment);
- } else {
- $blog_comments.append(comment);
- }
-
- erpnext.blog.toggle_no_result(wrapper);
- erpnext.blog.toggle_add_comment_btn(wrapper);
-}
-
-erpnext.blog.toggle_add_comment_btn = function(wrapper) {
- var $wrapper = $(wrapper);
- if ($wrapper.find('.blog-comments .comment-row').length > 50) {
- var $comment_btn = $wrapper.find('button.add-comment');
- $comment_btn.addClass('hide');
+ })
- // show comments are close
- $wrapper.find('.blog-comments').append("\
-
\
-
Comments Closed
\
-
\
-
");
- }
-}
\ No newline at end of file
+ return false;
+ })
+})
\ No newline at end of file
diff --git a/website/templates/js/login.js b/website/templates/js/login.js
index eb3a65c9b3..b57db49e0e 100644
--- a/website/templates/js/login.js
+++ b/website/templates/js/login.js
@@ -1,13 +1,13 @@
-wn.provide('erpnext.login');
+var login = {};
$(document).ready(function(wrapper) {
- $('#login_btn').click(erpnext.login.doLogin)
+ $('#login_btn').click(login.do_login)
$('#password').keypress(function(ev){
if(ev.which==13 && $('#password').val()) {
$('form').submit(function() {
- erpnext.login.doLogin();
+ login.do_login();
return false;
});
}
@@ -16,54 +16,60 @@ $(document).ready(function(wrapper) {
})
// Login
-erpnext.login.doLogin = function(){
+login.do_login = function(){
var args = {};
args['usr']=$("#login_id").val();
args['pwd']=$("#password").val();
if(!args.usr || !args.pwd) {
- msgprint("Sorry, you can't login if you don't enter both the email id and password.")
+ login.set_message("Both login and password required.");
}
- $('#login_btn').set_working();
- $('#login_message').empty();
+ $('#login_btn').attr("disabled", "disabled");
+ $('#login_message').toggle(false);
+
+ $.ajax({
+ type: "POST",
+ url: "server.py",
+ data: {cmd:"login", usr:args.usr, pwd: args.pwd},
+ dataType: "json",
+ success: function(data) {
+ $('#login_btn').attr("disabled", false);
+ if(data.message=="Logged In") {
+ window.location.href = "app.html";
+ } else {
+ login.set_message(data.message);
+ }
+ }
+ })
- $c("login", args, function(r, rtext) {
- $('#login_btn').done_working();
- if(r.message=="Logged In"){
- window.location.href='app.html' + (get_url_arg('page')
- ? ('?page='+get_url_arg('page')) : '');
- } else {
- $i('login_message').innerHTML = '
'
- +(r.message)+'';
- }
- });
-
return false;
}
-
-erpnext.login.show_forgot_password = function(){
+login.show_forgot_password = function(){
// create dialog
- var d = new wn.ui.Dialog({
- title:"Forgot Password",
- fields: [
- {'label':'Email Id', 'fieldname':'email_id', 'fieldtype':'Data', 'reqd':true},
- {'label':'Email Me A New Password', 'fieldname':'run', 'fieldtype':'Button'}
- ]
- });
+ var login_id = $("#login_id").val();
+ if(!login_id || !valid_email(login_id)) {
+ login.set_message("Please set your login id (which is your email where the password will be sent);");
+ return;
+ }
+ login.set_message("Sending email with new password...");
+ $("#forgot-password").remove();
- $(d.fields_dict.run.input).click(function() {
- var values = d.get_values();
- if(!values) return;
- wn.call({
- method:'reset_password',
- args: { user: values.email_id },
- callback: function() {
- d.hide();
- }
- })
+ $.ajax({
+ method: "POST",
+ url: "server.py",
+ data: {
+ cmd: "reset_password",
+ user: login_id
+ },
+ success: function(data) {
+ login.set_message("A new password has been sent to your email id.", "GREEN");
+ }
})
- d.show();
+}
+
+login.set_message = function(message, color) {
+ $('#login_message').html(message).toggle(true);
}
\ No newline at end of file
diff --git a/website/templates/pages/blog.html b/website/templates/pages/blog.html
index c4a5dad3d9..75681d5045 100644
--- a/website/templates/pages/blog.html
+++ b/website/templates/pages/blog.html
@@ -2,7 +2,6 @@
{% block javascript %}
{% include "js/blog.js" %}
- {% include "js/blog_subscribe.js" %}
{% endblock %}
{% block css %}
@@ -18,9 +17,12 @@
diff --git a/website/templates/pages/login.html b/website/templates/pages/login.html
index a81b2f5cea..0828f65ae3 100644
--- a/website/templates/pages/login.html
+++ b/website/templates/pages/login.html
@@ -14,6 +14,7 @@
{% block body %}
Be the first one to comment
-