Debian Codegraph @

dojox/mobile/dh/DataHandler.js

raw symbols SCIP
1 define([
2 "dojo/_base/declare",
3 "dojo/_base/lang",
4 "dojo/_base/Deferred",
5 "./ContentTypeMap"
6 ], function(declare, lang, Deferred, ContentTypeMap){
7
8 // module:
9 // dojox/mobile/dh/DataHandler
10
11 return declare("dojox.mobile.dh.DataHandler", null, {
12 // summary:
13 // A component that provides an interface between data and handlers.
14 // description:
15 // This module fetches data through DataSource and calls a
16 // ContentHandler to parse the content data and create a new view.
17
18 // ds: Object
19 // A DataSource instance.
20 ds: null,
21
22 // target: DomNode
23 // A DOM node under which a new view is created.
24 target: null,
25
26 // refNode: DomNode
27 // An optional reference DOM node before which a new view is created.
28 refNode: null,
29
30 constructor: function(/*DataSource*/ ds, /*DomNode*/ target, /*DomNode?*/ refNode){
31 // summary:
32 // Creates a new instance of the class.
33 this.ds = ds;
34 this.target = target;
35 this.refNode = refNode;
36 },
37
38 processData: function(/*String*/ contentType, /*Function*/ callback){
39 // summary:
40 // Fetches data through DataSource and passes it to a content
41 // handler.
42 // contentType:
43 // The type of the content. (ex. "html")
44 // It is used to determine what content handler to use.
45 // callback:
46 // A function to be called after creating a new view.
47 var ch = ContentTypeMap.getHandlerClass(contentType);
48 require([ch], lang.hitch(this, function(ContentHandler){
49 Deferred.when(this.ds.getData(), lang.hitch(this, function(){
50 Deferred.when(new ContentHandler().parse(this.ds.text, this.target, this.refNode), function(id){
51 callback(id);
52 });
53 }))
54 }));
55 }
56 });
57 });