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
var settings = [8081,8082,8083] | |
var writeTo = function() { | |
var con = this; | |
if (con.readyState == 'open') { | |
con.write('hello') // this is always the last connection | |
} else { | |
setTimeout(writeTo, 100, con); | |
} | |
} |
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
$.getJSON('buttons.json', function(users) { | |
var target_div = $('#users'); | |
$.each(users, function(i, user) { | |
target_div.append( | |
$.engineer.make('gbutton_link', { | |
"text":user['name'], | |
"href":user['website'] | |
}) |
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
$.engineer.define('gbutton_link', { | |
defaults: {href:'/', text:'Click Me'}, | |
structure: function(options) { | |
return $.engineer.make('gbutton', options) | |
// gbutton is part of the edison library http://github.com/jpoz/edison | |
}, | |
behavior: function(options) { | |
this.click(function() { | |
window.location = options.href | |
}) |
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
$.engineer.make('gbutton', {text:"This button will send all the other elements a message"}) | |
.click(function() { | |
$('div').send('blink'); | |
}); |
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
$('#some_element').behaveLike('blinky'); |
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
$.engineer.define('blinky', { | |
behavior: function(options) { | |
var self = this; | |
var publicMethods = {}; | |
publicMethods.blink = function() { | |
self.fadeOut(100).fadeIn(200); | |
} | |
return publicMethods; |
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
defaults: { color: '#336699', innerText: "This element" }, |
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
behavior: function(options) { | |
var self = this; | |
self.click(function() { | |
self.animate({ opacity: 0.4 }, 1500 ); | |
}); | |
} |
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
structure: function(options) { | |
var div = $('<div/>', { | |
css: { | |
'text-align':'center', 'background':options.color, 'color':'white', | |
'padding':'5px', 'margin':'5px', 'width': '140px', 'display': 'inline' | |
}, | |
html: options.innerText | |
}); | |
return div; |
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
$('body') | |
.append( $.engineer.make('example_button') ) | |
.append( $.engineer.make('example_button', {innerText:"this element"}) ) | |
.append( $.engineer.make('example_button', {innerText:"and"}) ) | |
.append( $.engineer.make('example_button', {color:"#994547",innerText:"this element"}) ); |