Skip to content

Commit

Permalink
Drag and drop s-table header using DnD class (Novik#2855)
Browse files Browse the repository at this point in the history
* Drag and drop s-table header using DnD class

- Modify `DnD` class initialization method a bit, so that the object
  can be attached to an HTML element or an `id` identifier. This is
  a preparation for the following change.
- Merge header cell resizing and moving methods into one object,
  reusing ruTorrent's `DnD` utility class, and thus removes the
  `dxSTable.ColumnMove` object defined in the s-table module that
  did the same thing as the `DnD` class.
- Rearrange header row drag-and-drop event handling process. Resizing,
  moving, and sorting actions are distributed according to the position
  of mouse clicks and displacement of the mouse cursor.
- Remove obsolete properties from S-Table class (`dxSTable.cancelMove`
  and `dxSTable.cancelSort`).

* Use ternary operator for DnD init
  • Loading branch information
jevenski authored Jan 19, 2025
1 parent b95fa10 commit 53f3428
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 195 deletions.
12 changes: 10 additions & 2 deletions js/objects.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@

// Drag & Drop object
class DnD {
constructor(id, options) {
this.obj = $('#' + id);
/**
* Construct a drag-and-drop instance.
* @param {string | HTMLElement} dndObj Reference to the drag-and-drop element.
* Can be the HTML `id` of the element, or a reference to the HTML element.
* @param {Object} options Drag and drop options to be passed.
*/
constructor(dndObj, options) {
this.obj = ($type(dndObj) === "string")
? $('#' + dndObj)
: $(dndObj);
const headers = this.obj.find(".dlg-header");
const header = headers.length > 0 ? $(headers[0]) : this.obj;
this.options = options || {};
Expand Down
Loading

0 comments on commit 53f3428

Please sign in to comment.