Merge pull request #9078 from netchampfaris/remove-globals

Lint and fix JS files
This commit is contained in:
Faris Ansari
2017-06-06 11:35:42 +05:30
committed by GitHub
138 changed files with 1280 additions and 1268 deletions

View File

@@ -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 @@ $.extend(shopping_cart, {
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 @@ $.extend(shopping_cart, {
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 @@ $.extend(shopping_cart, {
}
}
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 @@ frappe.ready(function() {
});
function show_terms() {
var html = $(".cart-terms").html();
frappe.msgprint(html);
var html = $(".cart-terms").html();
frappe.msgprint(html);
}

View File

@@ -13,7 +13,6 @@ window.get_product_list = function() {
$.ajax({
method: "GET",
url: "/",
dataType: "json",
data: {
cmd: "erpnext.templates.pages.product_search.get_product_list",
start: window.start,

View File

@@ -21,9 +21,9 @@ frappe.ready(function() {
$(".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 @@ frappe.ready(function() {
})
$("#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 @@ frappe.ready(function() {
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 @@ var toggle_update_cart = function(qty) {
}
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 @@ function get_item_code() {
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 @@ function get_item_code() {
}
throw "Unable to match variant";
} else {
return item_code;
return window.item_code;
}
}
@@ -126,6 +130,7 @@ function find_closest_match(selected_attribute, selected_attribute_value) {
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;

View File

@@ -47,7 +47,6 @@ frappe.ready(function() {
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 @@ frappe.ready(function() {
}
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 @@ frappe.ready(function() {
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;
}
});
}