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

Lucian Branescu lucian.branescu at gmail.com
Wed Nov 4 03:36:12 EST 2009

There's one point I want to nitpick on, you can make karma usable with any
library even if it uses jquery internally. Jquery is especially well suited
for this since it the least invasive (it even injects just one object).

On 4 Nov 2009 05:04, "Bryan Berry" <bryan at olenepal.org> wrote:

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

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 : [....]})

// 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

--- 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

--- 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 ;)

-- KButton ----

What is the purpose of KButton?

--- mouse.getRelativeCanvasPosition, handleEvents ---

do you have any code that uses these functions so I can see an example
of them in action?

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

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 :)

Bryan W. Berry
Senior Engineer
OLE Nepal, http://www.olenepal.org

Sugar-devel mailing list
Sugar-devel at lists.sugarlabs.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.sugarlabs.org/archive/sugar-devel/attachments/20091104/2c51bbef/attachment-0001.htm 

More information about the Sugar-devel mailing list