Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit

Permalink
Cleanup, docs and getting ready for 1.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed May 16, 2012
1 parent 8c2a1a2 commit e689045
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 75 deletions.
2 changes: 1 addition & 1 deletion build/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ steal.overwrite = true;

steal('steal/build/pluginify').then(function(s)
{
var version = '0.2.0';
var version = '1.0.0';
print('Building version ' + version);
s.build.pluginify('build',
{
Expand Down
57 changes: 0 additions & 57 deletions build/js

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 39 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,33 @@ Generates:
<option value="de" selected="selected">Germany</option>
</select>

To use option groups just pass an object of type *optgroup*:

{
"type" : "select",
"options" : {
"northamerica" : {
"type" : "optgroup",
"label" : "North America",
"options" : {
"us" : "USA",
"ca" : "Canada"
}
},
"europe" : {
"type" : "optgroup",
"label" : "Europe",
"options" : {
"de" : {
"selected" : "selected",
"html" : "Germany"
},
"fr" : "France"
}
}
}
}

You can also use options on *checkboxes* and *radiobuttons* which will create a list of *checkbox*
or *radio* elements:

Expand Down Expand Up @@ -303,7 +330,7 @@ Adds a caption to the element. The type used depends on the element type:
* A *label* next to *radio* or *checkbox* elements
* A *label* before any other element

If the element has its id set the *for* attribute of the label will be set as well.
If the element has its id set, the *for* attribute of the label will be set as well.

{
"type" : "text",
Expand Down Expand Up @@ -342,14 +369,14 @@ Generates:

<input type="text" class="ui-dform-text" />

Set `$.dform.options.prefix = false;` if you don't want any classes being added.
Set `$.dform.options.prefix = null;` if you don't want any classes being added.

### Add your own

It is easy to add your own subscribers. Similar to a type generator you just pass the key name you want to subscribe
to and a function that takes the options and the type name as a parameter to `$.dform.subscribe`. `this` in the
subscriber function will refer to the current element. That way it would be possible for example to add an alert to the
*hellobutton* created in the [types section](#subscribers/add-your-own):
subscriber function will refer to the current element. That way it is possible to add an alert to the
*hellobutton* example created in the [types section](#subscribers/add-your-own):

$.dform.subscribe("alert", function(options, type) {
// Just run if the type is a hellobutton
Expand Down Expand Up @@ -428,7 +455,7 @@ Returns a new object that contains all value from the given
object that do not have a key which is also in the array keys.

**$.dform.options**<br />
Static options for generating a form. Currently only $.dform.options.prefix
Static options for generating a form. Currently only `$.dform.options.prefix`
is being used.

**$.dform.defaultType(options)** *{Object}*<br />
Expand Down Expand Up @@ -464,9 +491,11 @@ Returns if there is any subscribers with the given name.

## jQuery UI

jQuery.dForm automatically adds support for jQuery UI if it is available. If the form has the *ui-widget* class
the plugin will automatically turn buttons into jQuery UI buttons and add corners to *text*, *textarea*, *password*
and *fieldset* elements.
jQuery.dForm automatically adds support for whichever jQuery UI plugin is available.
If the form has the *ui-widget* class the plugin will automatically turn buttons into jQuery UI buttons and add
corners to *text*, *textarea*, *password* and *fieldset* elements.

> Note: jQuery UI has to be loaded __before__ the plugin.
### Types

Expand Down Expand Up @@ -540,11 +569,11 @@ invalid fields.
### jQuery Globalize

[jQuery.Globalize] adds some nice internationalization to JavaScript. If available, the *html* and *options*
subscriber are enabled to use internationalized strings and option lists.
subscribers are enabled to use internationalized strings and option lists.

## Changelog

__0.2.0__
__1.0.0__

* Improved documentation using DocumentUp
* QUnit test suite runs test for the complete core
Expand Down
2 changes: 1 addition & 1 deletion src/dform.extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
var scoper = this;
$.each(options, function(index, options) {
var el = $.extend({ "type" : "div" }, options);
$(scoper).formElement(el);
$(scoper).dform('append', el);
if(options.caption) {
var label = $(scoper).children("div:last").prev();
label.replaceWith('<h3><a href="#">' + label.html() + '</a></h3>');
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ $(document).ready(function () {
equal(created.attr('id'), 'test-id', 'ID added');
equal(created.data('test'), 'Test data attribute', 'Added test data attribute');
});
});
});
2 changes: 1 addition & 1 deletion test/test_extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ $(document).ready(function () {
test("First", function () {
ok(true, 'Some test');
})
});
});
2 changes: 1 addition & 1 deletion test/test_subscribers.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,4 @@ $(document).ready(function () {
ok(checkboxes.find('[type="checkbox"][value="test1"]').length);
equal(checkboxes.find('label:first').html(), 'Test 1', 'Set for and found label');
});
});
});
2 changes: 1 addition & 1 deletion test/test_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ $(document).ready(function () {
ok(form.dform({ type : 'tel' }).find('[type="tel"]').length);
ok(form.dform({ type : 'email' }).find('[type="email"]').length);
});
});
});

0 comments on commit e689045

Please sign in to comment.