Пример #1
0
	public function getSearchInput($defaultValue = "")
	{
		if (!$this->isPublished())
		{
			return "";
		}

		if ($this->params->get("tag_search", 0))
		{
			$document = JFactory::getDocument();
			JUDownloadFrontHelper::loadjQueryUI();
			$document->addStyleSheet(JUri::root() . 'components/com_judownload/assets/css/tagit-style.css');
			$document->addScript(JUri::root() . "components/com_judownload/assets/js/tagit.js");
			$tagScript = '
            jQuery(document).ready(function($){
                    $("#' . $this->getId() . '_tags").tagit({
                    tagSource:' . ($this->params->get('auto_suggest') ? $this->getTags() : '[]') . ',
                    initialTags: ' . $this->getInitialTags($defaultValue) . ',
                    tagsChanged: function(){ getTags($("#' . $this->getId() . '_tags").tagit("tags")); },
                    triggerKeys:["enter", "comma", "tab"],
                    minLength: 3,
                    maxLength: 50,
                    maxTags: 50,
                    sortable: "handle",
                    placeholder: " ' . $this->params->get("placeholder", "") . ' "
                });

                function getTags(tags) {
                    var newtags = [];
                    for (var i in tags){
	                    if (tags[i].label != undefined ){
	                        var tagvalue = tags[i].value.replace("|", "");
	                        newtags.push(tagvalue);
	                        $(tags[i].element[0]).find(".tagit-label").text(tagvalue);
	                    }
                    }
                    var newtags_str = newtags.join(",");
                    $("#' . $this->getId() . '").val(newtags_str);
                }
            });
            ';
			$document->addScriptDeclaration($tagScript);

			$this->setVariable('value', $this->value);

			return $this->fetch('searchinput.php', __CLASS__);
		}
		else
		{
			return parent::getSearchInput($defaultValue);
		}
	}