summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-11-04 18:11:00 +0100
committerMartin Kosek <mkosek@redhat.com>2014-01-21 12:04:03 +0100
commit38cb39b67f0f504048ecfb9700db28f413e0d570 (patch)
tree591c495086194e8dafb93a1232f454c5274eb4b9
parent2d1e8d2e4938a74264c471aadd6d2e350c755a7f (diff)
downloadfreeipa-38cb39b67f0f504048ecfb9700db28f413e0d570.tar.gz
freeipa-38cb39b67f0f504048ecfb9700db28f413e0d570.tar.xz
freeipa-38cb39b67f0f504048ecfb9700db28f413e0d570.zip
Remove last usage of jQuery UI
https://fedorahosted.org/freeipa/ticket/3904
-rw-r--r--install/ui/index.html1
-rw-r--r--install/ui/src/freeipa/dialog.js19
-rw-r--r--install/ui/src/freeipa/ipa.js12
-rw-r--r--install/ui/src/freeipa/jquery.js73
-rw-r--r--install/ui/src/freeipa/widget.js27
5 files changed, 105 insertions, 27 deletions
diff --git a/install/ui/index.html b/install/ui/index.html
index e6371634e..ac6682cfb 100644
--- a/install/ui/index.html
+++ b/install/ui/index.html
@@ -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',
diff --git a/install/ui/src/freeipa/dialog.js b/install/ui/src/freeipa/dialog.js
index eb27a05cc..18e2dc501 100644
--- a/install/ui/src/freeipa/dialog.js
+++ b/install/ui/src/freeipa/dialog.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();
diff --git a/install/ui/src/freeipa/ipa.js b/install/ui/src/freeipa/ipa.js
index f59bed53c..54cd90cb6 100644
--- a/install/ui/src/freeipa/ipa.js
+++ b/install/ui/src/freeipa/ipa.js
@@ -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();
}
diff --git a/install/ui/src/freeipa/jquery.js b/install/ui/src/freeipa/jquery.js
index da86e95d3..446f884c8 100644
--- a/install/ui/src/freeipa/jquery.js
+++ b/install/ui/src/freeipa/jquery.js
@@ -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 $;
}); \ No newline at end of file
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 63e7a4197..7b0005adf 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -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);