mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Remove last usage of jQuery UI
https://fedorahosted.org/freeipa/ticket/3904
This commit is contained in:
committed by
Martin Kosek
parent
2d1e8d2e49
commit
38cb39b67f
@@ -41,7 +41,6 @@
|
||||
var scripts = [
|
||||
'js/libs/json2.js',
|
||||
'js/libs/jquery.js',
|
||||
'js/libs/jquery-ui.js',
|
||||
'js/libs/bootstrap.js',
|
||||
'js/libs/jquery.ordered-map.js',
|
||||
'js/libs/browser.js',
|
||||
|
||||
@@ -20,7 +20,14 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
define(['./ipa', './jquery', './text', './field', './widget'], function(IPA, $, text) {
|
||||
define([
|
||||
'dojo/keys',
|
||||
'./ipa',
|
||||
'./jquery',
|
||||
'./text',
|
||||
'./field',
|
||||
'./widget'],
|
||||
function(keys, IPA, $, text) {
|
||||
|
||||
/**
|
||||
* Opened dialogs
|
||||
@@ -371,14 +378,14 @@ IPA.dialog = function(spec) {
|
||||
that.on_key_down = function(event) {
|
||||
|
||||
if ( that.close_on_escape && !event.isDefaultPrevented() && event.keyCode &&
|
||||
event.keyCode === $.ui.keyCode.ESCAPE ) {
|
||||
event.keyCode === keys.ESCAPE ) {
|
||||
event.preventDefault();
|
||||
that.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// prevent tabbing out of dialogs
|
||||
if ( event.keyCode !== $.ui.keyCode.TAB ) {
|
||||
if ( event.keyCode !== keys.TAB ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -718,7 +725,7 @@ IPA.adder_dialog = function(spec) {
|
||||
type: 'text',
|
||||
name: 'filter',
|
||||
keyup: function(event) {
|
||||
if (event.keyCode === $.ui.keyCode.ENTER) {
|
||||
if (event.keyCode === keys.ENTER) {
|
||||
that.search();
|
||||
return false;
|
||||
}
|
||||
@@ -1256,12 +1263,12 @@ IPA.confirm_mixin = function() {
|
||||
* @param {Event} event
|
||||
*/
|
||||
on_key_up: function(event) {
|
||||
if (event.keyCode === $.ui.keyCode.ENTER &&
|
||||
if (event.keyCode === keys.ENTER &&
|
||||
!this.test_ignore(event) &&
|
||||
!!this.on_confirm) {
|
||||
event.preventDefault();
|
||||
this.on_confirm();
|
||||
} else if (event.keyCode === $.ui.keyCode.ESCAPE &&
|
||||
} else if (event.keyCode === keys.ESCAPE &&
|
||||
!!this.on_cancel) {
|
||||
event.preventDefault();
|
||||
this.on_cancel();
|
||||
|
||||
@@ -22,14 +22,16 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
define(['./jquery',
|
||||
define([
|
||||
'dojo/keys',
|
||||
'./jquery',
|
||||
'./json2',
|
||||
'./_base/i18n',
|
||||
'./metadata',
|
||||
'./builder',
|
||||
'./reg',
|
||||
'./text'],
|
||||
function($, JSON, i18n, metadata_provider, builder, reg, text) {
|
||||
function(keys, $, JSON, i18n, metadata_provider, builder, reg, text) {
|
||||
|
||||
/**
|
||||
* @class
|
||||
@@ -2353,15 +2355,15 @@ IPA.unauthorized_dialog = function(spec) {
|
||||
}
|
||||
|
||||
if (that.current_view === 'session') {
|
||||
if (event.keyCode === $.ui.keyCode.ENTER && !this.test_ignore(event)) {
|
||||
if (event.keyCode === keys.ENTER && !this.test_ignore(event)) {
|
||||
that.on_login();
|
||||
event.preventDefault();
|
||||
}
|
||||
} else {
|
||||
if (event.keyCode === $.ui.keyCode.ENTER && !this.test_ignore(event)) {
|
||||
if (event.keyCode === keys.ENTER && !this.test_ignore(event)) {
|
||||
that.on_reset();
|
||||
event.preventDefault();
|
||||
} else if (event.keyCode === $.ui.ESCAPE) {
|
||||
} else if (event.keyCode === keys.ESCAPE) {
|
||||
that.on_cancel();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
73
install/ui/src/freeipa/jquery.js
vendored
73
install/ui/src/freeipa/jquery.js
vendored
@@ -19,8 +19,77 @@
|
||||
*/
|
||||
|
||||
//
|
||||
// AMD Wrapper for jquery library
|
||||
// AMD Wrapper for jQuery
|
||||
//
|
||||
define(function() {
|
||||
return jQuery;
|
||||
|
||||
$ = jQuery;
|
||||
|
||||
//
|
||||
// Following code taken from jQuery UI library, MIT license, see
|
||||
// README-LICENSES.txt
|
||||
//
|
||||
|
||||
$.fn.extend({
|
||||
focus: (function( orig ) {
|
||||
return function( delay, fn ) {
|
||||
return typeof delay === "number" ?
|
||||
this.each(function() {
|
||||
var elem = this;
|
||||
window.setTimeout(function() {
|
||||
$( elem ).focus();
|
||||
if ( fn ) {
|
||||
fn.call( elem );
|
||||
}
|
||||
}, delay );
|
||||
}) :
|
||||
orig.apply( this, arguments );
|
||||
};
|
||||
})( $.fn.focus )
|
||||
});
|
||||
|
||||
// selectors
|
||||
function focusable( element, isTabIndexNotNaN ) {
|
||||
var map, mapName, img,
|
||||
nodeName = element.nodeName.toLowerCase();
|
||||
if ( "area" === nodeName ) {
|
||||
map = element.parentNode;
|
||||
mapName = map.name;
|
||||
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
|
||||
return false;
|
||||
}
|
||||
img = $( "img[usemap=#" + mapName + "]" )[0];
|
||||
return !!img && visible( img );
|
||||
}
|
||||
return ( /input|select|textarea|button|object/.test( nodeName ) ?
|
||||
!element.disabled :
|
||||
"a" === nodeName ?
|
||||
element.href || isTabIndexNotNaN :
|
||||
isTabIndexNotNaN) &&
|
||||
// the element and all of its ancestors must be visible
|
||||
visible( element );
|
||||
}
|
||||
|
||||
function visible( element ) {
|
||||
return $.expr.filters.visible( element ) &&
|
||||
!$( element ).parents().addBack().filter(function() {
|
||||
return $.css( this, "visibility" ) === "hidden";
|
||||
}).length;
|
||||
}
|
||||
|
||||
$.extend( $.expr[ ":" ], {
|
||||
|
||||
focusable: function( element ) {
|
||||
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
|
||||
},
|
||||
|
||||
tabbable: function( element ) {
|
||||
var tabIndex = $.attr( element, "tabindex" ),
|
||||
isTabIndexNaN = isNaN( tabIndex );
|
||||
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return $;
|
||||
});
|
||||
@@ -25,6 +25,7 @@
|
||||
define(['dojo/_base/array',
|
||||
'dojo/_base/lang',
|
||||
'dojo/Evented',
|
||||
'dojo/keys',
|
||||
'dojo/on',
|
||||
'./builder',
|
||||
'./ipa',
|
||||
@@ -33,7 +34,7 @@ define(['dojo/_base/array',
|
||||
'./reg',
|
||||
'./text'
|
||||
],
|
||||
function(array, lang, Evented, on, builder, IPA, $, phases, reg, text) {
|
||||
function(array, lang, Evented, keys, on, builder, IPA, $, phases, reg, text) {
|
||||
|
||||
/**
|
||||
* Widget module
|
||||
@@ -3159,10 +3160,10 @@ IPA.combobox_widget = function(spec) {
|
||||
|
||||
var key = e.which;
|
||||
|
||||
if (key === $.ui.keyCode.TAB ||
|
||||
key === $.ui.keyCode.ESCAPE ||
|
||||
key === $.ui.keyCode.ENTER ||
|
||||
key === $.ui.keyCode.SHIFT ||
|
||||
if (key === keys.TAB ||
|
||||
key === keys.ESCAPE ||
|
||||
key === keys.ENTER ||
|
||||
key === keys.SHIFT ||
|
||||
e.ctrlKey ||
|
||||
e.metaKey ||
|
||||
e.altKey) return true;
|
||||
@@ -3172,11 +3173,11 @@ IPA.combobox_widget = function(spec) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key === $.ui.keyCode.UP || key === $.ui.keyCode.DOWN) {
|
||||
if (key === keys.UP_ARROW || key === keys.DOWN_ARROW) {
|
||||
e.preventDefault();
|
||||
that.open();
|
||||
|
||||
if (key === $.ui.keyCode.UP) {
|
||||
if (key === keys.UP_ARROW) {
|
||||
that.select_prev();
|
||||
} else {
|
||||
that.select_next();
|
||||
@@ -3207,7 +3208,7 @@ IPA.combobox_widget = function(spec) {
|
||||
that.on_list_container_keydown = function(e) {
|
||||
// close on ESCAPE and consume event to prevent unwanted
|
||||
// behaviour like closing dialog
|
||||
if (e.which == $.ui.keyCode.ESCAPE) {
|
||||
if (e.which == keys.ESCAPE) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
that.close();
|
||||
@@ -3217,7 +3218,7 @@ IPA.combobox_widget = function(spec) {
|
||||
};
|
||||
|
||||
that.on_filter_keyup = function(e) {
|
||||
if (e.which == $.ui.keyCode.ENTER) {
|
||||
if (e.which == keys.ENTER) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
@@ -3229,11 +3230,11 @@ IPA.combobox_widget = function(spec) {
|
||||
|
||||
that.on_filter_keydown = function(e) {
|
||||
var key = e.which;
|
||||
if (key === $.ui.keyCode.UP) {
|
||||
if (key === keys.UP_ARROW) {
|
||||
e.preventDefault();
|
||||
that.select_prev();
|
||||
that.list.focus();
|
||||
} else if (key === $.ui.keyCode.DOWN) {
|
||||
} else if (key === keys.DOWN_ARROW) {
|
||||
e.preventDefault();
|
||||
that.select_next();
|
||||
that.list.focus();
|
||||
@@ -3241,7 +3242,7 @@ IPA.combobox_widget = function(spec) {
|
||||
};
|
||||
|
||||
that.list_on_keydown = function(e) {
|
||||
if (e.which === $.ui.keyCode.TAB) {
|
||||
if (e.which === keys.TAB) {
|
||||
e.preventDefault();
|
||||
if (that.searchable) {
|
||||
that.filter.focus();
|
||||
@@ -3253,7 +3254,7 @@ IPA.combobox_widget = function(spec) {
|
||||
};
|
||||
|
||||
that.list_on_keyup = function(e) {
|
||||
if (e.which === $.ui.keyCode.ENTER || e.which === $.ui.keyCode.SPACE) {
|
||||
if (e.which === keys.ENTER || e.which === keys.SPACE) {
|
||||
e.stopPropagation();
|
||||
that.close();
|
||||
IPA.select_range(that.input, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user