moved directory structure

This commit is contained in:
Rushabh Mehta
2012-09-24 19:13:42 +05:30
parent e47a6779e9
commit 2fa2f7178d
1637 changed files with 47 additions and 11450 deletions

View File

@@ -0,0 +1,43 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// 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.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.'
} else {
data.comment_text = data.comments + ' comments.'
}
if(data.content && data.content.length==1000) {
data.content += repl('... <a href="%(name)s.html">(read on)</a>', data);
}
parent.innerHTML = repl('<h2><a href="%(name)s.html">%(title)s</a></h2>\
<div class="help">%(comment_text)s</div>\
%(content)s<br /><br />', data);
},
page_length: 10
});
erpnext.blog_list.run();
}

View File

@@ -0,0 +1,181 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// js inside blog page
wn.provide('erpnext.blog');
wn.pages['{{ name }}'].onload = function(wrapper) {
erpnext.blog.wrapper = wrapper;
// 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());
}
}
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.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('<div style="font-size: 80%">\
<a href="%(page_name)s.html">%(title)s</a>\
<div class="comment">%(content)s</div><br></div>', 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');
}
}
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.widgets.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;
}
erpnext.blog.comment_dialog.fields_dict.post_comment
.input.onclick = function() {
erpnext.blog.add_comment(wrapper);
}
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.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();
}
}
});
}
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("\
<div class=\"help\"> \
<p>Comments Closed</p> \
<br /> \
</div>");
}
}

View File

@@ -0,0 +1,33 @@
wn.provide('erpnext.blog');
(function() {
$('body').on('click', '.btn-blog-subscribe', function() {
var d = new wn.ui.Dialog({
title: "Get Blog Updates via Email",
fields: [
{label: "Your Name", fieldtype:"Data", reqd:1},
{label: "Your Email Address", fieldtype:"Data", reqd:1
,description: "You can unsubscribe anytime."},
{label: "Subscribe", fieldtype:"Button"}
]
});
$(d.fields_dict.subscribe.input).click(function() {
var args = d.get_values();
if(!args) return;
wn.call({
method: 'website.blog.add_subscriber',
args: args,
callback: function(r) {
if(r.exc) {
msgprint('Opps there seems to be some error, Please check back after some time.');
} else {
msgprint('Thanks for subscribing!');
}
d.hide();
},
btn: this
})
})
d.show()
})
})()

View File

@@ -0,0 +1,92 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
wn.provide('erpnext.login');
wn.pages["{{ name }}"].onload = function(wrapper) {
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
wrapper.appframe.title('Login');
wrapper.appframe.$w.find('.close').toggle(false);
var lw = $i('login_wrapper');
$bs(lw, '1px 1px 3px #888');
$('#login_btn').click(erpnext.login.doLogin)
$('#password').keypress(function(ev){
if(ev.which==13 && $('#password').val()) {
$('form').submit(function() {
erpnext.login.doLogin();
return false;
});
}
});
$(document).trigger('login_rendered');
}
// Login Callback
erpnext.login.onLoginReply = 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 = '<span style="color: RED;">'+(r.message)+'</span>';
//if(r.exc)alert(r.exc);
}
}
// Login
erpnext.login.doLogin = function(){
var args = {};
args['usr']=$i("login_id").value;
args['pwd']=$i("password").value;
if($i('remember_me').checked)
args['remember_me'] = 1;
$('#login_btn').set_working();
$('#login_message').empty();
$c("login", args, erpnext.login.onLoginReply);
return false;
}
erpnext.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'}
]
});
$(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();
}
})
})
d.show();
}

View File

@@ -0,0 +1,18 @@
wn.provide('erpnext.products');
erpnext.products.make_product_categories = function(wrapper) {
if (!wrapper) { wrapper = erpnext.products.wrapper; }
if (!wrapper) { return; }
wrapper.category_list = new wn.ui.Listing({
parent: $(wrapper).find('.more-categories').get(0),
method: 'website.product.get_product_category_list',
hide_refresh: true,
render_row: function(parent, data) {
parent.innerHTML = repl(
'<a href="products.html#!products/%(item_group)s">%(item_group)s</a> (%(items)s)',
data);
}
});
wrapper.category_list.run();
}

View File

@@ -0,0 +1,92 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
{% include "js/product_category.js" %}
wn.pages['{{ name }}'].onload = function(wrapper) {
wrapper.product_group = "{{ item_group }}";
wrapper.product_name = "{{ name }}";
erpnext.products.make_product_categories(wrapper);
erpnext.products.make_similar_products(wrapper);
// if website image missing, autogenerate one
var $img = $(wrapper).find('.product-page-content .img-area');
if ($img && $img.length > 0) {
$img.append(wn.dom.placeholder(160, "{{ item_name }}"));
}
erpnext.products.adjust_page_height(wrapper);
}
erpnext.products.adjust_page_height = function(wrapper) {
if (!wrapper) { wrapper = erpnext.products.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());
}
}
erpnext.products.make_similar_products = function(wrapper) {
if (!wrapper) { wrapper = erpnext.products.wrapper; }
if (!wrapper) { return; }
// similar products
wrapper.similar = new wn.ui.Listing({
parent: $(wrapper).find('.similar-products').get(0),
hide_refresh: true,
page_length: 5,
method: 'website.product.get_similar_product_list',
get_args: function() {
return {
product_group: wrapper.product_group,
product_name: wrapper.product_name
}
},
render_row: function(parent, data) {
if (!data.web_short_description) {
data.web_short_description = data.description;
}
if(data.web_short_description.length > 100) {
data.web_short_description =
data.web_short_description.substr(0,100) + '...';
}
parent.innerHTML = repl('\
<a href="%(page_name)s.html"><div class="img-area"></div></a>\
<div class="similar-product-description">\
<h5><a href="%(page_name)s.html">%(item_name)s</a></h5>\
<span>%(web_short_description)s</span>\
</div>\
<div style="clear:both"></div>', data);
if(data.website_image) {
$(parent).find('.img-area').append(repl(
'<img src="files/%(website_image)s" />', data))
} else {
$(parent).find('.img-area').append(wn.dom.placeholder(55,
data.item_name));
}
// adjust page height, if sidebar height keeps increasing
erpnext.products.adjust_page_height(wrapper);
}
});
wrapper.similar.run();
}

View File

@@ -0,0 +1,106 @@
// ERPNext - web based ERP (http://erpnext.com)
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// js inside blog page
{% include "js/product_category.js" %}
wn.pages['{{ name }}'].onload = function(wrapper) {
erpnext.products.wrapper = wrapper;
// make product categories in the sidebar
erpnext.products.make_product_categories(wrapper);
// make lists
erpnext.products.make_product_list(wrapper);
// bind search button or enter key
$(wrapper).find('.products-search .btn').click(function() {
erpnext.products.product_list.run();
});
$(wrapper).find('.products-search input').keypress(function(ev) {
if(ev.which==13) $(wrapper).find('.products-search .btn').click();
});
}
erpnext.products.make_product_list = function(wrapper) {
if (!wrapper) { wrapper = erpnext.products.wrapper; }
if (!wrapper) { return; }
erpnext.products.product_list = new wn.ui.Listing({
parent: $(wrapper).find('#products-list').get(0),
run_btn: $(wrapper).find('.products-search .btn').get(0),
no_toolbar: true,
method: 'website.product.get_product_list',
get_args: function() {
return {
search: $('input[name="products-search"]').val() || '',
product_group: erpnext.products.cur_group || '',
};
},
render_row: function(parent, data) {
if (!data.web_short_description) {
data.web_short_description = data.description;
}
parent.innerHTML = repl('\
<a href="%(page_name)s.html"><div class="img-area"></div></a>\
<div class="product-list-description">\
<h4><a href="%(page_name)s.html">%(item_name)s</a></h4>\
<p>%(web_short_description)s</p></div>\
<div style="clear: both;"></div>', data);
if(data.website_image) {
$(parent).find('.img-area').append(repl(
'<img src="files/%(website_image)s" style="width:100px;">', data))
} else {
$(parent).find('.img-area').append(wn.dom.placeholder(100,
data.item_name));
}
}
});
}
wn.pages['{{ name }}'].onshow = function(wrapper) {
// show default product category
erpnext.products.set_group();
}
erpnext.products.set_group = function() {
var cat = erpnext.products.get_group();
// get erpnext.products.default_category
var wrapper = erpnext.products.wrapper;
$(wrapper).find('h1').html(cat.label);
erpnext.products.product_list.run();
}
erpnext.products.get_group = function() {
route = wn.get_route();
if(route && route.length>1) {
// from url
var grp = route[1];
var label = route[1];
erpnext.products.cur_group = grp;
} else {
// default
var grp = 'Products';
var label = 'Products';
erpnext.products.cur_group = null;
}
return {grp:grp, label:label};
}