Skip to content

Extended the documentation with a style manifesto #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extended style Manifesto for jQueryfied Modules
Extended 1.1 and 1.2.
  • Loading branch information
ieservices committed Jan 22, 2015
commit a0129b3080b6bacf159c7c6deb4fb46432fc97d2
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,35 @@ Just like in Idiomatic JavaScript Style Manifesto we will summarize some example

1.1. AMD compatible factory

If you use stricly jQuery loaded by RequireJS you can do this:

```javascript

// the usual definition how to define a RequireJs compatible module
define(["jquery", "jqueryui"], function ($) {
// your code here

$.fn.extend({

pluginName: function( options ) {

this.defaultOptions = {};

var settings = $.extend({}, this.defaultOptions, options);

return this.each(function() {
var $this = $(this);
});

}

});

});
```

1.2. AMD and CommonJS compatible module factory

1.2. A factory which can do AMD and CommonJS, but musn't
But if you want to use your modules also in other projects, where RequireJS is not available, you can add this factory pattern to provide your module

```javascript

Expand All @@ -79,10 +100,26 @@ Just like in Idiomatic JavaScript Style Manifesto we will summarize some example
// Browser globals
factory(jQuery);
}
}(function ($, window, document){

// write your module ...
}(function ($, window, document){

$.fn.extend({

pluginName: function( options ) {

this.defaultOptions = {};

var settings = $.extend({}, this.defaultOptions, options);

return this.each(function() {
var $this = $(this);
});

}

});

});

}(jQuery)));
```

Expand Down