Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

613 lines
21 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  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>
  7. </head>
  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
  14. */
  15. Ext.ns('Ext.ux.form');
  16. <div id="cls-Ext.ux.form.MultiSelect"></div>/**
  17. * @class Ext.ux.form.MultiSelect
  18. * @extends Ext.form.Field
  19. * A control that allows selection and form submission of multiple list items.
  20. *
  21. * @history
  22. * 2008-06-19 bpm Original code contributed by Toby Stuart (with contributions from Robert Williams)
  23. * 2008-06-19 bpm Docs and demo code clean up
  24. *
  25. * @constructor
  26. * Create a new MultiSelect
  27. * @param {Object} config Configuration options
  28. * @xtype multiselect
  29. */
  30. Ext.ux.form.MultiSelect = Ext.extend(Ext.form.Field, {
  31. <div id="cfg-Ext.ux.form.MultiSelect-legend"></div>/**
  32. * @cfg {String} legend Wraps the object with a fieldset and specified legend.
  33. */
  34. <div id="cfg-Ext.ux.form.MultiSelect-view"></div>/**
  35. * @cfg {Ext.ListView} view The {@link Ext.ListView} used to render the multiselect list.
  36. */
  37. <div id="cfg-Ext.ux.form.MultiSelect-dragGroup"></div>/**
  38. * @cfg {String/Array} dragGroup The ddgroup name(s) for the MultiSelect DragZone (defaults to undefined).
  39. */
  40. <div id="cfg-Ext.ux.form.MultiSelect-dropGroup"></div>/**
  41. * @cfg {String/Array} dropGroup The ddgroup name(s) for the MultiSelect DropZone (defaults to undefined).
  42. */
  43. <div id="cfg-Ext.ux.form.MultiSelect-ddReorder"></div>/**
  44. * @cfg {Boolean} ddReorder Whether the items in the MultiSelect list are drag/drop reorderable (defaults to false).
  45. */
  46. ddReorder:false,
  47. <div id="cfg-Ext.ux.form.MultiSelect-tbar"></div>/**
  48. * @cfg {Object/Array} tbar The top toolbar of the control. This can be a {@link Ext.Toolbar} object, a
  49. * toolbar config, or an array of buttons/button configs to be added to the toolbar.
  50. */
  51. <div id="cfg-Ext.ux.form.MultiSelect-appendOnly"></div>/**
  52. * @cfg {String} appendOnly True if the list should only allow append drops when drag/drop is enabled
  53. * (use for lists which are sorted, defaults to false).
  54. */
  55. appendOnly:false,
  56. <div id="cfg-Ext.ux.form.MultiSelect-width"></div>/**
  57. * @cfg {Number} width Width in pixels of the control (defaults to 100).
  58. */
  59. width:100,
  60. <div id="cfg-Ext.ux.form.MultiSelect-height"></div>/**
  61. * @cfg {Number} height Height in pixels of the control (defaults to 100).
  62. */
  63. height:100,
  64. <div id="cfg-Ext.ux.form.MultiSelect-displayField"></div>/**
  65. * @cfg {String/Number} displayField Name/Index of the desired display field in the dataset (defaults to 0).
  66. */
  67. displayField:0,
  68. <div id="cfg-Ext.ux.form.MultiSelect-valueField"></div>/**
  69. * @cfg {String/Number} valueField Name/Index of the desired value field in the dataset (defaults to 1).
  70. */
  71. valueField:1,
  72. <div id="cfg-Ext.ux.form.MultiSelect-allowBlank"></div>/**
  73. * @cfg {Boolean} allowBlank False to require at least one item in the list to be selected, true to allow no
  74. * selection (defaults to true).
  75. */
  76. allowBlank:true,
  77. <div id="cfg-Ext.ux.form.MultiSelect-minSelections"></div>/**
  78. * @cfg {Number} minSelections Minimum number of selections allowed (defaults to 0).
  79. */
  80. minSelections:0,
  81. <div id="cfg-Ext.ux.form.MultiSelect-maxSelections"></div>/**
  82. * @cfg {Number} maxSelections Maximum number of selections allowed (defaults to Number.MAX_VALUE).
  83. */
  84. maxSelections:Number.MAX_VALUE,
  85. <div id="cfg-Ext.ux.form.MultiSelect-blankText"></div>/**
  86. * @cfg {String} blankText Default text displayed when the control contains no items (defaults to the same value as
  87. * {@link Ext.form.TextField#blankText}.
  88. */
  89. blankText:Ext.form.TextField.prototype.blankText,
  90. <div id="cfg-Ext.ux.form.MultiSelect-minSelectionsText"></div>/**
  91. * @cfg {String} minSelectionsText Validation message displayed when {@link #minSelections} is not met (defaults to 'Minimum {0}
  92. * item(s) required'). The {0} token will be replaced by the value of {@link #minSelections}.
  93. */
  94. minSelectionsText:'Minimum {0} item(s) required',
  95. <div id="cfg-Ext.ux.form.MultiSelect-maxSelectionsText"></div>/**
  96. * @cfg {String} maxSelectionsText Validation message displayed when {@link #maxSelections} is not met (defaults to 'Maximum {0}
  97. * item(s) allowed'). The {0} token will be replaced by the value of {@link #maxSelections}.
  98. */
  99. maxSelectionsText:'Maximum {0} item(s) allowed',
  100. <div id="cfg-Ext.ux.form.MultiSelect-delimiter"></div>/**
  101. * @cfg {String} delimiter The string used to delimit between items when set or returned as a string of values
  102. * (defaults to ',').
  103. */
  104. delimiter:',',
  105. <div id="cfg-Ext.ux.form.MultiSelect-store"></div>/**
  106. * @cfg {Ext.data.Store/Array} store The data source to which this MultiSelect is bound (defaults to <tt>undefined</tt>).
  107. * Acceptable values for this property are:
  108. * <div class="mdetail-params"><ul>
  109. * <li><b>any {@link Ext.data.Store Store} subclass</b></li>
  110. * <li><b>an Array</b> : Arrays will be converted to a {@link Ext.data.ArrayStore} internally.
  111. * <div class="mdetail-params"><ul>
  112. * <li><b>1-dimensional array</b> : (e.g., <tt>['Foo','Bar']</tt>)<div class="sub-desc">
  113. * A 1-dimensional array will automatically be expanded (each array item will be the combo
  114. * {@link #valueField value} and {@link #displayField text})</div></li>
  115. * <li><b>2-dimensional array</b> : (e.g., <tt>[['f','Foo'],['b','Bar']]</tt>)<div class="sub-desc">
  116. * For a multi-dimensional array, the value in index 0 of each item will be assumed to be the combo
  117. * {@link #valueField value}, while the value at index 1 is assumed to be the combo {@link #displayField text}.
  118. * </div></li></ul></div></li></ul></div>
  119. */
  120. // private
  121. defaultAutoCreate : {tag: "div"},
  122. // private
  123. initComponent: function(){
  124. Ext.ux.form.MultiSelect.superclass.initComponent.call(this);
  125. if(Ext.isArray(this.store)){
  126. if (Ext.isArray(this.store[0])){
  127. this.store = new Ext.data.ArrayStore({
  128. fields: ['value','text'],
  129. data: this.store
  130. });
  131. this.valueField = 'value';
  132. }else{
  133. this.store = new Ext.data.ArrayStore({
  134. fields: ['text'],
  135. data: this.store,
  136. expandData: true
  137. });
  138. this.valueField = 'text';
  139. }
  140. this.displayField = 'text';
  141. } else {
  142. this.store = Ext.StoreMgr.lookup(this.store);
  143. }
  144. this.addEvents({
  145. 'dblclick' : true,
  146. 'click' : true,
  147. 'change' : true,
  148. 'drop' : true
  149. });
  150. },
  151. // private
  152. onRender: function(ct, position){
  153. Ext.ux.form.MultiSelect.superclass.onRender.call(this, ct, position);
  154. var fs = this.fs = new Ext.form.FieldSet({
  155. renderTo: this.el,
  156. title: this.legend,
  157. height: this.height,
  158. width: this.width,
  159. style: "padding:0;",
  160. tbar: this.tbar
  161. });
  162. fs.body.addClass('ux-mselect');
  163. this.view = new Ext.ListView({
  164. multiSelect: true,
  165. store: this.store,
  166. columns: [{ header: 'Value', width: 1, dataIndex: this.displayField }],
  167. hideHeaders: true
  168. });
  169. fs.add(this.view);
  170. this.view.on('click', this.onViewClick, this);
  171. this.view.on('beforeclick', this.onViewBeforeClick, this);
  172. this.view.on('dblclick', this.onViewDblClick, this);
  173. this.hiddenName = this.name || Ext.id();
  174. var hiddenTag = { tag: "input", type: "hidden", value: "", name: this.hiddenName };
  175. this.hiddenField = this.el.createChild(hiddenTag);
  176. this.hiddenField.dom.disabled = this.hiddenName != this.name;
  177. fs.doLayout();
  178. },
  179. // private
  180. afterRender: function(){
  181. Ext.ux.form.MultiSelect.superclass.afterRender.call(this);
  182. if (this.ddReorder && !this.dragGroup && !this.dropGroup){
  183. this.dragGroup = this.dropGroup = 'MultiselectDD-' + Ext.id();
  184. }
  185. if (this.draggable || this.dragGroup){
  186. this.dragZone = new Ext.ux.form.MultiSelect.DragZone(this, {
  187. ddGroup: this.dragGroup
  188. });
  189. }
  190. if (this.droppable || this.dropGroup){
  191. this.dropZone = new Ext.ux.form.MultiSelect.DropZone(this, {
  192. ddGroup: this.dropGroup
  193. });
  194. }
  195. },
  196. // private
  197. onViewClick: function(vw, index, node, e) {
  198. this.fireEvent('change', this, this.getValue(), this.hiddenField.dom.value);
  199. this.hiddenField.dom.value = this.getValue();
  200. this.fireEvent('click', this, e);
  201. this.validate();
  202. },
  203. // private
  204. onViewBeforeClick: function(vw, index, node, e) {
  205. if (this.disabled || this.readOnly) {
  206. return false;
  207. }
  208. },
  209. // private
  210. onViewDblClick : function(vw, index, node, e) {
  211. return this.fireEvent('dblclick', vw, index, node, e);
  212. },
  213. <div id="method-Ext.ux.form.MultiSelect-getValue"></div>/**
  214. * Returns an array of data values for the selected items in the list. The values will be separated
  215. * by {@link #delimiter}.
  216. * @return {Array} value An array of string data values
  217. */
  218. getValue: function(valueField){
  219. var returnArray = [];
  220. var selectionsArray = this.view.getSelectedIndexes();
  221. if (selectionsArray.length == 0) {return '';}
  222. for (var i=0; i<selectionsArray.length; i++) {
  223. returnArray.push(this.store.getAt(selectionsArray[i]).get((valueField != null) ? valueField : this.valueField));
  224. }
  225. return returnArray.join(this.delimiter);
  226. },
  227. <div id="method-Ext.ux.form.MultiSelect-setValue"></div>/**
  228. * Sets a delimited string (using {@link #delimiter}) or array of data values into the list.
  229. * @param {String/Array} values The values to set
  230. */
  231. setValue: function(values) {
  232. var index;
  233. var selections = [];
  234. this.view.clearSelections();
  235. this.hiddenField.dom.value = '';
  236. if (!values || (values == '')) { return; }
  237. if (!Ext.isArray(values)) { values = values.split(this.delimiter); }
  238. for (var i=0; i<values.length; i++) {
  239. index = this.view.store.indexOf(this.view.store.query(this.valueField,
  240. new RegExp('^' + values[i] + '$', "i")).itemAt(0));
  241. selections.push(index);
  242. }
  243. this.view.select(selections);
  244. this.hiddenField.dom.value = this.getValue();
  245. this.validate();
  246. },
  247. // inherit docs
  248. reset : function() {
  249. this.setValue('');
  250. },
  251. // inherit docs
  252. getRawValue: function(valueField) {
  253. var tmp = this.getValue(valueField);
  254. if (tmp.length) {
  255. tmp = tmp.split(this.delimiter);
  256. }
  257. else {
  258. tmp = [];
  259. }
  260. return tmp;
  261. },
  262. // inherit docs
  263. setRawValue: function(values){
  264. setValue(values);
  265. },
  266. // inherit docs
  267. validateValue : function(value){
  268. if (value.length < 1) { // if it has no value
  269. if (this.allowBlank) {
  270. this.clearInvalid();
  271. return true;
  272. } else {
  273. this.markInvalid(this.blankText);
  274. return false;
  275. }
  276. }
  277. if (value.length < this.minSelections) {
  278. this.markInvalid(String.format(this.minSelectionsText, this.minSelections));
  279. return false;
  280. }
  281. if (value.length > this.maxSelections) {
  282. this.markInvalid(String.format(this.maxSelectionsText, this.maxSelections));
  283. return false;
  284. }
  285. return true;
  286. },
  287. // inherit docs
  288. disable: function(){
  289. this.disabled = true;
  290. this.hiddenField.dom.disabled = true;
  291. this.fs.disable();
  292. },
  293. // inherit docs
  294. enable: function(){
  295. this.disabled = false;
  296. this.hiddenField.dom.disabled = false;
  297. this.fs.enable();
  298. },
  299. // inherit docs
  300. destroy: function(){
  301. Ext.destroy(this.fs, this.dragZone, this.dropZone);
  302. Ext.ux.form.MultiSelect.superclass.destroy.call(this);
  303. }
  304. });
  305. Ext.reg('multiselect', Ext.ux.form.MultiSelect);
  306. //backwards compat
  307. Ext.ux.Multiselect = Ext.ux.form.MultiSelect;
  308. Ext.ux.form.MultiSelect.DragZone = function(ms, config){
  309. this.ms = ms;
  310. this.view = ms.view;
  311. var ddGroup = config.ddGroup || 'MultiselectDD';
  312. var dd;
  313. if (Ext.isArray(ddGroup)){
  314. dd = ddGroup.shift();
  315. } else {
  316. dd = ddGroup;
  317. ddGroup = null;
  318. }
  319. Ext.ux.form.MultiSelect.DragZone.superclass.constructor.call(this, this.ms.fs.body, { containerScroll: true, ddGroup: dd });
  320. this.setDraggable(ddGroup);
  321. };
  322. Ext.extend(Ext.ux.form.MultiSelect.DragZone, Ext.dd.DragZone, {
  323. onInitDrag : function(x, y){
  324. var el = Ext.get(this.dragData.ddel.cloneNode(true));
  325. this.proxy.update(el.dom);
  326. el.setWidth(el.child('em').getWidth());
  327. this.onStartDrag(x, y);
  328. return true;
  329. },
  330. // private
  331. collectSelection: function(data) {
  332. data.repairXY = Ext.fly(this.view.getSelectedNodes()[0]).getXY();
  333. var i = 0;
  334. this.view.store.each(function(rec){
  335. if (this.view.isSelected(i)) {
  336. var n = this.view.getNode(i);
  337. var dragNode = n.cloneNode(true);
  338. dragNode.id = Ext.id();
  339. data.ddel.appendChild(dragNode);
  340. data.records.push(this.view.store.getAt(i));
  341. data.viewNodes.push(n);
  342. }
  343. i++;
  344. }, this);
  345. },
  346. // override
  347. onEndDrag: function(data, e) {
  348. var d = Ext.get(this.dragData.ddel);
  349. if (d && d.hasClass("multi-proxy")) {
  350. d.remove();
  351. }
  352. },
  353. // override
  354. getDragData: function(e){
  355. var target = this.view.findItemFromChild(e.getTarget());
  356. if(target) {
  357. if (!this.view.isSelected(target) && !e.ctrlKey && !e.shiftKey) {
  358. this.view.select(target);
  359. this.ms.setValue(this.ms.getValue());
  360. }
  361. if (this.view.getSelectionCount() == 0 || e.ctrlKey || e.shiftKey) return false;
  362. var dragData = {
  363. sourceView: this.view,
  364. viewNodes: [],
  365. records: []
  366. };
  367. if (this.view.getSelectionCount() == 1) {
  368. var i = this.view.getSelectedIndexes()[0];
  369. var n = this.view.getNode(i);
  370. dragData.viewNodes.push(dragData.ddel = n);
  371. dragData.records.push(this.view.store.getAt(i));
  372. dragData.repairXY = Ext.fly(n).getXY();
  373. } else {
  374. dragData.ddel = document.createElement('div');
  375. dragData.ddel.className = 'multi-proxy';
  376. this.collectSelection(dragData);
  377. }
  378. return dragData;
  379. }
  380. return false;
  381. },
  382. // override the default repairXY.
  383. getRepairXY : function(e){
  384. return this.dragData.repairXY;
  385. },
  386. // private
  387. setDraggable: function(ddGroup){
  388. if (!ddGroup) return;
  389. if (Ext.isArray(ddGroup)) {
  390. Ext.each(ddGroup, this.setDraggable, this);
  391. return;
  392. }
  393. this.addToGroup(ddGroup);
  394. }
  395. });
  396. Ext.ux.form.MultiSelect.DropZone = function(ms, config){
  397. this.ms = ms;
  398. this.view = ms.view;
  399. var ddGroup = config.ddGroup || 'MultiselectDD';
  400. var dd;
  401. if (Ext.isArray(ddGroup)){
  402. dd = ddGroup.shift();
  403. } else {
  404. dd = ddGroup;
  405. ddGroup = null;
  406. }
  407. Ext.ux.form.MultiSelect.DropZone.superclass.constructor.call(this, this.ms.fs.body, { containerScroll: true, ddGroup: dd });
  408. this.setDroppable(ddGroup);
  409. };
  410. Ext.extend(Ext.ux.form.MultiSelect.DropZone, Ext.dd.DropZone, {
  411. <div id="method-Ext.ux.form.MultiSelect-getTargetFromEvent"></div>/**
  412. * Part of the Ext.dd.DropZone interface. If no target node is found, the
  413. * whole Element becomes the target, and this causes the drop gesture to append.
  414. */
  415. getTargetFromEvent : function(e) {
  416. var target = e.getTarget();
  417. return target;
  418. },
  419. // private
  420. getDropPoint : function(e, n, dd){
  421. if (n == this.ms.fs.body.dom) { return "below"; }
  422. var t = Ext.lib.Dom.getY(n), b = t + n.offsetHeight;
  423. var c = t + (b - t) / 2;
  424. var y = Ext.lib.Event.getPageY(e);
  425. if(y <= c) {
  426. return "above";
  427. }else{
  428. return "below";
  429. }
  430. },
  431. // private
  432. isValidDropPoint: function(pt, n, data) {
  433. if (!data.viewNodes || (data.viewNodes.length != 1)) {
  434. return true;
  435. }
  436. var d = data.viewNodes[0];
  437. if (d == n) {
  438. return false;
  439. }
  440. if ((pt == "below") && (n.nextSibling == d)) {
  441. return false;
  442. }
  443. if ((pt == "above") && (n.previousSibling == d)) {
  444. return false;
  445. }
  446. return true;
  447. },
  448. // override
  449. onNodeEnter : function(n, dd, e, data){
  450. return false;
  451. },
  452. // override
  453. onNodeOver : function(n, dd, e, data){
  454. var dragElClass = this.dropNotAllowed;
  455. var pt = this.getDropPoint(e, n, dd);
  456. if (this.isValidDropPoint(pt, n, data)) {
  457. if (this.ms.appendOnly) {
  458. return "x-tree-drop-ok-below";
  459. }
  460. // set the insert point style on the target node
  461. if (pt) {
  462. var targetElClass;
  463. if (pt == "above"){
  464. dragElClass = n.previousSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-above";
  465. targetElClass = "x-view-drag-insert-above";
  466. } else {
  467. dragElClass = n.nextSibling ? "x-tree-drop-ok-between" : "x-tree-drop-ok-below";
  468. targetElClass = "x-view-drag-insert-below";
  469. }
  470. if (this.lastInsertClass != targetElClass){
  471. Ext.fly(n).replaceClass(this.lastInsertClass, targetElClass);
  472. this.lastInsertClass = targetElClass;
  473. }
  474. }
  475. }
  476. return dragElClass;
  477. },
  478. // private
  479. onNodeOut : function(n, dd, e, data){
  480. this.removeDropIndicators(n);
  481. },
  482. // private
  483. onNodeDrop : function(n, dd, e, data){
  484. if (this.ms.fireEvent("drop", this, n, dd, e, data) === false) {
  485. return false;
  486. }
  487. var pt = this.getDropPoint(e, n, dd);
  488. if (n != this.ms.fs.body.dom)
  489. n = this.view.findItemFromChild(n);
  490. if(this.ms.appendOnly) {
  491. insertAt = this.view.store.getCount();
  492. } else {
  493. insertAt = n == this.ms.fs.body.dom ? this.view.store.getCount() - 1 : this.view.indexOf(n);
  494. if (pt == "below") {
  495. insertAt++;
  496. }
  497. }
  498. var dir = false;
  499. // Validate if dragging within the same MultiSelect
  500. if (data.sourceView == this.view) {
  501. // If the first element to be inserted below is the target node, remove it
  502. if (pt == "below") {
  503. if (data.viewNodes[0] == n) {
  504. data.viewNodes.shift();
  505. }
  506. } else { // If the last element to be inserted above is the target node, remove it
  507. if (data.viewNodes[data.viewNodes.length - 1] == n) {
  508. data.viewNodes.pop();
  509. }
  510. }
  511. // Nothing to drop...
  512. if (!data.viewNodes.length) {
  513. return false;
  514. }
  515. // If we are moving DOWN, then because a store.remove() takes place first,
  516. // the insertAt must be decremented.
  517. if (insertAt > this.view.store.indexOf(data.records[0])) {
  518. dir = 'down';
  519. insertAt--;
  520. }
  521. }
  522. for (var i = 0; i < data.records.length; i++) {
  523. var r = data.records[i];
  524. if (data.sourceView) {
  525. data.sourceView.store.remove(r);
  526. }
  527. this.view.store.insert(dir == 'down' ? insertAt : insertAt++, r);
  528. var si = this.view.store.sortInfo;
  529. if(si){
  530. this.view.store.sort(si.field, si.direction);
  531. }
  532. }
  533. return true;
  534. },
  535. // private
  536. removeDropIndicators : function(n){
  537. if(n){
  538. Ext.fly(n).removeClass([
  539. "x-view-drag-insert-above",
  540. "x-view-drag-insert-left",
  541. "x-view-drag-insert-right",
  542. "x-view-drag-insert-below"]);
  543. this.lastInsertClass = "_noclass";
  544. }
  545. },
  546. // private
  547. setDroppable: function(ddGroup){
  548. if (!ddGroup) return;
  549. if (Ext.isArray(ddGroup)) {
  550. Ext.each(ddGroup, this.setDroppable, this);
  551. return;
  552. }
  553. this.addToGroup(ddGroup);
  554. }
  555. });
  556. </pre>
  557. </body>
  558. </html>