source: Dev/branches/rest-dojo-ui/client/dojox/layout/ContentPane.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

  • Property svn:executable set to *
File size: 3.4 KB
Line 
1define([
2        "dojo/_base/lang",
3        "dojo/_base/xhr",
4        "dijit/layout/ContentPane",
5        "dojox/html/_base",
6        "dojo/_base/declare"
7], function (lang, xhrUtil, ContentPane, htmlUtil, declare) {
8
9/*===== var ContentPane = dijit.layout.ContentPane =====*/
10return declare("dojox.layout.ContentPane", ContentPane, {
11        // summary:
12        //              An extended version of dijit.layout.ContentPane.
13        //              Supports infile scripts and external ones declared by <script src=''
14        //              relative path adjustments (content fetched from a different folder)
15        //              <style> and <link rel='stylesheet' href='..'> tags,
16        //              css paths inside cssText is adjusted (if you set adjustPaths = true)
17        //
18        //              NOTE that dojo.require in script in the fetched file isn't recommended
19        //              Many widgets need to be required at page load to work properly
20
21        // adjustPaths: Boolean
22        //              Adjust relative paths in html string content to point to this page.
23        //              Only useful if you grab content from a another folder then the current one
24        adjustPaths: false,
25
26        // cleanContent: Boolean
27        //      summary:
28        //              cleans content to make it less likely to generate DOM/JS errors.
29        //      description:
30        //              useful if you send ContentPane a complete page, instead of a html fragment
31        //              scans for
32        //
33        //                      * title Node, remove
34        //                      * DOCTYPE tag, remove
35        cleanContent: false,
36
37        // renderStyles: Boolean
38        //              trigger/load styles in the content
39        renderStyles: false,
40
41        // executeScripts: Boolean
42        //              Execute (eval) scripts that is found in the content
43        executeScripts: true,
44
45        // scriptHasHooks: Boolean
46        //              replace keyword '_container_' in scripts with 'dijit.byId(this.id)'
47        // NOTE this name might change in the near future
48        scriptHasHooks: false,
49
50        constructor: function(){
51                // init per instance properties, initializer doesn't work here because how things is hooked up in dijit._Widget
52                this.ioArgs = {};
53                this.ioMethod = xhrUtil.get;
54        },
55
56        onExecError: function(e){
57                // summary:
58                //              event callback, called on script error or on java handler error
59                //              overide and return your own html string if you want a some text
60                //              displayed within the ContentPane
61        },
62
63        _setContent: function(cont){
64                // override dijit.layout.ContentPane._setContent, to enable path adjustments
65               
66                var setter = this._contentSetter;
67                if(! (setter && setter instanceof htmlUtil._ContentSetter)) {
68                        setter = this._contentSetter = new htmlUtil._ContentSetter({
69                                node: this.containerNode,
70                                _onError: lang.hitch(this, this._onError),
71                                onContentError: lang.hitch(this, function(e){
72                                        // fires if a domfault occurs when we are appending this.errorMessage
73                                        // like for instance if domNode is a UL and we try append a DIV
74                                        var errMess = this.onContentError(e);
75                                        try{
76                                                this.containerNode.innerHTML = errMess;
77                                        }catch(e){
78                                                console.error('Fatal '+this.id+' could not change content due to '+e.message, e);
79                                        }
80                                })/*,
81                                _onError */
82                        });
83                };
84
85                // stash the params for the contentSetter to allow inheritance to work for _setContent
86                this._contentSetterParams = {
87                        adjustPaths: Boolean(this.adjustPaths && (this.href||this.referencePath)),
88                        referencePath: this.href || this.referencePath,
89                        renderStyles: this.renderStyles,
90                        executeScripts: this.executeScripts,
91                        scriptHasHooks: this.scriptHasHooks,
92                        scriptHookReplacement: "dijit.byId('"+this.id+"')"
93                };
94
95                this.inherited("_setContent", arguments);
96        }
97        // could put back _renderStyles by wrapping/aliasing dojox.html._ContentSetter.prototype._renderStyles
98});
99});
Note: See TracBrowser for help on using the repository browser.