Search plugin, Event when key ENTER is press

This commit is contained in:
Diego Najar 2019-01-27 13:36:39 +01:00
parent 03e035cb98
commit 629f43350c
7 changed files with 54 additions and 17 deletions

View File

@ -4,5 +4,6 @@
"name": "Suche",
"description": "Fügt ein Suchfeld ein, mit dem die Inhalte der Website durchsucht werden können."
},
"search": "Suchen"
"search": "Suchen",
"show-button-search": "Show button search"
}

View File

@ -4,5 +4,6 @@
"name": "Suche",
"description": "Fügt ein Suchfeld ein, mit dem die Inhalte der Website durchsucht werden können."
},
"search": "Suchen"
"search": "Suchen",
"show-button-search": "Show button search"
}

View File

@ -4,5 +4,6 @@
"name": "Search",
"description": "Provide a search box to your users to search through the content of your site."
},
"search": "Search"
"search": "Search",
"show-button-search": "Show button search"
}

View File

@ -4,5 +4,6 @@
"name": "Buscador",
"description": "Este plugin provee un buscador para tus usuarios para buscar a través del contenido de su sitio."
},
"search": "Buscador"
"search": "Buscar",
"show-button-search": "Mostrar boton buscar"
}

View File

@ -4,5 +4,6 @@
"name": "Поиск",
"description": "Добавляет поисковое поле по содержимому вашего сайта для пользователей."
},
"search": "Поиск"
"search": "Поиск",
"show-button-search": "Show button search"
}

View File

@ -2,9 +2,9 @@
"author": "Bludit",
"email": "",
"website": "https://plugins.bludit.com",
"version": "3.6.1",
"releaseDate": "2018-10-07",
"version": "3.7.0",
"releaseDate": "2019-01-27",
"license": "MIT",
"compatible": "3.6.1",
"compatible": "3.7.0",
"notes": ""
}

View File

@ -10,7 +10,8 @@ class pluginSearch extends Plugin {
// Fields and default values for the database of this plugin
$this->dbFields = array(
'label'=>'Search',
'wordsToCachePerPage'=>800
'wordsToCachePerPage'=>800,
'showButtonSearch'=>false
);
}
@ -28,6 +29,15 @@ class pluginSearch extends Plugin {
$html .= '<span class="tip">'.$L->get('This title is almost always used in the sidebar of the site').'</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$L->get('Show button search').'</label>';
$html .= '<select name="showButtonSearch">';
$html .= '<option value="true" '.($this->getValue('showButtonSearch')===true?'selected':'').'>'.$L->get('enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('showButtonSearch')===false?'selected':'').'>'.$L->get('disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
$html .= '<div>';
return $html;
}
@ -39,11 +49,33 @@ class pluginSearch extends Plugin {
$html = '<div class="plugin plugin-search">';
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
$html .= '<div class="plugin-content">';
$html .= '<input type="text" id="plugin-search-input" /> ';
$html .= '<input type="button" value="'.$L->get('Search').'" onClick="javascript: window.open(\''.DOMAIN_BASE.'search/\' + document.getElementById(\'plugin-search-input\').value, \'_self\');" />';
$html .= '<input type="text" id="jspluginSearchText" /> ';
if ($this->getValue('showButtonSearch')) {
$html .= '<input type="button" value="'.$L->get('Search').'" onClick="pluginSearch()" />';
}
$html .= '</div>';
$html .= '</div>';
$DOMAIN_BASE = DOMAIN_BASE;
$html .= <<<EOF
<script>
function pluginSearch() {
var text = document.getElementById("jspluginSearchText").value;
window.open('$DOMAIN_BASE'+'search/'+text, '_self');
return false;
}
document.getElementById("jspluginSearchText").onkeypress = function(e) {
if (!e) e = window.event;
var keyCode = e.keyCode || e.which;
if (keyCode == '13'){
pluginSearch();
return false;
}
}
</script>
EOF;
return $html;
}