-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fetch and load single pieces of content into the Frontend.
Added simple implementations for Graphic and Ticker Text content types and fetch available content from the backend.
- Loading branch information
Showing
6 changed files
with
152 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
goog.provide('concerto.frontend.Content.Graphic'); | ||
|
||
goog.require('concerto.frontend.Content'); | ||
goog.require('goog.Uri'); | ||
goog.require('goog.events.EventType'); | ||
goog.require('goog.net.ImageLoader'); | ||
|
||
|
||
|
||
/** | ||
* Graphic. | ||
* | ||
* @param {Object} data Properties for this piece of content. | ||
* @constructor | ||
* @extends {concerto.frontend.Content} | ||
*/ | ||
concerto.frontend.Content.Graphic = function(data) { | ||
concerto.frontend.Content.call(this, data); | ||
|
||
/** | ||
* The image loader, so we don't load an image that isn't ready. | ||
* @type {goog.net.ImageLoader} | ||
* @private | ||
*/ | ||
this.loader_ = new goog.net.ImageLoader(); | ||
goog.events.listen(this.loader_, goog.events.EventType.LOAD, | ||
this.loaderFinish_, false, this); | ||
|
||
var image_url = new goog.Uri(data.render_details.path); | ||
image_url.setParameterValue('height', data.field.size.height); | ||
image_url.setParameterValue('width', data.field.size.width); | ||
|
||
this.loader_.addImage('graphic', image_url.toString()); | ||
}; | ||
goog.inherits(concerto.frontend.Content.Graphic, concerto.frontend.Content); | ||
|
||
|
||
/** | ||
* Load the image and get ready for the complete event. | ||
* @private | ||
*/ | ||
concerto.frontend.Content.Graphic.prototype.load_ = function() { | ||
this.loader_.start(); | ||
}; | ||
|
||
|
||
/** | ||
* Called when the image finishes loading. | ||
* @param {goog.events.EventType} e The finish event. | ||
* @private | ||
*/ | ||
concerto.frontend.Content.Graphic.prototype.loaderFinish_ = function(e) { | ||
var image = e.target; | ||
goog.dom.appendChild(this.div_, image); | ||
this.finishLoad(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
goog.provide('concerto.frontend.Content.Ticker'); | ||
|
||
goog.require('concerto.frontend.Content'); | ||
|
||
|
||
|
||
/** | ||
* Ticker Text. | ||
* | ||
* @param {Object} data Properties for this piece of content. | ||
* @constructor | ||
* @extends {concerto.frontend.Content} | ||
*/ | ||
concerto.frontend.Content.Ticker = function(data) { | ||
concerto.frontend.Content.call(this, data); | ||
|
||
/** | ||
* The text. | ||
* @type {string} | ||
*/ | ||
this.text = data.render_details.data; | ||
|
||
}; | ||
goog.inherits(concerto.frontend.Content.Ticker, concerto.frontend.Content); | ||
|
||
|
||
/** | ||
* Load the text. | ||
* @private | ||
*/ | ||
concerto.frontend.Content.Ticker.prototype.load_ = function() { | ||
goog.dom.setTextContent(this.div_, this.text); | ||
this.finishLoad(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters