From 5bdacf3500e410f16eb115e427ea779916b1929a Mon Sep 17 00:00:00 2001 From: luchenqun Date: Mon, 27 Feb 2017 20:06:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6directive=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 6 +--- public/scripts/controllers/edit-controller.js | 17 ---------- public/scripts/controllers/tags-controller.js | 2 ++ .../directives/bookmark-info-directive.js | 7 ---- public/scripts/directives/edit-directive.js | 7 ---- .../element-render-finish-directive.js | 12 ------- public/scripts/directives/menus-directive.js | 8 ----- public/scripts/directives/module-directive.js | 33 +++++++++++++++++++ .../directives/pagination-directive.js | 12 ------- 9 files changed, 36 insertions(+), 68 deletions(-) delete mode 100644 public/scripts/directives/bookmark-info-directive.js delete mode 100644 public/scripts/directives/edit-directive.js delete mode 100644 public/scripts/directives/element-render-finish-directive.js delete mode 100644 public/scripts/directives/menus-directive.js create mode 100644 public/scripts/directives/module-directive.js delete mode 100644 public/scripts/directives/pagination-directive.js diff --git a/public/index.html b/public/index.html index a612e24..e3ca2b0 100644 --- a/public/index.html +++ b/public/index.html @@ -44,11 +44,7 @@ - - - - - + diff --git a/public/scripts/controllers/edit-controller.js b/public/scripts/controllers/edit-controller.js index cd9a511..ad55938 100644 --- a/public/scripts/controllers/edit-controller.js +++ b/public/scripts/controllers/edit-controller.js @@ -176,23 +176,6 @@ app.controller('editCtr', ['$scope', '$state', '$timeout', 'bookmarkService', 'p .catch((err) => console.log('getTags err', err)); } - // 元素构造完成之后,开始使用jquery初始化 - $scope.$on('viewContentLoaded', function(elementRenderFinishedEvent) { - console.log('edit ui dropdown viewContentLoaded') - $('.ui.modal.js-add-bookmark .ui.dropdown').removeClass('loading'); - $('.ui.dropdown.js-tags').dropdown({ - forceSelection: false, - maxSelections: maxSelections, - action: 'combo', - onChange: function(value, text, $choice) { - var selectedTags = $('.ui.modal.js-add-bookmark .ui.dropdown').dropdown('get value'); - $timeout(function() { - $scope.tagsError = (selectedTags.length == 0 || selectedTags.length > maxSelections) && ($('.ui.modal.js-add-bookmark').modal('is active')); - }); - } - }); - }); - function initJsTags() { setTimeout(function() { $('.ui.modal.js-add-bookmark .ui.dropdown').removeClass('loading'); diff --git a/public/scripts/controllers/tags-controller.js b/public/scripts/controllers/tags-controller.js index fef510f..6088fcc 100644 --- a/public/scripts/controllers/tags-controller.js +++ b/public/scripts/controllers/tags-controller.js @@ -309,10 +309,12 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', '$stateParams', '$tim toastr.info('您还没有书签分类,请点击菜单栏的添加按钮进行添加', "提示"); } $scope.loadTags = false; + updateEditPos(); }) .catch((err) => { console.log('getTags err', err); $scope.loadTags = false; + updateEditPos(); }); pubSubService.publish('Common.menuActive', { diff --git a/public/scripts/directives/bookmark-info-directive.js b/public/scripts/directives/bookmark-info-directive.js deleted file mode 100644 index 5210811..0000000 --- a/public/scripts/directives/bookmark-info-directive.js +++ /dev/null @@ -1,7 +0,0 @@ -app.directive('bookmarkinfo', function() { - return { - restrict: 'EAC', - templateUrl: '/views/bookmark-info.html', - replace: true - } -}); diff --git a/public/scripts/directives/edit-directive.js b/public/scripts/directives/edit-directive.js deleted file mode 100644 index 824729d..0000000 --- a/public/scripts/directives/edit-directive.js +++ /dev/null @@ -1,7 +0,0 @@ -app.directive('edit', function() { - return { - restrict: 'EAC', - templateUrl: '/views/edit.html', - replace: true - } -}); diff --git a/public/scripts/directives/element-render-finish-directive.js b/public/scripts/directives/element-render-finish-directive.js deleted file mode 100644 index 52a2ae6..0000000 --- a/public/scripts/directives/element-render-finish-directive.js +++ /dev/null @@ -1,12 +0,0 @@ -app.directive('onFinishRenderFilters', ['$timeout', function($timeout) { - return { - restrict: 'A', - link: function(scope, element, attr) { - if (scope.$last === true) { - $timeout(function() { - scope.$emit('elementRenderFinished'); - }); - } - } - }; -}]); diff --git a/public/scripts/directives/menus-directive.js b/public/scripts/directives/menus-directive.js deleted file mode 100644 index fd68afe..0000000 --- a/public/scripts/directives/menus-directive.js +++ /dev/null @@ -1,8 +0,0 @@ -// 不要使用已有的html作为指令,如menu,否则angular会陷入死循环 -app.directive('menus', function() { - return { - restrict: 'EAC', - templateUrl: '/views/menus.html', - replace: true - } -}); diff --git a/public/scripts/directives/module-directive.js b/public/scripts/directives/module-directive.js new file mode 100644 index 0000000..8001924 --- /dev/null +++ b/public/scripts/directives/module-directive.js @@ -0,0 +1,33 @@ +app.directive('bookmarkinfo', function() { + return { + restrict: 'EAC', + templateUrl: '/views/bookmark-info.html', + replace: true + } +}); + +app.directive('edit', function() { + return { + restrict: 'EAC', + templateUrl: '/views/edit.html', + replace: true + } +}); + +// 不要使用已有的html作为指令,如menu,否则angular会陷入死循环 +app.directive('menus', function() { + return { + restrict: 'EAC', + templateUrl: '/views/menus.html', + replace: true + } +}); + +app.directive('pagination', function() { + return { + restrict: 'EA', + templateUrl: '/views/pagination.html', + replace: true, + link: function(scope, element, attrs) {} + } +}); diff --git a/public/scripts/directives/pagination-directive.js b/public/scripts/directives/pagination-directive.js deleted file mode 100644 index 22071c6..0000000 --- a/public/scripts/directives/pagination-directive.js +++ /dev/null @@ -1,12 +0,0 @@ -// 不要使用已有的html作为指令,如menu,否则angular会陷入死循环 -app.directive('pagination', function() { - return { - restrict: 'EA', - templateUrl: '/views/pagination.html', - replace: true, - // scope: { - // conf: '=' - // }, - link: function(scope, element, attrs) {} - } -});