mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-22 14:39:19 +00:00
Redesigned templates. Now all templates must be inside templates/pages templates/generators
This commit is contained in:
294
erpnext/templates/includes/cart.js
Normal file
294
erpnext/templates/includes/cart.js
Normal file
@@ -0,0 +1,294 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
// js inside blog page
|
||||
|
||||
$(document).ready(function() {
|
||||
erpnext.cart.bind_events();
|
||||
return wn.call({
|
||||
type: "POST",
|
||||
method: "erpnext.selling.utils.cart.get_cart_quotation",
|
||||
callback: function(r) {
|
||||
$("#cart-container").removeClass("hide");
|
||||
$(".progress").remove();
|
||||
if(r.exc) {
|
||||
if(r.exc.indexOf("WebsitePriceListMissingError")!==-1) {
|
||||
erpnext.cart.show_error("Oops!", wn._("Price List not configured."));
|
||||
} else if(r["403"]) {
|
||||
erpnext.cart.show_error("Hey!", wn._("You need to be logged in to view your cart."));
|
||||
} else {
|
||||
erpnext.cart.show_error("Oops!", wn._("Something went wrong."));
|
||||
}
|
||||
} else {
|
||||
erpnext.cart.set_cart_count();
|
||||
erpnext.cart.render(r.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// shopping cart
|
||||
if(!erpnext.cart) erpnext.cart = {};
|
||||
$.extend(erpnext.cart, {
|
||||
show_error: function(title, text) {
|
||||
$("#cart-container").html('<div class="well"><h4>' + title + '</h4> ' + text + '</div>');
|
||||
},
|
||||
|
||||
bind_events: function() {
|
||||
// bind update button
|
||||
$(document).on("click", ".item-update-cart button", function() {
|
||||
var item_code = $(this).attr("data-item-code");
|
||||
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) {
|
||||
erpnext.cart.render(r.message);
|
||||
var $button = $('button[data-item-code="'+item_code+'"]').addClass("btn-success");
|
||||
setTimeout(function() { $button.removeClass("btn-success"); }, 1000);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$("#cart-add-shipping-address").on("click", function() {
|
||||
window.location.href = "address?address_fieldname=shipping_address_name";
|
||||
});
|
||||
|
||||
$("#cart-add-billing-address").on("click", function() {
|
||||
window.location.href = "address?address_fieldname=customer_address";
|
||||
});
|
||||
|
||||
$(".btn-place-order").on("click", function() {
|
||||
erpnext.cart.place_order(this);
|
||||
});
|
||||
},
|
||||
|
||||
render: function(out) {
|
||||
var doclist = out.doclist;
|
||||
var addresses = out.addresses;
|
||||
|
||||
var $cart_items = $("#cart-items").empty();
|
||||
var $cart_taxes = $("#cart-taxes").empty();
|
||||
var $cart_totals = $("#cart-totals").empty();
|
||||
var $cart_billing_address = $("#cart-billing-address").empty();
|
||||
var $cart_shipping_address = $("#cart-shipping-address").empty();
|
||||
|
||||
var no_items = $.map(doclist, function(d) { return d.item_code || null;}).length===0;
|
||||
if(no_items) {
|
||||
erpnext.cart.show_error("Empty :-(", wn._("Go ahead and add something to your cart."));
|
||||
$("#cart-addresses").toggle(false);
|
||||
return;
|
||||
}
|
||||
|
||||
var shipping_rule_added = false;
|
||||
var taxes_exist = false;
|
||||
var shipping_rule_labels = $.map(out.shipping_rules || [], function(rule) { return rule[1]; });
|
||||
$.each(doclist, function(i, doc) {
|
||||
if(doc.doctype === "Quotation Item") {
|
||||
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;
|
||||
erpnext.cart.render_tax_row($cart_taxes, doc, out.shipping_rules);
|
||||
} else {
|
||||
erpnext.cart.render_tax_row($cart_taxes, doc);
|
||||
}
|
||||
|
||||
taxes_exist = true;
|
||||
}
|
||||
});
|
||||
|
||||
if(out.shipping_rules && out.shipping_rules.length && !shipping_rule_added) {
|
||||
erpnext.cart.render_tax_row($cart_taxes, {description: "", formatted_tax_amount: ""},
|
||||
out.shipping_rules);
|
||||
taxes_exist = true;
|
||||
}
|
||||
|
||||
if(taxes_exist)
|
||||
$('<hr>').appendTo($cart_taxes);
|
||||
|
||||
erpnext.cart.render_tax_row($cart_totals, {
|
||||
description: "<strong>Total</strong>",
|
||||
formatted_tax_amount: "<strong>" + doclist[0].formatted_grand_total_export + "</strong>"
|
||||
});
|
||||
|
||||
if(!(addresses && addresses.length)) {
|
||||
$cart_shipping_address.html('<div class="well">'+wn._("Hey! Go ahead and add an address")+'</div>');
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
render_item_row: function($cart_items, doc) {
|
||||
doc.image_html = doc.website_image ?
|
||||
'<div style="height: 120px; overflow: hidden;"><img src="' + doc.website_image + '" /></div>' :
|
||||
'{% include "stock/doctype/item/templates/includes/product_missing_image.html" %}';
|
||||
|
||||
if(doc.description === doc.item_name) doc.description = "";
|
||||
|
||||
$(repl('<div class="row">\
|
||||
<div class="col-md-9 col-sm-9">\
|
||||
<div class="row">\
|
||||
<div class="col-md-3">%(image_html)s</div>\
|
||||
<div class="col-md-9">\
|
||||
<h4><a href="%(page_name)s">%(item_name)s</a></h4>\
|
||||
<p>%(description)s</p>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="col-md-3 col-sm-3 text-right">\
|
||||
<div class="input-group item-update-cart">\
|
||||
<input type="text" placeholder="Qty" value="%(qty)s" \
|
||||
data-item-code="%(item_code)s" class="text-right form-control">\
|
||||
<div class="input-group-btn">\
|
||||
<button class="btn btn-primary" data-item-code="%(item_code)s">\
|
||||
<i class="icon-ok"></i></button>\
|
||||
</div>\
|
||||
</div>\
|
||||
<p style="margin-top: 10px;">at %(formatted_rate)s</p>\
|
||||
<small class="text-muted" style="margin-top: 10px;">= %(formatted_amount)s</small>\
|
||||
</div>\
|
||||
</div><hr>', doc)).appendTo($cart_items);
|
||||
},
|
||||
|
||||
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>';
|
||||
}
|
||||
|
||||
var $tax_row = $(repl('<div class="row">\
|
||||
<div class="col-md-9 col-sm-9">\
|
||||
<div class="row">\
|
||||
<div class="col-md-9 col-md-offset-3">' +
|
||||
(shipping_selector || '<p>%(description)s</p>') +
|
||||
'</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
<div class="col-md-3 col-sm-3 text-right">\
|
||||
<p' + (shipping_selector ? ' style="margin-top: 5px;"' : "") + '>%(formatted_tax_amount)s</p>\
|
||||
</div>\
|
||||
</div>', doc)).appendTo($cart_taxes);
|
||||
|
||||
if(shipping_selector) {
|
||||
$tax_row.find('select option').each(function(i, opt) {
|
||||
if($(opt).html() == doc.description) {
|
||||
$(opt).attr("selected", "selected");
|
||||
}
|
||||
});
|
||||
$tax_row.find('select').on("change", function() {
|
||||
erpnext.cart.apply_shipping_rule($(this).val(), this);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
apply_shipping_rule: function(rule, btn) {
|
||||
return wn.call({
|
||||
btn: btn,
|
||||
type: "POST",
|
||||
method: "erpnext.selling.utils.cart.apply_shipping_rule",
|
||||
args: { shipping_rule: rule },
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
erpnext.cart.render(r.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
render_address: function($address_wrapper, addresses, address_name) {
|
||||
$.each(addresses, function(i, address) {
|
||||
$(repl('<div class="panel panel-default"> \
|
||||
<div class="panel-heading"> \
|
||||
<div class="row"> \
|
||||
<div class="col-md-10 address-title" \
|
||||
data-address-name="%(name)s"><strong>%(name)s</strong></div> \
|
||||
<div class="col-md-2"><input type="checkbox" \
|
||||
data-address-name="%(name)s"></div> \
|
||||
</div> \
|
||||
</div> \
|
||||
<div class="panel-collapse collapse" data-address-name="%(name)s"> \
|
||||
<div class="panel-body">%(display)s</div> \
|
||||
</div> \
|
||||
</div>', address))
|
||||
.css({"margin": "10px auto"})
|
||||
.appendTo($address_wrapper);
|
||||
});
|
||||
|
||||
$address_wrapper.find(".panel-heading")
|
||||
.find(".address-title")
|
||||
.css({"cursor": "pointer"})
|
||||
.on("click", function() {
|
||||
$address_wrapper.find('.panel-collapse[data-address-name="'
|
||||
+$(this).attr("data-address-name")+'"]').collapse("toggle");
|
||||
});
|
||||
|
||||
$address_wrapper.find('input[type="checkbox"]').on("click", function() {
|
||||
if($(this).prop("checked")) {
|
||||
var me = this;
|
||||
$address_wrapper.find('input[type="checkbox"]').each(function(i, chk) {
|
||||
if($(chk).attr("data-address-name")!=$(me).attr("data-address-name")) {
|
||||
$(chk).prop("checked", false);
|
||||
}
|
||||
});
|
||||
|
||||
return wn.call({
|
||||
type: "POST",
|
||||
method: "erpnext.selling.utils.cart.update_cart_address",
|
||||
args: {
|
||||
address_fieldname: $address_wrapper.attr("data-fieldname"),
|
||||
address_name: $(this).attr("data-address-name")
|
||||
},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
erpnext.cart.render(r.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$address_wrapper.find('input[type="checkbox"][data-address-name="'+ address_name +'"]')
|
||||
.prop("checked", true);
|
||||
|
||||
$address_wrapper.find(".panel-collapse").collapse({
|
||||
parent: $address_wrapper,
|
||||
toggle: false
|
||||
});
|
||||
|
||||
$address_wrapper.find('.panel-collapse[data-address-name="'+ address_name +'"]')
|
||||
.collapse("show");
|
||||
},
|
||||
|
||||
place_order: function(btn) {
|
||||
return wn.call({
|
||||
type: "POST",
|
||||
method: "erpnext.selling.utils.cart.place_order",
|
||||
btn: btn,
|
||||
callback: function(r) {
|
||||
if(r.exc) {
|
||||
var msg = "";
|
||||
if(r._server_messages) {
|
||||
msg = JSON.parse(r._server_messages || []).join("<br>");
|
||||
}
|
||||
|
||||
$("#cart-error")
|
||||
.empty()
|
||||
.html(msg || wn._("Something went wrong!"))
|
||||
.toggle(true);
|
||||
} else {
|
||||
window.location.href = "order?name=" + encodeURIComponent(r.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
36
erpnext/templates/includes/footer_extension.html
Normal file
36
erpnext/templates/includes/footer_extension.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="input-group col-sm-6 col-sm-offset-3" style="margin-top: 7px;">
|
||||
<input class="form-control" type="text" id="footer-subscribe-email" placeholder="Your email address...">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button" id="footer-subscribe-button">Stay Updated</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$("#footer-subscribe-button").click(function() {
|
||||
|
||||
$("#footer-subscribe-email").attr('disabled', true);
|
||||
$("#footer-subscribe-button").html("Sending...")
|
||||
.attr("disabled", true);
|
||||
|
||||
if($("#footer-subscribe-email").val()) {
|
||||
erpnext.send_message({
|
||||
subject:"Subscribe me",
|
||||
sender: $("#footer-subscribe-email").val(),
|
||||
message: "Subscribe to newsletter (via website footer).",
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
$("#footer-subscribe-button").html("Thank You :)")
|
||||
.addClass("btn-success").attr("disabled", true);
|
||||
} else {
|
||||
$("#footer-subscribe-button").html("Error :( Not a valid id?")
|
||||
.addClass("btn-danger").attr("disabled", false);
|
||||
$("#footer-subscribe-email").val("").attr('disabled', false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
1
erpnext/templates/includes/footer_powered.html
Normal file
1
erpnext/templates/includes/footer_powered.html
Normal file
@@ -0,0 +1 @@
|
||||
<a href="http://erpnext.org" style="color: #aaa;">ERPNext Powered</a>
|
||||
10
erpnext/templates/includes/product_breadcrumbs.html
Normal file
10
erpnext/templates/includes/product_breadcrumbs.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{% if obj.parent_groups and (obj.parent_groups|length) > 1 %}
|
||||
<div class="container">
|
||||
<ul class="breadcrumb">
|
||||
{% for ig in obj.parent_groups[:-1] %}
|
||||
<li><a href="{{ ig.page_name }}.html">{{ ig.name }}</a></li>
|
||||
{% endfor %}
|
||||
<li class="active">{{ obj.parent_groups[-1].name }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
14
erpnext/templates/includes/product_in_grid.html
Normal file
14
erpnext/templates/includes/product_in_grid.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<div class="col-md-3">
|
||||
<div style="height: 120px; overflow: hidden;">
|
||||
<a href="{{ page_name }}">
|
||||
{%- if website_image -%}
|
||||
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
|
||||
{%- else -%}
|
||||
{% include 'stock/doctype/item/templates/includes/product_missing_image.html' %}
|
||||
{%- endif -%}
|
||||
</a>
|
||||
</div>
|
||||
<div style="height: 100px; overflow: hidden; font-size: 80%;">
|
||||
<h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
|
||||
</div>
|
||||
</div>
|
||||
15
erpnext/templates/includes/product_in_list.html
Normal file
15
erpnext/templates/includes/product_in_list.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!-- TODO product listing -->
|
||||
<div class="container content">
|
||||
<div style="height: 120px; overflow: hidden;">
|
||||
<a href="{{ page_name }}">
|
||||
{%- if website_image -%}
|
||||
<img class="product-image" style="width: 80%; margin: auto;" src="{{ website_image }}">
|
||||
{%- else -%}
|
||||
{% include 'website/templates/html/product_missing_image.html' %}
|
||||
{%- endif -%}
|
||||
</a>
|
||||
</div>
|
||||
<div style="height: 100px; overflow: hidden; font-size: 80%;">
|
||||
<h4 style="margin-bottom: 2px;"><a href="{{ page_name }}">{{ item_name }}</a></h4>
|
||||
</div>
|
||||
</div>
|
||||
52
erpnext/templates/includes/product_list.js
Normal file
52
erpnext/templates/includes/product_list.js
Normal file
@@ -0,0 +1,52 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
window.get_product_list = function() {
|
||||
$(".more-btn .btn").click(function() {
|
||||
window.get_product_list()
|
||||
});
|
||||
|
||||
if(window.start==undefined) {
|
||||
throw "product list not initialized (no start)"
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/",
|
||||
dataType: "json",
|
||||
data: {
|
||||
cmd: "erpnext.selling.utils.product.get_product_list",
|
||||
start: window.start,
|
||||
search: window.search,
|
||||
product_group: window.product_group
|
||||
},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
window.render_product_list(data.message);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
window.render_product_list = function(data) {
|
||||
if(data.length) {
|
||||
var table = $("#search-list .table");
|
||||
if(!table.length)
|
||||
var table = $("<table class='table'>").appendTo("#search-list");
|
||||
|
||||
$.each(data, function(i, d) {
|
||||
$(d).appendTo(table);
|
||||
});
|
||||
}
|
||||
if(data.length < 10) {
|
||||
if(!table) {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='alert alert-warning'>No products found.</div>");
|
||||
} else {
|
||||
$(".more-btn")
|
||||
.replaceWith("<div class='text-muted'>Nothing more to show.</div>");
|
||||
}
|
||||
} else {
|
||||
$(".more-btn").toggle(true)
|
||||
}
|
||||
window.start += (data.length || 0);
|
||||
}
|
||||
1
erpnext/templates/includes/product_missing_image.html
Normal file
1
erpnext/templates/includes/product_missing_image.html
Normal file
@@ -0,0 +1 @@
|
||||
<div class="missing-image"><i class="icon-camera"></i></div>
|
||||
13
erpnext/templates/includes/product_page.css
Normal file
13
erpnext/templates/includes/product_page.css
Normal file
@@ -0,0 +1,13 @@
|
||||
<style>
|
||||
.item-main-image {
|
||||
max-width: 100%;
|
||||
margin: auto;
|
||||
}
|
||||
.web-long-description {
|
||||
font-size: 18px;
|
||||
line-height: 200%;
|
||||
}
|
||||
.item-stock {
|
||||
margin-bottom: 10px !important;
|
||||
}
|
||||
</style>
|
||||
78
erpnext/templates/includes/product_page.js
Normal file
78
erpnext/templates/includes/product_page.js
Normal file
@@ -0,0 +1,78 @@
|
||||
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
|
||||
// License: GNU General Public License v3. See license.txt
|
||||
|
||||
$(document).ready(function() {
|
||||
var item_code = $('[itemscope] [itemprop="productID"]').text().trim();
|
||||
var qty = 0;
|
||||
|
||||
wn.call({
|
||||
type: "POST",
|
||||
method: "erpnext.selling.utils.product.get_product_info",
|
||||
args: {
|
||||
item_code: "{{ name }}"
|
||||
},
|
||||
callback: function(r) {
|
||||
if(r.message && r.message.price) {
|
||||
$(".item-price")
|
||||
.html(r.message.price.formatted_price + " per " + r.message.uom);
|
||||
|
||||
if(r.message.stock==0) {
|
||||
$(".item-stock").html("<div class='help'>Not in stock</div>");
|
||||
}
|
||||
else if(r.message.stock==1) {
|
||||
$(".item-stock").html("<div style='color: green'>\
|
||||
<i class='icon-check'></i> Available (in stock)</div>");
|
||||
}
|
||||
|
||||
$(".item-price-info").toggle(true);
|
||||
|
||||
if(r.message.qty) {
|
||||
qty = r.message.qty;
|
||||
toggle_update_cart(qty);
|
||||
$("#item-update-cart input").val(qty);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
$("#item-add-to-cart button").on("click", function() {
|
||||
erpnext.cart.update_cart({
|
||||
item_code: item_code,
|
||||
qty: 1,
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
toggle_update_cart(1);
|
||||
qty = 1;
|
||||
}
|
||||
},
|
||||
btn: this,
|
||||
});
|
||||
});
|
||||
|
||||
$("#item-update-cart button").on("click", function() {
|
||||
erpnext.cart.update_cart({
|
||||
item_code: item_code,
|
||||
qty: $("#item-update-cart input").val(),
|
||||
btn: this,
|
||||
callback: function(r) {
|
||||
if(r.exc) {
|
||||
$("#item-update-cart input").val(qty);
|
||||
} else {
|
||||
qty = $("#item-update-cart input").val();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
if(localStorage && localStorage.getItem("pending_add_to_cart") && full_name) {
|
||||
localStorage.removeItem("pending_add_to_cart");
|
||||
$("#item-add-to-cart button").trigger("click");
|
||||
}
|
||||
});
|
||||
|
||||
var toggle_update_cart = function(qty) {
|
||||
$("#item-add-to-cart").toggle(qty ? false : true);
|
||||
$("#item-update-cart")
|
||||
.toggle(qty ? true : false)
|
||||
.find("input").val(qty);
|
||||
}
|
||||
28
erpnext/templates/includes/product_search_box.html
Normal file
28
erpnext/templates/includes/product_search_box.html
Normal file
@@ -0,0 +1,28 @@
|
||||
<div class="container" style="margin-bottom: 7px;">
|
||||
<form class="form-inline form-search row">
|
||||
<div class="input-group col-md-4 col-md-offset-8">
|
||||
<input class="form-control" type="text" id="product-search" placeholder="Product Search...">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button" id="btn-product-search">
|
||||
<i class="icon-search"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
// redirect to product search page
|
||||
$(document).ready(function() {
|
||||
$('.dropdown-toggle').dropdown();
|
||||
$("#btn-product-search").click(function() {
|
||||
var txt = $("#product-search").val();
|
||||
if(txt) {
|
||||
window.location.href="product_search?q=" + txt;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$("#product-search").keypress(function(e) {
|
||||
if(e.which==13) $("#btn-product-search").click();
|
||||
});
|
||||
$(".form-search").on("submit", function() { return false; });
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
60
erpnext/templates/includes/transactions.html
Normal file
60
erpnext/templates/includes/transactions.html
Normal file
@@ -0,0 +1,60 @@
|
||||
{% extends base_template %}
|
||||
|
||||
{% block content -%}
|
||||
<div class="container content">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="index">Home</a></li>
|
||||
<li class="active"><i class="{{ icon }} icon-fixed-width"></i> {{ title }}</li>
|
||||
</ul>
|
||||
<p id="msgprint-alert" class="alert alert-danger"
|
||||
style="display: none;"> </p>
|
||||
<div class="list-group transaction-list">
|
||||
<div class="progress progress-striped active">
|
||||
<div class="progress-bar progress-bar-info" style="width: 100%;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-default btn-show-more hide">More</button>
|
||||
</div>
|
||||
</div>
|
||||
{%- endblock %}
|
||||
|
||||
{% block javascript -%}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
window.start = 0;
|
||||
window.$list = $(".transaction-list");
|
||||
window.$show_more = $(".btn-show-more").on("click", function() { get_transactions(this); })
|
||||
|
||||
get_transactions();
|
||||
});
|
||||
|
||||
var get_transactions = function(btn) {
|
||||
wn.call({
|
||||
method: "{{ method }}",
|
||||
args: { start: start },
|
||||
btn: btn,
|
||||
callback: function(r) {
|
||||
$list.find(".progress").remove();
|
||||
$show_more.toggleClass("hide", !(r.message && r.message.length===20));
|
||||
if(!(r.message && r.message.length)) {
|
||||
console.log("empty");
|
||||
if(!$list.html().trim()) {
|
||||
$list.html("<div class='alert alert-warning'>\
|
||||
{{ empty_list_message }}</div>");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
start += r.message.length;
|
||||
|
||||
$.each(r.message, function(i, doc) {
|
||||
render(doc);
|
||||
});
|
||||
}
|
||||
})
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- // var render = function(doc) { }; -->
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user