From 7adb034e02c7a2a23f52d96d366273cc76e4717f Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Thu, 17 Oct 2013 10:28:47 +0200 Subject: Remove jquery button usage and unify button code https://fedorahosted.org/freeipa/ticket/3904 --- install/ui/src/freeipa/widget.js | 107 +++++++++++++++++++-------------------- ipatests/test_webui/ui_driver.py | 7 ++- 2 files changed, 58 insertions(+), 56 deletions(-) diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 3891bf9b..0fcf6182 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -3449,7 +3449,7 @@ IPA.link_widget = function(spec) { }; /** - * Create link which behaves as button + * Create button * * @method * @member IPA @@ -3469,38 +3469,13 @@ IPA.link_widget = function(spec) { */ IPA.action_button = function(spec) { - spec = spec || {}; - - var button = $('', { - id: spec.id, - name: spec.name, - href: spec.href || '#' + (spec.name || 'button'), - title: text.get(spec.title || spec.label), - 'class': 'button action-button', - style: spec.style, - click: spec.click, - blur: spec.blur - }); - - if (spec.focusable === false) { - button.attr('tabindex', '-1'); - } + spec = $.extend({}, spec); - if (spec['class']) button.addClass(spec['class']); - - if (spec.icon) { - $('', { - 'class': 'icon '+spec.icon - }).appendTo(button); - } - - if (spec.label) { - $('', { - 'class': 'button-label', - html: text.get(spec.label) - }).appendTo(button); - } + spec.element = spec.element || ''; + spec.button_class = spec.button_class || 'button action-button'; + var button = IPA.button(spec); + button.prop('href', spec.href || '#'); return button; }; @@ -3518,30 +3493,53 @@ IPA.action_button = function(spec) { * @param {string} [spec.title=label] button title * @param {string} [spec.icon] icon name (class) * @param {string} [spec.id] - * @param {string} [spec.href] * @param {string} [spec.style] css style * @param {string} [spec.class] + * @param {string} [spec.button_class] + * @param {string} [spec.element] + * @param {string} [spec.type] * @param {Function} [spec.click] click handler + * @param {boolean} [spec.focusable] button is focusable + * @param {Function} [spec.blur] blur handler */ IPA.button = function(spec) { spec = spec || {}; - var button = $('', { + var el = spec.element || '