Skip to content

Commit 3cd266e

Browse files
author
daffl
committed
DForm source update
1 parent 50cc870 commit 3cd266e

File tree

1 file changed

+37
-48
lines changed

1 file changed

+37
-48
lines changed

src/dform.js

Lines changed: 37 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55
* Licensed under the MIT license
66
*/
77

8-
/**
9-
* @page index
10-
* @tags home
11-
*
12-
* This is the documentation for the core helpers and jQuery
13-
* functions of the plugin.
14-
*
15-
* Author:
16-
* David Luecke (daff@neyeon.de)
17-
*/
188
(function($)
199
{
2010
var _subscriptions = {};
@@ -55,12 +45,14 @@
5545
* @return {Object} The jQuery object
5646
*/
5747
runSubscription : function(name, options, type) {
58-
var element = this;
5948
if ($.dform.hasSubscription(name))
6049
{
61-
$.each(_subscriptions[name], function(i, sfn) {
62-
// run subscriber function with options
63-
sfn.call($(element), options, type);
50+
this.each(function() {
51+
var element = this;
52+
$.each(_subscriptions[name], function(i, sfn) {
53+
// run subscriber function with options
54+
sfn.call($(element), options, type);
55+
});
6456
});
6557
}
6658
return this;
@@ -73,12 +65,10 @@
7365
*/
7466
runAll : function(options)
7567
{
76-
var type = options.type;
77-
var scoper = this;
68+
var type = options.type, scoper = this;
7869
// Run preprocessing subscribers
7970
this.runSubscription("[pre]", options, type);
8071
$.each(options, function(name, sopts) {
81-
// TODO each loop for list of dom elements
8272
$(scoper).runSubscription(name, sopts, type);
8373
});
8474
// Run post processing subscribers
@@ -145,7 +135,7 @@
145135
},
146136
/**
147137
* Adds HTML attributes to the current element from the given options.
148-
* Any subscriber will be ommited so that the attributes will contain any
138+
* Any subscriber will be omitted so that the attributes will contain any
149139
* key value pair where the key is not the name of a subscriber function
150140
* and is not in the string array excludes.
151141
*
@@ -253,44 +243,43 @@
253243
$.dform =
254244
{
255245
/**
256-
* @page options
246+
* @page options Options
257247
* @parent plugin
258248
*
259-
* Default options the plugin is initialized with
249+
* Default options the plugin is initialized with:
250+
*
251+
* ## prefix
252+
*
253+
* The Default prefix used for element classnames generated by the dform plugin.
254+
* Defaults to _ui-dform-_
255+
* E.g. an element with type text will have the class ui-dform-text
256+
*
257+
* ## ajaxFormat
258+
*
259+
* The format used if forms are loaded via AJAX.
260+
* Defaults to JSON
260261
*/
261262
options :
262263
{
263-
/**
264-
* var: prefix
265-
*
266-
* The Default prefix used for element classnames generated by the dform plugin.
267-
* Defaults to ui-dform-
268-
* E.g. an element with type text will have the class ui-dform-text
269-
*/
270264
prefix : "ui-dform-",
271-
/**
272-
* var: ajaxFormat
273-
*
274-
* The format used if forms are loaded via AJAX.
275-
* Defaults to JSON
276-
*/
277-
ajaxFormat : "json",
278-
/**
279-
* Function: defaultType
280-
*
281-
* A function that is called, when no registered type has been found.
282-
* The default behaviour returns an HTML element with the tag
283-
* as specified in type and the HTML attributes given in options
284-
* (without subscriber options).
285-
*/
286-
defaultType : function(options)
287-
{
288-
return $("<" + options.type + ">").dformAttr(options);
289-
}
265+
ajaxFormat : "json"
266+
},
267+
268+
/**
269+
* Function: defaultType
270+
*
271+
* A function that is called, when no registered type has been found.
272+
* The default behaviour returns an HTML element with the tag
273+
* as specified in type and the HTML attributes given in options
274+
* (without subscriber options).
275+
*/
276+
defaultType : function(options)
277+
{
278+
return $("<" + options.type + ">").dformAttr(options);
290279
},
291280

292281
/**
293-
* section: Static helper functions
282+
* @page static Static plugin functions
294283
*
295284
* Static helpers for the plugin, that can be found in the *$.dform* namespace.
296285
*/
@@ -418,7 +407,7 @@
418407
}
419408
else {
420409
// Call defaultType function if no type was found
421-
element = $.dform.options.defaultType(options);
410+
element = $.dform.defaultType(options);
422411
}
423412
return $(element);
424413
}

0 commit comments

Comments
 (0)