var Grnhse = Grnhse || {}; Grnhse.Settings = { targetDomain: 'https://boards.greenhouse.io', scrollOnLoad: true, autoLoad: true, boardURI: 'https://boards.greenhouse.io/embed/job_board?for=splashdamage', applicationURI: 'https://boards.greenhouse.io/embed/job_app?for=splashdamage', baseURI: 'http://www.splashdamage.com/careers', iFrameWidth: 650 }; var Grnhse = Grnhse || {}; Grnhse.Const = { JOB_ID: 'gh_jid', SOURCE_TOKEN: 'gh_src' }; Grnhse.Config = { IframeDefault: { id: 'grnhse_iframe', width: Grnhse.Settings.iFrameWidth, frameborder: '0', scrolling: 'no', onload: undefined } }; Grnhse.Route = { boardUrl: function(source) { var helper = Grnhse.UriHelper, settings = Grnhse.Settings, params = []; if (source) { params.push('t=' + source); } return helper.appendParams(settings.boardURI, params); }, applicationUrl: function(source, jobId) { var helper = Grnhse.UriHelper, settings = Grnhse.Settings, params = []; if (source) { params.push('t=' + source); } if (jobId) { params.push('token=' + jobId); } return helper.appendParams(settings.applicationURI, params); } }; Grnhse.UriHelper = { base: function() { var uriHelper = Grnhse.UriHelper, location = uriHelper.currentLocation(), settings = Grnhse.Settings; return window && location ? uriHelper.pathFromLocation(location) : settings.boardURI; }, // Gives us something stubbable for units currentLocation: function() { return window.top.location; }, getParam: function(name) { var location = Grnhse.UriHelper.currentLocation(), uri = location.href, start = uri.indexOf(name), end; if (start === -1) { return null; } start += name.length + 1; end = uri.substr(start).search(/(&|#|$)/); return uri.substr(start, end); }, appendParams: function(url, params) { params.push('b=' + Grnhse.UriHelper.base()); url += (url.indexOf('?') === -1) ? '?' : '&'; return url + params.join('&'); }, pathFromLocation: function(location) { return location.protocol + '//' + location.host + location.pathname; } }; Grnhse.BrowserHelper = { supportsPostMessage: function() { // Feature detect for 0) { instance.htmlElement.setAttribute('height', e.data); } } }; // Since IE8 and other old browsers don't support postMessage, // just let the iFrame scroll if postMessage is unsupported Grnhse.Iframe.prototype.supportAwfulBrowsers = function() { var browserHelper = Grnhse.BrowserHelper; if (!browserHelper.supportsPostMessage()) { this.config['scrolling'] = 'yes'; this.config['height'] = 1000; } }; Grnhse.Iframe.load = function(jobId, source) { var r = Grnhse.Route, uriHelper = Grnhse.UriHelper, jobId = jobId || uriHelper.getParam(Grnhse.Const.JOB_ID), source = source || uriHelper.getParam(Grnhse.Const.SOURCE_TOKEN), viewingApplication = !!jobId, pathToLoad = viewingApplication ? r.applicationUrl(source, jobId) : r.boardUrl(source); return new Grnhse.Iframe(pathToLoad); }; // This alias is being introduce for backwards compatibility // with the old job board code var _grnhse = _grnhse || {}; _grnhse.load = Grnhse.Iframe.load; (function() { if (Grnhse.Settings.autoLoad) { var f = window.onload; window.onload = function() { try { if (typeof f === 'function') { f(); } } catch(e) { console.error(e); } finally { Grnhse.Iframe.load(); } }; } })();