├── .gitignore ├── README.md ├── readme.txt ├── gf-hs-search.min.js ├── gravity-forms-help-scout-search.php ├── gf-hs-search.js └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | release.sh -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gravity Forms Help Scout Search Field 2 | 3 | Add a Help Scout Docs search field to your Gravity Forms form. Used on the [Easy Digital Downloads ticket submission page](https://easydigitaldownloads.com/support/). 4 | 5 | ![Demo](https://pippinspluginscom.c.presscdn.com/wp-content/uploads/2016/06/Jun-28-2016-13-44-03.gif) 6 | 7 | ## To use: 8 | 9 | 1. The Help Scout Docs Search Field plugin requires the Docs subdomain to be set. You can find it in Help Scout > Manage > Docs > Site Settings > Sub-domain. Define it using the `HELPSCOUT_DOCS_SUBDOMAIN` constant, or set it using the `gf_helpscout_docs_subdomain` filter. 10 | 2. Add a text field to your Gravity Forms form, then add `helpscout-docs` to the "Custom CSS Class" setting (in the field's Appearance tab). 11 | 3. Optionally, use the `GF_HELPSCOUT_DOCS_COLLECTIONS` constant to specify the collection IDs the plugin should search in. Example: 12 | ```php 13 | define( 'GF_HELPSCOUT_DOCS_COLLECTIONS', '538f1914e4b034fd486247ce:548f192ae4b07d03cb25288e:5488f10de4bs2c8d3cacdf29' ); 14 | ``` 15 | Each ID is separated by `:`. 16 | 17 | ### Modify the script settings 18 | 19 | You can change the script configuration using the `gf_helpscout_docs_script_settings` filter. Modify the following array keys: 20 | 21 | ``` 22 | 'debug' => false, // Print debug logs or not 23 | 'hideSubmit' => true, // Whether to hide the submit button until search is performed 24 | 'minLength' => 3, // Minimum number of characters required to trigger search 25 | 'limit' => 5, // Max limit for # of results to show 26 | 'text' => array( 27 | 'result_found' => '{count} result found…', 28 | 'results_found' => '{count} results found…', 29 | 'no_results_found' => 'No results found…', 30 | 'enter_search' => 'Please enter a search term.', 31 | 'not_long_enough' => 'Search must be at least {minLength} characters.', 32 | 'error' => 'There was an error fetching search results.', 33 | ), 34 | 'template' => array( 35 | 'wrap_class' => 'docs-search-wrap', 36 | 'before' => '', 39 | 'results_found' => '{text}', 40 | ), 41 | 'collections' => array( 'collection_id_1', 'collection_id_2' ), 42 | ``` -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Gravity Forms - Help Scout Docs Search Field === 2 | Author URI: https://pippinsplugins.com 3 | Plugin URI: https://pippinsplugins.com/gravity-forms-help-scout-docs-search-field 4 | Contributors: mordauk, katzwebservices 5 | Donate link: https://pippinsplugins.com/support-the-site 6 | Tags: gravity forms, help scout, helpscout, documentation 7 | Requires at least: 3.6 8 | Tested up to: 4.6 9 | Stable Tag: 3.0.2 10 | License: GNU Version 2 or Any Later Version 11 | 12 | Add a Help Scout Docs search field to your Gravity Forms form. 13 | 14 | == Description == 15 | 16 | Add a Help Scout Docs search field to your Gravity Forms form. Used on the [Easy Digital Downloads ticket submission page](https://easydigitaldownloads.com/support/). 17 | 18 | This plugin requires [Gravity Forms](https://gravityforms.com) and a [Help Scout](https://helpscout.net) account. 19 | 20 | See the Installation tab for instructions on configuring the plugin. 21 | 22 | ![Demo](https://pippinspluginscom.c.presscdn.com/wp-content/uploads/2016/06/Jun-28-2016-13-44-03.gif) 23 | 24 | Find a bug? Have a suggestion? Let us know on [GitHub](https://github.com/easydigitaldownloads/gravity-forms-help-scout-search)! 25 | 26 | == Installation == 27 | 28 | 1. The Help Scout Docs Search Field plugin requires the Help Scout Docs sub-domain to be set. Define it using the `HELPSCOUT_DOCS_SUBDOMAIN` constant, or set it using the `gf_helpscout_docs_subdomain` filter. You can find it in Help Scout under "Manage" > "Docs" > "Site Settings" > "Sub-domain". 29 | ` 30 | define( 'HELPSCOUT_DOCS_SUBDOMAIN', 'Your sub-domain here' ); 31 | ` 32 | 33 | 2. Add a text field to your Gravity Forms form, then add `helpscout-docs` to the "Custom CSS Class" setting (in the field's Appearance tab). 34 | 35 | 3. Optionally, use the GF_HELPSCOUT_DOCS_COLLECTIONS constant to specify the collection IDs the plugin should search in. Example: 36 | ` 37 | define( 'GF_HELPSCOUT_DOCS_COLLECTIONS', '538f1914e4b034fd486247ce:548f192ae4b07d03cb25288e:5488f10de4bs2c8d3cacdf29' ); 38 | ` 39 | 40 | 41 | == Changelog == 42 | 43 | = 3.0.2, July 7, 2016 = 44 | 45 | * Fix: Next page shown before search results are added to the page 46 | * Fix: Search could be bypassed by entering enter key 47 | * Tweak: Plugin now loaded on plugins_loaded 48 | * Tweak: Added JS browser events 49 | * Tweak: Added a loading icon when search is processing 50 | 51 | = 3.0.1, June 28, 2016 = 52 | * Fixed: Search no longer worked when clicking "back" on an AJAX form with multiple pages 53 | 54 | = 3.0, June 28, 2016 = 55 | 56 | * No longer requires a Help Scout API key 57 | * Now requires setting your Help Scout Docs sub-domain by using the `HELPSCOUT_DOCS_SUBDOMAIN` constant or `gf_helpscout_docs_subdomain` filter. Find your sub-domain in Help Scout under "Manage" > "Docs" > "Site Settings" > "Sub-domain". 58 | 59 | = 2.1, June 28, 2016 = 60 | 61 | * First offical release of the plugin after being in private use for many months! -------------------------------------------------------------------------------- /gf-hs-search.min.js: -------------------------------------------------------------------------------- 1 | jQuery(document).on("gform_post_render",function(){var e=jQuery.extend(GF_HS_Settings,{searching:!1,cancelled:!1,has_searched:!1,count:0,query:"",timeout:null,wrap:jQuery(".gform_wrapper .gfield.helpscout-docs"),form:jQuery(".gform_wrapper .gfield.helpscout-docs").closest(".gform_wrapper"),field:jQuery(".gform_wrapper .gfield.helpscout-docs").find('input[type="text"]'),onclick:"",keypress:"",results:{},init:function(){e.form.find(".gform_next_button").hide(),e.form.on("keypress",function(t){var r=t.which||t.keyCode;if(e.field.is(":focus"))return 13!=r||jQuery(t.target).is('textarea,input[type="submit"],input[type="button"]')?void 0:(t.preventDefault(),!1)}),e.wrap.append('