diff --git a/portal/templates/base.html b/portal/templates/base.html index cdbc045848d..bc6fb9755c6 100644 --- a/portal/templates/base.html +++ b/portal/templates/base.html @@ -1,23 +1,3 @@ {% extends "lib/website/templates/base.html" %} -{% block toolbar %} -
-
- {% if shopping_cart_enabled -%} - - | - {%- endif %} - Login -
-
- | - {% if shopping_cart_enabled -%} - - | - {%- endif %} - -
-
-{% endblock %} - {% block footer %}{% include "app/portal/templates/includes/footer.html" %}{% endblock %} \ No newline at end of file diff --git a/portal/templates/includes/cart.js b/portal/templates/includes/cart.js index 84d49f33c49..5ff6e3fb72f 100644 --- a/portal/templates/includes/cart.js +++ b/portal/templates/includes/cart.js @@ -4,7 +4,7 @@ // js inside blog page $(document).ready(function() { - wn.cart.bind_events(); + erpnext.cart.bind_events(); return wn.call({ type: "POST", method: "selling.utils.cart.get_cart_quotation", @@ -14,23 +14,23 @@ $(document).ready(function() { $(".progress").remove(); if(r.exc) { if(r.exc.indexOf("WebsitePriceListMissingError")!==-1) { - wn.cart.show_error("Oops!", "Price List not configured."); + erpnext.cart.show_error("Oops!", "Price List not configured."); } else if(r["403"]) { - wn.cart.show_error("Hey!", "You need to be logged in to view your cart."); + erpnext.cart.show_error("Hey!", "You need to be logged in to view your cart."); } else { - wn.cart.show_error("Oops!", "Something went wrong."); + erpnext.cart.show_error("Oops!", "Something went wrong."); } } else { - wn.cart.set_cart_count(); - wn.cart.render(r.message); + erpnext.cart.set_cart_count(); + erpnext.cart.render(r.message); } } }); }); // shopping cart -if(!wn.cart) wn.cart = {}; -$.extend(wn.cart, { +if(!erpnext.cart) erpnext.cart = {}; +$.extend(erpnext.cart, { show_error: function(title, text) { $("#cart-container").html('

' + title + '

' + text + '
'); }, @@ -39,14 +39,14 @@ $.extend(wn.cart, { // bind update button $(document).on("click", ".item-update-cart button", function() { var item_code = $(this).attr("data-item-code"); - wn.cart.update_cart({ + erpnext.cart.update_cart({ item_code: item_code, qty: $('input[data-item-code="'+item_code+'"]').val(), with_doclist: 1, btn: this, callback: function(r) { if(!r.exc) { - wn.cart.render(r.message); + erpnext.cart.render(r.message); var $button = $('button[data-item-code="'+item_code+'"]').addClass("btn-success"); setTimeout(function() { $button.removeClass("btn-success"); }, 1000); } @@ -63,7 +63,7 @@ $.extend(wn.cart, { }); $(".btn-place-order").on("click", function() { - wn.cart.place_order(); + erpnext.cart.place_order(this); }); }, @@ -79,7 +79,7 @@ $.extend(wn.cart, { var no_items = $.map(doclist, function(d) { return d.item_code || null;}).length===0; if(no_items) { - wn.cart.show_error("Empty :-(", "Go ahead and add something to your cart."); + erpnext.cart.show_error("Empty :-(", "Go ahead and add something to your cart."); $("#cart-addresses").toggle(false); return; } @@ -89,14 +89,14 @@ $.extend(wn.cart, { var shipping_rule_labels = $.map(out.shipping_rules || [], function(rule) { return rule[1]; }); $.each(doclist, function(i, doc) { if(doc.doctype === "Quotation Item") { - wn.cart.render_item_row($cart_items, doc); + erpnext.cart.render_item_row($cart_items, doc); } else if (doc.doctype === "Sales Taxes and Charges") { if(out.shipping_rules && out.shipping_rules.length && shipping_rule_labels.indexOf(doc.description)!==-1) { shipping_rule_added = true; - wn.cart.render_tax_row($cart_taxes, doc, out.shipping_rules); + erpnext.cart.render_tax_row($cart_taxes, doc, out.shipping_rules); } else { - wn.cart.render_tax_row($cart_taxes, doc); + erpnext.cart.render_tax_row($cart_taxes, doc); } taxes_exist = true; @@ -104,7 +104,7 @@ $.extend(wn.cart, { }); if(out.shipping_rules && out.shipping_rules.length && !shipping_rule_added) { - wn.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""}, + erpnext.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""}, out.shipping_rules); taxes_exist = true; } @@ -112,7 +112,7 @@ $.extend(wn.cart, { if(taxes_exist) $('
').appendTo($cart_taxes); - wn.cart.render_tax_row($cart_totals, { + erpnext.cart.render_tax_row($cart_totals, { description: "Total", formatted_tax_amount: "" + doclist[0].formatted_grand_total_export + "" }); @@ -120,8 +120,8 @@ $.extend(wn.cart, { if(!(addresses && addresses.length)) { $cart_shipping_address.html('
Hey! Go ahead and add an address
'); } else { - wn.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name); - wn.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address); + erpnext.cart.render_address($cart_shipping_address, addresses, doclist[0].shipping_address_name); + erpnext.cart.render_address($cart_billing_address, addresses, doclist[0].customer_address); } }, @@ -185,7 +185,7 @@ $.extend(wn.cart, { } }); $tax_row.find('select').on("change", function() { - wn.cart.apply_shipping_rule($(this).val(), this); + erpnext.cart.apply_shipping_rule($(this).val(), this); }); } }, @@ -198,7 +198,7 @@ $.extend(wn.cart, { args: { shipping_rule: rule }, callback: function(r) { if(!r.exc) { - wn.cart.render(r.message); + erpnext.cart.render(r.message); } } }); @@ -249,7 +249,7 @@ $.extend(wn.cart, { }, callback: function(r) { if(!r.exc) { - wn.cart.render(r.message); + erpnext.cart.render(r.message); } } }); @@ -270,10 +270,11 @@ $.extend(wn.cart, { .collapse("show"); }, - place_order: function() { + place_order: function(btn) { return wn.call({ type: "POST", method: "selling.utils.cart.place_order", + btn: btn, callback: function(r) { if(r.exc) { var msg = ""; diff --git a/portal/templates/includes/footer.html b/portal/templates/includes/footer.html index 1e8dd76142c..6963175d913 100644 --- a/portal/templates/includes/footer.html +++ b/portal/templates/includes/footer.html @@ -1,10 +1,6 @@ {% extends "lib/website/templates/includes/footer.html" %} -{% block powered %} -

- ERPNext Powered -

-{% endblock %} +{% block powered %}ERPNext Powered{% endblock %} {% block extension %}
diff --git a/portal/templates/includes/transactions.html b/portal/templates/includes/transactions.html index 23d5f812ea5..65651ca5c58 100644 --- a/portal/templates/includes/transactions.html +++ b/portal/templates/includes/transactions.html @@ -4,7 +4,6 @@
diff --git a/portal/templates/pages/account.html b/portal/templates/pages/account.html deleted file mode 100644 index da43dd24fa9..00000000000 --- a/portal/templates/pages/account.html +++ /dev/null @@ -1,27 +0,0 @@ -{% extends base_template %} - -{% set title="My Account" %} - -{% block content %} - -{% endblock %} \ No newline at end of file diff --git a/portal/templates/pages/account.py b/portal/templates/pages/account.py deleted file mode 100644 index 24b474a55c3..00000000000 --- a/portal/templates/pages/account.py +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals - -no_cache = True \ No newline at end of file diff --git a/portal/templates/pages/cart.html b/portal/templates/pages/cart.html index f2107728317..8b648e5cca4 100644 --- a/portal/templates/pages/cart.html +++ b/portal/templates/pages/cart.html @@ -13,7 +13,7 @@
- +


@@ -51,7 +51,7 @@

- +

{% endblock %} \ No newline at end of file diff --git a/portal/templates/pages/profile.html b/portal/templates/pages/profile.html index 65f3e379884..697190953be 100644 --- a/portal/templates/pages/profile.html +++ b/portal/templates/pages/profile.html @@ -6,7 +6,6 @@
diff --git a/portal/templates/sale.html b/portal/templates/sale.html index 3a49684863c..41ba297d3ab 100644 --- a/portal/templates/sale.html +++ b/portal/templates/sale.html @@ -6,7 +6,6 @@
diff --git a/public/js/website_utils.js b/public/js/website_utils.js index b5fea13bbe5..b42a986e2bb 100644 --- a/public/js/website_utils.js +++ b/public/js/website_utils.js @@ -2,7 +2,6 @@ // License: GNU General Public License v3. See license.txt if(!window.erpnext) erpnext = {}; -if(!window.wn) wn = {}; // Add / update a new Lead / Communication // subject, sender, description @@ -15,187 +14,20 @@ erpnext.send_message = function(opts) { }); } -wn.call = function(opts) { - if(opts.btn) { - $(opts.btn).prop("disabled", true); - } - - if(opts.msg) { - $(opts.msg).toggle(false); - } - - if(!opts.args) opts.args = {}; - - // get or post? - if(!opts.args._type) { - opts.args._type = opts.type || "GET"; - } - - // method - if(opts.method) { - opts.args.cmd = opts.method; - } - - // stringify - $.each(opts.args, function(key, val) { - if(typeof val != "string") { - opts.args[key] = JSON.stringify(val); - } - }); - - $.ajax({ - type: "POST", - url: "server.py", - data: opts.args, - dataType: "json", - success: function(data) { - if(opts.btn) { - $(opts.btn).prop("disabled", false); - } - if(data.exc) { - if(opts.btn) { - $(opts.btn).addClass("btn-danger"); - setTimeout(function() { $(opts.btn).removeClass("btn-danger"); }, 1000); - } - try { - var err = JSON.parse(data.exc); - if($.isArray(err)) { - err = err.join("\n"); - } - console.error ? console.error(err) : console.log(err); - } catch(e) { - console.log(data.exc); - } - } else{ - if(opts.btn) { - $(opts.btn).addClass("btn-success"); - setTimeout(function() { $(opts.btn).removeClass("btn-success"); }, 1000); - } - } - if(opts.msg && data.message) { - $(opts.msg).html(data.message).toggle(true); - } - if(opts.callback) - opts.callback(data); - }, - error: function(response) { - console.error ? console.error(response) : console.log(response); - } - }); - - return false; -} - // Setup the user tools // $(document).ready(function() { // update login - var full_name = getCookie("full_name"); - if(full_name) { - $("#user-tools").addClass("hide"); - $("#user-tools-post-login").removeClass("hide"); - $("#user-full-name").text(full_name); - } - - wn.cart.set_cart_count(); + erpnext.cart.set_cart_count(); $("#user-tools a").tooltip({"placement":"bottom"}); $("#user-tools-post-login a").tooltip({"placement":"bottom"}); }); -// Utility functions - -function valid_email(id) { - if(id.toLowerCase().search("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")==-1) - return 0; else return 1; } - -var validate_email = valid_email; - -function get_url_arg(name) { - name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); - var regexS = "[\\?&]"+name+"=([^&#]*)"; - var regex = new RegExp( regexS ); - var results = regex.exec( window.location.href ); - if(results == null) - return ""; - else - return decodeURIComponent(results[1]); -} - -function make_query_string(obj) { - var query_params = []; - $.each(obj, function(k, v) { query_params.push(encodeURIComponent(k) + "=" + encodeURIComponent(v)); }); - return "?" + query_params.join("&"); -} - -function repl(s, dict) { - if(s==null)return ''; - for(key in dict) { - s = s.split("%("+key+")s").join(dict[key]); - } - return s; -} - -function replace_all(s, t1, t2) { - return s.split(t1).join(t2); -} - -function getCookie(name) { - return getCookies()[name]; -} - -function getCookies() { - var c = document.cookie, v = 0, cookies = {}; - if (document.cookie.match(/^\s*\$Version=(?:"1"|1);\s*(.*)/)) { - c = RegExp.$1; - v = 1; - } - if (v === 0) { - c.split(/[,;]/).map(function(cookie) { - var parts = cookie.split(/=/, 2), - name = decodeURIComponent(parts[0].trimLeft()), - value = parts.length > 1 ? decodeURIComponent(parts[1].trimRight()) : null; - if(value && value.charAt(0)==='"') { - value = value.substr(1, value.length-2); - } - cookies[name] = value; - }); - } else { - c.match(/(?:^|\s+)([!#$%&'*+\-.0-9A-Z^`a-z|~]+)=([!#$%&'*+\-.0-9A-Z^`a-z|~]*|"(?:[\x20-\x7E\x80\xFF]|\\[\x00-\x7F])*")(?=\s*[,;]|$)/g).map(function($0, $1) { - var name = $0, - value = $1.charAt(0) === '"' - ? $1.substr(1, -1).replace(/\\(.)/g, "$1") - : $1; - cookies[name] = value; - }); - } - return cookies; -} - -if (typeof String.prototype.trimLeft !== "function") { - String.prototype.trimLeft = function() { - return this.replace(/^\s+/, ""); - }; -} -if (typeof String.prototype.trimRight !== "function") { - String.prototype.trimRight = function() { - return this.replace(/\s+$/, ""); - }; -} -if (typeof Array.prototype.map !== "function") { - Array.prototype.map = function(callback, thisArg) { - for (var i=0, n=this.length, a=[]; i")===-1 && txt.indexOf("