Lint and fix JS files
diff --git a/erpnext/templates/includes/cart.js b/erpnext/templates/includes/cart.js
index ee98b23..51be954 100644
--- a/erpnext/templates/includes/cart.js
+++ b/erpnext/templates/includes/cart.js
@@ -4,7 +4,8 @@
// js inside blog page
// shopping cart
-frappe.provide("shopping_cart");
+frappe.provide("erpnext.shopping_cart");
+var shopping_cart = erpnext.shopping_cart;
$.extend(shopping_cart, {
show_error: function(title, text) {
@@ -18,7 +19,7 @@
shopping_cart.bind_change_qty();
shopping_cart.bind_dropdown_cart_buttons();
},
-
+
bind_address_select: function() {
$(".cart-addresses").find('input[data-address-name]').on("click", function() {
if($(this).prop("checked")) {
@@ -65,13 +66,13 @@
var newVal = $(this).val();
shopping_cart.shopping_cart_update(item_code, newVal);
});
-
- $(".cart-items").on('click', '.number-spinner button', function () {
+
+ $(".cart-items").on('click', '.number-spinner button', function () {
var btn = $(this),
input = btn.closest('.number-spinner').find('input'),
oldValue = input.val().trim(),
newVal = 0;
-
+
if (btn.attr('data-dir') == 'up') {
newVal = parseInt(oldValue) + 1;
} else {
@@ -80,17 +81,17 @@
}
}
input.val(newVal);
- var item_code = input.attr("data-item-code");
+ var item_code = input.attr("data-item-code");
shopping_cart.shopping_cart_update(item_code, newVal);
});
},
-
+
render_tax_row: function($cart_taxes, doc, shipping_rules) {
var shipping_selector;
if(shipping_rules) {
shipping_selector = '<select class="form-control">' + $.map(shipping_rules, function(rule) {
- return '<option value="' + rule[0] + '">' + rule[1] + '</option>' }).join("\n") +
- '</select>';
+ return '<option value="' + rule[0] + '">' + rule[1] + '</option>' }).join("\n") +
+ '</select>';
}
var $tax_row = $(repl('<div class="row">\
@@ -162,6 +163,6 @@
});
function show_terms() {
- var html = $(".cart-terms").html();
- frappe.msgprint(html);
+ var html = $(".cart-terms").html();
+ frappe.msgprint(html);
}
diff --git a/erpnext/templates/includes/product_list.js b/erpnext/templates/includes/product_list.js
index 28c626f..7f63c17 100644
--- a/erpnext/templates/includes/product_list.js
+++ b/erpnext/templates/includes/product_list.js
@@ -13,7 +13,6 @@
$.ajax({
method: "GET",
url: "/",
- dataType: "json",
data: {
cmd: "erpnext.templates.pages.product_search.get_product_list",
start: window.start,
diff --git a/erpnext/templates/includes/product_page.js b/erpnext/templates/includes/product_page.js
index 4d1446b..e61ead1 100644
--- a/erpnext/templates/includes/product_page.js
+++ b/erpnext/templates/includes/product_page.js
@@ -21,9 +21,9 @@
$(".item-stock").html("<div style='color: red'> <i class='fa fa-close'></i> Not in stock</div>");
}
else if(r.message.in_stock==1) {
- qty_display = "In stock"
+ var qty_display = "In stock";
if (r.message.show_stock_qty) {
- qty_display = "Available ("+r.message.stock_qty+ " in stock)"
+ qty_display = "Available ("+r.message.stock_qty+ " in stock)";
}
$(".item-stock").html("<div style='color: green'>\
<i class='fa fa-check'></i> "+__(qty_display)+"</div>");
@@ -40,7 +40,9 @@
})
$("#item-add-to-cart button").on("click", function() {
- shopping_cart.update_cart({
+ frappe.provide('erpnext.shopping_cart');
+
+ erpnext.shopping_cart.update_cart({
item_code: get_item_code(),
qty: 1,
callback: function(r) {
@@ -66,7 +68,7 @@
var item_code = find_closest_match(attribute, attribute_value);
if (!item_code) {
- msgprint(__("Cannot find a matching Item. Please select some other value for {0}.", [attribute]))
+ frappe.msgprint(__("Cannot find a matching Item. Please select some other value for {0}.", [attribute]))
throw e;
}
}
@@ -87,7 +89,8 @@
}
function get_item_code() {
- if(window.variant_info) {
+ var variant_info = window.variant_info;
+ if(variant_info) {
var attributes = get_selected_attributes();
var no_of_attributes = Object.keys(attributes).length;
@@ -102,9 +105,10 @@
var match = true;
for(var j in variant.attributes) {
if(attributes[variant.attributes[j].attribute]
- != variant.attributes[j].attribute_value) {
- match = false;
- break;
+ != variant.attributes[j].attribute_value
+ ) {
+ match = false;
+ break;
}
}
if(match) {
@@ -113,7 +117,7 @@
}
throw "Unable to match variant";
} else {
- return item_code;
+ return window.item_code;
}
}
@@ -126,6 +130,7 @@
var previous_no_of_attributes = 0;
var matched;
+ var variant_info = window.variant_info;
for(var i in variant_info) {
var variant = variant_info[i];
var match_score = 0;
diff --git a/erpnext/templates/pages/projects.js b/erpnext/templates/pages/projects.js
index ecacc34..99f0663 100644
--- a/erpnext/templates/pages/projects.js
+++ b/erpnext/templates/pages/projects.js
@@ -47,7 +47,6 @@
project: '{{ doc.name }}',
item_status: item_status,
},
- dataType: "json",
success: function(data) {
if(typeof data.message == 'undefined') {
$('.project-'+ item).html("No "+ item_status +" "+ item);
@@ -68,8 +67,7 @@
}
var more_items = function(item, item_status){
- if(item_status)
- {
+ if(item_status) {
var item_status = $('.project-'+ item +'-section .btn-group .bold').hasClass('btn-closed-'+ item)
? 'closed' : 'open';
}
@@ -83,14 +81,13 @@
start: start,
item_status: item_status,
},
- dataType: "json",
success: function(data) {
$(data.message).appendTo('.project-'+ item);
if(typeof data.message == 'undefined') {
$(".more-"+ item).toggle(false);
}
- start = start+10;
+ start = start+10;
}
});
}