Skip to content

Commit

Permalink
Advanced Search in News section is now functional. Layout needs revie…
Browse files Browse the repository at this point in the history
…wing
  • Loading branch information
gastaldi committed May 7, 2015
1 parent 11d0fc8 commit 7d5c4d5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 69 deletions.
40 changes: 40 additions & 0 deletions app/js/controllers/newsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,46 @@ angular.module('jboss-forge').controller('newsCtrl', function($scope, $statePara
} else {
backendAPI.fetchNews(function(data) {
$scope.news = data;
var tags = [];
data.forEach(function (item) {
item.tags.split(',').forEach(
function(tag) {
tags.push(tag.trim());
}
);
});
$scope.newsCategories =
tags.filter(function (item, pos, self) {
return self.indexOf(item) == pos;
}
);
$scope.selectedCategories = [];
$scope.addCategory = function(item, selectedCategories) {
var i = $.inArray(item, selectedCategories);
if (i > -1) {
selectedCategories.splice(i, 1);
} else {
selectedCategories.push(item);
}
}

$scope.clearCategories = function() {
$scope.selectedCategories = [];
}
$scope.categoryFilter = function(item) {
if ($scope.selectedCategories.length > 0) {
var allTags = item.tags.split(',');
for (i=0;i<$scope.selectedCategories.length;i++)
{
if (item.tags.contains($scope.selectedCategories[i])) {
return item;
}
}
return;
}
return item;
}

});
}
});
77 changes: 8 additions & 69 deletions app/views/news.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h2>JBoss Forge is <strong>Continually Advancing</strong>.<br>
</div>
<div class="row">
<div class="col-sm-10 col-sm-offset-1 col-xs-4 col-xs-offset-4">
<a href="#" class="forge-btn btn btn-red btn-med reset-button">Reset Options</a>
<a href="#" class="forge-btn btn btn-red btn-med reset-button" ng-click="clearCategories()">Reset Options</a>
</div>
</div>
</div><!-- / End Left Side -->
Expand All @@ -68,76 +68,15 @@ <h2>JBoss Forge is <strong>Continually Advancing</strong>.<br>
<!-- Begin Checkboxes -->

<!-- Main Column 1 -->
<div class="col-sm-6 col-sm-offset-0 col-xs-5 col-xs-offset-2 checkbox-columns">

<div class="row">
<div class="col-sm-6 col-xs-12">
<div class=" checkbox-row">
<input type="checkbox" class="search-checkbox" id="latest-versions"> <label class="checkbox-label" for="latest-versions"><span></span>Latest Versions</label>
</div>
<div class=" checkbox-row">
<input type="checkbox" class="search-checkbox" id="video"> <label class="checkbox-label" for="video"><span></span>Video</label>
</div>
<div class=" checkbox-row">
<input type="checkbox" class="search-checkbox" id="article"> <label class="checkbox-label" for="article"><span></span>Article</label>
</div>

</div><!-- /.col-sm-6 col-xs-12 -->


<div class="col-sm-6 col-xs-12">
<div class="checkbox-row">
<input type="checkbox" class="search-checkbox" id="level1"> <label class="checkbox-label" for="level1"><span></span>Level 1</label>
</div>
<div class="checkbox-row">
<input type="checkbox" class="search-checkbox" id="level2"> <label class="checkbox-label" for="level2"><span></span>Level 2</label>
</div>
<div class="checkbox-row">
<input type="checkbox" class="search-checkbox" id="level3"> <label class="checkbox-label" for="level3"><span></span>Level 3</label>
</div>


</div><!-- /.col-sm-6 col-xs-12 -->


</div><!-- /.row -->
<!--TODO: MOVE THIS TO FORGE.CSS -->
<div style="display: flex; flex-flow: column wrap; height:120px; width:170px">
<div class="checkbox-row" ng-repeat="category in newsCategories">
<input type="checkbox" class="search-checkbox" ng-click="addCategory(category, selectedCategories)" id="{{category}}">
<label class="checkbox-label" for="{{category}}"><span></span>{{category}}</label>
</div>
</div><!-- / End Main Column 1 -->

<!-- Main Column 2 -->
<div class="col-sm-6 col-xs-5 checkbox-columns">
<div class="row">
<div class="col-sm-6 col-xs-12">
<div class=" checkbox-row">
<input type="checkbox" class="search-checkbox" id="popular"> <label class="checkbox-label" for="popular"><span></span>Popular</label>
</div>
<div class=" checkbox-row">
<input type="checkbox" class="search-checkbox" id="community"> <label class="checkbox-label" for="community"><span></span>Community</label>
</div>
<div class=" checkbox-row">
<input type="checkbox" class="search-checkbox" id="core"> <label class="checkbox-label" for="core"><span></span>Core</label>
</div>

</div><!-- /.col-sm-6 col-xs-12 -->

<div class="col-sm-6 col-xs-12">
<div class=" checkbox-row">
<input type="checkbox" class="search-checkbox" id="option_4"> <label class="checkbox-label" for="option_4"><span></span>Option 4</label>
</div>
<div class=" checkbox-row">
<input type="checkbox" class="search-checkbox" id="option_5"> <label class="checkbox-label" for="option_5"><span></span>Option 5</label>
</div>
<div class=" checkbox-row">
<input type="checkbox" class="search-checkbox" id="option_6"> <label class="checkbox-label" for="option_6"><span></span>Option 6</label>
</div>

</div><!-- /.col-sm-6 col-xs-12 -->

</div><!-- /.row -->
</div><!-- / End Main Column 2 -->
<!-- / End Checkboxes -->



</div><!-- /.row (.advanced-search-checkbox-area) -->
</div>
<!-- / End Right side -->
Expand All @@ -160,7 +99,7 @@ <h2>JBoss Forge is <strong>Continually Advancing</strong>.<br>
<div class="row news-item-boxes">

<!-- Item 2 -->
<div class="col-xs-12 news-item" ng-repeat="newsItem in news|filter:searchBox" ng-class="{'photo-version': newsItem.photo}">
<div class="col-xs-12 news-item" ng-repeat="newsItem in news|filter:searchBox|filter: categoryFilter" ng-class="{'photo-version': newsItem.photo}">
<!-- BEGIN PHOTO HEADER -->
<div class="col-xs-12 date-header" ng-if="newsItem.photo">

Expand Down

0 comments on commit 7d5c4d5

Please sign in to comment.