|
5 | 5 | * Licensed under the MIT license
|
6 | 6 | */
|
7 | 7 |
|
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 |
| - */ |
18 | 8 | (function($)
|
19 | 9 | {
|
20 | 10 | var _subscriptions = {};
|
|
55 | 45 | * @return {Object} The jQuery object
|
56 | 46 | */
|
57 | 47 | runSubscription : function(name, options, type) {
|
58 |
| - var element = this; |
59 | 48 | if ($.dform.hasSubscription(name))
|
60 | 49 | {
|
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 | + }); |
64 | 56 | });
|
65 | 57 | }
|
66 | 58 | return this;
|
|
73 | 65 | */
|
74 | 66 | runAll : function(options)
|
75 | 67 | {
|
76 |
| - var type = options.type; |
77 |
| - var scoper = this; |
| 68 | + var type = options.type, scoper = this; |
78 | 69 | // Run preprocessing subscribers
|
79 | 70 | this.runSubscription("[pre]", options, type);
|
80 | 71 | $.each(options, function(name, sopts) {
|
81 |
| - // TODO each loop for list of dom elements |
82 | 72 | $(scoper).runSubscription(name, sopts, type);
|
83 | 73 | });
|
84 | 74 | // Run post processing subscribers
|
|
145 | 135 | },
|
146 | 136 | /**
|
147 | 137 | * 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 |
149 | 139 | * key value pair where the key is not the name of a subscriber function
|
150 | 140 | * and is not in the string array excludes.
|
151 | 141 | *
|
|
253 | 243 | $.dform =
|
254 | 244 | {
|
255 | 245 | /**
|
256 |
| - * @page options |
| 246 | + * @page options Options |
257 | 247 | * @parent plugin
|
258 | 248 | *
|
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 |
260 | 261 | */
|
261 | 262 | options :
|
262 | 263 | {
|
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 |
| - */ |
270 | 264 | 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); |
290 | 279 | },
|
291 | 280 |
|
292 | 281 | /**
|
293 |
| - * section: Static helper functions |
| 282 | + * @page static Static plugin functions |
294 | 283 | *
|
295 | 284 | * Static helpers for the plugin, that can be found in the *$.dform* namespace.
|
296 | 285 | */
|
|
418 | 407 | }
|
419 | 408 | else {
|
420 | 409 | // Call defaultType function if no type was found
|
421 |
| - element = $.dform.options.defaultType(options); |
| 410 | + element = $.dform.defaultType(options); |
422 | 411 | }
|
423 | 412 | return $(element);
|
424 | 413 | }
|
|
0 commit comments