comparison js/Editor-1.5.6/js/editor.jqueryui.js @ 2:a64ece32a01a draft default tip

"planemo upload for repository https://github.com/ImmPortDB/immport-galaxy-tools/tree/master/flowtools/cs_overview commit a46097db0b6056e1125237393eb6974cfd51eb41"
author azomics
date Tue, 28 Jul 2020 08:32:36 -0400
parents
children
comparison
equal deleted inserted replaced
1:bca68066a957 2:a64ece32a01a
1 /*! jQuery UI integration for DataTables' Editor
2 * ©2015 SpryMedia Ltd - datatables.net/license
3 */
4
5 (function( factory ){
6 if ( typeof define === 'function' && define.amd ) {
7 // AMD
8 define( ['jquery', 'datatables.net-jqui', 'datatables.net-editor'], function ( $ ) {
9 return factory( $, window, document );
10 } );
11 }
12 else if ( typeof exports === 'object' ) {
13 // CommonJS
14 module.exports = function (root, $) {
15 if ( ! root ) {
16 root = window;
17 }
18
19 if ( ! $ || ! $.fn.dataTable ) {
20 $ = require('datatables.net-jqui')(root, $).$;
21 }
22
23 if ( ! $.fn.dataTable.Editor ) {
24 require('datatables.net-editor')(root, $);
25 }
26
27 return factory( $, root, root.document );
28 };
29 }
30 else {
31 // Browser
32 factory( jQuery, window, document );
33 }
34 }(function( $, window, document, undefined ) {
35 'use strict';
36 var DataTable = $.fn.dataTable;
37
38
39 var Editor = DataTable.Editor;
40 var doingClose = false;
41
42 /*
43 * Set the default display controller to be our foundation control
44 */
45 Editor.defaults.display = "jqueryui";
46
47 /*
48 * Change the default classes from Editor to be classes for Bootstrap
49 */
50 $.extend( true, $.fn.dataTable.Editor.classes, {
51 form: {
52 button: "btn ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only"
53 }
54 } );
55
56 /*
57 * jQuery UI display controller - this is effectively a proxy to the jQuery UI
58 * modal control.
59 */
60 Editor.display.jqueryui = $.extend( true, {}, Editor.models.displayController, {
61 init: function ( dte ) {
62 dte.__dialouge = $('<div/>')
63 .css('display', 'none')
64 .appendTo('body')
65 .dialog( $.extend( true, Editor.display.jqueryui.modalOptions, {
66 autoOpen: false,
67 buttons: { "A": function () {} }, // fake button so the button container is created
68 closeOnEscape: false // allow editor's escape function to run
69 } ) );
70
71 // Need to know when the dialogue is closed using its own trigger
72 // so we can reset the form
73 $(dte.__dialouge).on( 'dialogclose', function (e) {
74 if ( ! doingClose ) {
75 dte.close();
76 }
77 } );
78
79 return Editor.display.jqueryui;
80 },
81
82 open: function ( dte, append, callback ) {
83 dte.__dialouge
84 .append( append )
85 .dialog( 'open' );
86
87 $(dte.dom.formError).appendTo(
88 dte.__dialouge.parent().find('div.ui-dialog-buttonpane')
89 );
90
91 dte.__dialouge.parent().find('.ui-dialog-title').html( dte.dom.header.innerHTML );
92 dte.__dialouge.parent().addClass('DTED');
93
94 // Modify the Editor buttons to be jQuery UI suitable
95 var buttons = $(dte.dom.buttons)
96 .children()
97 .addClass( 'ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only' )
98 .each( function () {
99 $(this).wrapInner( '<span class="ui-button-text" />' );
100 } );
101
102 // Move the buttons into the jQuery UI button set
103 dte.__dialouge.parent().find('div.ui-dialog-buttonset')
104 .empty()
105 .append( buttons.parent() );
106
107 if ( callback ) {
108 callback();
109 }
110 },
111
112 close: function ( dte, callback ) {
113 if ( dte.__dialouge ) {
114 // Don't want to trigger a close() call from dialogclose!
115 doingClose = true;
116 dte.__dialouge.dialog( 'close' );
117 doingClose = false;
118 }
119
120 if ( callback ) {
121 callback();
122 }
123 },
124
125 node: function ( dte ) {
126 return dte.__dialouge[0];
127 },
128
129 // jQuery UI dialogues perform their own focus capture
130 captureFocus: false
131 } );
132
133
134 Editor.display.jqueryui.modalOptions = {
135 width: 600,
136 modal: true
137 };
138
139
140 return DataTable.Editor;
141 }));