Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
remove single or multiple shortpoint elements from inserter
(function() {
'use strict';
/**
* hook method to be executed as soon as shortpoint
* is available in the page
*/
function initHook() {
// our inserting framework
var inserter = window.shortPointInserter;
// not edit mode, exit
if( inserter == null ) {
return;
}
// ui binding framework ( knockout )
var ko = inserter.ko;
// if you want to check all shortpoints
// they are all available in the
// following observable
// ko.$root.dashboard.oShortPointList();
// remove a single shortpoint
// --------------------------
// remove button shortpoint for example
// Notes:
// - oItem: shortpoint element object
// - oItem.name: shortpoint ID
// - oItem.label: shortpoint title that appear in UI
ko.$root.dashboard.oShortPointList.remove(function(oItem) {
return oItem.name === 'button'
});
// or remove multiple items all at once
// ------------------------------------
// list contains all shortpoint
// that you wish to remove by their name
var aListToRemove = [
'accordions',
'tabs',
'toggles'
];
// removing multipe shortpoints by name
ko.$root.dashboard.oShortPointList.remove(function(oItem) {
return aListToRemove.indexOf( oItem.name ) !== -1;
});
};
// shortpoint not yet available in the page
// wait for shortpoint ready dom event
if( typeof shortpoint === 'undefined' ) {
document.body.addEventListener( 'shortpoint-init', initHook );
} else {
initHook();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment