~cdparra/gelee/trunk

« back to all changes in this revision

Viewing changes to webui/ecosystem/workspace/extjs/docs/source/Element-more.html

  • Committer: parra
  • Date: 2010-03-15 15:56:56 UTC
  • Revision ID: svn-v4:ac5bba68-f036-4e09-846e-8f32731cc928:trunk/gelee:1448
merged gelee at svn

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
  <title>The source code</title>
 
4
    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
 
5
    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
 
6
</head>
 
7
<body  onload="prettyPrint();">
 
8
    <pre class="prettyprint lang-js">/**
 
9
 * @class Ext.Element
 
10
 */
 
11
Ext.Element.addMethods({    
 
12
    <div id="method-Ext.Element-swallowEvent"></div>/**
 
13
     * Stops the specified event(s) from bubbling and optionally prevents the default action
 
14
     * @param {String/Array} eventName an event / array of events to stop from bubbling
 
15
     * @param {Boolean} preventDefault (optional) true to prevent the default action too
 
16
     * @return {Ext.Element} this
 
17
     */
 
18
    swallowEvent : function(eventName, preventDefault){
 
19
            var me = this;
 
20
        function fn(e){
 
21
            e.stopPropagation();
 
22
            if(preventDefault){
 
23
                e.preventDefault();
 
24
            }
 
25
        }
 
26
        if(Ext.isArray(eventName)){            
 
27
                Ext.each(eventName, function(e) {
 
28
                 me.on(e, fn);
 
29
            });
 
30
            return me;
 
31
        }
 
32
        me.on(eventName, fn);
 
33
        return me;
 
34
    },
 
35
    
 
36
    <div id="method-Ext.Element-relayEvent"></div>/**
 
37
     * Create an event handler on this element such that when the event fires and is handled by this element,
 
38
     * it will be relayed to another object (i.e., fired again as if it originated from that object instead).
 
39
     * @param {String} eventName The type of event to relay
 
40
     * @param {Object} object Any object that extends {@link Ext.util.Observable} that will provide the context
 
41
     * for firing the relayed event
 
42
     */
 
43
    relayEvent : function(eventName, observable){
 
44
        this.on(eventName, function(e){
 
45
            observable.fireEvent(eventName, e);
 
46
        });
 
47
    },
 
48
    
 
49
        <div id="method-Ext.Element-clean"></div>/**
 
50
     * Removes worthless text nodes
 
51
     * @param {Boolean} forceReclean (optional) By default the element
 
52
     * keeps track if it has been cleaned already so
 
53
     * you can call this over and over. However, if you update the element and
 
54
     * need to force a reclean, you can pass true.
 
55
     */
 
56
    clean : function(forceReclean){
 
57
        var me = this, 
 
58
            dom = me.dom,
 
59
                n = dom.firstChild, 
 
60
                ni = -1;
 
61
                
 
62
            if(Ext.Element.data(dom, 'isCleaned') && forceReclean !== true){
 
63
            return me;
 
64
        }      
 
65
                
 
66
            while(n){
 
67
                var nx = n.nextSibling;
 
68
            if(n.nodeType == 3 && !/\S/.test(n.nodeValue)){
 
69
                dom.removeChild(n);
 
70
            }else{
 
71
                n.nodeIndex = ++ni;
 
72
            }
 
73
                n = nx;
 
74
            }
 
75
        Ext.Element.data(dom, 'isCleaned', true);
 
76
            return me;
 
77
        },
 
78
    
 
79
    <div id="method-Ext.Element-load"></div>/**
 
80
     * Direct access to the Updater {@link Ext.Updater#update} method. The method takes the same object
 
81
     * parameter as {@link Ext.Updater#update}
 
82
     * @return {Ext.Element} this
 
83
     */
 
84
    load : function(){
 
85
        var um = this.getUpdater();
 
86
        um.update.apply(um, arguments);
 
87
        return this;
 
88
    },
 
89
 
 
90
    <div id="method-Ext.Element-getUpdater"></div>/**
 
91
    * Gets this element's {@link Ext.Updater Updater}
 
92
    * @return {Ext.Updater} The Updater
 
93
    */
 
94
    getUpdater : function(){
 
95
        return this.updateManager || (this.updateManager = new Ext.Updater(this));
 
96
    },
 
97
    
 
98
        <div id="method-Ext.Element-update"></div>/**
 
99
    * Update the innerHTML of this element, optionally searching for and processing scripts
 
100
    * @param {String} html The new HTML
 
101
    * @param {Boolean} loadScripts (optional) True to look for and process scripts (defaults to false)
 
102
    * @param {Function} callback (optional) For async script loading you can be notified when the update completes
 
103
    * @return {Ext.Element} this
 
104
     */
 
105
    update : function(html, loadScripts, callback){
 
106
        html = html || "";
 
107
            
 
108
        if(loadScripts !== true){
 
109
            this.dom.innerHTML = html;
 
110
            if(Ext.isFunction(callback)){
 
111
                callback();
 
112
            }
 
113
            return this;
 
114
        }
 
115
        
 
116
        var id = Ext.id(),
 
117
                dom = this.dom;
 
118
 
 
119
        html += '<span id="' + id + '"></span>';
 
120
 
 
121
        Ext.lib.Event.onAvailable(id, function(){
 
122
            var DOC = document,
 
123
                hd = DOC.getElementsByTagName("head")[0],
 
124
                re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
 
125
                srcRe = /\ssrc=([\'\"])(.*?)\1/i,
 
126
                typeRe = /\stype=([\'\"])(.*?)\1/i,
 
127
                match,
 
128
                attrs,
 
129
                srcMatch,
 
130
                typeMatch,
 
131
                el,
 
132
                s;
 
133
 
 
134
            while((match = re.exec(html))){
 
135
                attrs = match[1];
 
136
                srcMatch = attrs ? attrs.match(srcRe) : false;
 
137
                if(srcMatch && srcMatch[2]){
 
138
                   s = DOC.createElement("script");
 
139
                   s.src = srcMatch[2];
 
140
                   typeMatch = attrs.match(typeRe);
 
141
                   if(typeMatch && typeMatch[2]){
 
142
                       s.type = typeMatch[2];
 
143
                   }
 
144
                   hd.appendChild(s);
 
145
                }else if(match[2] && match[2].length > 0){
 
146
                    if(window.execScript) {
 
147
                       window.execScript(match[2]);
 
148
                    } else {
 
149
                       window.eval(match[2]);
 
150
                    }
 
151
                }
 
152
            }
 
153
            el = DOC.getElementById(id);
 
154
            if(el){Ext.removeNode(el);}
 
155
            if(Ext.isFunction(callback)){
 
156
                callback();
 
157
            }
 
158
        });
 
159
        dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
 
160
        return this;
 
161
    },
 
162
    
 
163
    <div id="method-Ext.Element-createProxy"></div>/**
 
164
     * Creates a proxy element of this element
 
165
     * @param {String/Object} config The class name of the proxy element or a DomHelper config object
 
166
     * @param {String/HTMLElement} renderTo (optional) The element or element id to render the proxy to (defaults to document.body)
 
167
     * @param {Boolean} matchBox (optional) True to align and size the proxy to this element now (defaults to false)
 
168
     * @return {Ext.Element} The new proxy element
 
169
     */
 
170
    createProxy : function(config, renderTo, matchBox){
 
171
        config = Ext.isObject(config) ? config : {tag : "div", cls: config};
 
172
 
 
173
        var me = this,
 
174
                proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
 
175
                                                   Ext.DomHelper.insertBefore(me.dom, config, true);        
 
176
        
 
177
        if(matchBox && me.setBox && me.getBox){ // check to make sure Element.position.js is loaded
 
178
           proxy.setBox(me.getBox());
 
179
        }
 
180
        return proxy;
 
181
    }
 
182
});
 
183
 
 
184
Ext.Element.prototype.getUpdateManager = Ext.Element.prototype.getUpdater;
 
185
 
 
186
// private
 
187
Ext.Element.uncache = function(el){
 
188
    for(var i = 0, a = arguments, len = a.length; i < len; i++) {
 
189
        if(a[i]){
 
190
            delete Ext.Element.cache[a[i].id || a[i]];
 
191
        }
 
192
    }
 
193
};</pre>    
 
194
</body>
 
195
</html>
 
 
b'\\ No newline at end of file'