├── .gitignore ├── README ├── jquery-ddNamespace.js ├── dflydev-namespace.js ├── LICENSE.txt └── dd-p2.xml /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Dragonfly Development jQuery Namespace Add-on 2 | http://github.com/dflydev/jquery-ddNamespace 3 | 4 | 5 | This add-on gives jQuery users the ability to manipulate global namespaces. 6 | In the most simple case, it can be used to create a namespace like this: 7 | 8 | $.namespace('dflydev.example.util'); 9 | dflydev.example.util.demo = function() { ... } 10 | 11 | 12 | Very much inspired by the following sources: 13 | http://stackoverflow.com/questions/527089/is-it-possible-to-create-a-namespace-in-jquery 14 | http://www.zachleat.com/web/2007/08/28/namespacing-outside-of-the-yahoo-namespace/ 15 | -------------------------------------------------------------------------------- /jquery-ddNamespace.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Dragonfly Development ddNamespace Add-on for jQuery 3 | * http://github.com/dflydev/jquery-ddNamespace 4 | * 5 | * Copyright (c) 2010 Dragonfly Development 6 | * Licensed under the New BSD License. 7 | */ 8 | if ( typeof jQuery != "undefined" && typeof dflydev.namespace != "undefined" ) { 9 | 10 | // 11 | // The safest location to place these functions in the jQuery 12 | // namespace is to prepend the functio names with "dd." 13 | // 14 | 15 | jQuery.ddNamespace = dflydev.namespace; 16 | jQuery.ddNsPropExists = dflydev.nsPropExists; 17 | 18 | 19 | // 20 | // The most convenient location to place tehse functions in the 21 | // jQuery namespace is the pure names. We only do this if we 22 | // do not detect any collisions. Overkill? Maybe. 23 | // 24 | 25 | if ( typeof jQuery.namespace == "undefined" ) { 26 | jQuery.namespace = jQuery.ddNamespace; 27 | } 28 | if ( typeof jQuery.nsPropExists == "undefined" ) { 29 | jQuery.nsPropExists = jQuery.ddNamespace; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /dflydev-namespace.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Dragonfly Development Namespace functions 3 | * http://github.com/dflydev/jquery-ddNamespace 4 | * 5 | * This code is not specific to jQuery, but it is not really worth keeping 6 | * track of in its own project. If the need comes up later, we can move 7 | * this elsewhere. 8 | * 9 | * Copyright (c) 2010 Dragonfly Development 10 | * Licensed under the New BSD License. 11 | */ 12 | if ( typeof dflydev == "undefined" || typeof dflydev.namespace == "undefined" ) { 13 | 14 | /** 15 | * Ensures that namespace exists 16 | */ 17 | var dflydevNamespace = function() { 18 | var a=arguments, o=null, i, j, d; 19 | for (i=0; i 2 | 3 | 0.1 4 | Dragonfly Development jQuery Namespace Add-on 5 | http://github.com/dflydev/jquery-ddNamespace 6 | Copyright (c) 2010 Dragonfly Development 7 | Licensed under the New BSD License. 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | --------------------------------------------------------------------------------