diff --git a/webroot/js/tags.js b/webroot/js/tags.js index 1b60e88..7979a2c 100644 --- a/webroot/js/tags.js +++ b/webroot/js/tags.js @@ -2,89 +2,88 @@ * Created by ryuji on 15/04/30. */ NetCommonsApp.controller('Tags.TagEdit', - function($scope, $filter, $http, filterFilter) { - var where = $filter('filter'); + ['$scope', '$filter', '$http', 'filterFilter', + function($scope, $filter, $http, filterFilter) { + var where = $filter('filter'); - $scope.frameId = 0; - $scope.modelName = ''; - $scope.tags = []; + $scope.frameId = 0; + $scope.modelName = ''; + $scope.tags = []; - $scope.init = function(frameId, modelName, tags) { - if (tags) { - $scope.tags = tags; - } - $scope.modelName = modelName; - $scope.frameId = frameId; - }; + $scope.init = function(frameId, modelName, tags) { + if (tags) { + $scope.tags = tags; + } + $scope.modelName = modelName; + $scope.frameId = frameId; + }; - $scope.newTag = ''; + $scope.newTag = ''; - $scope.tagExist = function(newTag) { - var result = filterFilter($scope.tags, newTag); - return (result.length > 0); - }; + $scope.tagExist = function(newTag) { + var result = filterFilter($scope.tags, newTag); + return (result.length > 0); + }; - $scope.addTag = function() { - if ($scope.newTag.length > 0) { - if ($scope.tagExist($scope.newTag) === false) { - $scope.tags.push({ - name: $scope.newTag - }); - $scope.newTag = ''; - $scope.showResult = false; + $scope.addTag = function() { + if ($scope.newTag.length > 0) { + if ($scope.tagExist($scope.newTag) === false) { + $scope.tags.push({ + name: $scope.newTag + }); + $scope.newTag = ''; + $scope.showResult = false; + } } - } - }; + }; - $scope.showResult = false; - $scope.showResultStyle = {}; - $scope.tagSearchResult = []; - $scope.searchUrl = '/tags/tags/search/'; - // タグ補完 - $scope.change = function() { - if ($scope.newTag.length > 2) { - // 3文字以上になったら検索してみる - // タグ候補を検索 - var url = $scope.searchUrl + $scope.frameId + - '/keyword:' + $scope.newTag + '/target:' + $scope.modelName + - '/' + Math.random() + '.json'; - console.log(url); - $http.get(url). - success(function(data, status, headers, config) { - $scope.tagSearchResult = data; - if ($scope.tagSearchResult.length > 0) { - $scope.showResult = true; - } else { - $scope.showResult = false; - } - - }). - error(function(data, status, headers, config) { - console.log(data); - }); - //$scope.tagSearchResult = ["結果1", "結果2", "結果3"]; - // - //$scope.showResultStyle = {display:"block"} + $scope.showResult = false; + $scope.showResultStyle = {}; + $scope.tagSearchResult = []; + $scope.searchUrl = '/tags/tags/search/'; + // タグ補完 + $scope.change = function() { + if ($scope.newTag.length > 2) { + // 3文字以上になったら検索してみる + // タグ候補を検索 + var url = $scope.searchUrl + $scope.frameId + + '/keyword:' + $scope.newTag + '/target:' + $scope.modelName + + '/' + Math.random() + '.json'; + console.log(url); + $http.get(url).success(function(data, status, headers, config) { + $scope.tagSearchResult = data; + if ($scope.tagSearchResult.length > 0) { + $scope.showResult = true; + } else { + $scope.showResult = false; + } - } - }; + }).error(function(data, status, headers, config) { + console.log(data); + }); + //$scope.tagSearchResult = ["結果1", "結果2", "結果3"]; + // + //$scope.showResultStyle = {display:"block"} + } + }; - $scope.selectTag = function(selectedTag) { - $scope.newTag = selectedTag; - //$scope.showResultStyle = {display:"none"} - //$scope.showResult = false; - $scope.showResult = false; - }; - // 任意の tag を削除 - $scope.removeTag = function(currentTag) { - $scope.tags = where($scope.tags, function(tag) { - return currentTag !== tag; - }); - }; + $scope.selectTag = function(selectedTag) { + $scope.newTag = selectedTag; + //$scope.showResultStyle = {display:"none"} + //$scope.showResult = false; + $scope.showResult = false; + }; - } + // 任意の tag を削除 + $scope.removeTag = function(currentTag) { + $scope.tags = where($scope.tags, function(tag) { + return currentTag !== tag; + }); + }; + } + ] );