-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#212 Select tags for project. Tags are fetched from StackOverflow.
- Loading branch information
1 parent
8e24893
commit 1ac423f
Showing
5 changed files
with
126 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var mod = angular.module('soapi', []); | ||
|
||
mod.factory('SOApi', function($http){ | ||
var get_tags = "https://api.stackexchange.com/2.1/tags"; | ||
|
||
|
||
function getTags(s){ | ||
return $http({ | ||
url: get_tags, | ||
method: "GET", | ||
params: { | ||
order: 'desc', | ||
sort: 'popular', | ||
inname: s, | ||
site: 'stackoverflow' | ||
} | ||
}); | ||
} | ||
|
||
return { | ||
getTags: getTags | ||
}; | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div> | ||
<a href="" class="tag" ng-repeat="tag in tags" style="margin-right: 10px;">{[{tag}]}</a> | ||
<div> | ||
<input type="text" ng-model="newtag" ng-keypress="keypress()"> | ||
<div ng-show="poptags"> | ||
<ul> | ||
<li ng-repeat="poptag in poptags" ng-click="addTag(poptag)">{{ poptag.name }}</li> | ||
</ul> | ||
</div> | ||
<img src="/static/img2/ajax-loader.gif" ng-show="loading"> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* | ||
Copyright (C) 2013 FreedomSponsors | ||
The JavaScript code in this page is free software: you can | ||
redistribute it and/or modify it under the terms of the GNU | ||
AFFERO GENERAL PUBLIC LICENSE (GNU AGPL) as published by the Free Software | ||
Foundation, either version 3 of the License, or (at your option) | ||
any later version. The code is distributed WITHOUT ANY WARRANTY; | ||
without even the implied warranty of MERCHANTABILITY or FITNESS | ||
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. | ||
As additional permission under GNU GPL version 3 section 7, you | ||
may distribute non-source (e.g., minimized or compacted) forms of | ||
that code without the copy of the GNU GPL normally required by | ||
section 4, provided you include this license notice and a URL | ||
through which recipients can access the Corresponding Source. | ||
For more information, refer to | ||
https://github.com/freedomsponsors/www.freedomsponsors.org/blob/master/AGPL_license.txt | ||
*/ | ||
|
||
var mod = angular.module('taglist', ['soapi' /*'tagsapi'*/]); | ||
mod.directive('taglist', function() { | ||
return { | ||
restrict: 'E', | ||
replace: true, | ||
scope:{ | ||
type: "@", | ||
objid: "@" | ||
}, | ||
templateUrl: '/static/js/tags/taglist.html', | ||
controller: function ($scope, $timeout, SOApi /*, TagApi, SOApi*/) { | ||
$scope.tags = ["java", "python"]; | ||
$scope.poptags = []; | ||
|
||
var timer = undefined; | ||
|
||
function restartTimer(){ | ||
if(timer){ | ||
$timeout.cancel(timer); | ||
} | ||
timer = $timeout(getTags, 200); | ||
} | ||
|
||
function getTags(){ | ||
$scope.loading = true; | ||
SOApi.getTags($scope.newtag).success(function(result){ | ||
$scope.loading = false; | ||
$scope.poptags = result.items; | ||
}) | ||
} | ||
|
||
$scope.keypress = function(){ | ||
restartTimer(); | ||
}; | ||
|
||
$scope.addTag = function(t){ | ||
$scope.tags.push(t.name); | ||
$scope.poptags = []; | ||
} | ||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters