{"version":3,"sources":["searchboxDrawer.js"],"names":["searchboxDrawerWrapper","nav","istats","$","focusInput","drawerInput","blur","focus","scopeWhiteList","suppressedPaths","searchboxDrawer","app","conf","searchScope","loadedSearchbox","loadingSearchbox","drawerLoaded","intervalId","resizeId","resizeThrottleMs","DRAWER_NAME","run","_this","this","ready","path","window","location","pathname","hideOnVariant","variant","isInWhiteList","isSuppressedPath","loadSearchboxCss","cssLoaded","setEventListeners","applyScopeClasses","applyTouchClasses","touchEnabled","document","documentElement","className","scope","classes","rexp","RegExp","output","exec","DocumentTouch","hasOwnProperty","navigator","msMaxTouchPoints","whiteList","flag","indexOf","i","length","pattern","exp","test","join","allow","viewAllResults","createHiddenInput","name","value","input","createElement","type","form","getElementById","appendChild","submit","isOrbSearchVisible","formElm","style","currentStyle","display","getComputedStyle","cb","searchboxIEVersion","loadCss","searchboxAppStaticPrefix","addDrawer","createContent","inputElm","handleInput","loadSearchboxDrawer","moduleLoaded","require","config","paths","bbc-search/searchbox-app","content","setAttribute","innerHTML","searchFormHtml","watchInput","_this2","addEventListener","attachEvent","event","propertyName","orbSearchClick","preventDefault","handleWindowResize","fn","node","querySelector","removeEventListener","_this3","drawerPanel","onDrawerPanelScroll","scrollTop","orbButtonHandler","bind","clearTimeout","setTimeout","target","_this4","selectorString","drawerState","getDrawerState","navMode","addDrawerStyles","getMastheadDrawer","showPanel","setQuery","SearchboxApp","updateHandler","updateDrawerHeight","closeHandler","closeSearchboxDrawer","viewResults","configs","changeHandler","isSearchPage","SEARCHBOX","searchPage","isResponsive","hidePanel","removeDrawerStyles","cssUtils","addClass","removeClass","element","hasClass","replace","classRegex","match","_typeof","Symbol","iterator","obj","constructor","prototype","define","amd","module","exports"],"mappings":"AAAA,YAAA,SAASA,wBAAuBC,EAAKC,EAAQC,GA6E3C,QAASC,GAAWC,GAClBA,EAAYC,OACZD,EAAYE,QA9Ed,GAAMC,IACJ,GACA,KACA,MACA,eACA,aACA,eACA,mBACA,gBACA,UAGIC,GACJ,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QAAP,YAAAR,QAAOQ,UAAuBA,OAAOC,UACvCD,OAAOC,QAAU/J","file":"searchboxDrawer.js","sourcesContent":["function searchboxDrawerWrapper(nav, istats, $) {\n const scopeWhiteList = [\n '',\n null,\n 'all',\n 'all:learning',\n 'iplayer:tv',\n 'iplayer_cbbc',\n 'iplayer_cbeebies',\n 'iplayer:radio',\n 'sounds',\n ];\n\n const suppressedPaths = [\n '/education',\n '/iwonder',\n '/iwondercommunity',\n '/guides',\n '/timelines',\n '/arts',\n '/earth',\n '/history',\n '/science',\n '/religion',\n '/makeitdigital',\n '/dishup',\n '/ulsterscots',\n '/aboutthebbc',\n '/annualreport',\n '/bbcfilms',\n '/bbctrust',\n '/branding',\n '/broadcastinghouse',\n '/careers',\n '/charityappeals',\n '/pudsey',\n '/climateasia',\n '/commissioning',\n '/copyright',\n '/developer',\n '/diversity',\n '/fmguidelines',\n '/foi',\n '/helpandfeedback',\n '/historyofthebbc',\n '/informationandarchives',\n '/mediaaction',\n '/mediacentre',\n '/mypension',\n '/partnersandsuppliers',\n '/performingartsfund',\n '/privacy',\n '/production',\n '/reception',\n '/responsibility',\n '/safety',\n '/social',\n '/supplying',\n '/terms',\n '/writerslicence',\n '/writersroom',\n '/newsbeat',\n '/terrificscientific(?!/map|/termsandconditions|/class-results)',\n '/tomorrowsworld',\n '/culture',\n '/capital',\n '/autos',\n '/future',\n '/travel',\n '/corporate2',\n 'genome.ch.bbc.co.uk',\n ];\n\n // Setting focus on the pre-rendered input means that the\n // react component doesn't appear to bind until the focus is lost, at\n // which point the events are bound. To fix this we need to blur the input\n // once the app has loaded and re-focus. This will allow React to bind to the input.\n function focusInput(drawerInput) {\n drawerInput.blur();\n drawerInput.focus();\n }\n\n const searchboxDrawer = {\n app: null,\n conf: null,\n searchScope: null,\n loadedSearchbox: false,\n loadingSearchbox: false,\n drawerLoaded: false,\n intervalId: 0,\n resizeId: 0,\n resizeThrottleMs: 200,\n DRAWER_NAME: 'drawer-search',\n run: function _run(conf) {\n $.ready(() => {\n this.conf = conf;\n const path = window.location.pathname;\n this.searchScope = conf.searchScope;\n if ( !this.hideOnVariant(conf.variant, this.searchScope)\n && this.isInWhiteList(this.searchScope, this.scopeWhiteList)\n && !this.isSuppressedPath(path)\n ) {\n this.loadSearchboxCss(conf, () => { this.cssLoaded(conf); } );\n this.setEventListeners();\n this.applyScopeClasses(this.searchScope);\n this.applyTouchClasses();\n }\n });\n },\n };\n\n\n searchboxDrawer.applyTouchClasses = function _applyTouchClasses() {\n if (this.touchEnabled()) {\n document.documentElement.className += ' se-touch';\n } else {\n document.documentElement.className += ' se-no-touch';\n }\n };\n\n searchboxDrawer.applyScopeClasses = function _applyScopeClasses(scope) {\n let classes = '';\n\n if (scope === 'sounds') {\n classes += ' se-sounds-theme';\n document.documentElement.className += classes;\n return;\n }\n\n const rexp = new RegExp('(iplayer):?(radio)?', 'ig');\n const output = rexp.exec(scope);\n if (output) {\n if (output[2]) {\n classes = ' se-iplayer-radio-theme';\n } else if (output[1]) {\n classes = ' se-iplayer-theme';\n }\n\n document.documentElement.className += classes;\n }\n };\n\n searchboxDrawer.touchEnabled = function _touchEnabled() {\n if (\n ('ontouchstart' in window) ||\n (window.DocumentTouch && document instanceof window.DocumentTouch) ||\n (window.hasOwnProperty &&\n (\n window.hasOwnProperty('ontouchstart') ||\n (window.DocumentTouch && document instanceof window.DocumentTouch) ||\n navigator.msMaxTouchPoints\n )\n )\n ) {\n return true;\n }\n // Fallback for certain samsung devices that fail above but pass below... :/\n if ('ontouchstart' in window) {\n return true;\n }\n return false;\n };\n\n searchboxDrawer.scopeWhiteList = scopeWhiteList;\n\n searchboxDrawer.isInWhiteList = function _isInWhiteList(searchScope, whiteList) {\n let flag = false;\n if (typeof whiteList.indexOf === 'function') {\n flag = whiteList.indexOf(searchScope) !== -1;\n } else { // ie8 fix, indexOf don't exists in ie8\n for ( let i = 0; i < whiteList.length; i++) {\n if (whiteList[i] === searchScope) {\n flag = true;\n break;\n }\n }\n }\n return flag;\n };\n\n searchboxDrawer.isSuppressedPath = function _issuppressedpath(path) {\n for (let i = 0; i < suppressedPaths.length; i++) {\n const pattern = `^${suppressedPaths[i]}`;\n const exp = new RegExp(pattern, 'i');\n if (exp.test(path)) {\n return true;\n }\n }\n return false;\n };\n\n searchboxDrawer.hideOnVariant = function _hideonvariant(variant, scope) {\n if ( ['cbeebies', 'cbbc'].join(' ').indexOf(variant) > -1) {\n const allow = ['iplayer_cbbc', 'iplayer_cbeebies'];\n return !this.isInWhiteList(scope, allow);\n }\n\n return false;\n };\n\n searchboxDrawer.viewAllResults = function _viewAllResults() {\n function createHiddenInput(name, value) {\n const input = document.createElement('input');\n input.type = 'hidden';\n input.name = name;\n input.value = value;\n return input;\n }\n\n const form = document.getElementById('searchboxDrawerForm');\n if (form) {\n form.appendChild(createHiddenInput('search_suggestion_type', 'serp'));\n form.appendChild(createHiddenInput('action_name', 'search'));\n form.appendChild(createHiddenInput('action_type', 'view-all-results'));\n form.submit();\n }\n };\n\n searchboxDrawer.isOrbSearchVisible = function _isNavInputVisible() {\n const formElm = document.getElementById('orb-search-form');\n const style = formElm.currentStyle ? formElm.currentStyle.display : getComputedStyle(formElm, null).display;\n return style !== 'none';\n };\n\n searchboxDrawer.loadSearchboxCss = function _loadSearchboxCss(conf, cb) {\n if (window.searchboxIEVersion && window.searchboxIEVersion === 8) {\n nav.loadCss(conf.searchboxAppStaticPrefix + '/style/fixed.css', cb);\n } else {\n nav.loadCss(conf.searchboxAppStaticPrefix + '/style/enhanced.css', cb);\n }\n };\n\n searchboxDrawer.cssLoaded = function _cssLoaded(conf) {\n nav.addDrawer(this.DRAWER_NAME, document.createElement('div'), this.createContent(conf));\n this.drawerLoaded = true;\n\n const inputElm = document.getElementById('orb-search-q');\n if (inputElm.value) {\n this.handleInput(inputElm);\n }\n };\n\n searchboxDrawer.loadSearchboxDrawer = function _loadSearchbox(moduleLoaded) {\n this.loadingSearchbox = true;\n require.config({\n paths: {\n 'bbc-search/searchbox-app': this.conf.searchboxAppStaticPrefix + '/app.min',\n },\n });\n\n require(['bbc-search/searchbox-app'], moduleLoaded);\n };\n\n searchboxDrawer.createContent = function _createContent(conf) {\n const content = document.createElement('div');\n content.setAttribute('class', 'orb-panel se-searchbox-app');\n content.setAttribute('id', 'se-searchbox-app');\n content.innerHTML = conf.searchFormHtml;\n return content;\n };\n\n searchboxDrawer.watchInput = function _watchInput(input) {\n const handleInput = () => {\n if (input.value) {\n this.handleInput(input);\n }\n };\n\n if (input.addEventListener) {\n input.addEventListener('input', handleInput);\n } else if (input.attachEvent) {\n input.attachEvent('onpropertychange', (event) => {\n if (event.propertyName === 'value') {\n handleInput();\n }\n });\n }\n };\n\n searchboxDrawer.orbSearchClick = function _orbSearchClick(event) {\n event.preventDefault();\n this.handleInput(document.getElementById('orb-search-q'));\n };\n\n searchboxDrawer.handleWindowResize = function _handleWindowResize(fn) {\n const node = document.querySelector('.orb-nav-search');\n if ( !this.isOrbSearchVisible() ) {\n node.addEventListener('click', fn, true);\n } else {\n node.removeEventListener('click', fn, true);\n }\n };\n\n searchboxDrawer.setEventListeners = function _setInputControl() {\n const inputElm = document.getElementById('orb-search-q');\n const drawerPanel = document.getElementById('orb-panels');\n const onDrawerPanelScroll = () => {\n drawerPanel.scrollTop = 0;\n };\n\n this.watchInput(inputElm);\n\n if (document.addEventListener) {\n const orbButtonHandler = this.orbSearchClick.bind(this);\n\n window.addEventListener('resize', () => {\n clearTimeout(this.resizeId);\n this.resizeId = setTimeout( () => {\n this.handleWindowResize(orbButtonHandler);\n }, this.resizeThrottleMs);\n });\n this.handleWindowResize(orbButtonHandler);\n\n drawerPanel.addEventListener('scroll', onDrawerPanelScroll);\n }\n };\n\n searchboxDrawer.handleInput = function _handleInput(target) {\n if (!this.drawerLoaded) {\n return;\n }\n\n const selectorString = 'se-searchbox-input-field';\n const input = target;\n const drawerInput = document.getElementById(selectorString);\n const drawerState = nav.getDrawerState(this.DRAWER_NAME);\n\n if (drawerState === 'hidden') {\n // Set navMode to mouse to animate drawer opening.\n // If IE8/9 we don't want animation due to race conditions.\n if ( !window.searchboxIEVersion ) document.getElementById('orb-header').navMode = 'mouse';\n this.addDrawerStyles();\n nav.getMastheadDrawer().showPanel(this.DRAWER_NAME);\n }\n\n // we (possibly) don't have the app yet - so access the input field directly.\n drawerInput.focus();\n drawerInput.value = input.value;\n input.value = '';\n\n if (!this.loadingSearchbox && !this.loadedSearchbox) {\n this.loadSearchboxDrawer( (SearchboxApp) => {\n const updateHandler = nav.updateDrawerHeight.bind(this, this.DRAWER_NAME);\n const closeHandler = this.closeSearchboxDrawer.bind(this);\n const viewResults = this.viewAllResults.bind(this);\n const configs = {\n istats: istats,\n changeHandler: updateHandler,\n closeHandler: closeHandler,\n viewResults: viewResults,\n searchScope: this.searchScope,\n isSearchPage: window.SEARCHBOX.searchPage || false,\n isResponsive: !window.searchboxIEVersion,\n };\n this.app = new SearchboxApp(configs);\n this.loadedSearchbox = true;\n focusInput(drawerInput);\n });\n } else if (this.loadedSearchbox) {\n this.app.setQuery(drawerInput.value);\n focusInput(drawerInput);\n }\n };\n\n searchboxDrawer.closeSearchboxDrawer = function _closeSearchboxDrawer() {\n const inputElm = document.getElementById('orb-search-q');\n nav.getMastheadDrawer().hidePanel();\n this.removeDrawerStyles();\n inputElm.focus();\n };\n\n searchboxDrawer.addDrawerStyles = function _addDrawerStyles() {\n const drawerPanel = document.getElementById('orb-panels');\n this.cssUtils.addClass(drawerPanel, 'se-panel-active');\n };\n\n searchboxDrawer.removeDrawerStyles = function _removeDrawerStyles() {\n const drawerPanel = document.getElementById('orb-panels');\n this.cssUtils.removeClass(drawerPanel, 'se-panel-active');\n };\n\n searchboxDrawer.cssUtils = {\n addClass: function _addClass(element, className) {\n if (!this.hasClass(element, className)) {\n element.className += ' ' + className;\n }\n },\n\n removeClass: function _removeClass(element, className) {\n if (this.hasClass(element, className)) {\n element.className = element.className.replace(this.classRegex(className), '');\n }\n },\n\n hasClass: function _hasClass(element, className) {\n return !!element.className.match(this.classRegex(className));\n },\n\n classRegex: function _classRegex(className) {\n return new RegExp('(\\\\s|^)' + className + '(\\\\s|$)');\n },\n };\n\n return searchboxDrawer;\n}\n\n// RequireJS\nif (typeof define === 'function' && define.amd) {\n define( ['orb/nav', 'istats-1', 'orb/lib/_$'], searchboxDrawerWrapper);\n}\n\n// CommonJS\nif (typeof module === 'object' && module.exports) {\n module.exports = searchboxDrawerWrapper;\n}\n"],"sourceRoot":"/source/"}