OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 Polymer('kb-key-import', { | 5 define("mojo/public/bindings/js/connection", [ |
6 /** | 6 "mojo/public/bindings/js/router", |
7 * The id of the document fragment that will be imported. | 7 ], function(router) { |
8 */ | |
9 importId: null, | |
10 | 8 |
11 /** | 9 function Connection(handle, localFactory, remoteFactory) { |
12 * Import content from a document fragment. | 10 this.router_ = new router.Router(handle); |
13 * @param {!DocumentFragment} content Document fragment that contains | 11 this.remote = new remoteFactory(this.router_); |
14 * the content to import. | 12 this.local = new localFactory(this.remote); |
15 */ | 13 this.router_.setIncomingReceiver(this.local); |
16 importDoc: function(content) { | |
17 var id = this.getAttribute('importId'); | |
18 var fragment = content.querySelector('#' + id); | |
19 return fragment && fragment.content ? fragment.content : fragment; | |
20 } | 14 } |
| 15 |
| 16 Connection.prototype.close = function() { |
| 17 this.router_.close(); |
| 18 this.router_ = null; |
| 19 this.local = null; |
| 20 this.remote = null; |
| 21 }; |
| 22 |
| 23 var exports = {}; |
| 24 exports.Connection = Connection; |
| 25 return exports; |
21 }); | 26 }); |
22 | |
OLD | NEW |