If I have an existing element inside a DOM, I can do
element := (document getElementById: 'someID' ). The problem is that it returns a Javascript object not a Smalltalk one. Is there a way to instantiate a Tagbrush or Widget from that "naked" element ? |
Hi,
AFAIK You can always use 'someObj' asJQuery to get an object and then send messages like let's say: ('someObj' asJQuery) load: 'http://hmpf.pf/newContent.php'. or... ('someObj' asJQuery) style: 'background-color' value: 'black'. Regards... On 16 Feb., 20:56, leonsmith <[hidden email]> wrote: > If I have an existing element inside a DOM, I can do > element := (document getElementById: 'someID' ). > > The problem is that it returns a Javascript object not a Smalltalk > one. Is there a way to instantiate a Tagbrush or Widget from that > "naked" element ? |
In reply to this post by leonsmith
On 16/02/12 20:56, leonsmith wrote:
> If I have an existing element inside a DOM, I can do > element := (document getElementById: 'someID' ). > > The problem is that it returns a Javascript object not a Smalltalk > one. Is there a way to instantiate a Tagbrush or Widget from that > "naked" element ? You instantiate a canvas like this: html := HTMLCanvas onJQuery: '#someID' asJQuery. Then, to use your canvas; html h1 with: 'hello world' HTH, Nico -- Nicolas Petton http://nicolas-petton.fr |
Thanks for the suggestions. I am pretty comfortable rendering a page,
what I am after is the other direction. If I have an HTML page already built with predefined <div> tags, I know how to get that as a Javascript object and how to call Javascript functions, what I'd like to do is create a Smalltalk object for it (other than JSObjectProxy) and send Smalltalk methods to that instance. I think I might create some HTMLDom objects that hold on to and use the JSObject and just wrap my new methods around that. Thanks again, whatever I come up with be in my repository on Github. On Feb 17, 7:16 am, Nicolas Petton <[hidden email]> wrote: > On 16/02/12 20:56, leonsmith wrote: > > > If I have an existing element inside a DOM, I can do > > element := (document getElementById: 'someID' ). > > > The problem is that it returns a Javascript object not a Smalltalk > > one. Is there a way to instantiate a Tagbrush or Widget from that > > "naked" element ? > > You instantiate a canvas like this: > > html := HTMLCanvas onJQuery: '#someID' asJQuery. > > Then, to use your canvas; > > html h1 with: 'hello world' > > HTH, > Nico > > -- > Nicolas Pettonhttp://nicolas-petton.fr |
I do not understand. What should that accomplish?
On Fri, Feb 17, 2012 at 7:20 PM, leonsmith <[hidden email]> wrote: Thanks for the suggestions. I am pretty comfortable rendering a page, |
Amber, what I hope to accomplish is to bring the entire Document
Object Model into Amber as true Smalltalk objects. Then we will have instant access to the millions of templates available without having to think in two languages. Companies like to distribute development efforts among the departments best suited for the tasks: the Tech writers come up with the documentation, the developers implement the "Business rules" that the analysts come up with, and the web designers make it all pleasing and functional. This may be one of those situations where you have to see it to believe it :-) On Feb 18, 2:59 pm, Amber Milan Eskridge <[hidden email]> wrote: > I do not understand. What should that accomplish? > > > > > > > > On Fri, Feb 17, 2012 at 7:20 PM, leonsmith <[hidden email]> wrote: > > Thanks for the suggestions. I am pretty comfortable rendering a page, > > what I am after is the other direction. If I have an HTML page already > > built with predefined <div> tags, I know how to get that as a > > Javascript object and how to call Javascript functions, what I'd like > > to do is create a Smalltalk object for it (other than JSObjectProxy) > > and send Smalltalk methods to that instance. > > > I think I might create some HTMLDom objects that hold on to and use > > the JSObject and just wrap my new methods around that. > > > Thanks again, whatever I come up with be in my repository on Github. > > > On Feb 17, 7:16 am, Nicolas Petton <[hidden email]> wrote: > > > On 16/02/12 20:56, leonsmith wrote: > > > > > If I have an existing element inside a DOM, I can do > > > > element := (document getElementById: 'someID' ). > > > > > The problem is that it returns a Javascript object not a Smalltalk > > > > one. Is there a way to instantiate a Tagbrush or Widget from that > > > > "naked" element ? > > > > You instantiate a canvas like this: > > > > html := HTMLCanvas onJQuery: '#someID' asJQuery. > > > > Then, to use your canvas; > > > > html h1 with: 'hello world' > > > > HTH, > > > Nico > > > > -- > > > Nicolas Pettonhttp://nicolas-petton.fr |
You can extend the core aspects Node, Element and so on, like Amber does it for String, Function and so on. smalltalk.mapClassName("Number", "Kernel", Number, smalltalk.Object); smalltalk.mapClassName("BlockClosure", "Kernel", Function, smalltalk.Object); smalltalk.mapClassName("Boolean", "Kernel", Boolean, smalltalk.Object); smalltalk.mapClassName("Date", "Kernel", Date, smalltalk.Object); smalltalk.mapClassName("UndefinedObject", "Kernel", SmalltalkNil, smalltalk.Object); On Sun, Feb 19, 2012 at 5:09 PM, leonsmith <[hidden email]> wrote: Amber, what I hope to accomplish is to bring the entire Document |
On 24/02/12 12:56, Amber Milan Eskridge wrote:
> > You can extend the core aspects Node, Element and so on, like Amber does > it for String, Function and so on. Hi! I wouldn't do that :) Extending the DOM is considered a bad practice, and has downsides. http://perfectionkills.com/whats-wrong-with-extending-the-dom/ Cheers, Nico > > smalltalk.mapClassName("Number", "Kernel", Number, smalltalk.Object); > > smalltalk.mapClassName("BlockClosure", "Kernel", Function, > smalltalk.Object); > > smalltalk.mapClassName("Boolean", "Kernel", Boolean, smalltalk.Object); > > smalltalk.mapClassName("Date", "Kernel", Date, smalltalk.Object); > > smalltalk.mapClassName("UndefinedObject", "Kernel", SmalltalkNil, > smalltalk.Object); > > > > (To transform the DOM into a custom object structure you could use a > Parsing Expression Grammar(PEG) with DOM-Objects as its Literals) > > On Sun, Feb 19, 2012 at 5:09 PM, leonsmith <[hidden email] > <mailto:[hidden email]>> wrote: > > Amber, what I hope to accomplish is to bring the entire Document > Object Model into Amber as true Smalltalk objects. Then we will have > instant access to the millions of templates available without having > to think in two languages. Companies like to distribute development > efforts among the departments best suited for the tasks: the Tech > writers come up with the documentation, the developers implement the > "Business rules" that the analysts come up with, and the web designers > make it all pleasing and functional. This may be one of those > situations where you have to see it to believe it :-) > > On Feb 18, 2:59 pm, Amber Milan Eskridge > <[hidden email] > <mailto:[hidden email]>> wrote: > > I do not understand. What should that accomplish? > > > > > > > > > > > > > > > > On Fri, Feb 17, 2012 at 7:20 PM, leonsmith > <[hidden email] <mailto:[hidden email]>> wrote: > > > Thanks for the suggestions. I am pretty comfortable rendering a > page, > > > what I am after is the other direction. If I have an HTML page > already > > > built with predefined <div> tags, I know how to get that as a > > > Javascript object and how to call Javascript functions, what > I'd like > > > to do is create a Smalltalk object for it (other than > JSObjectProxy) > > > and send Smalltalk methods to that instance. > > > > > I think I might create some HTMLDom objects that hold on to and use > > > the JSObject and just wrap my new methods around that. > > > > > Thanks again, whatever I come up with be in my repository on > Github. > > > > > On Feb 17, 7:16 am, Nicolas Petton <[hidden email] > <mailto:[hidden email]>> wrote: > > > > On 16/02/12 20:56, leonsmith wrote: > > > > > > > If I have an existing element inside a DOM, I can do > > > > > element := (document getElementById: 'someID' ). > > > > > > > The problem is that it returns a Javascript object not a > Smalltalk > > > > > one. Is there a way to instantiate a Tagbrush or Widget > from that > > > > > "naked" element ? > > > > > > You instantiate a canvas like this: > > > > > > html := HTMLCanvas onJQuery: '#someID' asJQuery. > > > > > > Then, to use your canvas; > > > > > > html h1 with: 'hello world' > > > > > > HTH, > > > > Nico > > > > > > -- > > > > Nicolas Pettonhttp://nicolas-petton.fr <http://nicolas-petton.fr> > > -- Nicolas Petton http://nicolas-petton.fr |
Okay, let me check. The alternative is modifying smalltalk.send to take objects whose prototypes have not been modified into account by dispatching on type. That would add the benefit, that Objects not participating in the smalltalk-enhanced context (e.g. Objects from another frame) could be used as if they did.On Fri, Feb 24, 2012 at 2:28 PM, Nicolas Petton <[hidden email]> wrote:
|
Thanks for the suggestions. I've already implemented the entire W3
HTML DOM in Amber. I just need to add setter methods (mutators), I have all the accessor methods coded with verbose comments everywhere. One result is that I now understand the DOM pretty well :-). This may not be what others want, but I need to be able to pull in an already built page and mess with it. I think this will work pretty well. Thanks to the work Nico and all have done it was pretty easy, just a lot of rote work. I didn't change any Amber methods or extend the DOM. I did manage to get a decent Class hierarchy out of it because the DOM doesn't have to be implemented in Javascript, it's really conceptual and best represented as an XML document. Too bad all the designers and architects in the world aren't forced to learn Smalltalk first so they REALLY understand OOP concepts. You never see the word "inherited" instead they say something like "HTMLButton Object can also use the properties and methods of Node and Element". I understand how prototypes work and they are sort of cool, but I'll keep my Class Hierarchy mindset. Thanks for thinking about the problem Amber, I'll be curious what you think when I am ready to show it. Probably first part of next week. On Feb 24, 9:01 am, Amber Milan Eskridge <[hidden email]> wrote: > Okay, let me check. > The alternative is modifying smalltalk.send to take objects whose > prototypes have not been modified into account by dispatching on type. That > would add the benefit, that Objects not participating in the > smalltalk-enhanced context (e.g. Objects from another frame) could be used > as if they did. > > On Fri, Feb 24, 2012 at 2:28 PM, Nicolas Petton <[hidden email]>wrote: > > > > > > > > > On 24/02/12 12:56, Amber Milan Eskridge wrote: > > >> You can extend the core aspects Node, Element and so on, like Amber does > >> it for String, Function and so on. > > > Hi! > > > I wouldn't do that :) > > > Extending the DOM is considered a bad practice, and has downsides. > >http://perfectionkills.com/**whats-wrong-with-extending-**the-dom/<http://perfectionkills.com/whats-wrong-with-extending-the-dom/> > > > Cheers, > > Nico > > >> smalltalk.mapClassName("**Number", "Kernel", Number, smalltalk.Object); > > >> smalltalk.mapClassName("**BlockClosure", "Kernel", Function, > >> smalltalk.Object); > > >> smalltalk.mapClassName("**Boolean", "Kernel", Boolean, smalltalk.Object); > > >> smalltalk.mapClassName("Date", "Kernel", Date, smalltalk.Object); > > >> smalltalk.mapClassName("**UndefinedObject", "Kernel", SmalltalkNil, > >> smalltalk.Object); > > >> (To transform the DOM into a custom object structure you could use a > >> Parsing Expression Grammar(PEG) with DOM-Objects as its Literals) > > >> On Sun, Feb 19, 2012 at 5:09 PM, leonsmith <[hidden email] > >> <mailto:leonpetersmith@gmail.**com <[hidden email]>>> wrote: > > >> Amber, what I hope to accomplish is to bring the entire Document > >> Object Model into Amber as true Smalltalk objects. Then we will have > >> instant access to the millions of templates available without having > >> to think in two languages. Companies like to distribute development > >> efforts among the departments best suited for the tasks: the Tech > >> writers come up with the documentation, the developers implement the > >> "Business rules" that the analysts come up with, and the web designers > >> make it all pleasing and functional. This may be one of those > >> situations where you have to see it to believe it :-) > > >> On Feb 18, 2:59 pm, Amber Milan Eskridge > >> <[hidden email] > >> <mailto:amber.eskri...@**googlemail.com<[hidden email]>>> > >> wrote: > >> > I do not understand. What should that accomplish? > > >> > On Fri, Feb 17, 2012 at 7:20 PM, leonsmith > >> <[hidden email] <mailto:leonpetersm...@gmail.**com<[hidden email]>>> > >> wrote: > >> > > Thanks for the suggestions. I am pretty comfortable rendering a > >> page, > >> > > what I am after is the other direction. If I have an HTML page > >> already > >> > > built with predefined <div> tags, I know how to get that as a > >> > > Javascript object and how to call Javascript functions, what > >> I'd like > >> > > to do is create a Smalltalk object for it (other than > >> JSObjectProxy) > >> > > and send Smalltalk methods to that instance. > > >> > > I think I might create some HTMLDom objects that hold on to and > >> use > >> > > the JSObject and just wrap my new methods around that. > > >> > > Thanks again, whatever I come up with be in my repository on > >> Github. > > >> > > On Feb 17, 7:16 am, Nicolas Petton <[hidden email] > >> <mailto:petton.nico...@gmail.**com <[hidden email]>>> wrote: > >> > > > On 16/02/12 20:56, leonsmith wrote: > > >> > > > > If I have an existing element inside a DOM, I can do > >> > > > > element := (document getElementById: 'someID' ). > > >> > > > > The problem is that it returns a Javascript object not a > >> Smalltalk > >> > > > > one. Is there a way to instantiate a Tagbrush or Widget > >> from that > >> > > > > "naked" element ? > > >> > > > You instantiate a canvas like this: > > >> > > > html := HTMLCanvas onJQuery: '#someID' asJQuery. > > >> > > > Then, to use your canvas; > > >> > > > html h1 with: 'hello world' > > >> > > > HTH, > >> > > > Nico > > >> > > > -- > >> > > > Nicolas Pettonhttp://nicolas-petton.fr< > >>http://nicolas-petton.fr> > > > -- > > Nicolas Petton > >http://nicolas-petton.fr |
On 02/26/2012 01:55 AM, leonsmith wrote:
> Thanks for thinking about the problem Amber, I'll be curious what you > think when I am ready to show it. Probably first part of next week. I think his (or her) name is Milan? Just a guess. regards, Göran |
whoops. The posts are always signed Amber Milan Eskridge. Sorry if I
screwed up. On Feb 27, 1:23 am, Göran Krampe <[hidden email]> wrote: > On 02/26/2012 01:55 AM, leonsmith wrote: > > > Thanks for thinking about the problem Amber, I'll be curious what you > > think when I am ready to show it. Probably first part of next week. > > I think his (or her) name is Milan? Just a guess. > > regards, G ran |
In reply to this post by leonsmith
On 2/26/12, leonsmith <[hidden email]> wrote:
> Thanks for the suggestions. I've already implemented the entire W3 > HTML DOM in Amber. I just need to add setter methods (mutators), I > have all the accessor methods coded with verbose comments everywhere. > One result is that I now understand the DOM pretty well :-). This may > not be what others want, but I need to be able to pull in an already > built page and mess with it. I think this will work pretty well. > Thanks to the work Nico and all have done it was pretty easy, just a > lot of rote work. I didn't change any Amber methods or extend the DOM. > I did manage to get a decent Class hierarchy out of it because the DOM > doesn't have to be implemented in Javascript, it's really conceptual > and best represented as an XML document. Too bad all the designers and > architects in the world aren't forced to learn Smalltalk first so they > REALLY understand OOP concepts. You never see the word "inherited" > instead they say something like "HTMLButton Object can also use the > properties and methods of Node and Element". I understand how > prototypes work and they are sort of cool, but I'll keep my Class > Hierarchy mindset. > > Thanks for thinking about the problem Amber, I'll be curious what you > think when I am ready to show it. Probably first part of next week. Yes, and I am curious to have a look at your implementation of a DOM hierarchy in Amber .... It will be useful to deal with existing HTML pages (e.g. a list of articles) Cheers Hannes |
Well its back to the Drawing board...
I kept finding all this weirdness when traversing the object model in a page and finally stumbled on this link. Seems there is a thing called the Browser Object Model. The only problem is that it is not defined ! There is no standard and every browser can implement it as they choose. My next attempt with only use the JQuery stuff I think. More research to do first. http://en.wikipedia.org/wiki/Browser_Object_Model On Feb 29, 12:28 am, "H. Hirzel" <[hidden email]> wrote: > On 2/26/12, leonsmith <[hidden email]> wrote: > > > > > > > > > > > Thanks for the suggestions. I've already implemented the entire W3 > > HTML DOM in Amber. I just need to add setter methods (mutators), I > > have all the accessor methods coded with verbose comments everywhere. > > One result is that I now understand the DOM pretty well :-). This may > > not be what others want, but I need to be able to pull in an already > > built page and mess with it. I think this will work pretty well. > > Thanks to the work Nico and all have done it was pretty easy, just a > > lot of rote work. I didn't change any Amber methods or extend the DOM. > > I did manage to get a decent Class hierarchy out of it because the DOM > > doesn't have to be implemented in Javascript, it's really conceptual > > and best represented as an XML document. Too bad all the designers and > > architects in the world aren't forced to learn Smalltalk first so they > > REALLY understand OOP concepts. You never see the word "inherited" > > instead they say something like "HTMLButton Object can also use the > > properties and methods of Node and Element". I understand how > > prototypes work and they are sort of cool, but I'll keep my Class > > Hierarchy mindset. > > > Thanks for thinking about the problem Amber, I'll be curious what you > > think when I am ready to show it. Probably first part of next week. > > Yes, and I am curious to have a look at your implementation of a DOM > hierarchy in Amber .... > It will be useful to deal with existing HTML pages (e.g. a list of articles) > > Cheers > Hannes |
Hello Leon
Coming back to your original question In the workspace I just tried ("doIt") myDrawing := window document getElementById: 'myDrawing' . myDrawing inspect (I have a <canvas id="myDrawing">.....</canvas> element) I got the inspector (see picture) Then I did a "doIt" for myDrawing style display: 'none'. It works fine and it show that the rules with which you can invoke JavaScript methods with Smalltalk selectors works fine as well for DOM methods. So it seems that it is not all that necessary to wrap the DOM elements to work with them in Amber Best wishes Hannes On 3/1/12, leonsmith <[hidden email]> wrote: > Well its back to the Drawing board... > > I kept finding all this weirdness when traversing the object model in > a page and finally stumbled on this link. Seems there is a thing > called the Browser Object Model. The only problem is that it is not > defined ! There is no standard and every browser can implement it as > they choose. My next attempt with only use the JQuery stuff I think. > More research to do first. > > http://en.wikipedia.org/wiki/Browser_Object_Model > > On Feb 29, 12:28 am, "H. Hirzel" <[hidden email]> wrote: >> On 2/26/12, leonsmith <[hidden email]> wrote: >> >> >> >> >> >> >> >> >> >> > Thanks for the suggestions. I've already implemented the entire W3 >> > HTML DOM in Amber. I just need to add setter methods (mutators), I >> > have all the accessor methods coded with verbose comments everywhere. >> > One result is that I now understand the DOM pretty well :-). This may >> > not be what others want, but I need to be able to pull in an already >> > built page and mess with it. I think this will work pretty well. >> > Thanks to the work Nico and all have done it was pretty easy, just a >> > lot of rote work. I didn't change any Amber methods or extend the DOM. >> > I did manage to get a decent Class hierarchy out of it because the DOM >> > doesn't have to be implemented in Javascript, it's really conceptual >> > and best represented as an XML document. Too bad all the designers and >> > architects in the world aren't forced to learn Smalltalk first so they >> > REALLY understand OOP concepts. You never see the word "inherited" >> > instead they say something like "HTMLButton Object can also use the >> > properties and methods of Node and Element". I understand how >> > prototypes work and they are sort of cool, but I'll keep my Class >> > Hierarchy mindset. >> >> > Thanks for thinking about the problem Amber, I'll be curious what you >> > think when I am ready to show it. Probably first part of next week. >> >> Yes, and I am curious to have a look at your implementation of a DOM >> hierarchy in Amber .... >> It will be useful to deal with existing HTML pages (e.g. a list of >> articles) >> >> Cheers >> Hannes Amber-Result-Of-document-getElementById-inspect.PNG (9K) Download Attachment |
Free forum by Nabble | Edit this page |