* Load the section from its url * @param {method} [_request] a request method to use for loading * @return {document} a promise with the xml document
(_request)
| 47 | * @return {document} a promise with the xml document |
| 48 | */ |
| 49 | load(_request) { |
| 50 | var request = _request || this.request || Request |
| 51 | var loading = new defer() |
| 52 | var loaded = loading.promise |
| 53 | |
| 54 | if (this.contents) { |
| 55 | loading.resolve(this.contents) |
| 56 | } else { |
| 57 | request(this.url) |
| 58 | .then( |
| 59 | function (xml) { |
| 60 | // var directory = new Url(this.url).directory; |
| 61 | |
| 62 | this.document = xml |
| 63 | this.contents = xml.documentElement |
| 64 | |
| 65 | return this.hooks.content.trigger(this.document, this) |
| 66 | }.bind(this), |
| 67 | ) |
| 68 | .then( |
| 69 | function () { |
| 70 | loading.resolve(this.contents) |
| 71 | }.bind(this), |
| 72 | ) |
| 73 | .catch(function (error) { |
| 74 | loading.reject(error) |
| 75 | }) |
| 76 | } |
| 77 | |
| 78 | return loaded |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Adds a base tag for resolving urls in the section |