PageSourceSearch

https://president.uz/js/jquery.resizableColumns.js?v=2

js president.uz collected 2026-10-01 08:41:35 UTC 8,627 bytes, 231 lines download raw bytes

1/* jQuery Resizable Columns v0.1.0 | http://dobtco.github.io/jquery-resizable-columns/ | Licensed MIT | Built Fri Dec 05 2015 22:21:04 */
2var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
3  __slice = [].slice;
4
5(function($, window) {
6  var ResizableColumns, parseWidth, pointerX, setWidth;
7  parseWidth = function(node) {
8    return parseFloat(node.style.width.replace('%', ''));
9  };
10  setWidth = function(node, width) {
11    width = width.toFixed(2);
12    width = width > 0 ? width : 0;
13    return node.style.width = "" + width + "%";
14  };
15  pointerX = function(e) {
16    if (e.type.indexOf('touch') === 0) {
17      return (e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]).pageX;
18    }
19    return e.pageX;
20  };
21  ResizableColumns = (function() {
22    ResizableColumns.prototype.defaults = {
23      selector: 'tr th:visible',
24      store: window.store,
25      syncHandlers: true,
26      resizeFromBody: true,
27      maxWidth: null,
28      minWidth: null
29    };
30
31    function ResizableColumns($table, options) {
32      this.pointerdown = __bind(this.pointerdown, this);
33      this.constrainWidth = __bind(this.constrainWidth, this);
34      this.options = $.extend({}, this.defaults, options);
35      this.$table = $table;
36      this.setHeaders();
37      this.restoreColumnWidths();
38      this.syncHandleWidths();
39      $(window).on('resize.rc', ((function(_this) {
40        return function() {
41          return _this.syncHandleWidths();
42        };
43      })(this)));
44      if (this.options.start) {
45        this.$table.bind('column:resize:start.rc', this.options.start);
46      }
47      if (this.options.resize) {
48        this.$table.bind('column:resize.rc', this.options.resize);
49      }
50      if (this.options.stop) {
51        this.$table.bind('column:resize:stop.rc', this.options.stop);
52      }
53    }
54
55    ResizableColumns.prototype.triggerEvent = function(type, args, original) {
56      var event;
57      event = $.Event(type);
58      event.originalEvent = $.extend({}, original);
59      return this.$table.trigger(event, [this].concat(args || []));
60    };
61
62    ResizableColumns.prototype.getColumnId = function($el) {
63      return this.$table.data('resizable-columns-id') + '-' + $el.data('resizable-column-id');
64    };
65
66    ResizableColumns.prototype.setHeaders = function() {
67      this.$tableHeaders = this.$table.find(this.options.selector);
68      this.assignPercentageWidths();
69      return this.createHandles();
70    };
71
72    ResizableColumns.prototype.destroy = function() {
73      this.$handleContainer.remove();
74      this.$table.removeData('resizableColumns');
75      return this.$table.add(window).off('.rc');
76    };
77
78    ResizableColumns.prototype.assignPercentageWidths = function() {
79      return this.$tableHeaders.each((function(_this) {
80        return function(_, el) {
81          var $el;
82          $el = $(el);
83          return setWidth($el[0], $el.outerWidth() / _this.$table.width() * 100);
84        };
85      })(this));
86    };
87
88    ResizableColumns.prototype.createHandles = function() {
89      var _ref;
90      if ((_ref = this.$handleContainer) != null) {
91        _ref.remove();
92      }
93      this.$table.before((this.$handleContainer = $("<div class='rc-handle-container' />")));
94      this.$tableHeaders.each((function(_this) {
95        return function(i, el) {
96          var $handle;
97          if (_this.$tableHeaders.eq(i + 1).length === 0 || (_this.$tableHeaders.eq(i).attr('data-noresize') != null) || (_this.$tableHeaders.eq(i + 1).attr('data-noresize') != null)) {
98            return;
99          }
100          $handle = $("<div class='rc-handle' />");
101          $handle.data('th', $(el));
102          return $handle.appendTo(_this.$handleContainer);
103        };
104      })(this));
105      return this.$handleContainer.on('mousedown touchstart', '.rc-handle', this.pointerdown);
106    };
107
108    ResizableColumns.prototype.syncHandleWidths = function() {
109      return this.$handleContainer.width(this.$table.width()).find('.rc-handle').each((function(_this) {
110        return function(_, el) {
111          var $el;
112          $el = $(el);
113          return $el.css({
114            left: $el.data('th').outerWidth() + ($el.data('th').offset().left - _this.$handleContainer.offset().left),
115            height: _this.options.resizeFromBody ? _this.$table.height() : _this.$table.find('thead').height()
116          });
117        };
118      })(this));
119    };
120
121    ResizableColumns.prototype.saveColumnWidths = function() {
122      return this.$tableHeaders.each((function(_this) {
123        return function(_, el) {
124          var $el;
125          $el = $(el);
126          if ($el.attr('data-noresize') == null) {
127            if (_this.options.store != null) {
128              return _this.options.store.set(_this.getColumnId($el), parseWidth($el[0]));
129            }
130          }
131        };
132      })(this));
133    };
134
135    ResizableColumns.prototype.restoreColumnWidths = function() {
136      return this.$tableHeaders.each((function(_this) {
137        return function(_, el) {
138          var $el, width;
139          $el = $(el);
140          if ((_this.options.store != null) && (width = _this.options.store.get(_this.getColumnId($el)))) {
141            return setWidth($el[0], width);
142          }
143        };
144      })(this));
145    };
146
147    ResizableColumns.prototype.totalColumnWidths = function() {
148      var total;
149      total = 0;
150      this.$tableHeaders.each((function(_this) {
151        return function(_, el) {
152          return total += parseFloat($(el)[0].style.width.replace('%', ''));
153        };
154      })(this));
155      return total;
156    };
157
158    ResizableColumns.prototype.constrainWidth = function(width) {
159      if (this.options.minWidth != null) {
160        width = Math.max(this.options.minWidth, width);
161      }
162      if (this.options.maxWidth != null) {
163        width = Math.min(this.options.maxWidth, width);
164      }
165      return width;
166    };
167
168    ResizableColumns.prototype.pointerdown = function(e) {
169      var $currentGrip, $leftColumn, $ownerDocument, $rightColumn, newWidths, startPosition, widths;
170      e.preventDefault();
171      $ownerDocument = $(e.currentTarget.ownerDocument);
172      startPosition = pointerX(e);
173      $currentGrip = $(e.currentTarget);
174      $leftColumn = $currentGrip.data('th');
175      $rightColumn = this.$tableHeaders.eq(this.$tableHeaders.index($leftColumn) + 1);
176      widths = {
177        left: parseWidth($leftColumn[0]),
178        right: parseWidth($rightColumn[0])
179      };
180      newWidths = {
181        left: widths.left,
182        right: widths.right
183      };
184      this.$handleContainer.add(this.$table).addClass('rc-table-resizing');
185      $leftColumn.add($rightColumn).add($currentGrip).addClass('rc-column-resizing');
186      this.triggerEvent('column:resize:start', [$leftColumn, $rightColumn, newWidths.left, newWidths.right], e);
187      $ownerDocument.on('mousemove.rc touchmove.rc', (function(_this) {
188        return function(e) {
189          var difference;
190          difference = (pointerX(e) - startPosition) / _this.$table.width() * 100;
191          setWidth($leftColumn[0], newWidths.left = _this.constrainWidth(widths.left + difference));
192          setWidth($rightColumn[0], newWidths.right = _this.constrainWidth(widths.right - difference));
193          if (_this.options.syncHandlers != null) {
194            _this.syncHandleWidths();
195          }
196          return _this.triggerEvent('column:resize', [$leftColumn, $rightColumn, newWidths.left, newWidths.right], e);
197        };
198      })(this));
199      return $ownerDocument.one('mouseup touchend', (function(_this) {
200        return function() {
201          $ownerDocument.off('mousemove.rc touchmove.rc');
202          _this.$handleContainer.add(_this.$table).removeClass('rc-table-resizing');
203          $leftColumn.add($rightColumn).add($currentGrip).removeClass('rc-column-resizing');
204          _this.syncHandleWidths();
205          _this.saveColumnWidths();
206          return _this.triggerEvent('column:resize:stop', [$leftColumn, $rightColumn, newWidths.left, newWidths.right], e);
207        };
208      })(this));
209    };
210
211    return ResizableColumns;
212
213  })();
214  return $.fn.extend({
215    resizableColumns: function() {
216      var args, option;
217      option = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
218      return this.each(function() {
219        var $table, data;
220        $table = $(this);
221        data = $table.data('resizableColumns');
222        if (!data) {
223          $table.data('resizableColumns', (data = new ResizableColumns($table, option)));
224        }
225        if (typeof option === 'string') {
226          return data[option].apply(data, args);
227        }
228      });
229    }
230  });
231})(window.jQuery, window);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.