3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
16 * @class Ext.DataView.LabelEditor
20 Ext.DataView.LabelEditor = Ext.extend(Ext.Editor, {
23 cls: "x-small-editor",
25 completeOnEnter: true,
27 labelSelector: 'span.x-editable',
29 constructor: function(cfg, field){
30 Ext.DataView.LabelEditor.superclass.constructor.call(this,
31 field || new Ext.form.TextField({
41 init : function(view){
43 view.on('render', this.initEditor, this);
44 this.on('complete', this.onSave, this);
47 initEditor : function(){
50 containerclick: this.doBlur,
53 this.view.getEl().on('mousedown', this.onMouseDown, this, {delegate: this.labelSelector});
62 onMouseDown : function(e, target){
63 if(!e.ctrlKey && !e.shiftKey){
64 var item = this.view.findItemFromChild(target);
66 var record = this.view.store.getAt(this.view.indexOf(item));
67 this.startEdit(target, record.data[this.dataIndex]);
68 this.activeRecord = record;
74 onSave : function(ed, value){
75 this.activeRecord.set(this.dataIndex, value);
80 Ext.DataView.DragSelector = function(cfg){
82 var view, proxy, tracker;
83 var rs, bodyRegion, dragRegion = new Ext.lib.Region(0,0,0,0);
84 var dragSafe = cfg.dragSafe === true;
86 this.init = function(dataView){
88 view.on('render', onRender);
91 function fillRegions(){
93 view.all.each(function(el){
94 rs[rs.length] = el.getRegion();
96 bodyRegion = view.el.getRegion();
99 function cancelClick(){
103 function onBeforeStart(e){
104 return !dragSafe || e.target == view.el.dom;
108 view.on('containerclick', cancelClick, view, {single:true});
110 proxy = view.el.createChild({cls:'x-view-selector'});
112 if(proxy.dom.parentNode !== view.el.dom){
113 view.el.dom.appendChild(proxy.dom);
115 proxy.setDisplayed('block');
118 view.clearSelections();
122 var startXY = tracker.startXY;
123 var xy = tracker.getXY();
125 var x = Math.min(startXY[0], xy[0]);
126 var y = Math.min(startXY[1], xy[1]);
127 var w = Math.abs(startXY[0] - xy[0]);
128 var h = Math.abs(startXY[1] - xy[1]);
132 dragRegion.right = x+w;
133 dragRegion.bottom = y+h;
135 dragRegion.constrainTo(bodyRegion);
136 proxy.setRegion(dragRegion);
138 for(var i = 0, len = rs.length; i < len; i++){
139 var r = rs[i], sel = dragRegion.intersect(r);
140 if(sel && !r.selected){
142 view.select(i, true);
143 }else if(!sel && r.selected){
152 view.un('containerclick', cancelClick, view);
155 proxy.setDisplayed(false);
159 function onRender(view){
160 tracker = new Ext.dd.DragTracker({
161 onBeforeStart: onBeforeStart,
166 tracker.initEl(view.el);