Skip to content

Commit

Permalink
latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Graeme Sutherland committed May 8, 2010
1 parent 280fbfd commit d0c1931
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 21 deletions.
24 changes: 16 additions & 8 deletions api-experiments/widget.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,29 +3,37 @@
<head> <head>
<title>My First Sqwidget</title> <title>My First Sqwidget</title>
<script> <script>
(function(){
if (!sqwidget){
return false;
}

// register the widget // register the widget
// based on seedjs: http://seedjs.org/documentation/#defining_your_packagejson // based on seedjs: http://seedjs.org/documentation/#defining_your_packagejson
sqwidget.register({ // Sqwidget exists when this is read
Sqwidget.register({
"name": "mysqwidget", "name": "mysqwidget",
"version": "0.1.0", "version": "0.1.0",
"title": "My widget does stuff", "title": "My widget does stuff",
"desc": "Lorem ipsum", "desc": "Lorem ipsum",
"url": "http://example.com/widget", // get the widget, via your taskbar "url": "http://example.com/widget", // get the widget, via your taskbar


// require.js or simpler
// settings for automatic or explicit exact versions
// TODO template is a dependency
// default dependencies for the template etc
"dependencies": { "dependencies": {
"nitelite": "1.3.0", "nitelite": "1.3.1",
"appleofmyiframe": "0.3.3", "appleofmyiframe": "0.3.3",
"cleanslate": "6.1.8" "cleanslate": "6.1.8"
} }
}); });
}());
//TODO controller script
<script type="text/javascript" charset="utf-8">
//controller
</script>

</script> </script>


<style></style>
<link rel=stylesheet>

<script type="text/template" id="lightbox"> <script type="text/template" id="lightbox">
<p>Look closer</p> <p>Look closer</p>
</script> </script>
Expand Down
3 changes: 2 additions & 1 deletion embed.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<body> <body>
<h1>Sqwidget demo</h1> <h1>Sqwidget demo</h1>


<script src=sqwidget.js> <script src="sqwidget.js"></script>
<script type="text/javascript" charset="utf-8">
Sqwidget('widget.html', {foo:'bar'}, ['100%', 618], 0.1); Sqwidget('widget.html', {foo:'bar'}, ['100%', 618], 0.1);


/* /*
Expand Down
2 changes: 1 addition & 1 deletion plugins/twitter_processor.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
var var
i,r, i,r,
text; text;
_('got twitter message', results);
if (results) { if (results) {
for (i=0; i<results.length; i+=1 ){ for (i=0; i<results.length; i+=1 ){
r = results[i]; r = results[i];
Expand Down
6 changes: 3 additions & 3 deletions plugins/twitter_stream.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
config = { config = {
limit: 3 limit: 3
}, },
searchTerm = '', searchTerm = '';
twitterlib = widget.plugins.twitterlib; twitterlib = widget.plugins.twitterlib;


_('twitter_stream called'); _('twitter_stream called');
Expand All @@ -26,10 +26,10 @@
/** /**
* Search the Twitter API * Search the Twitter API
*/ */
self.search = function(q, callback, limit) { self.search = function(q, callback, l) {
var var
count = 0, count = 0,
limit = limit || config.limit; limit = l || config.limit;


searchTerm = (q ? encodeURIComponent(q) : searchTerm); searchTerm = (q ? encodeURIComponent(q) : searchTerm);
twitterlib.search(searchTerm, { limit: limit }, callback); twitterlib.search(searchTerm, { limit: limit }, callback);
Expand Down
2 changes: 1 addition & 1 deletion plugins/twitterlib.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -517,6 +517,6 @@


Sqwidget.plugin('twitterlib', function(){ Sqwidget.plugin('twitterlib', function(){
return twitterlib; return twitterlib;
}, '0.1.0'); }, '0.1.0', ['jquery']);


}()); }());
5 changes: 3 additions & 2 deletions samples/dasher/tweet_display.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
jQuery('p',container).html('Messages received by ' + container.id + ' listening to stream ' + stream); jQuery('p',container).html('Messages received by ' + container.id + ' listening to stream ' + stream);
// append messages received // append messages received
plugins.messaging.listen(stream, function(event,stuff) { plugins.messaging.listen(stream, function(event,stuff) {
alert('got tweets');
jQuery(".message_list", container).append('<li>got msg ' + stuff.text + ' from ' + stuff.from + '</li>' ); jQuery(".message_list", container).append('<li>got msg ' + stuff.text + ' from ' + stuff.from + '</li>' );
}); });
// send a message to topic // send a message to topic
Expand All @@ -35,8 +36,8 @@
</head> </head>


<body> <body>
<p>Messages received:</p> <p></p>
<ul class="message_list"> <ul class="tweet_list">
</ul> </ul>
</body> </body>
</html> </html>
42 changes: 37 additions & 5 deletions sqwidget.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1252,6 +1252,10 @@ var ready = (function(){
template.config(dict); template.config(dict);
}; };


self.getContainer = function(dict) {
return container;
};

self.onTemplateLoaded= function() { self.onTemplateLoaded= function() {
self.runController(template.getScripts()); self.runController(template.getScripts());
template.loadDependencies(self); template.loadDependencies(self);
Expand All @@ -1262,7 +1266,7 @@ var ready = (function(){
//TODO check all plugins loaded //TODO check all plugins loaded
if (allPluginsLoaded()) { if (allPluginsLoaded()) {
if (!readyRun) { if (!readyRun) {
readyRun=true; readyRun = true;
if (readyFn) { if (readyFn) {
var widget=self; var widget=self;
_('running ready() for widget ' + container.id); _('running ready() for widget ' + container.id);
Expand All @@ -1276,6 +1280,23 @@ var ready = (function(){
} }
}; };


self.checkRun = function() {
if (allPluginsLoaded()) {
if (!readyRun) {
readyRun=true;
if (readyFn) {
var widget=self;
_('running ready() for widget ' + container.id);
readyFn.call(self);
}
else {
//TODO decide what extra contents will be displayed here
self.setTemplate('default', null, {});
}
}
}
};

//TODO fit this into the proper place //TODO fit this into the proper place
ui = { ui = {
head: function(content) { head: function(content) {
Expand All @@ -1301,7 +1322,15 @@ var ready = (function(){


self.error = function(fn) { self.error = function(fn) {
errorFn = fn; errorFn = fn;
} };

self.getReadyFn = function() {
return readyFn;
};

self.callReady = function() {
return readyFn.call(self);
};


/* /*
// set the ui engine // set the ui engine
Expand Down Expand Up @@ -1488,9 +1517,12 @@ Sqwidget.ready(function() {
jQuery.each(widgets, function(w,widget) { jQuery.each(widgets, function(w,widget) {
//_('init for w: ' + widgets[w].toString()); //_('init for w: ' + widgets[w].toString());
widget.init(); widget.init();
}); });



// jQuery.each(widgets, function(w,widget) {
// //_('init for w: ' + widgets[w].toString());
// widget.checkRun();
// });
} }
}); });


Expand Down

0 comments on commit d0c1931

Please sign in to comment.