source: Dev/branches/rest-dojo-ui/client/dojox/grid/util.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).

File size: 1.7 KB
Line 
1define([
2        "../main",
3        "dojo/_base/lang",
4        "dojo/dom"
5], function(dojox, lang, dom){
6
7// summary: grid utility library
8        var dgu = lang.getObject("grid.util", true, dojox);
9
10        dgu.na = '...';
11        dgu.rowIndexTag = "gridRowIndex";
12        dgu.gridViewTag = "gridView";
13
14
15        dgu.fire = function(ob, ev, args){
16                var fn = ob && ev && ob[ev];
17                return fn && (args ? fn.apply(ob, args) : ob[ev]());
18        };
19       
20        dgu.setStyleHeightPx = function(inElement, inHeight){
21                if(inHeight >= 0){
22                        var s = inElement.style;
23                        var v = inHeight + 'px';
24                        if(inElement && s['height'] != v){
25                                s['height'] = v;
26                        }
27                }
28        };
29       
30        dgu.mouseEvents = [ 'mouseover', 'mouseout', /*'mousemove',*/ 'mousedown', 'mouseup', 'click', 'dblclick', 'contextmenu' ];
31
32        dgu.keyEvents = [ 'keyup', 'keydown', 'keypress' ];
33
34        dgu.funnelEvents = function(inNode, inObject, inMethod, inEvents){
35                var evts = (inEvents ? inEvents : dgu.mouseEvents.concat(dgu.keyEvents));
36                for (var i=0, l=evts.length; i<l; i++){
37                        inObject.connect(inNode, 'on' + evts[i], inMethod);
38                }
39        };
40
41        dgu.removeNode = function(inNode){
42                inNode = dom.byId(inNode);
43                inNode && inNode.parentNode && inNode.parentNode.removeChild(inNode);
44                return inNode;
45        };
46       
47        dgu.arrayCompare = function(inA, inB){
48                for(var i=0,l=inA.length; i<l; i++){
49                        if(inA[i] != inB[i]){return false;}
50                }
51                return (inA.length == inB.length);
52        };
53       
54        dgu.arrayInsert = function(inArray, inIndex, inValue){
55                if(inArray.length <= inIndex){
56                        inArray[inIndex] = inValue;
57                }else{
58                        inArray.splice(inIndex, 0, inValue);
59                }
60        };
61       
62        dgu.arrayRemove = function(inArray, inIndex){
63                inArray.splice(inIndex, 1);
64        };
65       
66        dgu.arraySwap = function(inArray, inI, inJ){
67                var cache = inArray[inI];
68                inArray[inI] = inArray[inJ];
69                inArray[inJ] = cache;
70        };
71
72        return dojox.grid.util;
73
74});
Note: See TracBrowser for help on using the repository browser.