diff --git a/src/annotator/sidebar.coffee b/src/annotator/sidebar.coffee index dc184ba5554..e72e7f61da3 100644 --- a/src/annotator/sidebar.coffee +++ b/src/annotator/sidebar.coffee @@ -69,8 +69,6 @@ module.exports = class Sidebar extends Host _setupSidebarEvents: -> annotationCounts(document.body, @crossframe) - @crossframe.on('show', => this.show()) - @crossframe.on('hide', => this.hide()) @crossframe.on(events.LOGIN_REQUESTED, => if @onLoginRequest @onLoginRequest() diff --git a/src/annotator/test/sidebar-test.coffee b/src/annotator/test/sidebar-test.coffee index 272bd4d5865..32137f7201e 100644 --- a/src/annotator/test/sidebar-test.coffee +++ b/src/annotator/test/sidebar-test.coffee @@ -32,20 +32,6 @@ describe 'Sidebar', -> emitEvent = (event, args...) -> fn(args...) for [evt, fn] in fakeCrossFrame.on.args when event == evt - describe 'on "show" event', -> - it 'shows the frame', -> - target = sandbox.stub(Sidebar.prototype, 'show') - sidebar = createSidebar() - emitEvent('show') - assert.called(target) - - describe 'on "hide" event', -> - it 'hides the frame', -> - target = sandbox.stub(Sidebar.prototype, 'hide') - sidebar = createSidebar() - emitEvent('hide') - assert.called(target) - describe 'on LOGIN_REQUESTED event', -> it 'calls the onLoginRequest callback function if one was provided', -> onLoginRequest = sandbox.stub() diff --git a/src/sidebar/app.js b/src/sidebar/app.js index 9887428db20..34abf5b3bbb 100644 --- a/src/sidebar/app.js +++ b/src/sidebar/app.js @@ -192,7 +192,6 @@ module.exports = angular.module('h', [ .service('formRespond', require('./form-respond')) .service('frameSync', require('./frame-sync').default) .service('groups', require('./groups')) - .service('host', require('./host')) .service('localStorage', require('./local-storage')) .service('permissions', require('./permissions')) .service('queryParser', require('./query-parser')) diff --git a/src/sidebar/host.coffee b/src/sidebar/host.coffee deleted file mode 100644 index ae29f418486..00000000000 --- a/src/sidebar/host.coffee +++ /dev/null @@ -1,31 +0,0 @@ -###* -# @ngdoc service -# @name host -# -# @description -# The `host` service relays the instructions the sidebar needs to send -# to the host document. (As opposed to all guests) -# It uses the bridge service to talk to the host. -### -module.exports = [ - '$window', 'bridge' - ($window, bridge) -> - host = - showSidebar: -> callHost('show') - hideSidebar: -> callHost('hide') - - # Sends a message to the host frame - callHost = (method) -> - for {channel, window} in bridge.links when window is $window.parent - channel.call(method) - break - - channelListeners = - back: -> host.hideSidebar() - open: -> host.showSidebar() - - for own channel, listener of channelListeners - bridge.on(channel, listener) - - return host -] diff --git a/src/sidebar/test/host-test.coffee b/src/sidebar/test/host-test.coffee deleted file mode 100644 index d92976506b1..00000000000 --- a/src/sidebar/test/host-test.coffee +++ /dev/null @@ -1,81 +0,0 @@ -{module, inject} = angular.mock - -describe 'host', -> - sandbox = null - host = null - createChannel = -> call: sandbox.stub() - fakeBridge = null - $digest = null - publish = null - PARENT_WINDOW = 'PARENT_WINDOW' - dumpListeners = null - - before -> - angular.module('h', []) - .service('host', require('../host')) - - beforeEach module('h') - - beforeEach module ($provide) -> - sandbox = sinon.sandbox.create() - fakeWindow = parent: PARENT_WINDOW - - listeners = {} - - publish = (method, args...) -> - listeners[method](args...) - - fakeBridge = - ls: listeners - on: sandbox.spy (method, fn) -> listeners[method] = fn - call: sandbox.stub() - onConnect: sandbox.stub() - links: [ - {window: PARENT_WINDOW, channel: createChannel()} - {window: 'ANOTHER_WINDOW', channel: createChannel()} - {window: 'THIRD_WINDOW', channel: createChannel()} - ] - - $provide.value 'bridge', fakeBridge - $provide.value '$window', fakeWindow - - return - - afterEach -> - sandbox.restore() - - beforeEach inject ($rootScope, _host_) -> - host = _host_ - $digest = sandbox.stub($rootScope, '$digest') - - describe 'the public API', -> - - describe 'showSidebar()', -> - it 'sends the "showFrame" message to the host only', -> - host.showSidebar() - assert.calledWith(fakeBridge.links[0].channel.call, 'show') - assert.notCalled(fakeBridge.links[1].channel.call) - assert.notCalled(fakeBridge.links[2].channel.call) - - describe 'hideSidebar()', -> - it 'sends the "hideFrame" message to the host only', -> - host.hideSidebar() - assert.calledWith(fakeBridge.links[0].channel.call, 'hide') - assert.notCalled(fakeBridge.links[1].channel.call) - assert.notCalled(fakeBridge.links[2].channel.call) - - describe 'reacting to the bridge', -> - - describe 'on "back" event', -> - - it 'triggers the hideSidebar() API', -> - sandbox.spy host, "hideSidebar" - publish 'back' - assert.called host.hideSidebar - - describe 'on "open" event', -> - - it 'triggers the showSidebar() API', -> - sandbox.spy host, "showSidebar" - publish 'open' - assert.called host.showSidebar