Created
January 4, 2017 19:41
-
-
Save doublejosh/eca9a9165bbbe6e5e20dac08b0d68322 to your computer and use it in GitHub Desktop.
Manage past use of datasources via param
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Discover pane (web parts > 9.0). | |
* | |
* @namespace Tabia.DiscoverPane | |
*/ | |
var Tabia = window.Tabia || {}; | |
(function ($, _, Tabia, groucho, module) { | |
/** | |
* Data source connection awareness. | |
* | |
* @todo More content updates for data source use. | |
*/ | |
module.dataSources = function () { | |
var connections = groucho.userGet('connected') || []; | |
// Listen for URL changes indicating new connections. | |
$(window).bind('hashchange', function freshHash () { | |
var hashVal = window.location.hash.replace('#', ''), | |
dataSource; | |
// Confirm this is a datasource hash. | |
if (hashVal.match(/^connected-(\w|-)+$/g) !== null) { | |
// Discover datasource and log it. | |
dataSource = hashVal.replace('connected-', ''); | |
connections.push(dataSource); | |
groucho.userSet({connected: connections}); | |
Tabia.debug('Datasource connected', {type: 'discoverPane', data: { | |
dataSource: dataSource, query: window.location.search | |
}}); | |
module.checkTableauSource(); | |
} | |
}); | |
// Check once. | |
module.checkTableauSource(); | |
}; | |
/** | |
* Data-source-types from past events. | |
* | |
* @todo Try slideToggle() for more control. | |
*/ | |
module.checkTableauSource = function () { | |
var tableauPrefix = new RegExp(/^tableau-(\w|-)+$/g), | |
connections = groucho.userGet('connected') || []; | |
// Confirm if any connections. | |
if (_.isArray(connections) && connections.length > 0) { | |
// Find Tableau data source use. | |
_.some(connections, function checkPrefix (dataSourceName) { | |
// Check for "tableau-something" datasources to show sharing content. | |
if (dataSourceName.match(tableauPrefix) !== null) { | |
// Reveal and normalize style/CSS. | |
$('.sharing').slideDown().removeClass('hidden').attr('style', ''); | |
} | |
}); | |
} | |
}; | |
})(jQuery, _, Tabia, groucho, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment