From a5423278ebf72ec29fc5637f867edc743984bad9 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 16 Jul 2012 14:44:35 +0200 Subject: [PATCH] Added JS and CSS for language choosers --- wcfsetup/install/files/js/WCF.js | 100 ++++++++++++++++++++ wcfsetup/install/files/style/dropdown.less | 8 ++ wcfsetup/install/files/style/layout.less | 28 ++++++ wcfsetup/install/files/style/userPanel.less | 4 + 4 files changed, 140 insertions(+) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 5d55e8e9d5..d7889adc0e 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -6012,6 +6012,106 @@ WCF.Sitemap = Class.extend({ } }); +/** + * Provides a language chooser. + * + * @param string containerID + * @param string inputFieldID + * @param integer languageID + * @param object languages + * @param object callback + */ +WCF.Language.Chooser = Class.extend({ + /** + * callback object + * @var object + */ + _callback: null, + + /** + * dropdown object + * @var jQuery + */ + _dropdown: null, + + /** + * input field + * @var jQuery + */ + _input: null, + + /** + * Initializes the language chooser. + * + * @param string containerID + * @param string inputFieldID + * @param integer languageID + * @param object languages + * @param object callback + */ + init: function(containerID, inputFieldID, languageID, languages, callback) { + var $container = $('#' + containerID); + if ($container.length != 1) { + console.debug("[WCF.Language.Chooser] Invalid container id '" + containerID + "' given"); + return; + } + + // bind language id input + this._input = $('#' + inputFieldID); + if (!this._input.length) { + this._input = $('').appendTo($container); + } + + // handle callback + if (callback !== undefined) { + if (!$.isFunction(callback)) { + console.debug("[WCF.Language.Chooser] Given callback is invalid"); + return; + } + + this._callback = callback; + } + + // create language dropdown + this._dropdown = $('