forked from pusewicz/sonia
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract and move rest of the widgets to /widgets
Every widget now lies in it's own directory which contains it's ruby class, javascript and css
- Loading branch information
Showing
12 changed files
with
160 additions
and
129 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,51 @@ | ||
var Campfire = Class.create(Widget, { | ||
initialize: function($super, widget_id, config) { | ||
this.messages = []; | ||
return($super(widget_id, config)); | ||
}, | ||
|
||
handlePayload: function(payload) { | ||
if(this.messages.length >= this.config.nitems) { | ||
this.messages.shift(); | ||
} | ||
this.messages.push(payload); | ||
}, | ||
|
||
build: function() { | ||
this.contentContainer = this.buildContent(); | ||
this.headerContainer = this.buildHeader(); | ||
this.iconContainer = this.buildWidgetIcon(); | ||
|
||
this.container.insert(this.headerContainer); | ||
this.container.insert(this.iconContainer); | ||
this.container.insert(this.contentContainer); | ||
|
||
new Draggable(this.container, { scroll: window }); | ||
}, | ||
|
||
update: function() { | ||
this.contentContainer.childElements().invoke('remove'); | ||
this.messages.reverse(false).each(function(message) { | ||
var cont = new Element('p'); | ||
|
||
cont.insert(new Element('img', { src: message.avatar, width: 48, height: 48 })); | ||
cont.insert(new Element('div', { 'class': 'author' }).update(message.user)); | ||
cont.insert(new Element('div', { 'class': 'message' }).update(message.body)); | ||
cont.insert(new Element('hr' )); | ||
|
||
this.contentContainer.insert(cont); | ||
}.bind(this)); | ||
}, | ||
|
||
buildHeader: function() { | ||
return(new Element("h2", { 'class': 'handle' }).update(this.title)); | ||
}, | ||
|
||
buildWidgetIcon: function() { | ||
return(new Element("img", {src: "images/campfire.png", 'class': 'campfire icon'})); | ||
}, | ||
|
||
buildContent: function() { | ||
return(new Element("div", { 'class': "content" })); | ||
}, | ||
}); |
File renamed without changes.
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,38 @@ | ||
/* TfL Lines*/ | ||
|
||
div.tfl p { | ||
position: relative; | ||
width: 100%; | ||
} | ||
div.tfl p span { | ||
width: 50%; | ||
text-align: center; | ||
margin: 0; | ||
float: right; | ||
line-height: 32px; | ||
} | ||
div.tfl p span.station { | ||
float: left; | ||
} | ||
|
||
div.tfl p span.status { text-transform: uppercase; } | ||
div.tfl p span.good_service { background-color: green; color: white } | ||
div.tfl p span.part_suspended { background-color: #963; color: white } | ||
div.tfl p span.part_closure, | ||
div.tfl p span.planned_closure{ background-color: #F7A414; color: white } | ||
div.tfl p span.suspended { background-color: black; color: white } | ||
div.tfl p span.severe_delays { background-color: red; color: white; font-weight: bold } | ||
div.tfl p span.minor_delays { background-color: yellow; color: black } | ||
div.tfl p span.unknown { background-color: black; color: white } | ||
div.tfl p#bakerloo { background-color: #963; color: white } | ||
div.tfl p#central { background-color: #C03; color: white} | ||
div.tfl p#circle { background-color: #FC0 } | ||
div.tfl p#district { background-color: #063; color: white} | ||
div.tfl p#docklands { background-color: #099; } | ||
div.tfl p#hammersmithcity { background-color: #F9C; } | ||
div.tfl p#jubilee { background-color: #666; color: white } | ||
div.tfl p#metropolitan { background-color: #903; color: white } | ||
div.tfl p#northern { background-color: #000; color: white; } | ||
div.tfl p#piccadilly { background-color: #039; color: white; } | ||
div.tfl p#victoria { background-color: #39C; } | ||
div.tfl p#waterloocity { background-color: #6CC; } |
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,50 @@ | ||
var Tfl = Class.create(Widget, { | ||
initialize: function($super, widget_id, config) { | ||
this.messages = []; | ||
return($super(widget_id, config)); | ||
}, | ||
|
||
handlePayload: function(payload) { | ||
this.messages = []; | ||
payload.each(function(message) { | ||
this.messages.push(message); | ||
}.bind(this)); | ||
}, | ||
|
||
build: function() { | ||
this.contentContainer = this.buildContent(); | ||
this.headerContainer = this.buildHeader(); | ||
this.iconContainer = this.buildWidgetIcon(); | ||
|
||
this.container.insert(this.headerContainer); | ||
this.container.insert(this.iconContainer); | ||
this.container.insert(this.contentContainer); | ||
|
||
new Draggable(this.container, { scroll: window }); | ||
}, | ||
|
||
update: function() { | ||
this.contentContainer.childElements().invoke('remove'); | ||
|
||
this.messages.each(function(message) { | ||
var cont = new Element('p', { id: message.id }); | ||
|
||
cont.insert(new Element('span', { 'class': 'station' }).update(message.name.replace("&", "&"))); | ||
cont.insert(new Element('span', { 'class': "status " + message.status.replace(" ", "_")}).update(message.status)); | ||
|
||
this.contentContainer.insert(cont); | ||
}.bind(this)); | ||
}, | ||
|
||
buildWidgetIcon: function() { | ||
return(new Element("img", {src: "images/tfl.png", 'class': 'tfl icon'})); | ||
}, | ||
|
||
buildHeader: function() { | ||
return(new Element("h2", { 'class': 'handle' }).update(this.title)); | ||
}, | ||
|
||
buildContent: function() { | ||
return(new Element("div", { 'class': "content" })); | ||
}, | ||
}); |
File renamed without changes.
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
File renamed without changes.