Commit 035b80b8 authored by Janez K's avatar Janez K
Browse files

multiple select

parent d5aa32b7
/*! Drag Multiple Plugin - v0.1.1 - 2014-05-14
* https://github.com/javadoug/jquery.drag-multiple
* Copyright (c) 2014 Doug Ross; Licensed MIT */
!function(a){"use strict";function b(){return!1}function c(b){return a.extend({},h,b.options.multiple)}function d(b,c,d,e){return a.isFunction(b)?b.call(c,d,e):void 0}function e(a,b,c,e){return d(b.beforeStart,a,c,e)}function f(a,b,c,e){return d(b.beforeDrag,a,c,e)}function g(a,b,c,e){return d(b.beforeStop,a,c,e)}var h={items:function(){return a(".ui-draggable.ui-selected")},beforeStart:function(){return this.is(".ui-draggable")&&this.is(".ui-selected")?void 0:(a(".ui-draggable").removeClass("ui-selected"),!1)},beforeDrag:a.noop,beforeStop:a.noop};a.ui.plugin.add("draggable","multiple",{start:function(d,f){var g,h,i,j;return g=this,h=g.data("draggable")||g.data("ui-draggable"),h.multiple={},j=h.multiple.options=c(h),i=j.items(),!1===e(g,j,d,f)?(j.dragCanceled=!0,!1):(i.each(function(){var b=a(this).position();a(this).data("dragmultiple:originalPosition",a.extend({},b))}),h.originalRevert=j.revert=h.options.revert,void(h.options.revert=b))},drag:function(c,d){var e,g,h;return e=this,g=e.data("draggable")||e.data("ui-draggable"),h=g.multiple.options,h.dragCanceled?!1:(f(e,h,c,d),b!==g.options.revert&&(h.revert=g.options.revert,g.options.revert=b),void h.items().each(function(){var b=a(this).data("dragmultiple:originalPosition");a(this).css({top:b.top+(d.position.top-d.originalPosition.top),left:b.left+(d.position.left-d.originalPosition.left)})}))},stop:function(b,c){var d,e,f;return d=this,e=d.data("draggable")||d.data("ui-draggable"),f=e.multiple.options,f.dragCanceled?!1:(g(d,f,b,c),f.revert===!0&&f.items().each(function(){var b=a(this).data("dragmultiple:originalPosition");a(this).css(b)}),f.items().each(function(){a(this).removeData("dragmultiple:originalPosition")}),void(e.options.revert=e.originalRevert))}})}(jQuery);
\ No newline at end of file
......@@ -61,6 +61,8 @@ selectedInput = -1;
selectedOutput = -1;
selectedConnection = -1;
selectedWidgets = new Set([]);
connections = {};
executed = {};
......@@ -234,6 +236,7 @@ function deleteSelected() {
$("#widget"+newSelected).remove();
$("#widgetpreferences-"+newSelected).remove();
selectedWidget=-1;
selectedWidgets = new Set([]);
for (conId in connections) {
if (connections[conId].inputWidget==newSelected||connections[conId].outputWidget==newSelected) {
$("#drawingcanvas"+conId).remove();
......@@ -1051,6 +1054,7 @@ function updateWidgetListeners() {
});
$(".canvas div.widget").draggable({
multiple: true,
handle: "div.widgetcenter, img.widgetimage",
drag: function() {
// this function exectues every time the mouse moves and the user is holding down the left mouse button
......@@ -1094,17 +1098,36 @@ function updateWidgetListeners() {
//alert($(this).attr('rel'));
//get all selected widgets and save positions
$(".ui-selected").each(function () {
var y = parseInt($(this).css('top'));
var x = parseInt($(this).css('left'));
$.post(url['save-position'], { "widget_id": $(this).attr('rel'), "x": x, "y": y } );
})
redrawLines();
}}
);
$(".canvas div.widget").click(function() {
$(".canvas div.widget").click(function(e) {
selectedWidget = $(this).attr('rel');
$(".widgetcenter").removeClass("ui-state-highlight");
if (!(e.ctrlKey || e.metaKey || e.shiftKey))
{
$(".widgetcenter").removeClass("ui-state-highlight");
$(".widget").removeClass("ui-selected");
} else {
if ($(this).hasClass("ui-selected")) {
$(this).removeClass("ui-selected");
$(this).find(".widgetcenter").removeClass("ui-state-highlight");
return;
}
}
$(this).find(".widgetcenter").addClass("ui-state-highlight");
$(this).addClass("ui-selected");
selectedConnection=-1;
//clicking on a widget selects it and deselects any connection
......
......@@ -26,6 +26,7 @@
<link type="text/css" href="http://onehackoranother.com/projects/jquery/tipsy/stylesheets/tipsy.css" rel="stylesheet" />
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery-ui-1.8rc3.custom.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/drag.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.cookie.js"></script>
<script src="{{ STATIC_URL }}js/jquery.treeview.js" type="text/javascript"></script>
<script src="{{ STATIC_URL }}js/jquery.treeview.edit.js" type="text/javascript"></script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment