Re: [JSMentors] Image pre-loading

2011-02-17 Thread Rajat Mittal
I will try check if there is something common in the rejected images. -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here:

[JSMentors] Re: Image pre-loading

2011-02-17 Thread Rajat Mittal
@simonO whats the difference between natualWidth and width ? -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/

Re: [JSMentors] Re: Image pre-loading

2011-02-17 Thread Loic Giraudel
There is a trick to make naturalWidth|Height work with IE by creating a new Image object with the same src attribute and to check its width / height. -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a

[JSMentors] Re: 'on the fly' object generation

2011-02-17 Thread Jason Mulligan
Np, I only made it 'cause i read this thread and was bored at work :) .. and saw the value in it afterwards. I revised it a little, I recommend doing the same. On Feb 16, 5:44 pm, Jason Persampieri ja...@persampieri.net wrote: On Wed, Feb 16, 2011 at 10:02 AM, Dmitry A. Soshnikov

Re: [JSMentors] 'on the fly' object generation

2011-02-17 Thread Dmitry A. Soshnikov
On 17.02.2011 1:44, Jason Persampieri wrote: On Wed, Feb 16, 2011 at 10:02 AM, Dmitry A. Soshnikov dmitry.soshni...@gmail.com mailto:dmitry.soshni...@gmail.com wrote: By the way, CoffeeScript provides a convenient sugar for that: obj.foo?.bar? and stuff?() which desugars into

[JSMentors] Extending or wrapping APIs ?

2011-02-17 Thread Fran
Hi guys, I sometimes run into this doubt when I have to use someone else classes or API. Let's see this example: /* API or Class: */ var SomeOneElseClass = function (args) {/*...*/}; SomeOneElseClass.prototype = { doSomething : function () {/*...*/}, doSomethingElse : function ()

[JSMentors] Module pattern and testability

2011-02-17 Thread Matthias Reuter
Hi all, I use the module pattern to keep the global object clean. Mostly, my modules are completely independant, so I do not use the revealing module pattern. (function () { function a () {} function b () {} }()); Now the question is, how do I unit-test function a and function b?

[JSMentors] Re: Module pattern and testability

2011-02-17 Thread Julian Turner
On Feb 17, 12:32 pm, Matthias Reuter m...@gweax.de wrote: Hi all, I use the module pattern to keep the global object clean. Mostly, my   modules are completely independant, so I do not use the revealing module   pattern. (function () {    function a () {}    function b () {} }());

[JSMentors] Re: Nested Property Access

2011-02-17 Thread Scott Sauyet
Michael Haufe (TNO) wrote: Scott Sauyet wrote: I'm guessing that what Angus was suggesting with | Michael, If you've gone that far why not just have Person have a | getZip() method to encapsulate the null checking? is the same thing I feel:  you're trying to cram a Java/C# OO idiom into

[JSMentors] Re: Module pattern and testability

2011-02-17 Thread Maximilian Antoni
I thought about that the other day as well. It would be nice to have a post-processor that automatically encapsulates an existing file content with a custom prefix/postfix pair. The test case could work on the file contents without worrying about accessibility while the compiled version does not

Re: [JSMentors] Module pattern and testability

2011-02-17 Thread Nick Morgan
I think there's a chapter on this in Christian Johansen's Test-Driven JavaScript Development (tddjs.com). I'm not sure because I haven't got there yet, and I don't have the book with me, but I'm fairly sure it addresses this exact issue. On 17 February 2011 12:32, Matthias Reuter m...@gweax.de

RE: [JSMentors] Module pattern and testability

2011-02-17 Thread Joel Dart
Also be sure to read this thread from earlier where Christian Johansen weighs in on this directly: http://groups.google.com/group/jsmentors/browse_thread/thread/da28fe220dea609/fd44ec9cf4223e03?hl=enlnk=gstq=testing#fd44ec9cf4223e03 From: jsmentors@googlegroups.com

[JSMentors] Re: Nested Property Access

2011-02-17 Thread Michael Haufe (TNO)
On Feb 17, 8:04 am, Scott Sauyet scott.sau...@gmail.com wrote: Michael Haufe (TNO) wrote: As you or the OP or anyone else creates something beyond trivial code you mentally have some notion of types and contracts in your mind. But the contracts I consider when programming in Java are very

Re: [JSMentors] Extending or wrapping APIs ?

2011-02-17 Thread Fran
Hi Loic, I'm starting a project with Google Map, and for our necessities I'm thinking about implementing a API that wraps Google Map API. I'm not sure about extending Google Map classes because I'm afraid that if I implement a method, let's call it methodA, and later on Google decides to

Re: [JSMentors] Re: Module pattern and testability

2011-02-17 Thread Peter van der Zee
On Thu, Feb 17, 2011 at 9:11 PM, Jason Mulligan jason.mulli...@avoidwork.com wrote: Why is that called a Module Pattern? It's just closure? No, that's the revealing pattern. It's the module pattern because all the variables, functions and constructors he defines are in a new own scope, which

Re: [JSMentors] Re: Module pattern and testability

2011-02-17 Thread Peter van der Zee
On Thu, Feb 17, 2011 at 9:32 PM, Jason Mulligan jason.mulli...@avoidwork.com wrote: That's hilarious ... do all javascript people just make up names for ops and call it patterns? Yes. We call it the imaginary pattern. - peter -- To view archived discussions from the original JSMentors

Re: [JSMentors] Extending or wrapping APIs ?

2011-02-17 Thread Michael Geary
Google Maps API classes are definitely not meant to be extended with your own methods and properties. As you said, Google may later add a method or property of the same name. Or there may be an internal method or property you don't know about that conflicts with yours. You are completely correct

[JSMentors] Re: Module pattern and testability

2011-02-17 Thread Jason Mulligan
You guys are silly. It's an anonymous function with sub-functions. On Feb 17, 3:40 pm, Poetro poe...@gmail.com wrote: 2011/2/17 Jason Mulligan jason.mulli...@avoidwork.com: That's hilarious ... do all javascript people just make up names for ops and call it patterns? a design pattern is a

Re: [JSMentors] Re: Module pattern and testability

2011-02-17 Thread Jason Persampieri
On Thu, Feb 17, 2011 at 1:10 PM, Jason Mulligan jason.mulli...@avoidwork.com wrote: You guys are silly. It's an anonymous function with sub-functions. Ah yes... the common Affwisseff pattern. -- To view archived discussions from the original JSMentors Mailman list:

Re: [JSMentors] Extending or wrapping APIs ?

2011-02-17 Thread Angus Croll
Extending is most useful in languages where function invocation is constrained to the object hierarchy. In JavaScript there are no such constraints, so you can simply wrap the 3rd party objects or invoke their functions in situe with call or apply. I usually find either technique is more

[JSMentors] Re: 'on the fly' object generation

2011-02-17 Thread RobG
On Feb 17, 8:53 pm, Dmitry A. Soshnikov dmitry.soshni...@gmail.com wrote: [...] It to omit initial example, but instead to take a some common abstract, the last case with a function is useful for me. E.g. function foo(callback) {    /* stuff */    callback callback(data); } or even:

[JSMentors] Re: Module pattern and testability

2011-02-17 Thread Jason Mulligan
lol, ok well if you guys want to name common ops i'll just smile and nod. you probably know why it's been named; and i don't. On Feb 17, 4:30 pm, Jason Persampieri ja...@persampieri.net wrote: On Thu, Feb 17, 2011 at 1:10 PM, Jason Mulligan jason.mulli...@avoidwork.com wrote: You guys are