Add improved search implementation to TextareaOptionType
authorMatthias Schmidt <gravatronics@live.com>
Fri, 9 May 2014 13:21:07 +0000 (15:21 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Fri, 9 May 2014 13:21:07 +0000 (15:21 +0200)
com.woltlab.wcf/templates/textareaSearchableOptionType.tpl [new file with mode: 0644]
wcfsetup/install/files/acp/templates/textareaSearchableOptionType.tpl [new file with mode: 0644]
wcfsetup/install/files/lib/system/option/TextareaOptionType.class.php

diff --git a/com.woltlab.wcf/templates/textareaSearchableOptionType.tpl b/com.woltlab.wcf/templates/textareaSearchableOptionType.tpl
new file mode 100644 (file)
index 0000000..7d22daa
--- /dev/null
@@ -0,0 +1,17 @@
+<label><input type="checkbox" id="search_{$option->optionName}" name="searchOptions[{$option->optionName}]"{if $searchOption} checked="checked"{/if} /> {lang}wcf.user.option.searchTextOption{/lang}</label>
+<textarea id="{$option->optionName}" name="values[{$option->optionName}]"{if !$searchOption} disabled="disabled"{/if} cols="40" rows="10">{$value}</textarea>
+
+<script data-relocate="true">
+//<![CDATA[
+$(function() {
+       $('#search_{$option->optionName}').change(function(event) {
+               if ($(event.currentTarget).prop('checked')) {
+                       $('#{$option->optionName}').enable();
+               }
+               else {
+                       $('#{$option->optionName}').disable();
+               }
+       });
+});
+//]]>
+</script>
diff --git a/wcfsetup/install/files/acp/templates/textareaSearchableOptionType.tpl b/wcfsetup/install/files/acp/templates/textareaSearchableOptionType.tpl
new file mode 100644 (file)
index 0000000..7d22daa
--- /dev/null
@@ -0,0 +1,17 @@
+<label><input type="checkbox" id="search_{$option->optionName}" name="searchOptions[{$option->optionName}]"{if $searchOption} checked="checked"{/if} /> {lang}wcf.user.option.searchTextOption{/lang}</label>
+<textarea id="{$option->optionName}" name="values[{$option->optionName}]"{if !$searchOption} disabled="disabled"{/if} cols="40" rows="10">{$value}</textarea>
+
+<script data-relocate="true">
+//<![CDATA[
+$(function() {
+       $('#search_{$option->optionName}').change(function(event) {
+               if ($(event.currentTarget).prop('checked')) {
+                       $('#{$option->optionName}').enable();
+               }
+               else {
+                       $('#{$option->optionName}').disable();
+               }
+       });
+});
+//]]>
+</script>
index bdbf4775fa99ae8d9347a50fdedc789b67b01fac..93170da86622d536d9f03a795ac5141982b282a6 100644 (file)
@@ -26,6 +26,18 @@ class TextareaOptionType extends TextOptionType {
                return WCF::getTPL()->fetch('textareaOptionType');
        }
        
+       /**
+        * @see \wcf\system\option\ISearchableUserOption::getSearchFormElement()
+        */
+       public function getSearchFormElement(Option $option, $value) {
+               WCF::getTPL()->assign(array(
+                       'option' => $option,
+                       'searchOption' => isset($_POST['searchOptions'][$option->optionName]),
+                       'value' => $value
+               ));
+               return WCF::getTPL()->fetch('textareaSearchableOptionType');
+       }
+       
        /**
         * @see \wcf\system\option\IOptionType::getData()
         */