1
0

canvas.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. smalltalk.addClass('HTMLCanvas', smalltalk.Object, ['root'], 'Canvas');
  2. smalltalk.addMethod(
  3. '_root_',
  4. smalltalk.method({
  5. selector: 'root:',
  6. category: 'accessing',
  7. fn: function (aTagBrush){
  8. var self=this;
  9. self['@root']=aTagBrush;
  10. return self;},
  11. source: unescape('root%3A%20aTagBrush%0A%20%20%20%20root%20%3A%3D%20aTagBrush%0A')}),
  12. smalltalk.HTMLCanvas);
  13. smalltalk.addMethod(
  14. '_root',
  15. smalltalk.method({
  16. selector: 'root',
  17. category: 'accessing',
  18. fn: function (){
  19. var self=this;
  20. return self['@root'];
  21. return self;},
  22. source: unescape('root%0A%20%20%20%20%5Eroot%0A')}),
  23. smalltalk.HTMLCanvas);
  24. smalltalk.addMethod(
  25. '_initialize',
  26. smalltalk.method({
  27. selector: 'initialize',
  28. category: 'initialization',
  29. fn: function (){
  30. var self=this;
  31. self.klass.superclass.fn.prototype['_initialize'].apply(self, []);
  32. self['@root']=smalltalk.TagBrush._fromString_canvas_("div",self);
  33. return self;},
  34. source: unescape('initialize%0A%20%20%20%20super%20initialize.%0A%20%20%20%20root%20%3A%3D%20TagBrush%20fromString%3A%20%27div%27%20canvas%3A%20self%0A')}),
  35. smalltalk.HTMLCanvas);
  36. smalltalk.addMethod(
  37. '_newTag_',
  38. smalltalk.method({
  39. selector: 'newTag:',
  40. category: 'tags',
  41. fn: function (aString){
  42. var self=this;
  43. return smalltalk.TagBrush._fromString_canvas_(aString,self);
  44. return self;},
  45. source: unescape('newTag%3A%20aString%0A%20%20%20%20%5ETagBrush%20fromString%3A%20aString%20canvas%3A%20self%0A')}),
  46. smalltalk.HTMLCanvas);
  47. smalltalk.addMethod(
  48. '_tag_',
  49. smalltalk.method({
  50. selector: 'tag:',
  51. category: 'tags',
  52. fn: function (aString){
  53. var self=this;
  54. return self['@root']._addBrush_(self._newTag_(aString));
  55. return self;},
  56. source: unescape('tag%3A%20aString%0A%20%20%20%20%5Eroot%20addBrush%3A%20%28self%20newTag%3A%20aString%29%0A')}),
  57. smalltalk.HTMLCanvas);
  58. smalltalk.addMethod(
  59. '_h1',
  60. smalltalk.method({
  61. selector: 'h1',
  62. category: 'tags',
  63. fn: function (){
  64. var self=this;
  65. return self._tag_("h1");
  66. return self;},
  67. source: unescape('h1%0A%20%20%20%20%5Eself%20tag%3A%20%27h1%27%0A')}),
  68. smalltalk.HTMLCanvas);
  69. smalltalk.addMethod(
  70. '_h2',
  71. smalltalk.method({
  72. selector: 'h2',
  73. category: 'tags',
  74. fn: function (){
  75. var self=this;
  76. return self._tag_("h2");
  77. return self;},
  78. source: unescape('h2%0A%20%20%20%20%5Eself%20tag%3A%20%27h2%27%0A')}),
  79. smalltalk.HTMLCanvas);
  80. smalltalk.addMethod(
  81. '_h3',
  82. smalltalk.method({
  83. selector: 'h3',
  84. category: 'tags',
  85. fn: function (){
  86. var self=this;
  87. return self._tag_("h3");
  88. return self;},
  89. source: unescape('h3%0A%20%20%20%20%5Eself%20tag%3A%20%27h3%27%0A')}),
  90. smalltalk.HTMLCanvas);
  91. smalltalk.addMethod(
  92. '_h4',
  93. smalltalk.method({
  94. selector: 'h4',
  95. category: 'tags',
  96. fn: function (){
  97. var self=this;
  98. return self._tag_("h4");
  99. return self;},
  100. source: unescape('h4%0A%20%20%20%20%5Eself%20tag%3A%20%27h4%27%0A')}),
  101. smalltalk.HTMLCanvas);
  102. smalltalk.addMethod(
  103. '_h5',
  104. smalltalk.method({
  105. selector: 'h5',
  106. category: 'tags',
  107. fn: function (){
  108. var self=this;
  109. return self._tag_("h5");
  110. return self;},
  111. source: unescape('h5%0A%20%20%20%20%5Eself%20tag%3A%20%27h5%27%0A')}),
  112. smalltalk.HTMLCanvas);
  113. smalltalk.addMethod(
  114. '_h6',
  115. smalltalk.method({
  116. selector: 'h6',
  117. category: 'tags',
  118. fn: function (){
  119. var self=this;
  120. return self._tag_("h6");
  121. return self;},
  122. source: unescape('h6%0A%20%20%20%20%5Eself%20tag%3A%20%27h6%27%0A')}),
  123. smalltalk.HTMLCanvas);
  124. smalltalk.addMethod(
  125. '_p',
  126. smalltalk.method({
  127. selector: 'p',
  128. category: 'tags',
  129. fn: function (){
  130. var self=this;
  131. return self._tag_("p");
  132. return self;},
  133. source: unescape('p%0A%20%20%20%20%5Eself%20tag%3A%20%27p%27%0A')}),
  134. smalltalk.HTMLCanvas);
  135. smalltalk.addMethod(
  136. '_div',
  137. smalltalk.method({
  138. selector: 'div',
  139. category: 'tags',
  140. fn: function (){
  141. var self=this;
  142. return self._tag_("div");
  143. return self;},
  144. source: unescape('div%0A%20%20%20%20%5Eself%20tag%3A%20%27div%27%0A')}),
  145. smalltalk.HTMLCanvas);
  146. smalltalk.addMethod(
  147. '_span',
  148. smalltalk.method({
  149. selector: 'span',
  150. category: 'tags',
  151. fn: function (){
  152. var self=this;
  153. return self._tag_("span");
  154. return self;},
  155. source: unescape('span%0A%20%20%20%20%5Eself%20tag%3A%20%27span%27%0A')}),
  156. smalltalk.HTMLCanvas);
  157. smalltalk.addMethod(
  158. '_img',
  159. smalltalk.method({
  160. selector: 'img',
  161. category: 'tags',
  162. fn: function (){
  163. var self=this;
  164. return self._tag_("img");
  165. return self;},
  166. source: unescape('img%0A%20%20%20%20%5Eself%20tag%3A%20%27img%27%0A')}),
  167. smalltalk.HTMLCanvas);
  168. smalltalk.addMethod(
  169. '_ul',
  170. smalltalk.method({
  171. selector: 'ul',
  172. category: 'tags',
  173. fn: function (){
  174. var self=this;
  175. return self._tag_("ul");
  176. return self;},
  177. source: unescape('ul%0A%20%20%20%20%5Eself%20tag%3A%20%27ul%27%0A')}),
  178. smalltalk.HTMLCanvas);
  179. smalltalk.addMethod(
  180. '_ol',
  181. smalltalk.method({
  182. selector: 'ol',
  183. category: 'tags',
  184. fn: function (){
  185. var self=this;
  186. return self._tag_("ol");
  187. return self;},
  188. source: unescape('ol%0A%20%20%20%20%5Eself%20tag%3A%20%27ol%27%0A')}),
  189. smalltalk.HTMLCanvas);
  190. smalltalk.addMethod(
  191. '_li',
  192. smalltalk.method({
  193. selector: 'li',
  194. category: 'tags',
  195. fn: function (){
  196. var self=this;
  197. return self._tag_("li");
  198. return self;},
  199. source: unescape('li%0A%20%20%20%20%5Eself%20tag%3A%20%27li%27%0A')}),
  200. smalltalk.HTMLCanvas);
  201. smalltalk.addMethod(
  202. '_table',
  203. smalltalk.method({
  204. selector: 'table',
  205. category: 'tags',
  206. fn: function (){
  207. var self=this;
  208. return self._tag_("table");
  209. return self;},
  210. source: unescape('table%0A%20%20%20%20%5Eself%20tag%3A%20%27table%27%0A')}),
  211. smalltalk.HTMLCanvas);
  212. smalltalk.addMethod(
  213. '_tr',
  214. smalltalk.method({
  215. selector: 'tr',
  216. category: 'tags',
  217. fn: function (){
  218. var self=this;
  219. return self._tag_("tr");
  220. return self;},
  221. source: unescape('tr%0A%20%20%20%20%5Eself%20tag%3A%20%27tr%27%0A')}),
  222. smalltalk.HTMLCanvas);
  223. smalltalk.addMethod(
  224. '_td',
  225. smalltalk.method({
  226. selector: 'td',
  227. category: 'tags',
  228. fn: function (){
  229. var self=this;
  230. return self._tag_("td");
  231. return self;},
  232. source: unescape('td%20%0A%20%20%20%20%5Eself%20tag%3A%20%27td%27%0A')}),
  233. smalltalk.HTMLCanvas);
  234. smalltalk.addMethod(
  235. '_th',
  236. smalltalk.method({
  237. selector: 'th',
  238. category: 'tags',
  239. fn: function (){
  240. var self=this;
  241. return self._tag_("th");
  242. return self;},
  243. source: unescape('th%0A%20%20%20%20%5Eself%20tag%3A%20%27th%27%0A')}),
  244. smalltalk.HTMLCanvas);
  245. smalltalk.addMethod(
  246. '_form',
  247. smalltalk.method({
  248. selector: 'form',
  249. category: 'tags',
  250. fn: function (){
  251. var self=this;
  252. return self._tag_("form");
  253. return self;},
  254. source: unescape('form%0A%20%20%20%20%5Eself%20tag%3A%20%27form%27%0A')}),
  255. smalltalk.HTMLCanvas);
  256. smalltalk.addMethod(
  257. '_input',
  258. smalltalk.method({
  259. selector: 'input',
  260. category: 'tags',
  261. fn: function (){
  262. var self=this;
  263. return self._tag_("input");
  264. return self;},
  265. source: unescape('input%0A%20%20%20%20%5Eself%20tag%3A%20%27input%27%0A')}),
  266. smalltalk.HTMLCanvas);
  267. smalltalk.addMethod(
  268. '_button',
  269. smalltalk.method({
  270. selector: 'button',
  271. category: 'tags',
  272. fn: function (){
  273. var self=this;
  274. return self._tag_("button");
  275. return self;},
  276. source: unescape('button%0A%20%20%20%20%5Eself%20tag%3A%20%27button%27%0A')}),
  277. smalltalk.HTMLCanvas);
  278. smalltalk.addMethod(
  279. '_select',
  280. smalltalk.method({
  281. selector: 'select',
  282. category: 'tags',
  283. fn: function (){
  284. var self=this;
  285. return self._tag_("select");
  286. return self;},
  287. source: unescape('select%0A%20%20%20%20%5Eself%20tag%3A%20%27select%27%0A')}),
  288. smalltalk.HTMLCanvas);
  289. smalltalk.addMethod(
  290. '_option',
  291. smalltalk.method({
  292. selector: 'option',
  293. category: 'tags',
  294. fn: function (){
  295. var self=this;
  296. return self._tag_("option");
  297. return self;},
  298. source: unescape('option%0A%20%20%20%20%5Eself%20tag%3A%20%27option%27%0A')}),
  299. smalltalk.HTMLCanvas);
  300. smalltalk.addMethod(
  301. '_textarea',
  302. smalltalk.method({
  303. selector: 'textarea',
  304. category: 'tags',
  305. fn: function (){
  306. var self=this;
  307. return self._tag_("textarea");
  308. return self;},
  309. source: unescape('textarea%0A%20%20%20%20%5Eself%20tag%3A%20%27textarea%27%0A')}),
  310. smalltalk.HTMLCanvas);
  311. smalltalk.addMethod(
  312. '_a',
  313. smalltalk.method({
  314. selector: 'a',
  315. category: 'tags',
  316. fn: function (){
  317. var self=this;
  318. return self._tag_("a");
  319. return self;},
  320. source: unescape('a%0A%20%20%20%20%5Eself%20tag%3A%20%27a%27%0A')}),
  321. smalltalk.HTMLCanvas);
  322. smalltalk.addMethod(
  323. '_appendToJQuery_',
  324. smalltalk.method({
  325. selector: 'appendToJQuery:',
  326. category: '*JQuery',
  327. fn: function (aJQuery){
  328. var self=this;
  329. aJQuery._appendElement_(self['@root']._element());
  330. return self;},
  331. source: unescape('appendToJQuery%3A%20aJQuery%0A%20%20%20%20aJQuery%20appendElement%3A%20root%20element%0A')}),
  332. smalltalk.HTMLCanvas);
  333. smalltalk.addClass('TagBrush', smalltalk.Object, ['element'], 'Canvas');
  334. smalltalk.addMethod(
  335. '_contents_',
  336. smalltalk.method({
  337. selector: 'contents:',
  338. category: 'adding',
  339. fn: function (anObject){
  340. var self=this;
  341. self._asJQuery()._empty();
  342. self._append_(anObject);
  343. return self;},
  344. source: unescape('contents%3A%20anObject%0A%20%20%20%20self%20asJQuery%20empty.%0A%20%20%20%20self%20append%3A%20anObject%0A')}),
  345. smalltalk.TagBrush);
  346. smalltalk.addMethod(
  347. '_addBrush_',
  348. smalltalk.method({
  349. selector: 'addBrush:',
  350. category: 'adding',
  351. fn: function (aTagBrush){
  352. var self=this;
  353. self._appendChild_(aTagBrush._element());
  354. return aTagBrush;
  355. return self;},
  356. source: unescape('addBrush%3A%20aTagBrush%0A%20%20%20%20self%20appendChild%3A%20aTagBrush%20element.%0A%20%20%20%20%5EaTagBrush%0A')}),
  357. smalltalk.TagBrush);
  358. smalltalk.addMethod(
  359. '_with_',
  360. smalltalk.method({
  361. selector: 'with:',
  362. category: 'adding',
  363. fn: function (anObject){
  364. var self=this;
  365. self._append_(anObject);
  366. return self;},
  367. source: unescape('with%3A%20anObject%0A%20%20%20%20self%20append%3A%20anObject%0A')}),
  368. smalltalk.TagBrush);
  369. smalltalk.addMethod(
  370. '_append_',
  371. smalltalk.method({
  372. selector: 'append:',
  373. category: 'adding',
  374. fn: function (anObject){
  375. var self=this;
  376. anObject._appendToBrush_(self);
  377. return self;},
  378. source: unescape('append%3A%20anObject%0A%20%20%20%20anObject%20appendToBrush%3A%20self%0A')}),
  379. smalltalk.TagBrush);
  380. smalltalk.addMethod(
  381. '_appendToBrush_',
  382. smalltalk.method({
  383. selector: 'appendToBrush:',
  384. category: 'adding',
  385. fn: function (aTagBrush){
  386. var self=this;
  387. aTagBrush._addBrush_(self);
  388. return self;},
  389. source: unescape('appendToBrush%3A%20aTagBrush%0A%20%20%20%20aTagBrush%20addBrush%3A%20self%0A')}),
  390. smalltalk.TagBrush);
  391. smalltalk.addMethod(
  392. '_appendBlock_',
  393. smalltalk.method({
  394. selector: 'appendBlock:',
  395. category: 'adding',
  396. fn: function (aBlock){
  397. var self=this;
  398. var root=nil;
  399. root=canvas._root();
  400. canvas._root_(self);
  401. aBlock._value_(canvas);
  402. canvas._root_(root);
  403. return self;},
  404. source: unescape('appendBlock%3A%20aBlock%0A%20%20%20%20%7C%20root%20%7C%0A%20%20%20%20root%20%3A%3D%20canvas%20root.%0A%20%20%20%20canvas%20root%3A%20self.%0A%20%20%20%20aBlock%20value%3A%20canvas.%0A%20%20%20%20canvas%20root%3A%20root%0A')}),
  405. smalltalk.TagBrush);
  406. smalltalk.addMethod(
  407. '_appendChild_',
  408. smalltalk.method({
  409. selector: 'appendChild:',
  410. category: 'adding',
  411. fn: function (anElement){
  412. var self=this;
  413. (function(){self['@element'].appendChild(anElement)})();
  414. return self;},
  415. source: unescape('appendChild%3A%20anElement%0A%20%20%20%20%7B%27self%5B%27%27@element%27%27%5D.appendChild%28anElement%29%27%7D%0A')}),
  416. smalltalk.TagBrush);
  417. smalltalk.addMethod(
  418. '_appendString_',
  419. smalltalk.method({
  420. selector: 'appendString:',
  421. category: 'adding',
  422. fn: function (aString){
  423. var self=this;
  424. self._appendChild_(self._createTextNodeFor_(aString));
  425. return self;},
  426. source: unescape('appendString%3A%20aString%0A%20%20%20%20self%20appendChild%3A%20%28self%20createTextNodeFor%3A%20aString%29%0A')}),
  427. smalltalk.TagBrush);
  428. smalltalk.addMethod(
  429. '_at_put_',
  430. smalltalk.method({
  431. selector: 'at:put:',
  432. category: 'attributes',
  433. fn: function (aString, aValue){
  434. var self=this;
  435. (function(){self['@element'].setAttribute(aString, aValue)})();
  436. return self;},
  437. source: unescape('at%3A%20aString%20put%3A%20aValue%0A%20%20%20%20%7B%27self%5B%27%27@element%27%27%5D.setAttribute%28aString%2C%20aValue%29%27%7D%0A')}),
  438. smalltalk.TagBrush);
  439. smalltalk.addMethod(
  440. '_removeAt_',
  441. smalltalk.method({
  442. selector: 'removeAt:',
  443. category: 'attributes',
  444. fn: function (aString){
  445. var self=this;
  446. (function(){self['@element'].removeAttribute(aString)})();
  447. return self;},
  448. source: unescape('removeAt%3A%20aString%0A%20%20%20%20%7B%27self%5B%27%27@element%27%27%5D.removeAttribute%28aString%29%27%7D%0A')}),
  449. smalltalk.TagBrush);
  450. smalltalk.addMethod(
  451. '_class_',
  452. smalltalk.method({
  453. selector: 'class:',
  454. category: 'attributes',
  455. fn: function (aString){
  456. var self=this;
  457. self._at_put_("class",aString);
  458. return self;},
  459. source: unescape('class%3A%20aString%0A%20%20%20%20self%20at%3A%20%27class%27%20put%3A%20aString%0A')}),
  460. smalltalk.TagBrush);
  461. smalltalk.addMethod(
  462. '_id_',
  463. smalltalk.method({
  464. selector: 'id:',
  465. category: 'attributes',
  466. fn: function (aString){
  467. var self=this;
  468. self._at_put_("id",aString);
  469. return self;},
  470. source: unescape('id%3A%20aString%0A%20%20%20%20self%20at%3A%20%27id%27%20put%3A%20aString%0A')}),
  471. smalltalk.TagBrush);
  472. smalltalk.addMethod(
  473. '_src_',
  474. smalltalk.method({
  475. selector: 'src:',
  476. category: 'attributes',
  477. fn: function (aString){
  478. var self=this;
  479. self._at_put_("src",aString);
  480. return self;},
  481. source: unescape('src%3A%20aString%0A%20%20%20%20self%20%20at%3A%20%27src%27%20put%3A%20aString%0A')}),
  482. smalltalk.TagBrush);
  483. smalltalk.addMethod(
  484. '_href_',
  485. smalltalk.method({
  486. selector: 'href:',
  487. category: 'attributes',
  488. fn: function (aString){
  489. var self=this;
  490. self._at_put_("href",aString);
  491. return self;},
  492. source: unescape('href%3A%20aString%0A%20%20%20%20self%20at%3A%20%27href%27%20put%3A%20aString%0A')}),
  493. smalltalk.TagBrush);
  494. smalltalk.addMethod(
  495. '_title_',
  496. smalltalk.method({
  497. selector: 'title:',
  498. category: 'attributes',
  499. fn: function (aString){
  500. var self=this;
  501. self._at_put_("title",aString);
  502. return self;},
  503. source: unescape('title%3A%20aString%0A%20%20%20%20self%20at%3A%20%27title%27%20put%3A%20aString%0A')}),
  504. smalltalk.TagBrush);
  505. smalltalk.addMethod(
  506. '_style_',
  507. smalltalk.method({
  508. selector: 'style:',
  509. category: 'attributes',
  510. fn: function (aString){
  511. var self=this;
  512. self._at_put_("style",aString);
  513. return self;},
  514. source: unescape('style%3A%20aString%0A%20%20%20%20self%20at%3A%20%27style%27%20put%3A%20aString%0A')}),
  515. smalltalk.TagBrush);
  516. smalltalk.addMethod(
  517. '_initializeFromString_canvas_',
  518. smalltalk.method({
  519. selector: 'initializeFromString:canvas:',
  520. category: 'initialization',
  521. fn: function (aString, aCanvas){
  522. var self=this;
  523. self['@element']=self._createElementFor_(aString);
  524. canvas=aCanvas;
  525. return self;},
  526. source: unescape('initializeFromString%3A%20aString%20canvas%3A%20aCanvas%0A%20%20%20%20element%20%3A%3D%20self%20createElementFor%3A%20aString.%0A%20%20%20%20canvas%20%3A%3D%20aCanvas%0A')}),
  527. smalltalk.TagBrush);
  528. smalltalk.addMethod(
  529. '_element',
  530. smalltalk.method({
  531. selector: 'element',
  532. category: 'accessing',
  533. fn: function (){
  534. var self=this;
  535. return self['@element'];
  536. return self;},
  537. source: unescape('element%0A%20%20%20%20%5Eelement%0A')}),
  538. smalltalk.TagBrush);
  539. smalltalk.addMethod(
  540. '_asJQuery',
  541. smalltalk.method({
  542. selector: 'asJQuery',
  543. category: 'converting',
  544. fn: function (){
  545. var self=this;
  546. return (function(){return smalltalk.JQuery._from_(jQuery(self['@element']))})();
  547. return self;},
  548. source: unescape('asJQuery%0A%20%20%20%20%5E%7B%27return%20smalltalk.JQuery._from_%28jQuery%28self%5B%27%27@element%27%27%5D%29%29%27%7D%0A')}),
  549. smalltalk.TagBrush);
  550. smalltalk.addMethod(
  551. '_onKeyDown_',
  552. smalltalk.method({
  553. selector: 'onKeyDown:',
  554. category: 'events',
  555. fn: function (aBlock){
  556. var self=this;
  557. self._asJQuery()._on_do_("keydown",aBlock);
  558. return self;},
  559. source: unescape('onKeyDown%3A%20aBlock%0A%20%20%20%20self%20asJQuery%20on%3A%20%27keydown%27%20do%3A%20aBlock%0A')}),
  560. smalltalk.TagBrush);
  561. smalltalk.addMethod(
  562. '_onKeyPress_',
  563. smalltalk.method({
  564. selector: 'onKeyPress:',
  565. category: 'events',
  566. fn: function (aBlock){
  567. var self=this;
  568. self._asJQuery()._on_do_("keypress",aBlock);
  569. return self;},
  570. source: unescape('onKeyPress%3A%20aBlock%0A%20%20%20%20self%20asJQuery%20on%3A%20%27keypress%27%20do%3A%20aBlock%0A')}),
  571. smalltalk.TagBrush);
  572. smalltalk.addMethod(
  573. '_onKeyUp_',
  574. smalltalk.method({
  575. selector: 'onKeyUp:',
  576. category: 'events',
  577. fn: function (aBlock){
  578. var self=this;
  579. self._asJQuery()._on_do_("keyup",aBlock);
  580. return self;},
  581. source: unescape('onKeyUp%3A%20aBlock%0A%20%20%20%20self%20asJQuery%20on%3A%20%27keyup%27%20do%3A%20aBlock%0A')}),
  582. smalltalk.TagBrush);
  583. smalltalk.addMethod(
  584. '_onFocus_',
  585. smalltalk.method({
  586. selector: 'onFocus:',
  587. category: 'events',
  588. fn: function (aBlock){
  589. var self=this;
  590. self._asJQuery()._on_do_("focus",aBlock);
  591. return self;},
  592. source: unescape('onFocus%3A%20aBlock%0A%20%20%20%20self%20asJQuery%20on%3A%20%27focus%27%20do%3A%20aBlock%0A')}),
  593. smalltalk.TagBrush);
  594. smalltalk.addMethod(
  595. '_onBlur_',
  596. smalltalk.method({
  597. selector: 'onBlur:',
  598. category: 'events',
  599. fn: function (aBlock){
  600. var self=this;
  601. self._asJQuery()._on_do_("blur",aBlock);
  602. return self;},
  603. source: unescape('onBlur%3A%20aBlock%0A%20%20%20%20self%20asJQuery%20on%3A%20%27blur%27%20do%3A%20aBlock%0A')}),
  604. smalltalk.TagBrush);
  605. smalltalk.addMethod(
  606. '_onChange_',
  607. smalltalk.method({
  608. selector: 'onChange:',
  609. category: 'events',
  610. fn: function (aBlock){
  611. var self=this;
  612. self._asJQuery()._on_do_("change",aBlock);
  613. return self;},
  614. source: unescape('onChange%3A%20aBlock%0A%20%20%20%20self%20asJQuery%20on%3A%20%27change%27%20do%3A%20aBlock%0A')}),
  615. smalltalk.TagBrush);
  616. smalltalk.addMethod(
  617. '_onClick_',
  618. smalltalk.method({
  619. selector: 'onClick:',
  620. category: 'events',
  621. fn: function (aBlock){
  622. var self=this;
  623. self._asJQuery()._on_do_("click",aBlock);
  624. return self;},
  625. source: unescape('onClick%3A%20aBlock%0A%20%20%20%20self%20asJQuery%20on%3A%20%27click%27%20do%3A%20aBlock%0A')}),
  626. smalltalk.TagBrush);
  627. smalltalk.addMethod(
  628. '_createElementFor_',
  629. smalltalk.method({
  630. selector: 'createElementFor:',
  631. category: 'private',
  632. fn: function (aString){
  633. var self=this;
  634. return (function(){return document.createElement(String(aString))})();
  635. return self;},
  636. source: unescape('createElementFor%3A%20aString%0A%20%20%20%20%5E%7B%27return%20document.createElement%28String%28aString%29%29%27%7D%0A')}),
  637. smalltalk.TagBrush);
  638. smalltalk.addMethod(
  639. '_createTextNodeFor_',
  640. smalltalk.method({
  641. selector: 'createTextNodeFor:',
  642. category: 'private',
  643. fn: function (aString){
  644. var self=this;
  645. return (function(){return document.createTextNode(String(aString))})();
  646. return self;},
  647. source: unescape('createTextNodeFor%3A%20aString%0A%20%20%20%20%5E%7B%27return%20document.createTextNode%28String%28aString%29%29%27%7D%0A')}),
  648. smalltalk.TagBrush);
  649. smalltalk.addMethod(
  650. '_fromString_canvas_',
  651. smalltalk.method({
  652. selector: 'fromString:canvas:',
  653. category: 'instance creation',
  654. fn: function (aString, aCanvas){
  655. var self=this;
  656. return (function($rec){$rec._initializeFromString_canvas_(aString,aCanvas);return $rec._yourself();})(self._new());
  657. return self;},
  658. source: unescape('fromString%3A%20aString%20canvas%3A%20aCanvas%0A%20%20%20%20%5Eself%20new%0A%09initializeFromString%3A%20aString%20canvas%3A%20aCanvas%3B%0A%09yourself%0A')}),
  659. smalltalk.TagBrush.klass);
  660. smalltalk.addClass('Widget', smalltalk.Object, ['root'], 'Canvas');
  661. smalltalk.addMethod(
  662. '_root',
  663. smalltalk.method({
  664. selector: 'root',
  665. category: 'accessing',
  666. fn: function (){
  667. var self=this;
  668. return self['@root'];
  669. return self;},
  670. source: unescape('root%0A%20%20%20%20%5Eroot%0A')}),
  671. smalltalk.Widget);
  672. smalltalk.addMethod(
  673. '_appendToBrush_',
  674. smalltalk.method({
  675. selector: 'appendToBrush:',
  676. category: 'adding',
  677. fn: function (aTagBrush){
  678. var self=this;
  679. self._appendToJQuery_(aTagBrush._asJQuery());
  680. return self;},
  681. source: unescape('appendToBrush%3A%20aTagBrush%0A%20%20%20%20self%20appendToJQuery%3A%20aTagBrush%20asJQuery%0A')}),
  682. smalltalk.Widget);
  683. smalltalk.addMethod(
  684. '_appendToJQuery_',
  685. smalltalk.method({
  686. selector: 'appendToJQuery:',
  687. category: 'adding',
  688. fn: function (aJQuery){
  689. var self=this;
  690. self._render();
  691. aJQuery._append_(self._root()._asJQuery());
  692. return self;},
  693. source: unescape('appendToJQuery%3A%20aJQuery%0A%20%20%20%20self%20render.%0A%20%20%20%20aJQuery%20append%3A%20self%20root%20asJQuery%0A')}),
  694. smalltalk.Widget);
  695. smalltalk.addMethod(
  696. '_confirm_',
  697. smalltalk.method({
  698. selector: 'confirm:',
  699. category: 'actions',
  700. fn: function (aString){
  701. var self=this;
  702. return (function(){return window.confirm(aString)})();
  703. return self;},
  704. source: unescape('confirm%3A%20aString%0A%20%20%20%20%5E%7B%27return%20window.confirm%28aString%29%27%7D%0A')}),
  705. smalltalk.Widget);
  706. smalltalk.addMethod(
  707. '_prompt_',
  708. smalltalk.method({
  709. selector: 'prompt:',
  710. category: 'actions',
  711. fn: function (aString){
  712. var self=this;
  713. return self._prompt_default_(aString,"");
  714. return self;},
  715. source: unescape('prompt%3A%20aString%0A%20%20%20%20%5Eself%20prompt%3A%20aString%20default%3A%20%27%27%0A')}),
  716. smalltalk.Widget);
  717. smalltalk.addMethod(
  718. '_prompt_default_',
  719. smalltalk.method({
  720. selector: 'prompt:default:',
  721. category: 'actions',
  722. fn: function (aString, anotherString){
  723. var self=this;
  724. return (function(){return window.prompt(aString, anotherString)})();
  725. return self;},
  726. source: unescape('prompt%3A%20aString%20default%3A%20anotherString%0A%20%20%20%20%5E%7B%27return%20window.prompt%28aString%2C%20anotherString%29%27%7D%0A')}),
  727. smalltalk.Widget);
  728. smalltalk.addMethod(
  729. '_update',
  730. smalltalk.method({
  731. selector: 'update',
  732. category: 'actions',
  733. fn: function (){
  734. var self=this;
  735. var canvas=nil;
  736. canvas=smalltalk.HTMLCanvas._new();
  737. canvas._root_(self._root());
  738. self._root()._asJQuery()._empty();
  739. self._renderOn_(canvas);
  740. return self;},
  741. source: unescape('update%0A%20%20%20%20%7C%20canvas%20%7C%0A%20%20%20%20canvas%20%3A%3D%20HTMLCanvas%20new.%0A%20%20%20%20canvas%20root%3A%20self%20root.%0A%20%20%20%20self%20root%20asJQuery%20empty.%0A%20%20%20%20self%20renderOn%3A%20canvas%0A')}),
  742. smalltalk.Widget);
  743. smalltalk.addMethod(
  744. '_render',
  745. smalltalk.method({
  746. selector: 'render',
  747. category: 'rendering',
  748. fn: function (){
  749. var self=this;
  750. var canvas=nil;
  751. canvas=smalltalk.HTMLCanvas._new();
  752. self['@root']=canvas._root();
  753. self._renderOn_(canvas);
  754. return self;},
  755. source: unescape('render%0A%20%20%20%20%7C%20canvas%20%7C%0A%20%20%20%20canvas%20%3A%3D%20HTMLCanvas%20new.%0A%20%20%20%20root%20%3A%3D%20canvas%20root.%0A%20%20%20%20self%20renderOn%3A%20canvas%0A')}),
  756. smalltalk.Widget);
  757. smalltalk.addMethod(
  758. '_renderOn_',
  759. smalltalk.method({
  760. selector: 'renderOn:',
  761. category: 'rendering',
  762. fn: function (html){
  763. var self=this;
  764. self;
  765. return self;},
  766. source: unescape('renderOn%3A%20html%0A%20%20%20%20self%0A')}),
  767. smalltalk.Widget);
  768. smalltalk.addClass('Counter', smalltalk.Widget, ['count'], 'Canvas');
  769. smalltalk.addMethod(
  770. '_initialize',
  771. smalltalk.method({
  772. selector: 'initialize',
  773. category: 'initialization',
  774. fn: function (){
  775. var self=this;
  776. self.klass.superclass.fn.prototype['_initialize'].apply(self, []);
  777. self['@count']=(0);
  778. return self;},
  779. source: unescape('initialize%0A%20%20%20%20super%20initialize.%0A%20%20%20%20count%20%3A%3D%200%0A')}),
  780. smalltalk.Counter);
  781. smalltalk.addMethod(
  782. '_renderOn_',
  783. smalltalk.method({
  784. selector: 'renderOn:',
  785. category: 'rendering',
  786. fn: function (html){
  787. var self=this;
  788. html._h1()._with_(self['@count']._asString());
  789. (function($rec){$rec._with_(unescape("++"));return $rec._onClick_((function(){return self._increase();}));})(html._button());
  790. (function($rec){$rec._with_(unescape("--"));return $rec._onClick_((function(){return self._decrease();}));})(html._button());
  791. return self;},
  792. source: unescape('renderOn%3A%20html%0A%20%20%20%20html%20h1%20with%3A%20count%20asString.%0A%20%20%20%20html%20button%0A%09with%3A%20%27++%27%3B%0A%09onClick%3A%20%5Bself%20increase%5D.%0A%20%20%20%20html%20button%0A%09with%3A%20%27--%27%3B%0A%09onClick%3A%20%5Bself%20decrease%5D%0A')}),
  793. smalltalk.Counter);
  794. smalltalk.addMethod(
  795. '_increase',
  796. smalltalk.method({
  797. selector: 'increase',
  798. category: 'actions',
  799. fn: function (){
  800. var self=this;
  801. self['@count']=self['@count'].__plus((1));
  802. self._update();
  803. return self;},
  804. source: unescape('increase%0A%20%20%20%20count%20%3A%3D%20count%20+%201.%0A%20%20%20%20self%20update%0A')}),
  805. smalltalk.Counter);
  806. smalltalk.addMethod(
  807. '_decrease',
  808. smalltalk.method({
  809. selector: 'decrease',
  810. category: 'actions',
  811. fn: function (){
  812. var self=this;
  813. self['@count']=self['@count'].__minus((1));
  814. self._update();
  815. return self;},
  816. source: unescape('decrease%0A%20%20%20%20count%20%3A%3D%20count%20-%201.%0A%20%20%20%20self%20update%0A')}),
  817. smalltalk.Counter);