From b9ef6ab0c412913234f05f788b3fcd3c3277eb69 Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Mon, 26 Nov 2012 14:28:32 +0100 Subject: Move of core Web UI files to AMD directory SSIA https://fedorahosted.org/freeipa/ticket/112 --- install/ui/widget.js | 3559 -------------------------------------------------- 1 file changed, 3559 deletions(-) delete mode 100644 install/ui/widget.js (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js deleted file mode 100644 index 8d2239d8..00000000 --- a/install/ui/widget.js +++ /dev/null @@ -1,3559 +0,0 @@ -/*jsl:import ipa.js */ -/* Authors: - * Endi Sukma Dewata - * Adam Young - * Pavel Zuna - * - * Copyright (C) 2010 Red Hat - * see file 'COPYING' for use and warranty information - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* REQUIRES: ipa.js */ - -IPA.checkbox_column_width = 22; -IPA.required_indicator = '*'; - -IPA.widget = function(spec) { - - spec = spec || {}; - - var that = {}; - - that.name = spec.name; - that.id = spec.id; - that.label = spec.label; - that.tooltip = spec.tooltip; - that.measurement_unit = spec.measurement_unit; - that.entity = IPA.get_entity(spec.entity); //some old widgets still need it - that.facet = spec.facet; - - that.create = function(container) { - container.addClass('widget'); - that.container = container; - }; - - that.clear = function() { - }; - - that.set_visible = function(visible) { - - if (visible) { - that.container.show(); - } else { - that.container.hide(); - } - }; - - that.build_child = function(spec, factory) { - - if (typeof spec === 'function') { - spec = { - factory: spec - }; - } - - $.extend(spec, { - parent: that, - entity: that.entity, - facet: that.facet - }); - - var child = IPA.build(spec, factory); - return child; - }; - - that.widget_create = that.create; - - return that; -}; - -IPA.input_widget = function(spec) { - - spec = spec || {}; - - var that = IPA.widget(spec); - - that.width = spec.width; - that.height = spec.height; - - that.undo = spec.undo === undefined ? true : spec.undo; - that.writable = spec.writable === undefined ? true : spec.writable; - that.read_only = spec.read_only; - that.hidden = spec.hidden; - - //events - //each widget can contain several events - that.value_changed = IPA.observer(); - that.undo_clicked = IPA.observer(); - - - that.create_error_link = function(container) { - container.append(' '); - - $('', { - name: 'error_link', - 'class': 'ui-state-error ui-corner-all', - style: 'display:none' - }).appendTo(container); - }; - - that.create_required = function(container) { - that.required_indicator = $('', { - 'class': 'required-indicator', - text: IPA.required_indicator, - style: 'display: none;' - }).appendTo(container); - }; - - that.update = function() { - }; - - /** - * This function saves the values entered in the UI. - * It returns the values in an array, or null if - * the field should not be saved. - */ - that.save = function() { - return []; - }; - - /** - * This function creates an undo link in the container. - * On_undo is a link click callback. It can be specified to custom - * callback. If a callback isn't set, default callback is used. If - * spefified to value other than a function, no callback is registered. - */ - that.create_undo = function(container, on_undo) { - container.append(' '); - - that.undo_span = - $('', { - name: 'undo', - style: 'display: none;', - 'class': 'ui-state-highlight ui-corner-all undo', - html: IPA.messages.widget.undo - }).appendTo(container); - - if(on_undo === undefined) { - on_undo = function() { - that.undo_clicked.notify([], that); - }; - } - - if(typeof on_undo === 'function') { - that.undo_span.click(on_undo); - } - }; - - that.get_undo = function() { - return $(that.undo_span); - }; - - that.show_undo = function() { - that.get_undo().css('display', 'inline'); - }; - - that.hide_undo = function() { - $(that.undo_span).css('display', 'none'); - }; - - that.get_error_link = function() { - return $('span[name="error_link"]', that.container); - }; - - that.show_error = function(message) { - var error_link = that.get_error_link(); - error_link.html(message); - error_link.css('display', 'block'); - }; - - that.hide_error = function() { - var error_link = that.get_error_link(); - error_link.css('display', 'none'); - }; - - that.set_required = function(required) { - - that.required = required; - - if (that.required_indicator) { - that.required_indicator.css('display', that.required ? 'inline' : 'none'); - } - }; - - that.on_value_changed = function() { - var value = that.save(); - that.value_changed.notify([value], that); - }; - - that.focus_input = function() {}; - that.set_deleted = function() {}; - - // methods that should be invoked by subclasses - that.widget_hide_error = that.hide_error; - that.widget_show_error = that.show_error; - - return that; -}; - -/*uses a browser specific technique to select a range.*/ -IPA.select_range = function(input,start, end) { - input.focus(); - if (input[0].setSelectionRange) { - input[0].setSelectionRange(start, end); - } else if (input[0].createTextRange) { - var range = input[0].createTextRange(); - range.collapse(true); - range.moveEnd('character', end); - range.moveStart('character', start); - range.select(); - } -}; - - -IPA.text_widget = function(spec) { - - spec = spec || {}; - - var that = IPA.input_widget(spec); - - that.size = spec.size || 30; - that.input_type = spec.input_type || 'text'; - - that.select_range = function(start, end){ - IPA.select_range(that.input, start, end); - }; - - that.create = function(container) { - - that.widget_create(container); - - container.addClass('text-widget'); - - that.display_control = $('