2
0

Tweet.deploy.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. smalltalk.addClass('Tweet', smalltalk.Widget, ['json'], 'Examples');
  2. smalltalk.addMethod(
  3. '_renderOn_',
  4. smalltalk.method({
  5. selector: 'renderOn:',
  6. fn: function (tr) {
  7. var self = this;
  8. var tdUser = nil;
  9. var tdMessage = nil;
  10. var img = nil;
  11. var a = nil;
  12. var pMessage = nil;
  13. var pDate = nil;
  14. tdUser = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_td", []);
  15. smalltalk.send(smalltalk.send(tdUser, "_element", []), "_id_", ["user"]);
  16. tdMessage = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_td", []);
  17. smalltalk.send(smalltalk.send(tdMessage, "_element", []), "_id_", ["messageBox"]);
  18. smalltalk.send(tr, "_append_", [tdUser]);
  19. smalltalk.send(tr, "_append_", [tdMessage]);
  20. img = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_img", []), "_src_", [smalltalk.send(self['@json'], "_at_", ["profile_image_url"])]);
  21. smalltalk.send(smalltalk.send(img, "_element", []), "_title_", [smalltalk.send(self['@json'], "_at_", ["from_user"])]);
  22. smalltalk.send(smalltalk.send(img, "_element", []), "_longDesc_", [smalltalk.send(unescape("http%3A//twitter.com/"), "__comma", [smalltalk.send(self['@json'], "_at_", ["from_user"])])]);
  23. a = smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_a", []), "_href_", [smalltalk.send(unescape("http%3A//twitter.com/"), "__comma", [smalltalk.send(self['@json'], "_at_", ["from_user"])])]);
  24. smalltalk.send(a, "_append_", [img]);
  25. smalltalk.send(tdUser, "_append_", [a]);
  26. pMessage = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_p", []);
  27. smalltalk.send(smalltalk.send(pMessage, "_element", []), "_id_", ["message"]);
  28. smalltalk.send(pMessage, "_append_", [smalltalk.send(self['@json'], "_at_", ["text"])]);
  29. smalltalk.send(tdMessage, "_append_", [pMessage]);
  30. pDate = smalltalk.send(smalltalk.send(smalltalk.HTMLCanvas || HTMLCanvas, "_new", []), "_p", []);
  31. smalltalk.send(smalltalk.send(pDate, "_element", []), "_id_", ["date"]);
  32. smalltalk.send(pDate, "_append_", [smalltalk.send(self['@json'], "_at_", ["created_at"])]);
  33. smalltalk.send(tdMessage, "_append_", [pDate]);
  34. return self;
  35. }
  36. }),
  37. smalltalk.Tweet);
  38. smalltalk.addMethod(
  39. '_json',
  40. smalltalk.method({
  41. selector: 'json',
  42. fn: function () {
  43. var self = this;
  44. return self['@json'];
  45. return self;
  46. }
  47. }),
  48. smalltalk.Tweet);
  49. smalltalk.addMethod(
  50. '_json_',
  51. smalltalk.method({
  52. selector: 'json:',
  53. fn: function (aJson) {
  54. var self = this;
  55. self['@json'] = aJson;
  56. return self;
  57. }
  58. }),
  59. smalltalk.Tweet);
  60. smalltalk.addMethod(
  61. '_openAt_with_',
  62. smalltalk.method({
  63. selector: 'openAt:with:',
  64. fn: function (tr, aJson) {
  65. var self = this;
  66. var tweet = nil;
  67. tweet = smalltalk.send(self, "_new", []);
  68. smalltalk.send(tweet, "_json_", [aJson]);
  69. smalltalk.send(tweet, "_renderOn_", [tr]);
  70. return tr;
  71. return self;
  72. }
  73. }),
  74. smalltalk.Tweet.klass);