3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
8 * @class Ext.DataView.LabelEditor
\r
9 * @extends Ext.Editor
\r
12 Ext.DataView.LabelEditor = Ext.extend(Ext.Editor, {
\r
15 cls: "x-small-editor",
\r
17 completeOnEnter: true,
\r
19 labelSelector: 'span.x-editable',
\r
21 constructor: function(cfg, field){
\r
22 Ext.DataView.LabelEditor.superclass.constructor.call(this,
\r
23 field || new Ext.form.TextField({
\r
33 init : function(view){
\r
35 view.on('render', this.initEditor, this);
\r
36 this.on('complete', this.onSave, this);
\r
39 initEditor : function(){
\r
42 containerclick: this.doBlur,
\r
45 this.view.getEl().on('mousedown', this.onMouseDown, this, {delegate: this.labelSelector});
\r
54 onMouseDown : function(e, target){
\r
55 if(!e.ctrlKey && !e.shiftKey){
\r
56 var item = this.view.findItemFromChild(target);
\r
58 var record = this.view.store.getAt(this.view.indexOf(item));
\r
59 this.startEdit(target, record.data[this.dataIndex]);
\r
60 this.activeRecord = record;
\r
66 onSave : function(ed, value){
\r
67 this.activeRecord.set(this.dataIndex, value);
\r
72 Ext.DataView.DragSelector = function(cfg){
\r
74 var view, proxy, tracker;
\r
75 var rs, bodyRegion, dragRegion = new Ext.lib.Region(0,0,0,0);
\r
76 var dragSafe = cfg.dragSafe === true;
\r
78 this.init = function(dataView){
\r
80 view.on('render', onRender);
\r
83 function fillRegions(){
\r
85 view.all.each(function(el){
\r
86 rs[rs.length] = el.getRegion();
\r
88 bodyRegion = view.el.getRegion();
\r
91 function cancelClick(){
\r
95 function onBeforeStart(e){
\r
96 return !dragSafe || e.target == view.el.dom;
\r
99 function onStart(e){
\r
100 view.on('containerclick', cancelClick, view, {single:true});
\r
102 proxy = view.el.createChild({cls:'x-view-selector'});
\r
104 proxy.setDisplayed('block');
\r
107 view.clearSelections();
\r
110 function onDrag(e){
\r
111 var startXY = tracker.startXY;
\r
112 var xy = tracker.getXY();
\r
114 var x = Math.min(startXY[0], xy[0]);
\r
115 var y = Math.min(startXY[1], xy[1]);
\r
116 var w = Math.abs(startXY[0] - xy[0]);
\r
117 var h = Math.abs(startXY[1] - xy[1]);
\r
119 dragRegion.left = x;
\r
120 dragRegion.top = y;
\r
121 dragRegion.right = x+w;
\r
122 dragRegion.bottom = y+h;
\r
124 dragRegion.constrainTo(bodyRegion);
\r
125 proxy.setRegion(dragRegion);
\r
127 for(var i = 0, len = rs.length; i < len; i++){
\r
128 var r = rs[i], sel = dragRegion.intersect(r);
\r
129 if(sel && !r.selected){
\r
131 view.select(i, true);
\r
132 }else if(!sel && r.selected){
\r
133 r.selected = false;
\r
141 view.un('containerclick', cancelClick, view);
\r
144 proxy.setDisplayed(false);
\r
148 function onRender(view){
\r
149 tracker = new Ext.dd.DragTracker({
\r
150 onBeforeStart: onBeforeStart,
\r
155 tracker.initEl(view.el);
\r