Debian Codegraph @

js/extras/jquery.dragtable.mod.js

raw symbols SCIP
1 /*! Dragtable Mod for TableSorter - updated 10/31/2015 (v2.24.0) *//*
2 * Requires
3 * tablesorter v2.8+
4 * jQuery 1.7+
5 * jQuery UI (Core, Widget, Mouse & Sortable)
6 * Dragtable by Akottr (https://github.com/akottr) modified by Rob Garrison
7 */
8 /*jshint browser:true, jquery:true, unused:false */
9 /*global jQuery: false */
10 ;(function( $ ) {
11 'use strict';
12 var undef,
13 ts = $.tablesorter;
14
15 ts.dragtable = {
16 create : function( _this ) {
17 var hasAccept,
18 $table = _this.originalTable.el,
19 handle = _this.options.dragHandle.replace('.', '');
20 $table.children('thead').children().children('th,td').each(function(){
21 var $this = $(this);
22 if ( !$this.find( _this.options.dragHandle + ',.' + handle + '-disabled' ).length ) {
23 hasAccept = _this.options.dragaccept ? $this.hasClass( _this.options.dragaccept.replace('.', '') ) : true;
24 $this
25 // sortClass includes a "." to match the tablesorter selectorSort option - for consistency
26 .wrapInner('<div class="' + _this.options.sortClass.replace('.', '') + '"/>')
27 // add handle class + "-disabled" to drag-disabled columns
28 .prepend('<div class="' + handle + ( hasAccept ? '' : '-disabled' ) + '"></div>');
29 }
30 });
31 },
32 start : function( table ) {
33 table = $( table )[0];
34 if ( table && table.config ) {
35 table.config.widgetOptions.dragtableLast = {
36 search : $( table ).data( 'lastSearch' ),
37 order : ts.dragtable.getOrder( table )
38 };
39 }
40 },
41 update : function( _this ) {
42 var t, list, val,
43 dragTable = _this.originalTable,
44 table = dragTable.el[ 0 ],
45 $table = $( table ),
46 c = table.config,
47 wo = c && c.widgetOptions,
48 startIndex = dragTable.startIndex - 1,
49 endIndex = dragTable.endIndex - 1,
50 columnOrder = ts.dragtable.getOrder( table ) || [],
51 hasFilters = ts.hasWidget( $table, 'filter' ) || false,
52 last = wo && wo.dragtableLast || {},
53 // update moved filters
54 filters = [];
55
56 // only trigger updateAll if column order changed
57 if ( ( last.order || [] ).join( '' ) !== columnOrder.join( '' ) ) {
58
59 if ( c.sortList.length ) {
60 // must deep extend (nested arrays) to prevent list from changing with c.sortList
61 list = $.extend( true, [], c.sortList );
62 $.each( columnOrder, function( indx, value ) {
63 val = ts.isValueInArray( parseInt( value, 10 ), list );
64 if ( value !== last.order[ indx ] && val >= 0 ) {
65 c.sortList[ val ][ 0 ] = indx;
66 }
67 });
68 }
69
70 // update filter widget
71 if ( hasFilters ) {
72 $.each( last.search || [], function( indx ) {
73 filters[ indx ] = last.search[ columnOrder[ indx ] ];
74 });
75 }
76
77 // update preset editable widget columns
78 t = ( ts.hasWidget( c.$table, 'editable' ) || false ) ? wo.editable_columnsArray : false;
79 if ( t ) {
80 c.widgetOptions.editable_columnsArray = ts.dragtable.reindexArrayItem( t, startIndex, endIndex );
81 }
82 // update ignore math columns
83 t = ( ts.hasWidget( c.$table, 'math' ) || false ) ? wo.math_ignore : false;
84 if ( t ) {
85 c.widgetOptions.math_ignore = ts.dragtable.reindexArrayItem( t, startIndex, endIndex );
86 }
87 // update preset resizable widget widths
88 t = ( ts.hasWidget( c.$table, 'resizable' ) || false ) ? wo.resizable_widths : false;
89 if ( t ) {
90 // use zero-based indexes in the array
91 wo.resizable_widths = ts.dragtable.moveArrayItem( t, startIndex, endIndex );
92 }
93 /*
94 // chart widget WIP - there are other options that need to be rearranged!
95 t = ( ts.hasWidget( c.$table, 'chart' ) || false ) ? wo.chart_ignoreColumns : false;
96 if ( t ) {
97 // use zero-based indexes in the array
98 wo.chart_ignoreColumns = ts.dragtable.moveArrayItem( t, startIndex, endIndex );
99 }
100 */
101
102 ts.updateAll( c, false, function() {
103 if ( hasFilters ) {
104 setTimeout( function() {
105 // just update the filter values
106 c.lastCombinedFilter = null;
107 c.$table.data('lastSearch', filters);
108 ts.setFilters( $table, filters );
109 if ($.isFunction(_this.options.tablesorterComplete)) {
110 _this.options.tablesorterComplete( c.table );
111 }
112 }, 10 );
113 }
114 });
115 }
116 },
117 getOrder : function( table ) {
118 return $( table ).children( 'thead' ).children( '.' + ts.css.headerRow ).children().map( function() {
119 return $( this ).attr( 'data-column' );
120 }).get() || [];
121 },
122 // bubble the moved col left or right
123 startColumnMove : function( dragTable ) {
124 var $cols,
125 c = dragTable.el[ 0 ].config,
126 startIndex = dragTable.startIndex - 1,
127 endIndex = dragTable.endIndex - 1,
128 cols = c.columns - 1,
129 pos = endIndex === cols ? false : endIndex <= startIndex,
130 $rows = c.$table.children().children( 'tr' );
131 if ( c.debug ) {
132 console.log( 'Inserting column ' + startIndex + ( pos ? ' before' : ' after' ) + ' column ' + endIndex );
133 }
134 $rows.each( function() {
135 $cols = $( this ).children();
136 $cols.eq( startIndex )[ pos ? 'insertBefore' : 'insertAfter' ]( $cols.eq( endIndex ) );
137 });
138 // rearrange col in colgroup
139 $cols = c.$table.children( 'colgroup' ).children();
140 $cols.eq( startIndex )[ pos ? 'insertBefore' : 'insertAfter' ]( $cols.eq( endIndex ) );
141 },
142 swapNodes : function( a, b ) {
143 var indx, aparent, asibling,
144 len = a.length;
145 for ( indx = 0; indx < len; indx++ ) {
146 aparent = a[ indx ].parentNode;
147 asibling = a[ indx ].nextSibling === b[ indx ] ? a[ indx ] : a[ indx ].nextSibling;
148 b[ indx ].parentNode.insertBefore( a[ indx ], b[ indx ] );
149 aparent.insertBefore( b[ indx ], asibling );
150 }
151 },
152 // http://stackoverflow.com/a/5306832/145346
153 moveArrayItem : function( array, oldIndex, newIndex ) {
154 var indx, len = array.length;
155 if ( newIndex >= len ) {
156 indx = newIndex - len;
157 while ( ( indx-- ) + 1 ) {
158 array.push( undef );
159 }
160 }
161 array.splice( newIndex, 0, array.splice( oldIndex, 1 )[ 0 ] );
162 return array;
163 },
164 reindexArrayItem : function( array, oldIndex, newIndex ) {
165 var nIndx = $.inArray( newIndex, array ),
166 oIndx = $.inArray( oldIndex, array ),
167 max = Math.max.apply( Math, array ),
168 arry = [];
169 // columns in the array were swapped so return original array
170 if ( nIndx >= 0 && oIndx >= 0 ) {
171 return array;
172 }
173 // columns not in the array were moved
174 $.each( array, function( indx, value ) {
175 // column (not in array) inserted between indexes
176 if ( newIndex < oldIndex ) {
177 // ( [ 0,1,2,3 ], 5, 1 ) -> column inserted between 0 & 1 => [ 0,2,3,4 ]
178 if ( value >= newIndex ) {
179 // 5 -> 1 [ 0, 2, 3 ] then 1 -> 0 [ 1, 2, 3 ]
180 arry.push( value + ( value < oldIndex ? 1 : 0 ) );
181 } else {
182 arry.push( value );
183 }
184 } else if ( newIndex > oldIndex ) {
185 // ( [ 0,1,2,3 ], 1, 5 ) -> column in array moved outside => [ 0,1,2,5 ]
186 if ( value === oldIndex ) {
187 arry.push( newIndex );
188 } else if ( value < newIndex && value >= oldIndex ) {
189 arry.push( value - 1 );
190 } else if ( value <= newIndex ) {
191 arry.push( value );
192 } else if ( value > oldIndex ) {
193 arry.push( value + ( value < newIndex ? 0 : 1 ) );
194 }
195 }
196 });
197 return arry.sort();
198 }
199 };
200
201 /*! dragtable v2.0.14 Mod *//*
202 * _____ _
203 * | |___ _| |
204 * | | | | . | . |
205 * |_|_|_|___|___|
206 *
207 * Copyright (c) 2010-2013, Andres [email protected]
208 * Dual licensed under the MIT (MIT-LICENSE.txt)
209 * and GPL (GPL-LICENSE.txt) licenses.
210 *
211 * Inspired by the the dragtable from Dan Vanderkam (danvk.org/dragtable/)
212 * Thanks to the jquery and jqueryui comitters
213 *
214 * Any comment, bug report, feature-request is welcome
215 * Feel free to contact me.
216 */
217
218 /* TOKNOW:
219 * For IE7 you need this css rule:
220 * table {
221 * border-collapse: collapse;
222 * }
223 * Or take a clean reset.css (see http://meyerweb.com/eric/tools/css/reset/)
224 */
225
226 /* TODO: investigate
227 * Does not work properly with css rule:
228 * html {
229 * overflow: -moz-scrollbars-vertical;
230 * }
231 * Workaround:
232 * Fixing Firefox issues by scrolling down the page
233 * http://stackoverflow.com/questions/2451528/jquery-ui-sortable-scroll-helper-element-offset-firefox-issue
234 *
235 * var start = $.noop;
236 * var beforeStop = $.noop;
237 * if($.browser.mozilla) {
238 * var start = function (event, ui) {
239 * if( ui.helper !== undefined )
240 * ui.helper.css('position','absolute').css('margin-top', $(window).scrollTop() );
241 * }
242 * var beforeStop = function (event, ui) {
243 * if( ui.offset !== undefined )
244 * ui.helper.css('margin-top', 0);
245 * }
246 * }
247 *
248 * and pass this as start and stop function to the sortable initialisation
249 * start: start,
250 * beforeStop: beforeStop
251 */
252 /*
253 * Special thx to all pull requests comitters
254 */
255
256 $.widget("akottr.dragtable", {
257 options: {
258 revert: false, // smooth revert
259 dragHandle: '.table-handle', // handle for moving cols, if not exists the whole 'th' is the handle
260 maxMovingRows: 40, // 1 -> only header. 40 row should be enough, the rest is usually not in the viewport
261 excludeFooter: false, // excludes the footer row(s) while moving other columns. Make sense if there is a footer with a colspan. */
262 onlyHeaderThreshold: 100, // TODO: not implemented yet, switch automatically between entire col moving / only header moving
263 dragaccept: null, // draggable cols -> default all
264 persistState: null, // url or function -> plug in your custom persistState function right here. function call is persistState(originalTable)
265 restoreState: null, // JSON-Object or function: some kind of experimental aka Quick-Hack TODO: do it better
266 exact: true, // removes pixels, so that the overlay table width fits exactly the original table width
267 clickDelay: 10, // ms to wait before rendering sortable list and delegating click event
268 containment: null, // @see http://api.jqueryui.com/sortable/#option-containment, use it if you want to move in 2 dimesnions (together with axis: null)
269 cursor: 'move', // @see http://api.jqueryui.com/sortable/#option-cursor
270 cursorAt: false, // @see http://api.jqueryui.com/sortable/#option-cursorAt
271 distance: 0, // @see http://api.jqueryui.com/sortable/#option-distance, for immediate feedback use "0"
272 tolerance: 'pointer', // @see http://api.jqueryui.com/sortable/#option-tolerance
273 axis: 'x', // @see http://api.jqueryui.com/sortable/#option-axis, Only vertical moving is allowed. Use 'x' or null. Use this in conjunction with the 'containment' setting
274 beforeStart: $.noop, // returning FALSE will stop the execution chain.
275 beforeMoving: $.noop,
276 beforeReorganize: $.noop,
277 beforeStop: $.noop,
278 // new options
279 tablesorterComplete: null,
280 sortClass : '.sorter'
281 },
282 originalTable: {
283 el: null,
284 selectedHandle: null,
285 sortOrder: null,
286 startIndex: 0,
287 endIndex: 0
288 },
289 sortableTable: {
290 el: $(),
291 selectedHandle: $(),
292 movingRow: $()
293 },
294 persistState: function() {
295 var _this = this;
296 this.originalTable.el.find('th').each(function(i) {
297 if (this.id !== '') {
298 _this.originalTable.sortOrder[this.id] = i;
299 }
300 });
301 $.ajax({
302 url: this.options.persistState,
303 data: this.originalTable.sortOrder
304 });
305 },
306 /*
307 * persistObj looks like
308 * {'id1':'2','id3':'3','id2':'1'}
309 * table looks like
310 * | id2 | id1 | id3 |
311 */
312 _restoreState: function(persistObj) {
313 for (var n in persistObj) {
314 if (n in persistObj) {
315 this.originalTable.startIndex = $('#' + n).closest('th').prevAll().length + 1;
316 this.originalTable.endIndex = parseInt(persistObj[n], 10) + 1;
317 this._bubbleCols();
318 }
319 }
320 },
321 // bubble the moved col left or right
322 _bubbleCols: function() {
323 ts.dragtable.startColumnMove(this.originalTable);
324 },
325 _rearrangeTableBackroundProcessing: function() {
326 var _this = this;
327 return function() {
328 _this._bubbleCols();
329 _this.options.beforeStop(_this.originalTable);
330 _this.sortableTable.el.remove();
331 restoreTextSelection();
332 ts.dragtable.update(_this);
333 // persist state if necessary
334 if ($.isFunction(_this.options.persistState)) {
335 _this.options.persistState(_this.originalTable);
336 } else {
337 _this.persistState();
338 }
339
340 };
341 },
342 _rearrangeTable: function() {
343 var _this = this;
344 return function() {
345 // remove handler-class -> handler is now finished
346 _this.originalTable.selectedHandle.removeClass('dragtable-handle-selected');
347 // add disabled class -> reorgorganisation starts soon
348 _this.sortableTable.el.sortable("disable");
349 _this.sortableTable.el.addClass('dragtable-disabled');
350 _this.options.beforeReorganize(_this.originalTable, _this.sortableTable);
351 // do reorganisation asynchronous
352 // for chrome a little bit more than 1 ms because we want to force a rerender
353 _this.originalTable.endIndex = _this.sortableTable.movingRow.prevAll().length + 1;
354 setTimeout(_this._rearrangeTableBackroundProcessing(), 50);
355 };
356 },
357 /*
358 * Disrupts the table. The original table stays the same.
359 * But on a layer above the original table we are constructing a list (ul > li)
360 * each li with a separate table representig a single col of the original table.
361 */
362 _generateSortable: function(e) {
363 if (e.cancelBubble) {
364 e.cancelBubble = true;
365 } else {
366 e.stopPropagation();
367 }
368 var _this = this;
369 // table attributes
370 var attrs = this.originalTable.el[0].attributes;
371 var tableAttrsString = '';
372 for (var i = 0; i < attrs.length; i++) {
373 if ( (attrs[i].value || attrs[i].nodeValue) && attrs[i].nodeName != 'id' && attrs[i].nodeName != 'width') {
374 tableAttrsString += attrs[i].nodeName + '="' + ( attrs[i].value || attrs[i].nodeValue ) + '" ';
375 }
376 }
377 // row attributes
378 var rowAttrsArr = [];
379 //compute height, special handling for ie needed :-(
380 var heightArr = [];
381
382 // don't save tfoot attributes because it messes up indexing
383 _this.originalTable.el.children('thead, tbody').children('tr:visible').slice(0, _this.options.maxMovingRow).each(function() {
384 // row attributes
385 var attrs = this.attributes;
386 var attrsString = '';
387 for (var j = 0; j < attrs.length; j++) {
388 if ( (attrs[j].value || attrs[j].nodeValue ) && attrs[j].nodeName != 'id') {
389 attrsString += ' ' + attrs[j].nodeName + '="' + ( attrs[j].value || attrs[j].nodeValue ) + '"';
390 }
391 }
392 rowAttrsArr.push(attrsString);
393 heightArr.push($(this).height());
394 });
395
396 // compute width, no special handling for ie needed :-)
397 var widthArr = [];
398 // compute total width, needed for not wrapping around after the screen ends (floating)
399 var totalWidth = 0;
400 /* Find children thead and tbody.
401 * Only to process the immediate tr-children. Bugfix for inner tables
402 */
403 var thtb = _this.originalTable.el.children();
404 var headerRows = thtb.filter('thead').children('tr:visible');
405 var visibleRows = thtb.filter('tbody').children('tr:visible');
406
407 headerRows.eq(0).children('th, td').filter(':visible').each(function() {
408 var w = $(this).outerWidth();
409 widthArr.push(w);
410 totalWidth += w;
411 });
412 if(_this.options.exact) {
413 var difference = totalWidth - _this.originalTable.el.outerWidth();
414 widthArr[0] -= difference;
415 }
416 // one extra px on right and left side
417 totalWidth += 2;
418
419 var captionHeight = 0;
420 thtb.filter('caption').each(function(){
421 captionHeight += $(this).outerHeight();
422 });
423
424 var sortableHtml = '<ul class="dragtable-sortable" style="position:absolute; width:' + totalWidth + 'px;">';
425 var sortableColumn = [];
426 // assemble the needed html
427 // build list
428 var rowIndex,
429 columns = headerRows.eq(0).children('th, td').length;
430 /*jshint loopfunc:true */
431 for (i = 0; i < columns; i++) {
432 var row = headerRows.children(':nth-child(' + (i + 1) + ')');
433 if (row.is(':visible')) {
434 rowIndex = 0;
435 sortableColumn[i] = '<li style="width:' + row.outerWidth() + 'px;">' +
436 '<table ' + tableAttrsString + '>' +
437 ( captionHeight ? '<caption style="height:' + captionHeight + 'px;"></caption>' : '' ) +
438 '<thead>';
439 // thead
440 headerRows.each(function(j){
441 sortableColumn[i] += '<tr ' + rowAttrsArr[rowIndex++] +
442 ( heightArr[j] ? ' style="height:' + heightArr[j] + 'px;"' : '' ) + '>' +
443 row[j].outerHTML + '</tr>';
444 });
445 sortableColumn[i] += '</thead><tbody>';
446 // tbody
447 row = visibleRows.children(':nth-child(' + (i + 1) + ')');
448 if (_this.options.maxMovingRows > 1) {
449 row = row.add(visibleRows.children(':nth-child(' + (i + 1) + ')').slice(0, _this.options.maxMovingRows - 1));
450 }
451 row.each(function(j) {
452 sortableColumn[i] += '<tr ' + rowAttrsArr[rowIndex++] +
453 ( heightArr[j] ? ' style="height:' + heightArr[j] + 'px;"' : '' ) + '>' +
454 this.outerHTML + '</tr>';
455 });
456 sortableColumn[i] += '</tbody>';
457
458 // add footer to end of max Rows
459 if (!_this.options.excludeFooter) {
460 sortableColumn[i] += '<tfoot><tr ' + rowAttrsArr[rowIndex++] + '>' +
461 thtb.filter('tfoot').children('tr:visible').children()[i].outerHTML + '</tr></tfoot>';
462 }
463 sortableColumn[i] += '</table></li>';
464 }
465 }
466 sortableHtml += sortableColumn.join('') + '</ul>';
467 this.sortableTable.el = this.originalTable.el.before(sortableHtml).prev();
468 // set width if necessary
469 this.sortableTable.el.find('> li > table').each(function(i) {
470 $(this).css('width', widthArr[i] + 'px');
471 });
472
473 // assign this.sortableTable.selectedHandle
474 this.sortableTable.selectedHandle = this.sortableTable.el.find('th .dragtable-handle-selected');
475
476 var items = !this.options.dragaccept ? 'li' : 'li:has(' + this.options.dragaccept + ')';
477 this.sortableTable.el.sortable({
478 items: items,
479 stop: this._rearrangeTable(),
480 // pass thru options for sortable widget
481 revert: this.options.revert,
482 tolerance: this.options.tolerance,
483 containment: this.options.containment,
484 cursor: this.options.cursor,
485 cursorAt: this.options.cursorAt,
486 distance: this.options.distance,
487 axis: this.options.axis
488 });
489
490 // assign start index
491 this.originalTable.startIndex = $(e.target).closest('th,td').prevAll().length + 1;
492 this.options.beforeMoving(this.originalTable, this.sortableTable);
493 // Start moving by delegating the original event to the new sortable table
494 this.sortableTable.movingRow = this.sortableTable.el.children('li:nth-child(' + this.originalTable.startIndex + ')');
495
496 // prevent the user from drag selecting "highlighting" surrounding page elements
497 disableTextSelection();
498 // clone the initial event and trigger the sort with it
499 this.sortableTable.movingRow.trigger($.extend($.Event(e.type), {
500 which: 1,
501 clientX: e.clientX,
502 clientY: e.clientY,
503 pageX: e.pageX,
504 pageY: e.pageY,
505 screenX: e.screenX,
506 screenY: e.screenY
507 }));
508
509 // Some inner divs to deliver the posibillity to style the placeholder more sophisticated
510 var placeholder = this.sortableTable.el.find('.ui-sortable-placeholder');
511 if(placeholder.height() > 0) {
512 placeholder.css('height', this.sortableTable.el.find('.ui-sortable-helper').height());
513 }
514
515 placeholder.html('<div class="outer" style="height:100%;"><div class="inner" style="height:100%;"></div></div>');
516 },
517 bindTo: {},
518 _create: function() {
519 var _this = this;
520 _this.originalTable = {
521 el: _this.element,
522 selectedHandle: $(),
523 sortOrder: {},
524 startIndex: 0,
525 endIndex: 0
526 };
527 ts.dragtable.create( _this );
528 // filter only the cols that are accepted
529 _this.bindTo = '> thead > tr > ' + ( _this.options.dragaccept || 'th, td' );
530 // bind draggable to handle if exists
531 if (_this.element.find(_this.bindTo).find(_this.options.dragHandle).length) {
532 _this.bindTo += ' ' + _this.options.dragHandle;
533 }
534 // restore state if necessary
535 if ($.isFunction(_this.options.restoreState)) {
536 _this.options.restoreState(_this.originalTable);
537 } else {
538 _this._restoreState(_this.options.restoreState);
539 }
540 _this.originalTable.el.on( 'mousedown.dragtable', _this.bindTo, function(evt) {
541 // listen only to left mouse click
542 if (evt.which!==1) return;
543 ts.dragtable.start( _this.originalTable.el );
544 if (_this.options.beforeStart(_this.originalTable) === false) {
545 return;
546 }
547 clearTimeout(_this.downTimer);
548 _this.downTimer = setTimeout(function() {
549 _this.originalTable.selectedHandle = $(_this);
550 _this.originalTable.selectedHandle.addClass('dragtable-handle-selected');
551 _this._generateSortable(evt);
552 }, _this.options.clickDelay);
553 }).on( 'mouseup.dragtable', _this.options.dragHandle,function() {
554 clearTimeout(_this.downTimer);
555 });
556 },
557 redraw: function(){
558 this.destroy();
559 this._create();
560 },
561 destroy: function() {
562 this.originalTable.el.off('mousedown.dragtable mouseup.dragtable', this.bindTo);
563 $.Widget.prototype.destroy.apply(this, arguments); // default destroy
564 // now do other stuff particular to this widget
565 }
566 });
567
568 /** closure-scoped "private" functions **/
569 var body_onselectstart_save = $(document.body).attr('onselectstart'),
570 body_unselectable_save = $(document.body).attr('unselectable');
571
572 // css properties to disable user-select on the body tag by appending a <style> tag to the <head>
573 // remove any current document selections
574 function disableTextSelection() {
575 // jQuery doesn't support the element.text attribute in MSIE 8
576 // http://stackoverflow.com/questions/2692770/style-style-textcss-appendtohead-does-not-work-in-ie
577 var $style = $('<style id="__dragtable_disable_text_selection__" type="text/css">body { -ms-user-select:none;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;user-select:none; }</style>');
578 $(document.head).append($style);
579 $(document.body).attr('onselectstart', 'return false;').attr('unselectable', 'on');
580 if (window.getSelection) {
581 window.getSelection().removeAllRanges();
582 } else {
583 document.selection.empty(); // MSIE http://msdn.microsoft.com/en-us/library/ms535869%28v=VS.85%29.aspx
584 }
585 }
586
587 // remove the <style> tag, and restore the original <body> onselectstart attribute
588 function restoreTextSelection() {
589 $('#__dragtable_disable_text_selection__').remove();
590 if (body_onselectstart_save) {
591 $(document.body).attr('onselectstart', body_onselectstart_save);
592 } else {
593 $(document.body).removeAttr('onselectstart');
594 }
595 if (body_unselectable_save) {
596 $(document.body).attr('unselectable', body_unselectable_save);
597 } else {
598 $(document.body).removeAttr('unselectable');
599 }
600 }
601
602 })(jQuery);