From babb0b1ba7b819040a5c0a83f6b3a1460031c543 Mon Sep 17 00:00:00 2001 From: Tomer Yechiel Date: Mon, 5 Aug 2013 16:50:15 +0300 Subject: [PATCH 1/2] 1. changed module name templates-main to templates-palette 2. at the beginning the controller load the current command at the service to the palette directive scope.commands --- dist/angular-palette.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/angular-palette.js b/dist/angular-palette.js index 95e43b3..b478f40 100644 --- a/dist/angular-palette.js +++ b/dist/angular-palette.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('palette', [ 'ngSanitize', - 'templates-main' + 'templates-palette' ]).factory('paletteService', [function () { var oldCommands = []; return { @@ -114,7 +114,7 @@ angular.module('palette', [ function ($scope) { var ENTER_KEY = 13, UP_ARROW_KEY = 38, DOWN_ARROW_KEY = 40, ESCAPE_KEY = 27; $scope.visible = false; - $scope.commands = []; + $scope.commands = paletteService.getCommands(); function addRoutesToPallete() { for (var path in $route.routes) { var route = $route.routes[path]; @@ -216,7 +216,7 @@ angular.module('palette', [ }; } ]); -angular.module('templates-main', ['angular-palette/palette.tpl.html']); +angular.module('templates-palette', ['angular-palette/palette.tpl.html']); angular.module('angular-palette/palette.tpl.html', []).run([ '$templateCache', function ($templateCache) { From 2c87e8cd74dd19a57b8734c0ab40250a011278b2 Mon Sep 17 00:00:00 2001 From: Tomer Yechiel Date: Tue, 6 Aug 2013 10:57:49 +0300 Subject: [PATCH 2/2] 1. add to paletteService method to store commands that are relevant to the whole application. --- dist/angular-palette.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/dist/angular-palette.js b/dist/angular-palette.js index b478f40..1cb7d36 100644 --- a/dist/angular-palette.js +++ b/dist/angular-palette.js @@ -4,6 +4,7 @@ angular.module('palette', [ 'templates-palette' ]).factory('paletteService', [function () { var oldCommands = []; + var sharedCommands = []; return { subscribedMethod: undefined, exportCommands: function (newCommands) { @@ -13,10 +14,16 @@ angular.module('palette', [ oldCommands = newCommands; }, getCommands: function () { - return oldCommands; + return oldCommands.concat(sharedCommands); }, subscribe: function (fn) { this.subscribedMethod = fn; + }, + addSharedCommand: function(commands){ + sharedCommands = sharedCommands.concat(commands); + }, + clearSharedCommand: function(){ + sharedCommands.splice(-sharedCommands.length, sharedCommands.length); } }; }]).directive('drBlur', function () { @@ -114,7 +121,7 @@ angular.module('palette', [ function ($scope) { var ENTER_KEY = 13, UP_ARROW_KEY = 38, DOWN_ARROW_KEY = 40, ESCAPE_KEY = 27; $scope.visible = false; - $scope.commands = paletteService.getCommands(); + $scope.commands = []; function addRoutesToPallete() { for (var path in $route.routes) { var route = $route.routes[path]; @@ -138,6 +145,7 @@ angular.module('palette', [ addNewCommands(newCommands); }); $scope.activeCmd = 0; + $scope.commands = paletteService.getCommands(); addRoutesToPallete(); $scope.paletteInputKeyHandler = function (e) { if (e.keyCode === UP_ARROW_KEY) {