Generates the JavaScript to filter categories.<p>

@return the JavaScript
765129
private String filterCategoryJS() {

        StringBuffer result = new StringBuffer();
        // fool the widget with a hidden categories input field
        result.append("<input name=\"dummysearchcategory\" id=\"dummysearchcategory\" type=\"hidden\" value=\"\">\n");
        result.append("<input name=\"dummysearchpage\" id=\"dummysearchpage\" type=\"hidden\" value=\"\">\n");
        // delete all other chosen "cateogries.x" values and put a value here
        result.append("<script type=\"text/javascript\">\n");
        result.append("  function filterCategory(category) {\n");
        result.append("    var searchform = document.forms['EDITOR'];\n");
        result.append("    var inputFields = searchform.elements;\n");
        result.append("    for (var i=0; i<inputFields.length; i++) {\n");
        result.append("      if(inputFields[i].name != null && inputFields[i].name.indexOf('categories') != -1) {\n");
        result.append("        inputFields[i].value='';\n");
        result.append("        inputFields[i].name='invalidsearchcategory';\n");
        result.append("      }\n");
        result.append("    }\n");
        // if we found a category field use it, if not, set the name of our
        // fooling field to "categories.0" or the widget filling will fail
        result.append("    var categoryField = inputFields['dummysearchcategory'];\n");
        result.append("    categoryField.name = 'categories.0';\n");
        result.append("    categoryField.value = category;\n");
        // additionally set searchpage to zero because filtered results may / will be smaller
        result.append("    inputFields['dummysearchpage'].value = '0';\n");
        result.append("    inputFields['dummysearchpage'].name = 'searchpage.0';\n");
        result.append("    validateQuery();\n");
        result.append("    searchform.submit();\n");
        result.append("  }\n");
        result.append("</script>\n");
        return result.toString();
    }
1009153
public String getJsIncludes() {

        StringBuffer result = new StringBuffer();

        result.append("<script type=\"text/javascript\" src=\"");
        result.append(CmsWorkplace.getSkinUri());
        result.append("commons/ajax.js\"></script>\n");

        result.append("<script type=\"text/javascript\">\n");

        // initialize global variables
        result.append("\tvar progressState = 0;\n");
        result.append("\tvar progressResult = '';\n");

        // function update progress bar
        result.append("\tfunction updateProgressBar(msg, state) {\n");

        // check state of progress
        result.append("\t\tif (progressState != 1) {\n");
        result.append("\t\t\tprogressState = 0;\n");
        result.append("\t\t\treturn;\n");
        result.append("\t\t}\n");

        result.append("\t\tif (state == 'ok') {\n");

        // get all elements to use
        result.append("\t\t\tvar bar = document.getElementById(\"progressbar_bar\");\n");
        result.append("\t\t\tvar percent = document.getElementById(\"progressbar_percent\");\n");
        result.append("\t\t\tvar wait = document.getElementById(\"progressbar_wait\");\n");
        result.append("\t\t\tvar desc = document.getElementById(\"progressbar_desc\");\n");

        result.append("\t\t\tif (msg != \"\") {\n");

        result.append("\t\t\t\tbar.parentNode.style.display = \"block\";\n");
        result.append("\t\t\t\tpercent.style.display = \"inline\";\n");
        result.append("\t\t\t\twait.style.display = \"none\";\n");
        result.append("\t\t\t\tdesc.style.display = \"block\";\n");

        // update progress
        result.append("\t\t\t\tif (msg.substring(0,3) == \"PRO\") {\n");
        result.append("\t\t\t\t\tvar splitted = msg.split(\"|\");\n");
        result.append("\t\t\t\t\tbar.style.width = splitted[0].substr(3);\n");
        result.append("\t\t\t\t\tpercent.innerHTML = splitted[0].substr(3);\n");
        result.append("\t\t\t\t\tdesc.innerHTML = splitted[1];\n");
        result.append("\t\t\t\t\tmakeRequest('");
        result.append(getJsp().link("/system/workplace/commons/report-progress.jsp"));
        result.append("', '");
        result.append(PARAMETER_KEY);
        result.append("=");
        result.append(getKey());
        result.append("&");
        result.append(PARAMETER_SHOWWAITTIME);
        result.append("=");
        result.append(getShowWaitTime());
        result.append("&");
        result.append(PARAMETER_REFRESHRATE);
        result.append("=");
        result.append(getRefreshRate());
        result.append("', 'updateProgressBar');\n");

        // set error message
        result.append("\t\t\t\t} else if (msg.substring(0,3) == \"ERR\") {\n");
        result.append("\t\t\t\t\tsetProgressBarError(msg.substr(3));\n");

        // set result
        result.append("\t\t\t\t} else {\n");
        result.append("\t\t\t\t\tprogressState = 0;\n");
        result.append("\t\t\t\t\tbar.style.width = \"100%\";\n");
        result.append("\t\t\t\t\tpercent.innerHTML = \"100%\";\n");
        result.append("\t\t\t\t\tprogressResult = msg;\n");

        result.append("\t\t\t\t\tbar.parentNode.style.display = \"none\";\n");
        result.append("\t\t\t\t\tpercent.style.display = \"none\";\n");
        result.append("\t\t\t\t\tdesc.style.display = \"none\";\n");
        result.append("\t\t\t\t\twait.style.display = \"block\";\n");

        result.append("\t\t\t\t\twindow.setTimeout(\"");
        result.append(getJsFinishMethod());
        result.append("()\",100);\n");
        result.append("\t\t\t\t}\n");
        result.append("\t\t\t} else {\n");
        result.append("\t\t\t\tbar.style.width = \"100%\";\n");
        result.append("\t\t\t}\n");

        // fatal error returned by ajax
        result.append("\t\t} else if (state == 'fatal') {\n");
        result.append("\t\t\tprogressState = 0;\n");
        result.append("\t\t\tsetProgressBarError(\"");
        result.append(
            org.opencms.workplace.Messages.get().getBundle(getJsp().getRequestContext().getLocale()).key(
                org.opencms.workplace.Messages.GUI_AJAX_REPORT_GIVEUP_0));
        result.append("\");\n");

        // error returned by ajax
        result.append("\t\t} else if (state == 'error') {\n");
        result.append("\t\t\tprogressState = 0;\n");
        result.append("\t\t\tsetProgressBarError(\"");
        result.append(
            org.opencms.workplace.Messages.get().getBundle(getJsp().getRequestContext().getLocale()).key(
                org.opencms.workplace.Messages.GUI_AJAX_REPORT_ERROR_0));
        result.append(" \" + msg);\n");

        // wait returned by ajax -> display wait symbol
        result.append("\t\t} else if (state == 'wait') {\n");
        result.append("\t\t\tbar.parentNode.style.display = \"none\";\n");
        result.append("\t\t\tpercent.style.display = \"none\";\n");
        result.append("\t\t\twait.style.display = \"block\";\n");
        result.append("\t\t}\n");
        result.append("\t}\n");

        // function set error
        result.append("\tfunction setProgressBarError(msg) {\n");
        result.append("\t\tvar error = document.getElementById(\"progressbar_error\");\n");
        result.append("\t\tvar bar = document.getElementById(\"progressbar_bar\");\n");
        result.append("\t\tvar percent = document.getElementById(\"progressbar_percent\");\n");
        result.append("\t\tvar desc = document.getElementById(\"progressbar_desc\");\n");

        result.append("\t\terror.innerHTML = msg;\n");
        result.append("\t\terror.style.display = \"block\";\n");

        result.append("\t\tbar.style.display = \"none\";\n");
        result.append("\t\tpercent.style.display = \"none\";\n");
        result.append("\t\tdesc.style.display = \"none\";\n");

        result.append("\t}\n");

        // function reset progress bar
        result.append("\tfunction resetProgressBar() {\n");
        result.append("\t\tvar bar = document.getElementById(\"progressbar_bar\");\n");
        result.append("\t\tbar.parentNode.style.display = \"inline\";\n");
        result.append("\t\tbar.style.width = \"0%\";\n");
        result.append("\t\tbar.style.display = \"block\";\n");

        result.append("\t\tvar percent = document.getElementById(\"progressbar_percent\");\n");
        result.append("\t\tpercent.innerHTML = \"0%\";\n");
        result.append("\t\tpercent.style.display = \"inline\";\n");

        result.append("\t\tvar error = document.getElementById(\"progressbar_error\");\n");
        result.append("\t\terror.innerHTML = \"\";\n");
        result.append("\t\terror.style.display = \"none\";\n");

        result.append("\t\tvar wait = document.getElementById(\"progressbar_wait\");\n");
        result.append("\t\twait.style.display = \"none\";\n");

        result.append("\t\tvar desc = document.getElementById(\"progressbar_desc\");\n");
        result.append("\t\tdesc.style.display = \"block\";\n");
        result.append("\t\tdesc.innerHTML = \"\";\n");

        result.append("\t\t\t\t\tprogressResult = \"\";\n");

        result.append("\t}\n");

        // function start progress bar
        result.append("\tfunction startProgressBar() {\n");
        result.append("\t\tif (progressState > 0) {\n");
        result.append("\t\t\tprogressState = 2;\n");
        result.append("\t\t\twindow.setTimeout(\"startProgressBar()\",");
        result.append(getRefreshRate());
        result.append(");\n");
        result.append("\t\t\treturn;\n");
        result.append("\t\t}\n");
        result.append("\t\tprogressState = 1;\n");
        result.append("\t\tmakeRequest('");
        result.append(getJsp().link("/system/workplace/commons/report-progress.jsp"));
        result.append("', '");
        result.append(PARAMETER_KEY);
        result.append("=");
        result.append(getKey());
        result.append("&");
        result.append(PARAMETER_SHOWWAITTIME);
        result.append("=");
        result.append(getShowWaitTime());
        result.append("&");
        result.append(PARAMETER_REFRESHRATE);
        result.append("=");
        result.append(getRefreshRate());
        result.append("', 'updateProgressBar');\n");
        result.append("\t}\n");

        result.append("</script>\n");

        return result.toString();
    }
505574
function() {

            // Build filter if filtering OR case insensitive filtering is enabled and the number of options exceeds (or equals) enableFilterLength.
            if (this.options.enableFiltering || this.options.enableCaseInsensitiveFiltering) {
                var enableFilterLength = Math.max(this.options.enableFiltering, this.options.enableCaseInsensitiveFiltering);

                if (this.$select.find('option').length >= enableFilterLength) {

                    this.$filter = $(this.options.templates.filter);
                    $('input', this.$filter).attr('placeholder', this.options.filterPlaceholder);

                    // Adds optional filter clear button
                    if(this.options.includeFilterClearBtn){
                        var clearBtn = $(this.options.templates.filterClearBtn);
                        clearBtn.on('click', $.proxy(function(event){
                            clearTimeout(this.searchTimeout);
                            this.$filter.find('.multiselect-search').val('');
                            $('li', this.$ul).show().removeClass("filter-hidden");
                            this.updateSelectAll();
                        }, this));
                        this.$filter.find('.input-group').append(clearBtn);
                    }

                    this.$ul.prepend(this.$filter);

                    this.$filter.val(this.query).on('click', function(event) {
                        event.stopPropagation();
                    }).on('input keydown', $.proxy(function(event) {
                        // Cancel enter key default behaviour
                        if (event.which === 13) {
                            event.preventDefault();
                        }

                        // This is useful to catch "keydown" events after the browser has updated the control.
                        clearTimeout(this.searchTimeout);

                        this.searchTimeout = this.asyncFunction($.proxy(function() {

                            if (this.query !== event.target.value) {
                                this.query = event.target.value;

                                var currentGroup, currentGroupVisible;
                                $.each($('li', this.$ul), $.proxy(function(index, element) {
                                    var value = $('input', element).length > 0 ? $('input', element).val() : "";
                                    var text = $('label', element).text();

                                    var filterCandidate = '';
                                    if ((this.options.filterBehavior === 'text')) {
                                        filterCandidate = text;
                                    }
                                    else if ((this.options.filterBehavior === 'value')) {
                                        filterCandidate = value;
                                    }
                                    else if (this.options.filterBehavior === 'both') {
                                        filterCandidate = text + '\n' + value;
                                    }

                                    if (value !== this.options.selectAllValue && text) {
                                        // By default lets assume that element is not
                                        // interesting for this search.
                                        var showElement = false;

                                        if (this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) {
                                            showElement = true;
                                        }
                                        else if (filterCandidate.indexOf(this.query) > -1) {
                                            showElement = true;
                                        }

                                        // Toggle current element (group or group item) according to showElement boolean.
                                        $(element).toggle(showElement).toggleClass('filter-hidden', !showElement);

                                        // Differentiate groups and group items.
                                        if ($(element).hasClass('multiselect-group')) {
                                            // Remember group status.
                                            currentGroup = element;
                                            currentGroupVisible = showElement;
                                        }
                                        else {
                                            // Show group name when at least one of its items is visible.
                                            if (showElement) {
                                                $(currentGroup).show().removeClass('filter-hidden');
                                            }

                                            // Show all group items when group name satisfies filter.
                                            if (!showElement && currentGroupVisible) {
                                                $(element).show().removeClass('filter-hidden');
                                            }
                                        }
                                    }
                                }, this));
                            }

                            this.updateSelectAll();
                        }, this), 300, this);
                    }, this));
                }
            }
        }
1272216
String getResourceTypeFilter() {

        String result = "";
        List<String> typeVals = Lists.newArrayList();
        if (!m_config.getDisplayTypes().isEmpty()) {
            for (String displayType : m_config.getDisplayTypes()) {
                if (displayType.contains(CmsXmlDisplayFormatterValue.SEPARATOR)) {
                    displayType = displayType.substring(0, displayType.indexOf(CmsXmlDisplayFormatterValue.SEPARATOR));
                }
                typeVals.add("\"" + displayType + "\"");
            }
        }
        if (!typeVals.isEmpty()) {
            result = "&fq=type:(" + CmsStringUtil.listAsString(typeVals, " OR ") + ")";
        }
        return result;
    }
250077
public function getJavascripts()
    {
        $self = $this;
        $parse_javascripts = function ($params, $javascripts) use ($self) {
            foreach ($params as $js) {
                if (is_string($js)) {
                    $js = array(
                        'path' => $js,
                    );
                } elseif (isset($js['route'])) {
                    $js = array(
                        'path' => $self->getGenerator()
                                        ->getRouter()
                                        ->generate($js['route'], $js['routeparams']),
                    );
                }

                $javascripts[] = $js;
            }

            return $javascripts;
        };

        // From config.yml
        $javascripts = $parse_javascripts(
            $this->getGenerator()->getFromBundleConfig('javascripts', array()), array()
        );

        // From generator.yml
        $javascripts = $parse_javascripts(
            $this->getVariable('javascripts', array()), $javascripts
        );

        return $javascripts;
    }
1146808
public CmsRelationFilter filterUserDefined() {

        CmsRelationFilter filter = (CmsRelationFilter)clone();
        if (filter.m_types.isEmpty()) {
            filter.m_types.addAll(CmsRelationType.getAllUserDefined());
        } else {
            filter.m_types = new HashSet<CmsRelationType>(CmsRelationType.filterUserDefined(filter.m_types));
        }
        return filter;
    }
34801
function() {
			if (this.tag) { return this.tag; }

			if (!this.absolute && !this.content) { return null; }

			var tag = this.tag = document.createElement('script');

			this.bind();

			if (this.absolute) { tag.src = this.absolute; }
			else {
				var terminator = ';stratum.classes.Loader.inlineComplete();';

				try{
					tag.innerHTML = this.content + terminator;
				}catch(e) {
					// IE < 9 doesn't like setting the content of script tags
					// using innerHTML, and setting tag.text doesn't work on
					// 'sensible' browsers.
					tag.text = this.content + terminator;
				}
			}

			tag.defer = false;
			tag.async = false;

			tag[SCRIPT_MARKER] = this;
			return tag;
		}
1011213
public Map<String, Integer> getCategoryCountResult() {

        Map<String, Integer> result = new TreeMap<String, Integer>();
        Iterator<Map.Entry<String, CmsCategroyCount>> i = m_categories.entrySet().iterator();
        while (i.hasNext()) {
            Map.Entry<String, CmsCategroyCount> entry = i.next();
            result.put(entry.getKey(), entry.getValue().toInteger());
        }
        return result;
    }
361085
public CmsRelationFilter filterInternal() {

        CmsRelationFilter filter = (CmsRelationFilter)clone();
        if (filter.m_types.isEmpty()) {
            filter.m_types.addAll(CmsRelationType.getAllInternal());
        } else {
            filter.m_types = new HashSet<CmsRelationType>(CmsRelationType.filterInternal(filter.m_types));
        }
        return filter;
    }
267204
public static HtmlTree SCRIPT() {
        HtmlTree htmltree = new HtmlTree(HtmlTag.SCRIPT);
        htmltree.addAttr(HtmlAttr.TYPE, "text/javascript");
        return htmltree;
    }
1155040
function() {

            // Build filter if filtering OR case insensitive filtering is enabled and the number of options exceeds (or equals) enableFilterLength.
            if (this.options.enableFiltering || this.options.enableCaseInsensitiveFiltering) {
                var enableFilterLength = Math.max(this.options.enableFiltering, this.options.enableCaseInsensitiveFiltering);

                if (this.$select.find('option').length >= enableFilterLength) {

                    this.$filter = $(this.options.templates.filter);
                    $('input', this.$filter).attr('placeholder', this.options.filterPlaceholder);
                    this.$ul.prepend(this.$filter);

                    this.$filter.val(this.query).on('click', function(event) {
                        event.stopPropagation();
                    }).on('input keydown', $.proxy(function(event) {
                        // This is useful to catch "keydown" events after the browser has updated the control.
                        clearTimeout(this.searchTimeout);

                        this.searchTimeout = this.asyncFunction($.proxy(function() {

                            if (this.query !== event.target.value) {
                                this.query = event.target.value;

                                $.each($('li', this.$ul), $.proxy(function(index, element) {
                                    var value = $('input', element).val();
                                    var text = $('label', element).text();

                                    var filterCandidate = '';
                                    if ((this.options.filterBehavior === 'text')) {
                                        filterCandidate = text;
                                    }
                                    else if ((this.options.filterBehavior === 'value')) {
                                        filterCandidate = value;
                                    }
                                    else if (this.options.filterBehavior === 'both') {
                                        filterCandidate = text + '\n' + value;
                                    }

                                    if (value !== this.options.selectAllValue && text) {
                                        // by default lets assume that element is not
                                        // interesting for this search
                                        var showElement = false;

                                        if (this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) {
                                            showElement = true;
                                        }
                                        else if (filterCandidate.indexOf(this.query) > -1) {
                                            showElement = true;
                                        }

                                        if (showElement) {
                                            $(element).show().removeClass("filter-hidden");
                                        }
                                        else {
                                            $(element).hide().addClass("filter-hidden");
                                        }
                                    }
                                }, this));
                            }

                            this.updateSelectAll();
                        }, this), 300, this);
                    }, this));
                }
            }
        }
1293391
private List<CmsCategoryBean> getFilteredCategories(String filter) {

        List<CmsCategoryBean> result;
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(filter)) {
            result = new ArrayList<CmsCategoryBean>();
            for (CmsCategoryBean category : getCategoryList()) {
                if (category.matchesFilter(filter)) {
                    result.add(category);
                }
            }
        } else {
            result = getCategoryList();
        }
        return result;
    }
55109
public String htmlSearchBar() {

        if (!isSearchable()) {
            return "";
        }
        StringBuffer html = new StringBuffer(1024);
        html.append("<td class='main'>\n");
        html.append("\t<div>\n");
        html.append(
            "\t\t<input type='text' name='listSearchFilter' id='"
                + SEARCH_BAR_INPUT_ID
                + "' value='' size='20' maxlength='245' style='vertical-align: bottom;'>\n");
        html.append(m_searchAction.buttonHtml());
        I_CmsListAction showAllAction = m_searchAction.getShowAllAction();
        if (showAllAction != null) {
            html.append("&nbsp;&nbsp;");
            html.append(showAllAction.buttonHtml());
        }
        html.append("\t</div>\n");
        html.append("</td>\n");
        return html.toString();
    }
1067680
protected void quickSearch() {

        List<CmsTreeItem> categories = new ArrayList<CmsTreeItem>();
        if ((m_quickSearch != null)) {
            categories = getFilteredCategories(hasQuickFilter() ? m_quickSearch.getFormValueAsString() : null);
            sort(categories, SortParams.valueOf(m_sortSelectBox.getFormValueAsString()));
        }
    }
1084781
public function getScript() {
		$this->jquery_code_for_compile=array ();
		foreach ( $this->jsCodes as $jsCode ) {
			$this->jquery_code_for_compile []=$jsCode->compile(array (
					"identifier" => $this->attachTo
			));
		}
		$this->compileEvents();
		return $this->compileJQueryCode();
	}
362426
protected function getInlineJavaScript()
    {
        $javascript = sprintf(
            "var %s = new SwatTileView('%s');",
            $this->id,
            $this->id
        );

        if ($this->tile !== null) {
            $tile_javascript = $this->tile->getRendererInlineJavaScript();
            if ($tile_javascript != '') {
                $javascript .= $tile_javascript;
            }

            $tile_javascript = $this->tile->getInlineJavaScript();
            if ($tile_javascript != '') {
                $javascript .= "\n" . $tile_javascript;
            }
        }

        if ($this->showCheckAll()) {
            $check_all = $this->getCompositeWidget('check_all');

            $renderer = $this->getCheckboxCellRenderer();
            $javascript .= "\n" . $check_all->getInlineJavascript();

            // set the controller of the check-all widget
            $javascript .= sprintf(
                "\n%s_obj.setController(%s);",
                $check_all->id,
                $renderer->id
            );
        }

        return $javascript;
    }
1162907
protected function getInlineJavaScript()
    {
        $javascript = parent::getInlineJavaScript();

        $colors = "'" . implode("', '", $this->colors) . "'";

        if ($this->none_option) {
            $none_option =
                $this->none_option_title === null
                    ? 'null'
                    : SwatString::quoteJavaScriptString(
                        $this->none_option_title
                    );
        } else {
            $none_option = 'null';
        }

        $js_class_name = $this->getJavaScriptClassName();

        $javascript .=
            "\nvar {$this->id}_obj = new {$js_class_name}(" .
            "'{$this->id}', [{$colors}], {$none_option});\n";

        return $javascript;
    }