cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [25/53] [abbrv] git commit: Adding in the searching and filtering functionality. Added back in search service to keep the search query for the back to search results functionality on the plugin details page.
Date Mon, 07 Apr 2014 21:07:21 GMT
Adding in the searching and filtering functionality. Added back in search service to keep the
search query for the back to search results functionality on the plugin details page.


Project: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/commit/2d6f7aaa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/tree/2d6f7aaa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-registry-web/diff/2d6f7aaa

Branch: refs/heads/master
Commit: 2d6f7aaa8b69f42ce736915aebcfbc66100f4638
Parents: 1839823
Author: Josh Bavari <josh@raisemore.com>
Authored: Thu Mar 20 02:12:53 2014 -0500
Committer: Josh Bavari <josh@raisemore.com>
Committed: Thu Mar 20 02:12:53 2014 -0500

----------------------------------------------------------------------
 attachments/index.html                          |  1 +
 attachments/js/controllers/packageDetails.js    |  6 +-
 attachments/js/controllers/search.js            | 68 +++++++++++++++++++-
 attachments/js/directives/topbar.js             |  7 +-
 attachments/js/filters/platformFilter.js        | 50 ++++++++++++++
 attachments/js/services.js                      |  8 +++
 attachments/partials/directives/pluginlist.html |  3 +-
 attachments/partials/views/search.html          | 48 ++++++++++++--
 8 files changed, 180 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/2d6f7aaa/attachments/index.html
----------------------------------------------------------------------
diff --git a/attachments/index.html b/attachments/index.html
index 4cab8bb..a2fa64f 100644
--- a/attachments/index.html
+++ b/attachments/index.html
@@ -80,5 +80,6 @@
   <script type="text/javascript" src="js/controllers/search.js"></script>
   <script type="text/javascript" src="js/directives/topbar.js"></script>
   <script type="text/javascript" src="js/directives/pluginlist.js"></script>
+  <script type="text/javascript" src="js/filters/platformFilter.js"></script>
 </body>
 </html>

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/2d6f7aaa/attachments/js/controllers/packageDetails.js
----------------------------------------------------------------------
diff --git a/attachments/js/controllers/packageDetails.js b/attachments/js/controllers/packageDetails.js
index c0e8c9f..f1748d3 100644
--- a/attachments/js/controllers/packageDetails.js
+++ b/attachments/js/controllers/packageDetails.js
@@ -1,4 +1,4 @@
-angular.module('registry.controllers').controller('PackageDetailsController', ['$rootScope',
'$scope', '$location', '$routeParams', '$http', function($rootScope, $scope, $location, $routeParams,
$http) 
+angular.module('registry.controllers').controller('PackageDetailsController', ['$rootScope',
'$scope', '$location', '$routeParams', '$http', 'SearchService', function($rootScope, $scope,
$location, $routeParams, $http, SearchService) 
 {
     $scope.packageID = $routeParams.id
     $scope.description = null;
@@ -17,6 +17,10 @@ angular.module('registry.controllers').controller('PackageDetailsController',
['
     $scope.platforms = null;
     $scope.keywords = null;
 
+    $scope.backToSearch = function backToSearch() {
+        window.location.href = '/#/search?search=' + SearchService.getSearch();
+    };
+
     $scope.getPackage = function(){
         console.log($scope.packageID);
         $http({method: 'GET', url:('/api/' + $scope.packageID)}).

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/2d6f7aaa/attachments/js/controllers/search.js
----------------------------------------------------------------------
diff --git a/attachments/js/controllers/search.js b/attachments/js/controllers/search.js
index 87a51c4..d445824 100644
--- a/attachments/js/controllers/search.js
+++ b/attachments/js/controllers/search.js
@@ -1,3 +1,69 @@
-angular.module('registry.controllers').controller('SearchController', ['$rootScope', function($rootScope)
{
+angular.module('registry.controllers').controller('SearchController', ['$rootScope', '$scope',
'SearchService', function($rootScope, $scope, SearchService) {
+
+	$scope.filter = [];
+	$scope.showFilters = false;
+	$scope.hideFilters = true;
+
+	$scope.filteriOS = false;
+	$scope.filterAndroid = false;
+	$scope.filterWindowsPhone7 = false;
+	$scope.filterWindowsPhone8 = false;
+	$scope.filterWindows8 = false;
+	$scope.filterFirefox = false;
+	$scope.filterBlackberry = false;
+
+	$scope.searchTerm = SearchService.getSearch();
+
+	$scope.selectedPlatforms = function() {
+		//send back null if we arent showing filters
+		if(!$scope.showFilters) {
+			return null;
+		}
+
+		var platformFilters = [];
+	    // "firefoxos"
+		// "android"
+		// "amazon-fireos"
+		// "ubuntu"
+		// "ios"
+		// "blackberry10"
+		// "wp7"
+		// "wp8"
+		// "windows8"
+		if($scope.filterFirefox) {
+			platformFilters.push('firefoxos');
+		}
+		if($scope.filterAndroid) {
+			platformFilters.push('android');
+		}
+		if($scope.filterFireOs) {
+			platformFilters.push('amazon-fireos');
+		}
+		if($scope.filterUbuntu) {
+			platformFilters.push('ubuntu');
+		}
+		if($scope.filteriOS) {
+			platformFilters.push('ios');
+		}
+		if($scope.filterBlackberry) {
+			platformFilters.push('blackberry10');
+		}
+		if($scope.filterWindows7) {
+			platformFilters.push('wp7');
+		}
+		if($scope.filterWindows8) {
+			platformFilters.push('wp8');
+		}
+		if($scope.filterWindows8) {
+			platformFilters.push('windows8');
+		}
+
+		return platformFilters;
+	};
+
+	$scope.toggleFilters = function toggleFilters() {
+		$scope.hideFilters = $scope.showFilters;
+		$scope.showFilters = !($scope.showFilters);
+	};
     
 }]);

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/2d6f7aaa/attachments/js/directives/topbar.js
----------------------------------------------------------------------
diff --git a/attachments/js/directives/topbar.js b/attachments/js/directives/topbar.js
index 249ffad..9f1c1dc 100644
--- a/attachments/js/directives/topbar.js
+++ b/attachments/js/directives/topbar.js
@@ -1,8 +1,8 @@
-angular.module('registry.controllers').directive('topbar', function ($http, $location, $window,
$rootScope, $routeParams) {
+angular.module('registry.controllers').directive('topbar', ['$http', '$location', '$window',
'$rootScope', '$routeParams', function ($http, $location, $window, $rootScope, $routeParams)
{
     return {
         restrict: 'E',
         templateUrl: '/partials/directives/topbar.html',
-        controller:['$scope', '$rootScope', function($scope, $rootScope){
+        controller:['$scope', '$rootScope', 'SearchService', function($scope, $rootScope,
SearchService){
             var currentSearch, currentTerms;
             var searchResults = {};
             $scope.plugins = [];
@@ -12,6 +12,7 @@ angular.module('registry.controllers').directive('topbar', function ($http,
$loc
             $scope.search = function(evt) {
                 if($location.url().indexOf("search") != -1){
                     currentSearch = $scope.searchText.toLowerCase();
+                    SearchService.searchTerm = currentSearch;
                     currentTerms = currentSearch.trim().split(' ');
 
                     //todo: add a short timeout to lower number of requests
@@ -66,4 +67,4 @@ angular.module('registry.controllers').directive('topbar', function ($http,
$loc
         link: function(scope, element, attrs, controller){
         }
     };
-});
+}]);

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/2d6f7aaa/attachments/js/filters/platformFilter.js
----------------------------------------------------------------------
diff --git a/attachments/js/filters/platformFilter.js b/attachments/js/filters/platformFilter.js
new file mode 100644
index 0000000..492fa03
--- /dev/null
+++ b/attachments/js/filters/platformFilter.js
@@ -0,0 +1,50 @@
+angular.module('registry').filter('platformFilter', function () {
+    return function (items, platformFilters) {
+        if(platformFilters == null || platformFilters.length == 0) {
+            return items;//short circuit, if no filter, return original list.
+        }
+        console.log(items);
+        console.log(platformFilters);
+        var newItems = [];
+
+        // "firefoxos"
+        // "android"
+        // "amazon-fireos"
+        // "ubuntu"
+        // "ios"
+        // "blackberry10"
+        // "wp7"
+        // "wp8"
+        // "windows8"
+
+        for(var i = 0, j = items.length -1; i < j; i++) {
+
+            var item = items[i];
+            if(!item.value || !item.value.versions)
+                continue;//cant do anything & we dont want in list if it doenst exist,
right?
+
+            var latestVersion = item.value.versions[item.value['dist-tags'].latest];
+
+            if(!latestVersion)
+                continue; //no latest version, what can you do?
+
+            if(!latestVersion.platforms)
+                continue;
+
+            var platformCount = 0;
+
+            for(platform in platformFilters) {
+                if(latestVersion.platforms.indexOf(platformFilters[platform]) != -1)
+                    platformCount++;
+            }
+            if(platformCount <= 0)
+                continue;
+    
+            newItems.push(item);
+        }
+
+        
+
+        return newItems;
+    };
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/2d6f7aaa/attachments/js/services.js
----------------------------------------------------------------------
diff --git a/attachments/js/services.js b/attachments/js/services.js
index 62efba3..3aaea39 100644
--- a/attachments/js/services.js
+++ b/attachments/js/services.js
@@ -1,5 +1,13 @@
 service = angular.module('registry.services', []);
 
+angular.module('registry').service('SearchService', function(){
+    this.searchTerm = '';
+
+    this.getSearch = function() {
+        return this.searchTerm;
+    };
+});
+
 service.factory('Downloads', function($http, $window, $q) {
     
     var promise;

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/2d6f7aaa/attachments/partials/directives/pluginlist.html
----------------------------------------------------------------------
diff --git a/attachments/partials/directives/pluginlist.html b/attachments/partials/directives/pluginlist.html
index 7262fc6..fedbadf 100644
--- a/attachments/partials/directives/pluginlist.html
+++ b/attachments/partials/directives/pluginlist.html
@@ -10,13 +10,14 @@
             Downloads
         </div>
     </div>
-    <div ng-repeat="plugin in plugins" class="row pluginItem">
+    <div ng-repeat="plugin in plugins | platformFilter: selectedPlatforms()" class="row
pluginItem">
         <div class="column-9--hand column-8--lap">
             <div><a ng-href="#/package/{{plugin.key}}">{{plugin.key}}</a></div>
             <div class="pluginItemDescription">{{((plugin.value.description)||(plugin.doc.description))}}</div>
         </div>
         <div class="column-3--hand column-2--lap center">
             <div class="pluginItemVersion">{{((plugin.value['dist-tags'].latest)||(plugin.doc['dist-tags'].latest))}}</div>
+            <span ng-repeat="pf in plugin.value.versions[plugin.value['dist-tags'].latest].platforms">{{pf}}&nbsp;</span>
         </div>
         <div class="column-2--hand invisible--hand visible--lap center">
             <div class="pluginItemDownloads">{{downloads[plugin.key]}}</div>

http://git-wip-us.apache.org/repos/asf/cordova-registry-web/blob/2d6f7aaa/attachments/partials/views/search.html
----------------------------------------------------------------------
diff --git a/attachments/partials/views/search.html b/attachments/partials/views/search.html
index 2ea8fb4..a45840f 100644
--- a/attachments/partials/views/search.html
+++ b/attachments/partials/views/search.html
@@ -6,14 +6,52 @@
             <ng-pluralize count="plugins.length"
                 when="{'0': 'No plugins found',
                     '1': '1 plugin found',
-                    'other': '{{plugins.length}} plugins found'}">
+                    'other': '{{(plugins|platformFilter: selectedPlatforms()).length}} plugins
found'}">
             </ng-pluralize>
             </div>
         </div>
-
-    <!--<div class="row">
-            <a href="">Filter by Platform:</a> All
-        </div>-->
+        <div class="row">
+            <a ng-click="toggleFilters()"><i ng-class="{'icon-minus-circled': showFilters,
'icon-plus-circled': hideFilters}"></i>Filter by Platform:</a> <span ng-show="showFilters"
class="filter-platform-note">* Note, if the plugin developer did not specify platforms
available, it will be filtered out. Sorry!</span>
+        </div>
+        <div class="row">
+            <div class="filter-list" ng-show="showFilters">
+                <label class="topcoat-checkbox">
+                    <input type="checkbox" ng-model="filteriOS" />
+                    <div class="topcoat-checkbox__checkmark"></div>
+                    <span>iOS</span>
+                </label>
+                <label class="topcoat-checkbox">
+                    <input type="checkbox" ng-model="filterAndroid" />
+                    <div class="topcoat-checkbox__checkmark"></div>
+                    <span>Android</span>
+                </label>
+                <label class="topcoat-checkbox">
+                    <input type="checkbox" ng-model="filterWindowsPhone7" />
+                    <div class="topcoat-checkbox__checkmark"></div>
+                    <span>Windows Phone 7</span>
+                </label>
+                <label class="topcoat-checkbox">
+                    <input type="checkbox" ng-model="filterWindowsPhone8" />
+                    <div class="topcoat-checkbox__checkmark"></div>
+                    <span>Windows Phone 8</span>
+                </label>
+                <label class="topcoat-checkbox">
+                    <input type="checkbox" ng-model="filterWindows8" />
+                    <div class="topcoat-checkbox__checkmark"></div>
+                    <span>Windows 8</span>
+                </label>
+                <label class="topcoat-checkbox">
+                    <input type="checkbox" ng-model="filterFirefox" />
+                    <div class="topcoat-checkbox__checkmark"></div>
+                    <span>Firefox OS</span>
+                </label>
+                <label class="topcoat-checkbox">
+                    <input type="checkbox" ng-model="filterBlackberry" />
+                    <div class="topcoat-checkbox__checkmark"></div>
+                    <span>Blackberry</span>
+                </label>
+            </div>
+        </div>
 
         <pluginlist></pluginlist>
     </div>


Mime
View raw message