Last active
August 8, 2016 08:23
-
-
Save vxsx/1f2b8f340e4e979c90bb2299525d81b0 to your computer and use it in GitHub Desktop.
https://chrome.google.com/webstore/detail/shortkeys-custom-keyboard/logpjaacgmcbpdkdchjiaagddngobkck
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
Useful shortcuts |
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
var editBtn=document.querySelector('.cms-btn.cms-btn-action.cms-btn-switch-edit'); | |
if (editBtn) { | |
editBtn.click() | |
} |
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
var showOverlay = function _showOverlay(pluginId) { | |
var coordinates = {}; | |
var positions = []; | |
CMS.$('.cms-plugin-' + pluginId).each(function () { | |
var offset = $(this).offset(); | |
positions.push( | |
{ | |
x1: offset.left, | |
x2: offset.left + $(this).outerWidth(), | |
y1: offset.top, | |
y2: offset.top + $(this).outerHeight() | |
} | |
); | |
}); | |
coordinates.left = Math.min.apply(null, positions.map(pos => pos.x1)); | |
coordinates.top = Math.min.apply(null, positions.map(pos => pos.y1)); | |
coordinates.width = Math.max.apply(null, positions.map(pos => pos.x2)) - coordinates.left; | |
coordinates.height = Math.max.apply(null, positions.map(pos => pos.y2)) - coordinates.top; | |
$(window).scrollTop(coordinates.top + coordinates.height / 2 - $(window).height() / 2) | |
$('<div class="cms-plugin-overlay"></div>').css(coordinates).css({ | |
background: 'rgba(0, 187, 244, 0.3)', | |
boxShadow: '0 0 3px 2px #00BBFF', | |
borderRadius: 3, | |
position: 'absolute', | |
zIndex: 9999, | |
opacity: 0.9, | |
pointerEvents: 'none' | |
}).appendTo($('body')); | |
setTimeout(function () { | |
CMS.$('.cms-plugin-overlay').fadeOut(1000, function () { CMS.$(this).remove();}) | |
}, 300) | |
}; | |
var dragitem = []; | |
try { | |
dragitem = CMS.$('.cms-dragitem:hover'); | |
} catch(e) { | |
// weird bug in jquery, dance around it | |
var dragitems = CMS.$('.cms-dragitem'); | |
dragitems.each(function () { | |
var $t = $(this); | |
if ($t.is(':hover')) { | |
dragitem = $t; | |
} | |
}); | |
} | |
if (dragitem.length) { | |
var draggable = dragitem.closest('.cms-draggable'); | |
var pluginId = CMS.API.StructureBoard.getId(draggable); | |
CMS.API.StructureBoard.hide(); | |
showOverlay(pluginId); | |
} | |
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
if (typeof CMS !== 'undefined') { | |
function showSuccess(el) { | |
var tpl = CMS.$('<div class="cms-dragitem-success"></div>'); | |
var SUCCESS_TIMEOUT = 1000; | |
el.addClass('cms-draggable-success').append(tpl); | |
// start animation | |
tpl.fadeOut(SUCCESS_TIMEOUT, function () { | |
$(this).remove(); | |
el.removeClass('cms-draggable-success'); | |
}); | |
// make sure structurboard gets updated after success | |
CMS.$(window).trigger('resize.sideframe'); | |
} | |
var tooltip = CMS.$('.cms-tooltip'); | |
if (tooltip.is(':visible')) { | |
var pluginId = tooltip.data('plugin_id'); | |
if (pluginId) { | |
CMS.API.StructureBoard.show(); | |
var draggable = CMS.$('.cms-draggable-' + pluginId); | |
// open parents | |
draggable.parents('.cms-draggable').find('.cms-dragitem-collapsable:not(".cms-dragitem-expanded") .cms-dragitem-text').trigger('click'); | |
setTimeout(function () { | |
var position = draggable.position().top; | |
draggable.offsetParent().scrollTop(position - window.innerHeight / 2); | |
showSuccess(draggable.find('.cms-dragitem:first')); | |
}, 100) | |
} | |
} | |
} |
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
var btn = document.querySelector('.cms-btn.cms-btn-action.cms-btn-publish.cms-btn-publish-active'); | |
if(btn) { | |
btn.click(); | |
} |
what other shortcuts should be implemented?
- go to content mode from hovered structureboard plugin
- open page tree
- go to page settings
- ...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use https://chrome.google.com/webstore/detail/shortkeys-custom-keyboard/logpjaacgmcbpdkdchjiaagddngobkck
set hotkeys
paste the code
profit
Video of "go to plugin in structure" http://d.pr/v/1gTHy