From c04b6e64f61be6c3a830a921d53106225b3f80ae Mon Sep 17 00:00:00 2001 From: David Cormier <david.cormier@savoirfairelinux.com> Date: Tue, 25 Feb 2014 09:12:52 -0500 Subject: [PATCH] Let user specify the id of the input bar Input bar id is not globally set, but passed to the directive through the input-id attribute. --- directives/input.html | 2 +- index.html | 2 +- js/glowingbear.js | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/directives/input.html b/directives/input.html index b432fca..4b58053 100644 --- a/directives/input.html +++ b/directives/input.html @@ -1,6 +1,6 @@ <form class="form form-horizontal" ng-submit="sendMessage()"> <div class="input-group"> - <input type="text" class="form-control monospace" autocomplete="off" > + <input id="{{inputId}}" type="text" class="form-control monospace" autocomplete="off" > <span class="input-group-btn"> <button class="btn btn-default btn-primary">Send</button> </span> diff --git a/index.html b/index.html index c4a42a9..1b10c3c 100644 --- a/index.html +++ b/index.html @@ -349,7 +349,7 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel </div> <div id="footer" ng-show="connected"> <div class="navbar navbar-inverse navbar-fixed-bottom" ng-class="{'withnicklist': showNicklist, 'withsidebar': showSidebar}"> - <div input-bar></div> + <div input-bar input-id="sendMessage"></div> </div> </body> </html> diff --git a/js/glowingbear.js b/js/glowingbear.js index a8bdf6e..7a3b2da 100644 --- a/js/glowingbear.js +++ b/js/glowingbear.js @@ -1007,6 +1007,9 @@ weechat.directive('inputBar', function() { return { templateUrl: 'directives/input.html', + scope: { + inputId: '@inputId', + }, controller: function($rootScope, $scope, $element, @@ -1067,7 +1070,7 @@ weechat.directive('inputBar', function() { }; // Handle key presses in the input bar - $scope.handleKeyPress = function($event) { + $rootScope.handleKeyPress = function($event) { // don't do anything if not connected if (!$rootScope.connected) { return true;