[Search] Menu checkboxes and labels
Added checkboxes with styling to the menu. Set up a types list for the menu.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
{
|
||||
"key": "SearchController",
|
||||
"implementation": "controllers/SearchController.js",
|
||||
"depends": [ "$scope", "searchService" ]
|
||||
"depends": [ "$scope", "searchService", "types[]" ]
|
||||
},
|
||||
{
|
||||
"key": "SearchItemController",
|
||||
|
||||
@@ -56,9 +56,23 @@
|
||||
<div class="menu-element search-menu-holder">
|
||||
<div class="menu dropdown search-menu">
|
||||
<ul>
|
||||
<li>Contents 1</li>
|
||||
<li>Contents 2</li>
|
||||
<li>Contents 3</li>
|
||||
<li class="search-menu-item"
|
||||
ng-repeat="type in types">
|
||||
|
||||
<label class="checkbox custom search-menu-checkbox">
|
||||
<input type="checkbox"
|
||||
class="checkbox"
|
||||
checked="true"/>
|
||||
<em></em>
|
||||
</label>
|
||||
|
||||
<span class="ui-symbol search-menu-icon">
|
||||
{{ type.glyph }}
|
||||
</span>
|
||||
|
||||
{{ type.name }}
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -30,12 +30,14 @@ define(function () {
|
||||
var INITIAL_LOAD_NUMBER = 20,
|
||||
LOAD_INCREMENT = 20;
|
||||
|
||||
function SearchController($scope, searchService) {
|
||||
function SearchController($scope, searchService, types) {
|
||||
// Starting amount of results to load. Will get increased.
|
||||
var numResults = INITIAL_LOAD_NUMBER,
|
||||
loading = false,
|
||||
fullResults = {hits: []};
|
||||
|
||||
console.log('types', types);
|
||||
|
||||
function search(maxResults) {
|
||||
var inputText = $scope.ngModel.input;
|
||||
|
||||
@@ -71,6 +73,31 @@ define(function () {
|
||||
});
|
||||
}
|
||||
|
||||
function filter(types) {
|
||||
var newResults = [],
|
||||
i = 0;
|
||||
|
||||
while (newResults.length < numResults && newResults.length < fullResults.hits.length) {
|
||||
// If this is of an acceptable type, add it to the list
|
||||
if (types.indexOf(fullResults.hits[i].getModel().type) !== -1) {
|
||||
newResults.push(fullResults.hits[i]);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
$scope.results = newResults;
|
||||
}
|
||||
|
||||
$scope.types = [];
|
||||
// On initialization, fill the scope's types with type keys
|
||||
types.forEach(function (type) {
|
||||
// We only want some types: the ones that have keys and
|
||||
// descriptions are probably human user usable types
|
||||
if (type.key && type.description) {
|
||||
$scope.types.push(type);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
/**
|
||||
* Search the filetree.
|
||||
|
||||
Reference in New Issue
Block a user