You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by Qi LUO <lu...@polyvi.com> on 2013/10/12 10:55:45 UTC

What's the rule when determine where to attach plugin object/method to window or navigator object?

Hi all,  

Everyone can access plugins at window or navigator object, but I’m quite curious that how you guys make the decision when you define a plugin? Why someone is on the window object but another is on the navigator object or any custom namespace else?
Thanks.  

Best Regards,
  
Qi LUO
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


Re: What's the rule when determine where to attach plugin object/method to window or navigator object?

Posted by Ian Clelland <ic...@chromium.org>.
I can't speak officially for any of the early decisions made in the
project, but the guiding principles seem to be:

1. If possible, adhere to an existing W3C standard
(File, Storage)
2. If there is a de facto standard implemented on desktop browsers,use that
(Accelerometer, Geolocation)
3. If there is a natural mapping to a closely related desktop API, then
mimic that. (e.g, window.open -> InAppBrowser)
4. Other plugins were generally attached to navigator (navigator.compass,
navigator.globalization, navigator.splashscreen), except for
5. A couple of APIs (e.g., Device, Media) which were assigned to window.

Custom namespaces are really just objects attached to the global window
object; that's how Media and File are defined. (In the browser, all lookups
eventually go back to window; that's just where globals live.)

Ian



On Sat, Oct 12, 2013 at 4:55 AM, Qi LUO <lu...@polyvi.com> wrote:

> Hi all,
>
> Everyone can access plugins at window or navigator object, but I’m quite
> curious that how you guys make the decision when you define a plugin? Why
> someone is on the window object but another is on the navigator object or
> any custom namespace else?
> Thanks.
>
> Best Regards,
>
> Qi LUO
> Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
>
>

Re: What's the rule when determine where to attach plugin object/method to window or navigator object?

Posted by Andrew Grieve <ag...@chromium.org>.
I don't think we have much in the way of guidelines here.

That said, I'd like to see things go under: cordova.plugins.PLUGIN_NAME.


On Sat, Oct 12, 2013 at 4:55 AM, Qi LUO <lu...@polyvi.com> wrote:

> Hi all,
>
> Everyone can access plugins at window or navigator object, but I’m quite
> curious that how you guys make the decision when you define a plugin? Why
> someone is on the window object but another is on the navigator object or
> any custom namespace else?
> Thanks.
>
> Best Regards,
>
> Qi LUO
> Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
>
>