Created
March 20, 2017 16:05
-
-
Save brantwedel/d028c1bdf1acb34bb00d702913d948b3 to your computer and use it in GitHub Desktop.
Script for adding select-all functionality to jscut.org using tampermonkey.net browser plugin
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
// ==UserScript== | |
// @name JSCUT Select All | |
// @namespace http://bitbased.net/ | |
// @version 0.1 | |
// @description Add double click select all to jscut.org | |
// @author Brant Wedel - bitbased.net | |
// @match http://jscut.org/jscut.html | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
$("#MainSvg").off('click'); | |
$("#MainSvg").click(function (e) { | |
// Ignore double click | |
if (e.originalEvent.detail > 1) | |
return; | |
var element = Snap.getElementByPoint(e.pageX, e.pageY); | |
if (element !== null) { | |
operationsViewModel.clickOnSvg(element) || tabsViewModel.clickOnSvg(element) || selectionViewModel.clickOnSvg(element); | |
if (selectionViewModel.selNumSelected() > 0) { | |
tutorial(3, 'Click "Create Operation" after you have finished selecting objects.'); | |
} | |
} | |
}); | |
$("#MainSvg").dblclick(function (e) { | |
// Toggle select all | |
if (selectionViewModel.selNumSelected() > 1) { | |
selectionViewModel.clearSelection(); | |
return; | |
} | |
var selectedPaths = mainSvg.selectAll('path'); | |
if (selectedPaths.length > 0) { | |
selectedPaths.forEach(function (element) { | |
if (element.attr("class") != "selectedPath") { | |
operationsViewModel.clickOnSvg(element) || tabsViewModel.clickOnSvg(element) || selectionViewModel.clickOnSvg(element); | |
} | |
}); | |
if (selectionViewModel.selNumSelected() > 0) { | |
tutorial(3, 'Click "Create Operation" after you have finished selecting objects.'); | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment