Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
filedrop enter press #156
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-PatrickOFriel committed Dec 15, 2015
1 parent 622d889 commit a463081
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 2 additions & 1 deletion js/sky/src/fileattachments/filedrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
scope.bbFileDrop = {
hasTranscludeContents: $.trim(el.find('.bb-file-drop-contents-custom').html()).length > 0,
allowLinks: angular.isDefined(attrs.bbFileDropLink),
addLink: function () {
addLink: function ($event) {
$event.preventDefault();
scope.bbFileDropLinkChange({
link: {
url: scope.bbFileDrop.url
Expand Down
24 changes: 24 additions & 0 deletions js/sky/src/fileattachments/test/filedrop.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,28 @@ describe('File drop directive', function () {
el.remove();
nonTargetEl.remove();
});

it('should call event prevent default on enter', function () {
var $scope = $rootScope.$new(),
el,
$event,
isolateScope;

$event = jasmine.createSpyObj('$event', ['preventDefault']);

$scope.addLink = angular.noop;

el = getDropWithLinkEl($scope);

// The element has to be in the DOM to trigger its change event in Firefox.
el.appendTo(document.body);

isolateScope = el.isolateScope();

isolateScope.bbFileDrop.addLink($event);

expect($event.preventDefault).toHaveBeenCalled();

el.remove();
});
});
4 changes: 2 additions & 2 deletions js/sky/templates/fileattachments/filedrop.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ <h4 class="bb-file-drop-link-header">{{'file_upload_paste_link' | bbResources}}<
class="form-control"
placeholder="{{'file_upload_link_placeholder' | bbResources}}"
ng-model="bbFileDrop.url"
ng-keypress="$event.keyCode === 13 && bbFileDrop.addLink()"
ng-keypress="$event.keyCode === 13 && bbFileDrop.addLink($event)"
/>
</div>
<button type="button" class="btn btn-primary" ng-disabled="!bbFileDrop.url" ng-click="bbFileDrop.addLink()">
<button type="button" class="btn btn-primary" ng-disabled="!bbFileDrop.url" ng-click="bbFileDrop.addLink($event)">
{{'file_upload_paste_link_done' | bbResources}}
</button>
</div>
Expand Down

0 comments on commit a463081

Please sign in to comment.