Commit 7dd33198 authored by bogdan's avatar bogdan

Basic search function, needs further tweaking

parent a81e20e2
function search () {
if (searchBox.value) {
corewidgets.hidden = true;
} else{
corewidgets.hidden = false;
};
}
jQuery.expr[':'].Contains = function(a, i, m) {
return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
};
$(function() {
$('#searchBox').on('keyup', function() {
var w = $(this).val();
if (w) {
$('#corewidgets li').hide();
$('#corewidgets li:Contains('+w+')').show();
} else {
$('#corewidgets li').show();
}
});
});
\ No newline at end of file
......@@ -38,6 +38,7 @@
<script src="{{STATIC_URL}}js/highcharts-2.2.5-tooltip-id.js"></script>
<script src="{{STATIC_URL}}js/highcharts-exporting.js"></script>
<script src="{{STATIC_URL}}js/d3/d3.v3.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/search.js"></script>
<!-- <script src="{{STATIC_URL}}js/d3/d3.js"></script>
<script src="{{STATIC_URL}}js/d3/d3.layout.js"></script> -->
<script type="text/javascript">
......@@ -125,33 +126,41 @@ userIsStaff = '{{ user.is_staff }}'=='True';
</div>
</div>
<div id="widgets">
<input type="text" name="searchBox" id="searchBox" onkeyup="search()" placeholder="Search"/>
<ul class="browser filetree">
<li class="closed"><span class="folder">Local services</span>
<ul id="corewidgets">
{% for category in categories %}
{% if not category.parent %}
{% if not category.user %}
<li class="closed"><span class="folder" rel="{{ category.id }}" relType="category">{{ category.name }}</span><ul>
{% for c in category.children.all %}
<li class="closed"><span class="folder" rel="{{ c.id }}" relType="category">{{ c.name }}</span><ul>
{% for d in c.children.all %}
<li class="closed"><span class="folder" rel="{{ d.id }}" relType="category">{{ d.name }}</span><ul>
{% for widget in d.widgets.all %}
{% include "treeview_widget.html" with widget=widget %}
{% endfor %}
</ul></li>
{% endfor %}
{% for widget in c.widgets.all %}
{% include "treeview_widget.html" with widget=widget %}
{% endfor %}
</ul></li>
{% endfor %}
{% for widget in category.widgets.all %}
{% include "treeview_widget.html" with widget=widget %}
{% endfor %}
</ul></li>
{% endif %}
{% endif %}
{% if not category.parent %}
{% if not category.user %}
<li class="closed">
<span class="folder" rel="{{ category.id }}" relType="category">{{ category.name }}</span>
<ul>
{% for c in category.children.all %}
<li class="closed"><span class="folder" rel="{{ c.id }}" relType="category">{{ c.name }}</span>
<ul>
{% for d in c.children.all %}
<li class="closed"><span class="folder" rel="{{ d.id }}" relType="category">{{ d.name }}</span>
<ul>
{% for widget in d.widgets.all %}
{% include "treeview_widget.html" with widget=widget %}
{% endfor %}
</ul>
</li>
{% endfor %}
{% for widget in c.widgets.all %}
{% include "treeview_widget.html" with widget=widget %}
{% endfor %}
</ul>
</li>
{% endfor %}
{% for widget in category.widgets.all %}
{% include "treeview_widget.html" with widget=widget %}
{% endfor %}
</ul>
</li>
{% endif %}
{% endif %}
{% endfor %}
</ul>
</li>
......
<li><a class="widget wid" rel="{{ widget.id }}" relType="abstractwidget"><span class="image" style="background-size:16px;background-image:url('{% if widget.static_image %}{{STATIC_URL}}{{widget.package}}/icons/treeview/{{widget.static_image}}{% else %}{% if widget.treeview_image %}{{MEDIA_URL}}{{widget.treeview_image}}{% else %}{% if widget.wsdl %}{{STATIC_URL}}widget-icons/ws_1.png{% else %}{{STATIC_URL}}widget-icons/question-mark.png{% endif %}{% endif %}{% endif %}');">{{ widget.name }}</span></a></li>
\ No newline at end of file
<li>
<a class="widget wid" rel="{{ widget.id }}" relType="abstractwidget">
<span class="image" style="
background-size:16px;
background-image:url('{% if widget.static_image %}{{STATIC_URL}}{{widget.package}}/icons/treeview/{{widget.static_image}}{% else %}{% if widget.treeview_image %}{{MEDIA_URL}}{{widget.treeview_image}}{% else %}{% if widget.wsdl %}{{STATIC_URL}}widget-icons/ws_1.png{% else %}{{STATIC_URL}}widget-icons/question-mark.png{% endif %}{% endif %}{% endif %}');">
{{ widget.name }}
</span>
</a>
</li>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment