updates to product_page (search) and kb fix

This commit is contained in:
Rushabh Mehta
2012-12-18 14:47:54 +05:30
parent 7adf17e95d
commit 647e0d1164
8 changed files with 131 additions and 100 deletions

View File

@@ -20,15 +20,19 @@
<div class="layout-wrapper layout-wrapper-background">
<div class="web-content" id="content-product-{{ name }}">
<div class="layout-main" style="padding: 30px;">
{% include 'html/product_search.html' %}
{% include 'html/product_search_box.html' %}
<h1>{{ item_name }}</h1>
<div class="product-page-content">
<div class="span6">
{% if website_image %}
<image class="item-main-image" src="files/{{ website_image }}" />
{% else %}
<div class="img-area"></div>
<span style="font-size: 11px">This is an auto-generated Image</span>
<div class="img-area">
<div style='background-color: #eee; padding: 40px;
width: 32px; font-size: 32px; color: #888;'>
<i class='icon-camera'></i></div>
</div>
{% endif %}
<br><br>
</div>
@@ -51,7 +55,7 @@
{% for d in obj.doclist.get(
{"doctype":"Item Website Specification"}) %}
<tr>
<td>{{ d.label }}</td>
<td style="min-width: 150px;">{{ d.label }}</td>
<td>{{ d.description }}</td>
</tr>
{% endfor %}

View File

@@ -1,9 +0,0 @@
<div class="pull-right">
<form class="form-search">
<div class="input-append">
<input type="text" class="span2 search-query" id="product-search">
<button class="btn"><i class="icon-search"></i></button>
</div>
</form>
</div>
<div class="clearfix"></div>

View File

@@ -0,0 +1,24 @@
<div class="pull-right">
<form class="form-search">
<div class="input-append">
<input type="text" class="span2 search-query" id="product-search">
<button class="btn" id="btn-product-search">
<i class="icon-search"></i></button>
</div>
</form>
<script>
// redirect to product search page
$(document).ready(function() {
$("#btn-product-search").click(function() {
var txt = $("#product-search").val();
if(txt) {
window.location.href="product_search.html?q=" + txt;
}
return false;
});
$("#product-search").keypress(function(e) {
if(e.which==13) $("#product-search-btn").click();
})
})
</script>
</div>

View File

@@ -0,0 +1,88 @@
{% extends "html/page.html" %}
{% block title %}Product Search{% endblock %}
{% block content %}
<script>
$(document).ready(function() {
var txt = get_url_arg("q");
$(".search-results").html("Search results for: " + txt);
window.start = 0;
var get_list = function() {
$.ajax({
method: "GET",
url: "server.py",
dataType: "json",
data: {
cmd: "website.helpers.product.get_product_list",
start: window.start,
search: txt
},
dataType: "json",
success: function(data) {
render(data.message);
}
})
}
var render = 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) {
if(!d.web_short_description)
d.web_short_description = "No description given."
var $tr = $(repl('<tr>\
<td style="width: 30%;">\
<img class="product-image" style="width: 80%;" src="files/%(website_image)s">\
</td>\
<td>\
<h4><a href="%(page_name)s">%(item_name)s</a></h4>\
<p class="help">Item Code: %(name)s</p>\
<p>%(web_short_description)s</p>\
</td>\
</tr>', d)).appendTo(table);
if(!d.website_image) {
$tr.find(".product-image").replaceWith("<div\
style='background-color: #eee; padding: 40px; \
width: 32px; font-size: 32px; color: #888;'>\
<i class='icon-camera'></i></div>");
}
});
}
if(data.length < 10) {
$(".more-btn").replaceWith("<div class='alert'>Nothing more to show</div>");
} else {
$(".more-btn").toggle(true)
}
window.start += (data.length || 0);
}
get_list();
$(".more-btn .btn").click(function() {
get_list()
});
});
</script>
<div class="layout-wrapper layout-wrapper-background">
<div class="web-content" id="content-product_search">
<div class="layout-main" style="padding: 30px;">
{% include 'html/product_search_box.html' %}
<h3 class="search-results">Search Results</h3>
<div id="search-list">
</div>
<div class="more-btn" style="text-align: middle; display: none;">
<button class="btn">More...</button>
</div>
</div>
</div>
</div>
{% endblock %}