Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable built-in JS #130

Merged
merged 3 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@ You should now have all the plugin files under
To effectively use the plugin, you first need to create an override config. To do so, create the folder `user/config/plugins` (if it doesn't exist already) and copy the [simplesearch.yaml][simplesearch] config file in there.

```
search_content: rendered
enabled: true
built_in_css: true
built_in_js: true
display_button: false
min_query_length: 3
route: /search
search_content: rendered
template: simplesearch_results
filters:
category: blog
filter_combinator: and
ignore_accented_characters: false
order:
by: date
dir: desc
Expand Down
11 changes: 11 additions & 0 deletions blueprints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ form:
validate:
type: bool

built_in_js:
type: toggle
label: Use built in javascript
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool

display_button:
type: toggle
label: Display Search Button
Expand Down
5 changes: 3 additions & 2 deletions simplesearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,9 @@ public function onTwigSiteVariables()
$this->grav['assets']->add('plugin://simplesearch/css/simplesearch.css');
}


$this->grav['assets']->addJs('plugin://simplesearch/js/simplesearch.js', [ 'group' => 'bottom' ]);
if ($this->config->get('plugins.simplesearch.built_in_js')) {
$this->grav['assets']->addJs('plugin://simplesearch/js/simplesearch.js', [ 'group' => 'bottom' ]);
}
}

private function matchText($haystack, $needle) {
Expand Down
1 change: 1 addition & 0 deletions simplesearch.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
enabled: true
built_in_css: true
built_in_js: true
display_button: false
min_query_length: 3
route: /search
Expand Down