home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / AvantBrowser / asetup.exe / _data / webkit / resources.pak / Unnamed File 000081.txt < prev    next >
Encoding:
Text File  |  2013-04-03  |  2.2 KB  |  87 lines

  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4.  
  5. /**
  6.  * @fileoverview This implements a splitter element which can be used to resize
  7.  * table columns.
  8.  *
  9.  * Each splitter is associated with certain column and resizes it when dragged.
  10.  * It is column model responsibility to resize other columns accordingly.
  11.  */
  12.  
  13. cr.define('cr.ui', function() {
  14.   /** @const */ var Splitter = cr.ui.Splitter;
  15.  
  16.   /**
  17.    * Creates a new table splitter element.
  18.    * @param {Object=} opt_propertyBag Optional properties.
  19.    * @constructor
  20.    * @extends {Splitter}
  21.    */
  22.   var TableSplitter = cr.ui.define('div');
  23.  
  24.   TableSplitter.prototype = {
  25.     __proto__: Splitter.prototype,
  26.  
  27.     table_: null,
  28.  
  29.     columnIndex_: null,
  30.  
  31.     /**
  32.      * Initializes the element.
  33.      */
  34.     decorate: function() {
  35.       Splitter.prototype.decorate.call(this);
  36.  
  37.       this.classList.add('table-header-splitter');
  38.     },
  39.  
  40.     /**
  41.      * Handles start of the splitter dragging.
  42.      * Saves starting width of the column and changes the cursor.
  43.      * @param {Event} e Splitter event.
  44.      */
  45.     handleSplitterDragStart: function() {
  46.       var cm = this.table_.columnModel;
  47.       this.ownerDocument.documentElement.classList.add('col-resize');
  48.  
  49.       this.columnWidth_ = cm.getWidth(this.columnIndex);
  50.       this.nextColumnWidth_ = cm.getWidth(this.columnIndex + 1);
  51.     },
  52.  
  53.     /**
  54.      * Handles spliter moves. Sets new width of the column.
  55.      * @param {Event} e Splitter event.
  56.      */
  57.     handleSplitterDragMove: function(deltaX) {
  58.       this.table_.columnModel.setWidth(this.columnIndex,
  59.                                        this.columnWidth_ + deltaX);
  60.     },
  61.  
  62.     /**
  63.      * Handles end of the splitter dragging. Restores cursor.
  64.      * @param {Event} e Splitter event.
  65.      */
  66.     handleSplitterDragEnd: function() {
  67.       this.ownerDocument.documentElement.classList.remove('col-resize');
  68.     },
  69.   };
  70.  
  71.   /**
  72.    * The column index.
  73.    * @type {number}
  74.    */
  75.   cr.defineProperty(TableSplitter, 'columnIndex');
  76.  
  77.   /**
  78.    * The table associated with the splitter.
  79.    * @type {cr.ui.Table}
  80.    */
  81.   cr.defineProperty(TableSplitter, 'table');
  82.  
  83.   return {
  84.     TableSplitter: TableSplitter
  85.   };
  86. });
  87.