[Sugar-devel] [Karma] questions about jquery.karma.js

Felipe López Toledo zer.subzero at gmail.com
Thu Nov 5 16:43:11 EST 2009


2009/11/4 Bryan Berry <bryan at olenepal.org>

> I am refactoring jquery.karma.js using test-driven development.

> I think you did a great job in writing it in the first place, but I am
> far to lazy to manually test out the entire library every time I make a
> change.
interesting, +1 to use test-driven
I think it will consume more time, but it will make easier the introduction
to new developers

> Reading through jquery.karma.js, I have some questions:
> --- the init function ---
> You have an init function that receives the assets to be loaded as an
> argument but actually loading them happens in the first part of the if
> statement of karma.main . To me it would make more sense to just pass
> the assets as an argument to karma.main({ /* assets object */}) and not
> the function call back as currently.
> Ideally I would like the use of Karma in lesson.js to be as simple as
> var k = Karma({ images: [ .....], sounds : [...], surfaces : [....]})
then it will be necessary to define the i18n options first
var k = Karma({ i18n: []...., images: [ .....], sounds : [...], surfaces :

other way what images/sounds are we suppose to load?

> // the rest of the code for a lesson
> I don't understand the if statement in karma.main. It seems to me that
> the callback to main function would never be called. That the first if
> clause will always be true and karma.main() won't be called a second
> time.
I'm checking if there is something to load ( pendingToLoad ), if yes then I
load all the stuff
other way the else statement will be executed

anyway the callback function will be executed (if it's defined)

> --- taking out the jquery inside Karma ---
> I like how we have packaged  karma as a jquery library because it gives
> us a standard pattern to follow. That said, I don't want to use jquery
> internally to the library so dojo or prototype fans can use it freely
we won't have *any* dependencies, anyway we're using specific parts
(helpers) of jquery (example: $.each )

> --- to prototype or not to prototype? ----
> I intend to use monkey-patch the Object object with the function create
> so Object.prototype.create = function ...
> this create function will be implemented in Ecmascript 5 and it matches
> Crockford's object(o) function for prototypal inheritance. This is my
> excuse for monkey patching ;)
interesting, let me read (more) about in order to give you good arguments to
discuss it

> -- KButton ----
> What is the purpose of KButton?
> there is no way to create buttons or clickeable elements inside a canvas,
as for example, svg has its clickeable property (or something called like
KButton is a "fast way" to create clickeable canvas sub-regions, this
feature can be replaced by multiple canvas

> --- mouse.getRelativeCanvasPosition, handleEvents ---
> do you have any code that uses these functions so I can see an example
> of them in action?
the mouse class is a helper when using the mouse, if you try to get the
mouse coordinates in the "common" ways you will face some troubles, this
method fix that problem.

as its name says it, it's a "master" dispatcher for events, actually just
KButton uses it.

> those are the main questions I have for now. Thanks for reading this far
> in a long e-mail ;)
thanks for asking ;)

> I know you are very busy with your exams right now, but do u think we
> could chat in the next couple days for about an hour about the structure
> of jquery.karma.js?
> I am on the east coast of the US right now so timezones are easier :)
what about this weekend?

cheers ;)

Felipe López Toledo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.sugarlabs.org/archive/sugar-devel/attachments/20091105/e1a5d3e1/attachment-0001.htm 

More information about the Sugar-devel mailing list