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 @@ ...@@ -38,6 +38,7 @@
<script src="{{STATIC_URL}}js/highcharts-2.2.5-tooltip-id.js"></script> <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/highcharts-exporting.js"></script>
<script src="{{STATIC_URL}}js/d3/d3.v3.min.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.js"></script>
<script src="{{STATIC_URL}}js/d3/d3.layout.js"></script> --> <script src="{{STATIC_URL}}js/d3/d3.layout.js"></script> -->
<script type="text/javascript"> <script type="text/javascript">
...@@ -125,33 +126,41 @@ userIsStaff = '{{ user.is_staff }}'=='True'; ...@@ -125,33 +126,41 @@ userIsStaff = '{{ user.is_staff }}'=='True';
</div> </div>
</div> </div>
<div id="widgets"> <div id="widgets">
<input type="text" name="searchBox" id="searchBox" onkeyup="search()" placeholder="Search"/>
<ul class="browser filetree"> <ul class="browser filetree">
<li class="closed"><span class="folder">Local services</span> <li class="closed"><span class="folder">Local services</span>
<ul id="corewidgets"> <ul id="corewidgets">
{% for category in categories %} {% for category in categories %}
{% if not category.parent %} {% if not category.parent %}
{% if not category.user %} {% if not category.user %}
<li class="closed"><span class="folder" rel="{{ category.id }}" relType="category">{{ category.name }}</span><ul> <li class="closed">
{% for c in category.children.all %} <span class="folder" rel="{{ category.id }}" relType="category">{{ category.name }}</span>
<li class="closed"><span class="folder" rel="{{ c.id }}" relType="category">{{ c.name }}</span><ul> <ul>
{% for d in c.children.all %} {% for c in category.children.all %}
<li class="closed"><span class="folder" rel="{{ d.id }}" relType="category">{{ d.name }}</span><ul> <li class="closed"><span class="folder" rel="{{ c.id }}" relType="category">{{ c.name }}</span>
{% for widget in d.widgets.all %} <ul>
{% include "treeview_widget.html" with widget=widget %} {% for d in c.children.all %}
{% endfor %} <li class="closed"><span class="folder" rel="{{ d.id }}" relType="category">{{ d.name }}</span>
</ul></li> <ul>
{% endfor %} {% for widget in d.widgets.all %}
{% for widget in c.widgets.all %} {% include "treeview_widget.html" with widget=widget %}
{% include "treeview_widget.html" with widget=widget %} {% endfor %}
{% endfor %} </ul>
</ul></li> </li>
{% endfor %} {% endfor %}
{% for widget in category.widgets.all %} {% for widget in c.widgets.all %}
{% include "treeview_widget.html" with widget=widget %} {% include "treeview_widget.html" with widget=widget %}
{% endfor %} {% endfor %}
</ul></li> </ul>
{% endif %} </li>
{% endif %} {% endfor %}
{% for widget in category.widgets.all %}
{% include "treeview_widget.html" with widget=widget %}
{% endfor %}
</ul>
</li>
{% endif %}
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
</li> </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> <li>
\ No newline at end of file <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