Ok take a look at this! source - http://thadeusb.com/code/py2jquery.txt examples - http://thadeusb.com/code/examples.txt
What do you think? -Thadeus On Fri, Sep 25, 2009 at 7:19 AM, mr.freeze <nat...@freezable.com> wrote: > > This may break the record for fastest derived work ever :) Your code > looks really good. Let me know if/when you have some example together > so I can compare implementations. > > On Sep 24, 12:25 pm, Thadeus Burgess <thadeus.burg...@gmail.com> > wrote: > > Solved the problem. You give every function a uuid. > > > > I spend last night and wrote my own module based off of yours. > > > > Here is the lastest version of the code:http://pastebin.com/m570fe50a > > > > It is a bit more involved to set up than your clienttools, however it > uses > > polymorphism and interfaces (I never thought I would say that outside of > > college haha). > > > > Obviously, this allows scripts to extend other scripts, to provide more > > functionality. This also allows scripts, to call other scripts, either by > > their function name (if they are a function) or by including their xml > > representation directly. > > > > Every script can be assigned a UUID, which allows you for multiple events > on > > the same object. > > > > Every Script objects have the def xml(): so that they can be called > directly > > from the template without the need for a manager class, so that they can > be > > returned from ajax. > > > > Scripts can also have global javascript variables, based off their name > and > > assigned uuid. For example, a Timer() will create a javascript variable > such > > as "interval_uuid_timerid", this allows for the timer to be accessed by a > > StopTimer() script, so that it can stop the timer, even from ajax, > without > > having to write any javascript :) > > > > -Thadeus > > > > On Wed, Sep 23, 2009 at 6:07 PM, mr.freeze <nat...@freezable.com> wrote: > > > > > Not sure if it's a best practice, but you could do a separate client > > > handler and server handler to get a Please Wait effect: > > > > > d = DIV("Click Me",_id="clickme") > > > event.listen("click", d, "jQuery('#clickme').html('Please Wait...');") > > > event.listen("click",d, handle_it, d) > > > > > def handle_it(): > > > return "Done!" > > > > > On Sep 23, 5:37 pm, Thadeus Burgess <thadeus.burg...@gmail.com> wrote: > > > > Yes it would. > > > > > > But would you ever place the same event on two different callbacks? > > > > > > -Thadeus > > > > > > On Wed, Sep 23, 2009 at 12:18 PM, mr.freeze <nat...@freezable.com> > > > wrote: > > > > > > > I get it now. I like the idea but I'm worried it will break > multiple > > > > > subscriptions. Currently you can do: > > > > > > > d = DIV("clickme",_id="clickme") > > > > > event.listen("click",d,"alert('hello');") > > > > > event.listen("click",d,"alert('hello again');") > > > > > > > Wouldn't this create two functions with the same name? > > > > > > > On Sep 23, 11:39 am, Thadeus Burgess <thadeus.burg...@gmail.com> > > > > > wrote: > > > > > > Yeah, Like put the jQuery commands in their own little function. > > > > > > > > So instead of > > > > > > > > function page_onready(){ > > > > > > jQuery().click(blahblah); > > > > > > jQuery().change(blahblah);} > > > > > > > > jQuery().page_onready(); > > > > > > > > It will become > > > > > > > > function my_div__click(){ > > > > > > jQuery.click(blahblah);} > > > > > > > > function my_input__change(){ > > > > > > jQuery.change(blahblah);} > > > > > > > > function page_onready(){ > > > > > > my_div__click() > > > > > > my_input__change()} > > > > > > > > jquery().page_onready(); > > > > > > > > Hope that helps clear up what I ment. > > > > > > > > I'm not sure of any big advantage except it helps make it more > > > organized. > > > > > > That and it would make using the legacy rebinding easier. > > > > > > > > -Thadeus > > > > > > > > On Wed, Sep 23, 2009 at 11:28 AM, mr.freeze < > nat...@freezable.com> > > > > > wrote: > > > > > > > > > I think I missed your point. Let me take a closer look. > > > > > > > > > On Sep 23, 11:22 am, "mr.freeze" <nat...@freezable.com> wrote: > > > > > > > > I actually realized that last night and refactored > everything. > > > Can > > > > > > > > you check out the latest version and see if it does what you > > > want? > > > > > > > > > > On Sep 23, 11:14 am, Thadeus Burgess < > thadeus.burg...@gmail.com> > > > > > > > > wrote: > > > > > > > > > > > What about grouping the actions in individual functions, > that > > > way > > > > > > > calling > > > > > > > > > these functions from returned jQuery commands, or from > other > > > > > JavaScript > > > > > > > > > would make it easier! (also if you needed to support a > legacy > > > > > version > > > > > > > of > > > > > > > > > jQuery for add-on compatibility, you could use it for > rebinding > > > > > much > > > > > > > easier. > > > > > > > > > > > This includes example output of what I'm talking about, and > > > code to > > > > > > > make > > > > > > > > > that happen, note this doesn't include your recent > additions > > > Nathan > > > > > > > (live or > > > > > > > > > args) > > > > > > > > > > >http://pastebin.com/m70de2cc0 > > > > > > > > > > > -Thadeus > > > > > > > > > > > On Tue, Sep 22, 2009 at 8:53 PM, mr.freeze < > > > nat...@freezable.com> > > > > > > > wrote: > > > > > > > > > > > > As promised, I have added some new examples. I have also > > > added > > > > > > > > > > several new things to the module: > > > > > > > > > > > > ScriptManager - a collection of reusable scripts that > include > > > (so > > > > > > > > > > far): > > > > > > > > > > 1) call_server (generates the script for an ajax > callback) > > > > > > > > > > 2) alert and confirm (exactly what you think) > > > > > > > > > > 3) delay (setTimeout) > > > > > > > > > > 4) timer (setInterval) > > > > > > > > > > 5) stop_timer (clearTimeout) > > > > > > > > > > > > *experimental* > > > > > > > > > > JQuery - helper to generate jQuery script string from > Python > > > (to > > > > > > > > > > reduce nested quotes): > > > > > > > > > > JQuery("#servertime").css("color","red")() # produces > > > 'jQuery > > > > > > > > > > ("#servertime").css("color", "red");' > > > > > > > > > > > > You can check out examples here: > > > > > > > > > >http://www.web2pyslices.com/main/slices/take_slice/8 > > > > > > > > > > > > The timer example is the most interesting I think. Enjoy > > > and, as > > > > > > > > > > always, feedback is welcome. > > > > > > > > > > > > On Sep 20, 6:57 am, Iceberg <iceb...@21cn.com> wrote: > > > > > > > > > > > On Sep20, 2:14am, "mr.freeze" <nat...@freezable.com> > > > wrote: > > > > > > > > > > > > > > Hi folks, > > > > > > > > > > > > > > I just wanted to share a module that I'm working > on > > > for a > > > > > > > > > > > > project. It containstoolsfor managingclientevents > and > > > > > resources > > > > > > > > > > > > from the server. Here are the main features: > > > > > > > > > > > > > > 1) Dynamic inclusion and downloading of resources > > > > > (scripts/css). > > > > > > > > > > > > 2) Server side event handling forclientside events. > > > > > > > > > > > > 3) Dynamic execution of script from the controller. > > > (through > > > > > > > > > > > > document.ready injection) > > > > > > > > > > > > 4) Helpers for google hosted ajax APIs. > > > > > > > > > > > > > > You can see instructions and examples here: > > > > > > > > > > > > > >http://www.web2pyslices.com/main/slices/take_slice/8 > > > > > > > > > > > > > > It's definitely a work in progress, but let me know > what > > > you > > > > > > > think. > > > > > > > > > > > > > > -Nathan > > > > > > > > > > > > > After trying to implement your 4 examples in a "normal" > > > way, > > > > > which > > > > > > > > > > > turns out to be tricky or even difficult (especially in > the > > > > > last > > > > > > > two > > > > > > > > > > > cases), I am convinced that thisclienttoolshave its > great > > > > > value! > > > > > > > > > > > Well done, Nathan! > > > > > > > > > > > > > This stuff looks cool. Would you please give some more > > > example > > > > > (in > > > > > > > > > > > your slice site) to demonstrate what mission this tool > > > performs > > > > > > > easier > > > > > > > > > > > than otherwise? > > > > > > > > > > > > > I don't mean this stuff is not good. I just have poor > > > > > imagination > > > > > > > and > > > > > > > > > > > sorry for that. :-) > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---