Skip to content

Instantly share code, notes, and snippets.

@anasnakawa
Last active August 31, 2016 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anasnakawa/75101a155b26ebe78bb207a02828074c to your computer and use it in GitHub Desktop.
Save anasnakawa/75101a155b26ebe78bb207a02828074c to your computer and use it in GitHub Desktop.
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