Added option to use WCF.Language.Chooser as language filter
authorAlexander Ebert <ebert@woltlab.com>
Tue, 13 Nov 2012 16:42:27 +0000 (17:42 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 13 Nov 2012 16:42:27 +0000 (17:42 +0100)
com.woltlab.wcf/template/headInclude.tpl
wcfsetup/install/files/js/WCF.js
wcfsetup/install/lang/de.xml

index 9e8c0bfad9c198fb4d30af358c13798fcd4ee9a9..0a23ee5d12b111a4339c3d369f4ec21c73aebb8c 100644 (file)
        //<![CDATA[
        $(function() {
                WCF.Language.addObject({
+                       '__days': [ '{lang}wcf.date.day.sunday{/lang}', '{lang}wcf.date.day.monday{/lang}', '{lang}wcf.date.day.tuesday{/lang}', '{lang}wcf.date.day.wednesday{/lang}', '{lang}wcf.date.day.thursday{/lang}', '{lang}wcf.date.day.friday{/lang}', '{lang}wcf.date.day.saturday{/lang}' ],
+                       'wcf.date.relative.minutes': '{capture assign=relativeMinutes}{lang}wcf.date.relative.minutes{/lang}{/capture}{@$relativeMinutes|encodeJS}',
+                       'wcf.date.relative.hours': '{capture assign=relativeHours}{lang}wcf.date.relative.hours{/lang}{/capture}{@$relativeHours|encodeJS}',
+                       'wcf.date.relative.pastDays': '{capture assign=relativePastDays}{lang}wcf.date.relative.pastDays{/lang}{/capture}{@$relativePastDays|encodeJS}',
+                       'wcf.date.dateTimeFormat': '{lang}wcf.date.dateTimeFormat{/lang}',
                        'wcf.global.button.add': '{lang}wcf.global.button.add{/lang}',
                        'wcf.global.button.cancel': '{lang}wcf.global.button.cancel{/lang}',
                        'wcf.global.button.collapsible': '{lang}wcf.global.button.collapsible{/lang}',
                        'wcf.global.button.save': '{lang}wcf.global.button.save{/lang}',
                        'wcf.global.button.search': '{lang}wcf.global.button.search{/lang}',
                        'wcf.global.button.submit': '{lang}wcf.global.button.submit{/lang}',
+                       'wcf.global.confirmation.cancel': '{lang}wcf.global.confirmation.cancel{/lang}',
+                       'wcf.global.confirmation.confirm': '{lang}wcf.global.confirmation.confirm{/lang}',
+                       'wcf.global.confirmation.title': '{lang}wcf.global.confirmation.title{/lang}',
+                       'wcf.global.decimalPoint': '{capture assign=decimalPoint}{lang}wcf.global.decimalPoint{/lang}{/capture}{$decimalPoint|encodeJS}',
                        'wcf.global.error.title': '{lang}wcf.global.error.title{/lang}',
+                       'wcf.global.form.edit.success': '{lang}wcf.global.form.edit.success{/lang}',
+                       'wcf.global.language.noSelection': '{lang}wcf.global.language.noSelection{/lang}',
                        'wcf.global.loading': '{lang}wcf.global.loading{/lang}',
-                       'wcf.date.relative.minutes': '{capture assign=relativeMinutes}{lang}wcf.date.relative.minutes{/lang}{/capture}{@$relativeMinutes|encodeJS}',
-                       'wcf.date.relative.hours': '{capture assign=relativeHours}{lang}wcf.date.relative.hours{/lang}{/capture}{@$relativeHours|encodeJS}',
-                       'wcf.date.relative.pastDays': '{capture assign=relativePastDays}{lang}wcf.date.relative.pastDays{/lang}{/capture}{@$relativePastDays|encodeJS}',
-                       'wcf.date.dateTimeFormat': '{lang}wcf.date.dateTimeFormat{/lang}',
-                       '__days': [ '{lang}wcf.date.day.sunday{/lang}', '{lang}wcf.date.day.monday{/lang}', '{lang}wcf.date.day.tuesday{/lang}', '{lang}wcf.date.day.wednesday{/lang}', '{lang}wcf.date.day.thursday{/lang}', '{lang}wcf.date.day.friday{/lang}', '{lang}wcf.date.day.saturday{/lang}' ],
-                       'wcf.global.thousandsSeparator': '{capture assign=thousandsSeparator}{lang}wcf.global.thousandsSeparator{/lang}{/capture}{@$thousandsSeparator|encodeJS}',
-                       'wcf.global.decimalPoint': '{capture assign=decimalPoint}{lang}wcf.global.decimalPoint{/lang}{/capture}{$decimalPoint|encodeJS}',
                        'wcf.global.page.jumpTo': '{lang}wcf.global.page.jumpTo{/lang}',
                        'wcf.global.page.jumpTo.description': '{lang}wcf.global.page.jumpTo.description{/lang}',
                        'wcf.global.page.pageNavigation': '{lang}wcf.global.page.pageNavigation{/lang}',
                        'wcf.global.page.next': '{capture assign=pageNext}{lang}wcf.global.page.next{/lang}{/capture}{@$pageNext|encodeJS}',
                        'wcf.global.page.previous': '{capture assign=pagePrevious}{lang}wcf.global.page.previous{/lang}{/capture}{@$pagePrevious|encodeJS}',
-                       'wcf.global.confirmation.cancel': '{lang}wcf.global.confirmation.cancel{/lang}',
-                       'wcf.global.confirmation.confirm': '{lang}wcf.global.confirmation.confirm{/lang}',
-                       'wcf.global.confirmation.title': '{lang}wcf.global.confirmation.title{/lang}',
+                       'wcf.global.thousandsSeparator': '{capture assign=thousandsSeparator}{lang}wcf.global.thousandsSeparator{/lang}{/capture}{@$thousandsSeparator|encodeJS}',
                        'wcf.sitemap.title': '{lang}wcf.sitemap.title{/lang}',
-                       'wcf.style.changeStyle': '{lang}wcf.style.changeStyle{/lang}',
-                       'wcf.global.form.edit.success': '{lang}wcf.global.form.edit.success{/lang}'
+                       'wcf.style.changeStyle': '{lang}wcf.style.changeStyle{/lang}'
                        {event name='javascriptLanguageImport'}
                });
                
index 8933e8c0ed05f79af89c935fa59914d49d3a2634..9549ed1115ee151fb20143aefb448b0eac6e7985 100755 (executable)
@@ -6835,8 +6835,9 @@ WCF.Language.Chooser = Class.extend({
         * @param       integer         languageID
         * @param       object          languages
         * @param       object          callback
+        * @param       boolean         allowEmptyValue
         */
-       init: function(containerID, inputFieldID, languageID, languages, callback) {
+       init: function(containerID, inputFieldID, languageID, languages, callback, allowEmptyValue) {
                var $container = $('#' + containerID);
                if ($container.length != 1) {
                        console.debug("[WCF.Language.Chooser] Invalid container id '" + containerID + "' given");
@@ -6877,6 +6878,16 @@ WCF.Language.Chooser = Class.extend({
                        }
                }
                
+               // allow an empty selection (e.g. using as language filter)
+               if (allowEmptyValue) {
+                       $('<li class="dropdownDivider" />').appendTo($dropdownMenu);
+                       var $item = $('<li><a>' + WCF.Language.get('wcf.global.language.noSelection') + '</a></li>').data('languageID', 0).click($.proxy(this._click, this)).appendTo($dropdownMenu);
+                       
+                       if (languageID === 0) {
+                               this._dropdown.children('.dropdownToggle').empty().append($item.html());
+                       }
+               }
+               
                WCF.Dropdown.init();
        },
        
@@ -6887,13 +6898,14 @@ WCF.Language.Chooser = Class.extend({
         */
        _click: function(event) {
                var $item = $(event.currentTarget);
+               var $languageID = $item.data('languageID');
                
                // update input field
-               this._input.val($item.data('languageID'));
+               this._input.val($languageID);
                
                // update dropdown label
                var $html = $('' + $item.html());
-               var $innerContent = $html.children().detach();
+               var $innerContent = ($languageID === 0) ? $html : $html.children().detach();
                this._dropdown.children('.dropdownToggle').empty().append($innerContent);
                
                // execute callback
index a2ea62a04954f137aeb93fb56c3ef9e90a91683e..631bc6382f29cbbb4ccddef305c46bfafe97a322 100644 (file)
                <item name="wcf.global.form.error"><![CDATA[Ihre Angaben sind ungültig. Bitte überprüfen Sie die markierten Eingabefelder.]]></item>
                <item name="wcf.global.form.error.empty"><![CDATA[Bitte füllen Sie dieses Eingabefeld aus.]]></item>
                <item name="wcf.global.form.error.multilingual"><![CDATA[Bitte füllen Sie dieses Eingabefeld für jede Sprache aus.]]></item>
+               <item name="wcf.global.language.noSelection"><![CDATA[Keine Auswahl]]></item>
                <item name="wcf.global.loading"><![CDATA[Lädt …]]></item>
                <item name="wcf.global.locale.unix"><![CDATA[de_DE]]></item> <!-- system variable; do not translate -->
                <item name="wcf.global.locale.win"><![CDATA[deu_deu]]></item> <!-- system variable; do not translate -->