summaryrefslogtreecommitdiff
path: root/design/templates/admin/insert_products.html
blob: b38389e28949d5f8a72c029d80395651a1a9a202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{% load get_image_by_size %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<style>
.item-wrapper {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 6px;
    font-family: sans-serif;
    font-size: 11px;
    padding: 6px 0 4px;
    border-top: #ccc 1px solid;
}
.item { }
.item img { margin: 0 0 4px 0;}
h5 {
    max-width: 180px;
    font-size: 18px;
    line-height: 22px;
    margin: 12px;
}
.actions {
    list-style-type: none;
    margin: 0 0 0 10px;
    padding: 0;
}
.actions li {
    margin: 3px 0;
}
.actions a {
    color: #666;
}
</style>
<script>
function buildImage(id, prod_name) {
    html = '<div id="product-'+id+'">'+prod_name+'</div>';
    return html;
}
function openInNewTab(url) {
    var win = window.open(url, '_blank');
    win.focus();
    return false;
}
</script>
</head>
<body>
    <input type="button" value="Refresh" onClick="window.location.reload()">
    <button id="add_id_image" onClick="window.parent.open('/admin/products/product/add/?_to_field=id&amp;_popup=1')">Add Product
        <img src="/static/admin/img/icon-addlink.svg" alt="Add">
    </button>
    <div class="up-wrapper">{% for object in object_list %}
        <div class="item-wrapper images">
        <h5 class="item" >
            {{object.get_full_name}}
        </h5>
        <ul class="actions">
            <li><a data-id="{{object.id}}" data-name="{{object.get_full_name}}" onclick="insertProduct(this);return false;" href="#" >Insert Product</a></li>
            <li><a onclick='openInNewTab("/admin/photos/luximage/{{object.pk}}/change/");' href="#">Edit Image</a></li>
        </ul>
    </div>
{% endfor %}
</div>

<!-- "next page" action -->
<a class="nextPage browse right"></a>
<script>
function insertProduct(item) {
        var code = buildImage(item.dataset.id, item.dataset.name);
        var el = parent.document.getElementById('{{textarea_id}}');
        var start = el.selectionStart;
        var end = el.selectionEnd;
        var text = el.value;
        var before = text.substring(0, start);
        var after  = text.substring(end, text.length);
        el.value = (before + code + after);
        el.selectionStart = el.selectionEnd = start + code.length;
        el.focus();
}
</script>
</body>
</html>