To make a modification in jQuery UI and get a compressed version?

0 like 0 dislike
10 views
Some time ago I wrote about the fact that you write some "analog jQuery Treeview". Thanks to the hint nikitammf problem "otprygivat item" I overcame.

But there was another problem. To describe her, I first explain how the jQuery UI Draggable plugin is determines whether or not the portable element over the droppable element.


At the beginning of the transfer of the seized item the method is called $.ui.ddmanager.prepareOffsets(this, event) (line 152 of file /development-bundle/ui/jquery.ui.draggable.js). This method stores in the cache the absolute coordinates of all droppable elements. Then, in the process of migrating a draggable element, it's evolving constantly check the coordinates with the coordinates of the droppable elements from the cache, and when the intersection coordinates, the plugin recognizes that the seized item was over-droppable-element (i.e., the event occurs "hover"). The cache coordinates droppable elements are always calculated only once at the beginning of the transfer of the seized item.

As it conflicts with my code? As I wrote at the time of occurrence of the event "hover" I have sent a request to the server, which returns a list of child elements, which are inserted in a nested list. Is inserted as a nested list, the coordinates of subsequent (downstream) droppable elements are changing, but the cache coordinates doesn't know about it.

As a result, if to seize the very first item, hold on a second element (wait for the nested list) and then lead it down, the third and subsequent elements will react even before the dragged item really will be over them (because the cache coordinates was the old coordinates and he still thinks that all droppable elements remained in their original positions).

How to solve this problem, the principle is clear: to count the cache's coordinates (you call a method $.ui.ddmanager.prepareOffsets(this, event)) after the insertion of child list.

But just calling this method does not work: his name has changed in the design process and minimize the designer of jQuery UI (I don't use a giant archive with a bunch of js files, and collected designer single file).

How here to be? How to call a method whose name has "obfuscated"?


Online example of my own development here.
by | 10 views

6 Answers

0 like 0 dislike
The solution is already found by myself. As always, it was much simpler: not noticed in the documentation that jQuery UI draggable has the option refreshPositions and if it is set to true, then the position of the droppable elements will be updated whenever the mouse moves.
On the other hand, to save computer resources, you still would like to learn how to update the position of elements not on every mouse movement, and only when necessary by calling the appropriate method.
by
0 like 0 dislike
I suggest You to use the automatic write JavaScript in a nice way, which will write concise code in a structured way, though, of course, will not restore the original name of the shortened identifiers (variables, fields, functions, methods, and so on).
\r
Then, by close looking, You will be able to determine the name of the desired method (by comparing its content with the known content of the original uncompressed code of the same method and making sure their logical similarity). Use found name in your call, and the forbidding reaches the desired.
by
0 like 0 dislike
A more radical method of solving this problem is the rejection of the standard designer-packer, available on the website of jQuery UI, and the transition to a handwritten pasting the desired files JavaScript end to end, with a further package of their own — though with such a packaging, which does not change the method names so that creates the problems You described.
\r
For this purpose, for example, you can use a famous packer of Dean Edwards, putting him in settings check the "Base62 encode", but uncheck the box "Shrink variables".
by
0 like 0 dislike
Write a feature request in their bug tracker :)
by
0 like 0 dislike
And why, if the list was opened and items evening training session and then closed, reopening again they are loaded? Can make a flag, loaded or not? Or is it critical and so often updated? (a bit оффquestion) (:
by
0 like 0 dislike
you can use the method "option" draggable and set the option to recalculate if you refresh after loading the items, then again to remove it.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
28,799 users