Swiftype search in Flare output?

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
sforsyth
Propeller Head
Posts: 25
Joined: Wed Feb 18, 2015 11:06 pm

Swiftype search in Flare output?

Post by sforsyth »

Hey there, has anybody had success using Swiftype custom search in their Flare output? (see www.swiftype.com)

We're testing it out and we love it, but including their script causes a bug with the TopNav output (the hamburger menu navigation sporadically breaks and so does the native search feature.) It seems to be a Chrome-only bug.

We suspect this might have something to do with require.js but none of us are experts in that area.

Anyways if anybody has had success including the Swiftype widget in their Flare output please let me know if you managed to work around this issue.
cgulliver
Jr. Propeller Head
Posts: 1
Joined: Fri Sep 23, 2016 4:10 pm

Re: Swiftype search in Flare output?

Post by cgulliver »

sforsyth and I worked out a solution.

Like Google Analytics, Swiftype uses an anonymous function call to initialize some global objects to store configuration data. The conflict with RequireJS was that the anonymous function also deploys the swiftype library into the page, and it use defines for other libraries like jQuery (which is a dependency). We changed the anonymous function to only initialize the objects, then we set the config data, finally loading the Swiftype library using RequireJS.

Here's the original code:

Code: Select all

(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
  (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
  e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
  })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

  _st('install','YOUR_INSTALL_KEY');
Here's the modified code that worked with RequireJS:

Code: Select all

(function(w, n) {
      w['SwiftypeObject'] = n;
      w[n] = w[n] || function() {
          (w[n].q = w[n].q || []).push(arguments);
      };
})(window,  '_st');
_st('install', 'YOUR_INSTALL_KEY');
require(["//s.swiftypecdn.com/install/v2/st.js"]);
sforsyth wrote:Hey there, has anybody had success using Swiftype custom search in their Flare output? (see http://www.swiftype.com)

We're testing it out and we love it, but including their script causes a bug with the TopNav output (the hamburger menu navigation sporadically breaks and so does the native search feature.) It seems to be a Chrome-only bug.

We suspect this might have something to do with require.js but none of us are experts in that area.

Anyways if anybody has had success including the Swiftype widget in their Flare output please let me know if you managed to work around this issue.
Last edited by cgulliver on Fri Sep 30, 2016 12:14 pm, edited 2 times in total.
Post Reply