Skip to content

szepeviktor/amd-window

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

amd-window

Helps depending on the window object
It is useful in UMD compatible window-manipulating jQuery plugins.

Usage with curl.js

Your AMD module should depend on AMD window:

// Uses AMD or browser globals to create a jQuery plugin.
(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['jquery', 'amd-window'], factory);
    } else {
        // Browser globals
        factory(jQuery, window);
    }
}(function ($, window, undefined) {
...
}));

Why window and undefined?

You can read about it in this SO question

The window object cannot be shadowed

window = {
    num: 5,
    str: 'text'
}

if (typeof window.num === 'undefined') {
    console.log('Yes, you cannot shadow the windows object');
}

Is your code running in multiple environments?

amd-global

About

Helps depending on the window object

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published