diff --git a/lib/galaxy/web/controllers/workflow.py b/lib/galaxy/web/controllers/workflow.py
index cdc3cd82210..52a34ebe7d1 100644
--- a/lib/galaxy/web/controllers/workflow.py
+++ b/lib/galaxy/web/controllers/workflow.py
@@ -79,13 +79,6 @@ class WorkflowController( BaseController ):
return trans.show_error_message( "Must be logged in to create or modify workflows" )
return trans.fill_template( "workflow/editor.mako",
workflow_id=id )
-
- @web.expose
- def editor_canvas( self, trans ):
- """
- Render the workflow editor canvas.
- """
- return trans.fill_template( "workflow/editor_canvas.mako" )
@web.json
def editor_tool_form( self, trans, tool_id=None, **incoming ):
diff --git a/static/june_2007_style/blue/panel_layout.css b/static/june_2007_style/blue/panel_layout.css
index b5d29693bba..3e93a3a7d09 100644
--- a/static/june_2007_style/blue/panel_layout.css
+++ b/static/june_2007_style/blue/panel_layout.css
@@ -13,8 +13,11 @@ body
}
#background
{
+ position: absolute;
background: #eee;
z-index: -1;
+ top: 0;
+ left: 0;
margin: 0;
padding: 0;
width: 100%;
@@ -141,7 +144,7 @@ table.column-layout
height: 100%;
}
-div.unified-panel-header {
+.unified-panel-header {
height: 2em;
overflow: hidden;
z-index: 1000;
@@ -158,7 +161,7 @@ div.unified-panel-header {
font-weight: bold;
}
-div.unified-panel-header-inner {
+.unified-panel-header-inner {
padding-top: 0.45em;
}
@@ -175,37 +178,6 @@ div.unified-panel-body {
margin-top: 1px;
}
-.dialog-wrapper {
- position: fixed;
- top: 0; left: 0; width: 100%; height: 100%;
- z-index: 30000;
-}
-.dialog-box {
- top: 80px;
- position: fixed;
- border: solid #999 1px;
- background: white;
- min-width: 230px;
- z-index: 80000;
-}
-.dialog-box .title, .dialog-box .body, .dialog-box .buttons {
- padding: 5px;
-}
-.dialog-box .title {
- height: 2em;
- z-index: 1000;
- background: #cccccc;
- background-image: url(panel_header_bg.png);
- background-position: top center;
- background-repeat: repeat-x;
- border-bottom: solid #999 1px;
- margin: 0;
- padding: 0;
- padding-right: 10px;
- padding-left: 10px;
- font-weight: bold;
-}
-
.panel-header-button {
color: #333;
text-decoration: none;
@@ -268,16 +240,45 @@ div.popupmenu-item:hover {
}
#overlay {
- position: fixed;
+ position: absolute;
top: 0; left: 0; width: 100%; height: 100%;
z-index: 20000;
}
-#overlay-inner
-{
+#overlay-inner {
width: 100%; height: 100%;
background-color:#FFF;
filter:alpha(opacity=75);
-moz-opacity: 0.75;
opacity: 0.75;
z-index: 20000;
+}
+
+.dialog-box-container {
+ position: relative;
+ margin-top: 80px;
+ margin-right: auto;
+ margin-left: auto;
+}
+.dialog-box-underlay {
+ position: absolute;
+ left: -1em;
+ right: -1em;
+ top: -1em;
+ bottom: -1em;
+ opacity: 0.5;
+ background: black;
+ z-index: -1;
+ -moz-border-radius: 1em;
+ -webkit-border-radius: 1em;
+}
+
+.dialog-box {
+ border: solid #999 1px;
+ background: white;
+ min-width: 230px;
+ z-index: 80000;
+}
+
+.dialog-box .body, .dialog-box .buttons {
+ padding: 5px;
}
\ No newline at end of file
diff --git a/static/june_2007_style/panel_layout.css.tmpl b/static/june_2007_style/panel_layout.css.tmpl
index d37a0e52228..a150fc42cef 100644
--- a/static/june_2007_style/panel_layout.css.tmpl
+++ b/static/june_2007_style/panel_layout.css.tmpl
@@ -13,8 +13,11 @@ body
}
#background
{
+ position: absolute;
background: ${layout_bg};
z-index: -1;
+ top: 0;
+ left: 0;
margin: 0;
padding: 0;
width: 100%;
@@ -141,7 +144,7 @@ table.column-layout
height: 100%;
}
-div.unified-panel-header {
+.unified-panel-header {
height: 2em;
z-index: 1000;
background: ${panel_header_bg_bottom};
@@ -157,7 +160,7 @@ div.unified-panel-header {
font-weight: bold;
}
-div.unified-panel-header-inner {
+.unified-panel-header-inner {
padding-top: 0.45em;
}
@@ -173,37 +176,6 @@ div.unified-panel-body {
margin-top: 1px;
}
-.dialog-wrapper {
- position: fixed;
- top: 0; left: 0; width: 100%; height: 100%;
- z-index: 30000;
-}
-.dialog-box {
- top: 80px;
- position: fixed;
- border: solid ${layout_border} 1px;
- background: white;
- min-width: 230px;
- z-index: 80000;
-}
-.dialog-box .title, .dialog-box .body, .dialog-box .buttons {
- padding: 5px;
-}
-.dialog-box .title {
- height: 2em;
- z-index: 1000;
- background: ${panel_header_bg_bottom};
- background-image: url(panel_header_bg.png);
- background-position: top center;
- background-repeat: repeat-x;
- border-bottom: solid ${layout_border} 1px;
- margin: 0;
- padding: 0;
- padding-right: 10px;
- padding-left: 10px;
- font-weight: bold;
-}
-
.panel-header-button {
color: #333;
text-decoration: none;
@@ -271,12 +243,42 @@ div.popupmenu-item:hover {
top: 0; left: 0; width: 100%; height: 100%;
z-index: 20000;
}
-#overlay-inner
-{
+
+#overlay-inner {
width: 100%; height: 100%;
background-color:#FFF;
filter:alpha(opacity=75);
-moz-opacity: 0.75;
opacity: 0.75;
z-index: 20000;
+}
+
+.dialog-box-container {
+ position: relative;
+ margin-top: 80px;
+ margin-right: auto;
+ margin-left: auto;
+}
+.dialog-box-underlay {
+ position: absolute;
+ left: -1em;
+ right: -1em;
+ top: -1em;
+ bottom: -1em;
+ opacity: 0.5;
+ background: black;
+ z-index: -1;
+ -moz-border-radius: 1em;
+ -webkit-border-radius: 1em;
+}
+
+.dialog-box {
+ border: solid #999 1px;
+ background: white;
+ min-width: 230px;
+ z-index: 80000;
+}
+
+.dialog-box .body, .dialog-box .buttons {
+ padding: 5px;
}
\ No newline at end of file
diff --git a/static/scripts/galaxy.panels.js b/static/scripts/galaxy.panels.js
index 716d554b295..f163a692fe8 100644
--- a/static/scripts/galaxy.panels.js
+++ b/static/scripts/galaxy.panels.js
@@ -84,8 +84,8 @@ function make_left_panel( panel_el, center_el, border_el ) {
}
resize( x );
// Constrain helper position
- ui.draggable.pos[0] = x;
- ui.draggable.pos[1] = ui.options.co.top;
+ ui.position.left = x;
+ ui.position.top = ui.instance.originalPosition.top;
},
click: function() {
toggle();
@@ -151,7 +151,7 @@ function make_right_panel( panel_el, center_el, border_el ) {
function() { jq( this ).removeClass( "hover" ) }
).draggable( {
start: function( _, ui ) {
- jq( '#DD-helper' ).show();
+ jq( '#DD-helper' ).show();
},
stop: function( _, ui ) {
x = ui.position.left;
@@ -181,8 +181,8 @@ function make_right_panel( panel_el, center_el, border_el ) {
}
resize( w - x - border_tweak );
// Constrain helper position
- ui.draggable.pos[0] = x;
- ui.draggable.pos[1] = ui.options.co.top;
+ ui.position.left = x;
+ ui.position.top = ui.instance.originalPosition.top;
}
}
).find( "div" ).show();
diff --git a/static/scripts/galaxy.workflow_editor.canvas.js b/static/scripts/galaxy.workflow_editor.canvas.js
index 1ab9e051df1..46c35322a25 100644
--- a/static/scripts/galaxy.workflow_editor.canvas.js
+++ b/static/scripts/galaxy.workflow_editor.canvas.js
@@ -81,18 +81,19 @@ $.extend( Connector.prototype, {
$(this.canvas).remove();
},
redraw : function () {
+ var canvas_container = $("#canvas-container");
if ( ! this.canvas ) {
this.canvas = document.createElement( "canvas" );
- $("body").append( this.canvas );
+ canvas_container.append( $(this.canvas) );
if ( this.dragging ) { this.canvas.style.zIndex = "300" }
}
+ var relativeLeft = function( e ) { return $(e).offset().left - canvas_container.offset().left + canvas_container.scrollLeft(); }
+ var relativeTop = function( e ) { return $(e).offset().top - canvas_container.offset().top + canvas_container.scrollTop(); }
// Find the position of each handle
- var o = $(this.handle1.element).offset();
- var start_x = o.left + 5;
- var start_y = o.top + 5;
- var o = $(this.handle2.element).offset();
- var end_x = o.left + 5;
- var end_y = o.top + 5;
+ var start_x = relativeLeft( this.handle1.element ) + 5;
+ var start_y = relativeTop( this.handle1.element ) + 5;
+ var end_x = relativeLeft( this.handle2.element ) + 5;
+ var end_y = relativeTop( this.handle2.element ) + 5;
// Calculate canvas area
var canvas_extra = 100;
var canvas_min_x = Math.min( start_x, end_x );
@@ -109,11 +110,6 @@ $.extend( Connector.prototype, {
this.canvas.style.top = canvas_top + "px";
this.canvas.setAttribute( "width", canvas_width );
this.canvas.setAttribute( "height", canvas_height );
- // HACK: Calling this again makes drawing work in Safari and I have
- // no idea why. Need to figure out what this refreshes (some
- // sort of side effect)
- var o = $(this.handle1.element).offset()
- var o = $(this.handle2.element).offset()
// Adjust points to be relative to the canvas
start_x -= canvas_left;
start_y -= canvas_top;
@@ -149,24 +145,25 @@ $.extend( Node.prototype, {
node = this;
$(elements).each( function() {
var terminal = this.terminal = new InputTerminal( this, types );
- terminal.node = node;
- terminal.name = name
+ terminal.node = node;
+ terminal.name = name
$(this).droppable( {
tolerance: 'intersect',
accept: function( draggable ) {
+ draggable = draggable.get( 0 );
return ( draggable.terminal ) && ( terminal.can_accept( draggable.terminal ) );
},
activeClass: 'input-terminal-active',
// hoverClass: 'input-terminal-active',
over: function( e, ui ) {
- ui.helper.terminal.connectors[0].inner_color = "#BBFFBB";
+ ui.helper.get(0).terminal.connectors[0].inner_color = "#BBFFBB";
},
out: function( e, ui ) {
- ui.helper.terminal.connectors[0].inner_color = "#EEEEEE";
+ ui.helper.get(0).terminal.connectors[0].inner_color = "#EEEEEE";
},
drop: function( e, ui ) {
- var source = ui.draggable.element.terminal;
- var target = ui.droppable.element.terminal;
+ var source = ui.draggable.get(0).terminal;
+ var target = ui.element.get(0).terminal;
var c = new Connector();
c.connect( source, target );
c.redraw();
@@ -187,7 +184,7 @@ $.extend( Node.prototype, {
// appendTo: "body",
// cursorAt: { top: 5, left: 5 },
helper: function () {
- var h = $( '
' ).get(0);
+ var h = $( '' ).appendTo( "#canvas-container" ).get(0);
h.terminal = new OutputTerminal( h );
// // Already a connector? Destroy... no wait, don't
// if ( this.terminal.connector ) {
@@ -200,7 +197,8 @@ $.extend( Node.prototype, {
return h;
},
drag: function ( e, options ) {
- options.helper.terminal.redraw();
+ h = options.helper.get(0);
+ h.terminal.redraw();
},
stop: function( e, options ) {
this.drag_temp_connector.destroy();
@@ -397,7 +395,7 @@ function prebuild_node_for_tool( id, title_text ) {
function() { $(this).attr( 'src', "../images/delete_icon_dark.png" ) },
function() { $(this).attr( 'src', "../images/delete_icon.png" ) }
) );
- f.appendTo( "body" );
+ f.appendTo( "#canvas-container" );
var width = f.width();
buttons.prependTo( title );
width += ( buttons.width() + 10 );
@@ -409,11 +407,10 @@ function prebuild_node_for_tool( id, title_text ) {
scroll: true,
scrollSensitivity: 10,
scrollSpeed: 20,
- containment: $("#shim"),
+ // containment: $("#shim"),
// grow: true,
- click: function() {
- document.body.removeChild( this );
- document.body.appendChild( this );
+ click: function( _, element ) {
+ (function(p) { p.removeChild( element ); p.appendChild( element ) })(element.parentNode)
workflow.activate_node( node );
},
start: function() {
@@ -425,9 +422,9 @@ function prebuild_node_for_tool( id, title_text ) {
this.terminal.redraw();
})
},
- stop: function() {
- document.body.removeChild( this );
- document.body.appendChild( this );
+ stop: function( _, ui ) {
+ element = ui.element.get(0);
+ (function(p) { p.removeChild( element ); p.appendChild( element ) })(element.parentNode)
$(this).css( 'z-index', '100' );
$(this).find( ".terminal" ).each( function() {
this.terminal.redraw();
diff --git a/static/scripts/jquery.ui.js b/static/scripts/jquery.ui.js
index c9cbe11f2a7..61314337a1c 100644
--- a/static/scripts/jquery.ui.js
+++ b/static/scripts/jquery.ui.js
@@ -1,906 +1,1097 @@
-(function($) {
-
- //If the UI scope is not availalable, add it
+/*
+ * jQuery UI @VERSION
+ *
+ * Copyright (c) 2008 Paul Bakaus (ui.jquery.com)
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ * http://docs.jquery.com/UI
+ *
+ * $Date: 2008-04-29 19:19:03 -0400 (Tue, 29 Apr 2008) $
+ * $Rev: 5355 $
+ */
+;(function($) {
+
+ //If the UI scope is not available, add it
$.ui = $.ui || {};
//Add methods that are vital for all mouse interaction stuff (plugin registering)
$.extend($.ui, {
plugin: {
- add: function(w, c, o, p) {
- var a = $.ui[w].prototype; if(!a.plugins[c]) a.plugins[c] = [];
- a.plugins[c].push([o,p]);
+ add: function(module, option, set) {
+ var proto = $.ui[module].prototype;
+ for(var i in set) {
+ proto.plugins[i] = proto.plugins[i] || [];
+ proto.plugins[i].push([option, set[i]]);
+ }
},
- call: function(instance, name, args) {
- var c = instance.plugins[name]; if(!c) return;
- var o = instance.interaction ? instance.interaction.options : instance.options;
- var e = instance.interaction ? instance.interaction.element : instance.element;
-
- for (var i = 0; i < c.length; i++) {
- if (o[c[i][0]]) c[i][1].apply(e, args);
- }
+ call: function(instance, name, arguments) {
+ var set = instance.plugins[name]; if(!set) return;
+ for (var i = 0; i < set.length; i++) {
+ if (instance.options[set[i][0]]) set[i][1].apply(instance.element, arguments);
+ }
}
+ },
+ cssCache: {},
+ css: function(name) {
+ if ($.ui.cssCache[name]) return $.ui.cssCache[name];
+ var tmp = $('').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');
+
+ //if (!$.browser.safari)
+ //tmp.appendTo('body');
+
+ //Opera and Safari set width and height to 0px instead of auto
+ //Safari returns rgba(0,0,0,0) when bgcolor is not set
+ $.ui.cssCache[name] = !!(
+ (!/auto|default/.test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) ||
+ !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor')))
+ );
+ try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){}
+ return $.ui.cssCache[name];
+ },
+ disableSelection: function(e) {
+ e.unselectable = "on";
+ e.onselectstart = function() { return false; };
+ if (e.style) e.style.MozUserSelect = "none";
+ },
+ enableSelection: function(e) {
+ e.unselectable = "off";
+ e.onselectstart = function() { return true; };
+ if (e.style) e.style.MozUserSelect = "";
+ },
+ hasScroll: function(e, a) {
+ var scroll = /top/.test(a||"top") ? 'scrollTop' : 'scrollLeft', has = false;
+ if (e[scroll] > 0) return true; e[scroll] = 1;
+ has = e[scroll] > 0 ? true : false; e[scroll] = 0;
+ return has;
+ }
+ });
+
+ /******* fn scope modifications ********/
+
+ var _remove = $.fn.remove;
+ $.fn.extend({
+ mouseInteraction: function(o) {
+ return this.each(function() {
+ new $.ui.mouseInteraction(this, o);
+ });
+ },
+ removeMouseInteraction: function(o) {
+ return this.each(function() {
+ if($.data(this, "ui-mouse"))
+ $.data(this, "ui-mouse").destroy();
+ });
+ },
+ remove: function() {
+ jQuery("*", this).add(this).trigger("remove");
+ return _remove.apply(this, arguments );
}
});
- $.fn.mouseInteractionDestroy = function() {
- this.each(function() {
- if($.data(this, "ui-mouse")) $.data(this, "ui-mouse").destroy();
- });
- };
- $.ui.mouseInteraction = function(el,o) {
+ /********** Mouse Interaction Plugin *********/
+
+ $.ui.mouseInteraction = function(element, options) {
- if(!o) var o = {};
- this.element = el;
- $.data(this.element, "ui-mouse", this);
-
- this.options = {};
- $.extend(this.options, o);
- $.extend(this.options, {
- handle : o.handle ? ($(o.handle, el)[0] ? $(o.handle, el) : $(el)) : $(el),
- helper: o.helper || 'original',
- preventionDistance: o.preventionDistance || 0,
- dragPrevention: o.dragPrevention ? o.dragPrevention.toLowerCase().split(',') : ['input','textarea','button','select','option'],
- cursorAt: { top: ((o.cursorAt && o.cursorAt.top) ? o.cursorAt.top : 0), left: ((o.cursorAt && o.cursorAt.left) ? o.cursorAt.left : 0), bottom: ((o.cursorAt && o.cursorAt.bottom) ? o.cursorAt.bottom : 0), right: ((o.cursorAt && o.cursorAt.right) ? o.cursorAt.right : 0) },
- cursorAtIgnore: (!o.cursorAt) ? true : false, //Internal property
- appendTo: o.appendTo || 'parent'
- });
- o = this.options; //Just Lazyness
-
- if(!this.options.nonDestructive && (o.helper == 'clone' || o.helper == 'original')) {
-
- // Let's save the margins for better reference
- o.margins = {
- top: parseInt($(el).css('marginTop')) || 0,
- left: parseInt($(el).css('marginLeft')) || 0,
- bottom: parseInt($(el).css('marginBottom')) || 0,
- right: parseInt($(el).css('marginRight')) || 0
- };
-
- // We have to add margins to our cursorAt
- if(o.cursorAt.top != 0) o.cursorAt.top = o.margins.top;
- if(o.cursorAt.left != 0) o.cursorAt.left += o.margins.left;
- if(o.cursorAt.bottom != 0) o.cursorAt.bottom += o.margins.bottom;
- if(o.cursorAt.right != 0) o.cursorAt.right += o.margins.right;
-
-
- if(o.helper == 'original')
- o.wasPositioned = $(el).css('position');
-
- } else {
- o.margins = { top: 0, left: 0, right: 0, bottom: 0 };
- }
-
var self = this;
- this.mousedownfunc = function(e) { // Bind the mousedown event
- return self.click.apply(self, [e]);
- };
- o.handle.bind('mousedown', this.mousedownfunc);
+ this.element = element;
+
+ $.data(this.element, "ui-mouse", this);
+ this.options = $.extend({}, options);
- //Prevent selection of text when starting the drag in IE
- if($.browser.msie) $(this.element).attr('unselectable', 'on');
+ $(element).bind('mousedown.draggable', function() { return self.click.apply(self, arguments); });
+ if($.browser.msie) $(element).attr('unselectable', 'on'); //Prevent text selection in IE
+ // prevent draggable-options-delay bug #2553
+ $(element).mouseup(function() {
+ if(self.timer) clearInterval(self.timer);
+ });
};
$.extend($.ui.mouseInteraction.prototype, {
- plugins: {},
- currentTarget: null,
- lastTarget: null,
- timer: null,
- slowMode: false,
- init: false,
- destroy: function() {
- this.options.handle.unbind('mousedown', this.mousedownfunc);
- },
- trigger: function(e) {
- return this.click.apply(this, arguments);
- },
+
+ destroy: function() { $(this.element).unbind('mousedown.draggable'); },
+ trigger: function() { return this.click.apply(this, arguments); },
click: function(e) {
-
- var o = this.options;
- window.focus();
- if(e.which != 1) return true; //only left click starts dragging
-
- // Prevent execution on defined elements
- var targetName = (e.target) ? e.target.nodeName.toLowerCase() : e.srcElement.nodeName.toLowerCase();
- for(var i=0;i= self.options.distance || Math.abs(self._MP.top-e.pageY) >= self.options.distance) {
+ if(self.options.start) self.options.start.call(self.options.executor || self, e, self.element);
+ if(self.options.drag) self.options.drag.call(self.options.executor || self, e, this.element); //This is actually not correct, but expected
+ self.initialized = true;
+ }
};
-
- if(o.preventionTimeout) { //use prevention timeout
+
+ if(this.options.delay) {
if(this.timer) clearInterval(this.timer);
- this.timer = setTimeout(function() { initFunc(); }, o.preventionTimeout);
- return false;
+ this.timer = setTimeout(initialize, this.options.delay);
+ } else {
+ initialize();
}
-
- initFunc();
+
return false;
},
- start: function(e) {
+ stop: function(e) {
- var o = this.options; var a = this.element;
- o.co = $(a).offset(); //get the current offset
-
- this.helper = typeof o.helper == 'function' ? $(o.helper.apply(a, [e,this]))[0] : (o.helper == 'clone' ? $(a).clone()[0] : a);
-
- if(o.appendTo == 'parent') { // Let's see if we have a positioned parent
- var cp = a.parentNode;
- while (cp) {
- if(cp.style && ($(cp).css('position') == 'relative' || $(cp).css('position') == 'absolute')) {
- o.pp = cp;
- o.po = $(cp).offset();
- o.ppOverflow = !!($(o.pp).css('overflow') == 'auto' || $(o.pp).css('overflow') == 'scroll'); //TODO!
- break;
- }
- cp = cp.parentNode ? cp.parentNode : null;
- };
-
- if(!o.pp) o.po = { top: 0, left: 0 };
+ var o = this.options;
+ if(!this.initialized) {
+ // james@bx.psu.edu
+ if(this.options.click) this.options.click.call(this.options.executor || this, e, this.element);
+ return $(document).unbind('mouseup.draggable').unbind('mousemove.draggable');
}
-
- this.pos = [this.opos[0],this.opos[1]]; //Use the relative position
- this.rpos = [this.pos[0],this.pos[1]]; //Save the absolute position
-
- if(o.cursorAtIgnore) { // If we want to pick the element where we clicked, we borrow cursorAt and add margins
- o.cursorAt.left = this.pos[0] - o.co.left + o.margins.left;
- o.cursorAt.top = this.pos[1] - o.co.top + o.margins.top;
- }
-
-
-
- if(o.pp) { // If we have a positioned parent, we pick the draggable relative to it
- this.pos[0] -= o.po.left;
- this.pos[1] -= o.po.top;
- }
-
- this.slowMode = (o.cursorAt && (o.cursorAt.top-o.margins.top > 0 || o.cursorAt.bottom-o.margins.bottom > 0) && (o.cursorAt.left-o.margins.left > 0 || o.cursorAt.right-o.margins.right > 0)) ? true : false; //If cursorAt is within the helper, set slowMode to true
-
- if(!o.nonDestructive) $(this.helper).css('position', 'absolute');
- if(o.helper != 'original') $(this.helper).appendTo((o.appendTo == 'parent' ? a.parentNode : o.appendTo)).show();
-
- // Remap right/bottom properties for cursorAt to left/top
- if(o.cursorAt.right && !o.cursorAt.left) o.cursorAt.left = this.helper.offsetWidth+o.margins.right+o.margins.left - o.cursorAt.right;
- if(o.cursorAt.bottom && !o.cursorAt.top) o.cursorAt.top = this.helper.offsetHeight+o.margins.top+o.margins.bottom - o.cursorAt.bottom;
-
- this.init = true;
-
- if(o._start) o._start.apply(a, [this.helper, this.pos, o.cursorAt, this, e]); // Trigger the start callback
- this.helperSize = { width: outerWidth(this.helper), height: outerHeight(this.helper) }; //Set helper size property
- return false;
-
- },
- stop: function(e) {
-
- var o = this.options; var a = this.element; var self = this;
-
- $(document).unbind('mouseup', self.mouseup);
- $(document).unbind('mousemove', self.mousemove);
-
- if(this.init == false) {
- // james@bx.psu.edu
- // if ( o.click ) o.click.apply();
- $(this.element).triggerHandler("click", [e], o.click);
- this.opos = this.pos = null;
- return null;
- }
- if(o._beforeStop) o._beforeStop.apply(a, [this.helper, this.pos, o.cursorAt, this, e]);
-
- if(this.helper != a && !o.beQuietAtEnd) { // Remove helper, if it's not the original node
- $(this.helper).remove(); this.helper = null;
- }
-
- if(!o.beQuietAtEnd) {
- //if(o.wasPositioned) $(a).css('position', o.wasPositioned);
- if(o._stop) o._stop.apply(a, [this.helper, this.pos, o.cursorAt, this, e]);
- }
-
- this.init = false;
- this.opos = this.pos = null;
+ if(this.options.stop) this.options.stop.call(this.options.executor || this, e, this.element);
+ $(document).unbind('mouseup.draggable').unbind('mousemove.draggable');
+ this.initialized = false;
return false;
},
drag: function(e) {
- if (!this.opos || ($.browser.msie && !e.button)) return this.stop.apply(this, [e]); // check for IE mouseup when moving into the document again
var o = this.options;
+ if ($.browser.msie && !e.button) return this.stop.apply(this, [e]); // IE mouseup check
- this.pos = [e.pageX,e.pageY]; //relative mouse position
- if(this.rpos && this.rpos[0] == this.pos[0] && this.rpos[1] == this.pos[1]) return false;
- this.rpos = [this.pos[0],this.pos[1]]; //absolute mouse position
-
- if(o.pp) { //If we have a positioned parent, use a relative position
- this.pos[0] -= o.po.left;
- this.pos[1] -= o.po.top;
+ if(!this.initialized && (Math.abs(this._MP.left-e.pageX) >= o.distance || Math.abs(this._MP.top-e.pageY) >= o.distance)) {
+ if(this.options.start) this.options.start.call(this.options.executor || this, e, this.element);
+ this.initialized = true;
+ } else {
+ if(!this.initialized) return false;
}
-
- if( (Math.abs(this.rpos[0]-this.opos[0]) > o.preventionDistance || Math.abs(this.rpos[1]-this.opos[1]) > o.preventionDistance) && this.init == false) //If position is more than x pixels from original position, start dragging
- this.start.apply(this,[e]);
- else {
- if(this.init == false) return false;
- }
-
- if(o._drag) o._drag.apply(this.element, [this.helper, this.pos, o.cursorAt, this, e]);
+
+ if(o.drag) o.drag.call(this.options.executor || this, e, this.element);
return false;
}
});
-
- var num = function(el, prop) {
- return parseInt($.css(el.jquery?el[0]:el,prop))||0;
- };
- function outerWidth(el) {
- var $el = $(el), ow = $el.width();
- for (var i = 0, props = ['borderLeftWidth', 'paddingLeft', 'paddingRight', 'borderRightWidth']; i < props.length; i++)
- ow += num($el, props[i]);
- return ow;
- };
- function outerHeight(el) {
- var $el = $(el), oh = $el.width();
- for (var i = 0, props = ['borderTopWidth', 'paddingTop', 'paddingBottom', 'borderBottomWidth']; i < props.length; i++)
- oh += num($el, props[i]);
- return oh;
- };
-
- //Make nodes selectable by expression
- $.extend($.expr[':'], { draggable: "(' '+a.className+' ').indexOf(' ui-draggable ')" });
-
-
- //Macros for external methods that support chaining
- var methods = "destroy,enable,disable".split(",");
- for(var i=0;i this.maxLeft - this.helperProportions.width) this.position.left = this.maxLeft - this.helperProportions.width;
+ if(this.position.top < this.minTop) this.position.top = this.minTop;
+ if(this.position.top > this.maxTop - this.helperProportions.height) this.position.top = this.maxTop - this.helperProportions.height;
+ },
+ recallOffset: function(e) {
+
+ var elementPosition = { left: this.elementOffset.left - this.offsetParentOffset.left, top: this.elementOffset.top - this.offsetParentOffset.top };
+ var r = this.helper.css('position') == 'relative'; var o = this.options;
+
+ //Generate the original position
+ this.originalPosition = {
+ left: (elementPosition.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft)),
+ top: (elementPosition.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop))
+ };
+ //Generate a flexible offset that will later be subtracted from e.pageX/Y
+ this.offset = {left: this._pageX - this.originalPosition.left, top: this._pageY - this.originalPosition.top };
+
+ //Substract margins
+ if(this.element[0] != this.helper[0]) {
+ this.offset.left += parseInt(this.element.css('marginLeft'),10) || 0;
+ this.offset.top += parseInt(this.element.css('marginTop'),10) || 0;
+ }
+
+ },
+ start: function(e) {
var o = this.options;
- $.ui.ddmanager.current = this;
+ if($.ui.ddmanager) $.ui.ddmanager.current = this;
- $.ui.plugin.call(that, 'start', [e, that.prepareCallbackObj(this)]);
- $(this.element).triggerHandler("dragstart", [e, that.prepareCallbackObj(this)], o.start);
+ //Create and append the visible helper
+ this.helper = typeof o.helper == 'function' ? $(o.helper.apply(this.element[0], [e])) : (o.helper == 'clone' ? this.element.clone().appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo)) : this.element);
+ if(this.helper[0] != this.element[0]) this.helper.css('position', 'absolute');
+ if(!this.helper.parents('body').length) this.helper.appendTo((o.appendTo == 'parent' ? this.element[0].parentNode : o.appendTo));
- if (this.slowMode && $.ui.droppable && !o.dropBehaviour)
- $.ui.ddmanager.prepareOffsets(this, e);
- return false;
-
- },
- stop: function(that, e) {
+ //Find out the next positioned parent
+ this.offsetParent = (function(cp) {
+ while(cp) {
+ if(cp.style && (/(absolute|relative|fixed)/).test($.css(cp,'position'))) return $(cp);
+ cp = cp.parentNode ? cp.parentNode : null;
+ }; return $("body");
+ })(this.helper[0].parentNode);
- var o = this.options;
+ //Prepare variables for position generation
+ this.elementOffset = this.element.offset();
+ this.offsetParentOffset = this.offsetParent.offset();
+ var elementPosition = { left: this.elementOffset.left - this.offsetParentOffset.left, top: this.elementOffset.top - this.offsetParentOffset.top };
+ this._pageX = e.pageX; this._pageY = e.pageY;
+ this.clickOffset = { left: e.pageX - this.elementOffset.left, top: e.pageY - this.elementOffset.top };
+ var r = this.helper.css('position') == 'relative';
+
+ //Generate the original position
+ this.originalPosition = {
+ left: (r ? parseInt(this.helper.css('left'),10) || 0 : elementPosition.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft)),
+ top: (r ? parseInt(this.helper.css('top'),10) || 0 : elementPosition.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop))
+ };
- $.ui.plugin.call(that, 'stop', [e, that.prepareCallbackObj(this)]);
- $(this.element).triggerHandler("dragstop", [e, that.prepareCallbackObj(this)], o.stop);
-
- if (this.slowMode && $.ui.droppable && !o.dropBehaviour) //If cursorAt is within the helper, we must use our drop manager
- $.ui.ddmanager.fire(this, e);
-
- $.ui.ddmanager.current = null;
- $.ui.ddmanager.last = this;
-
- return false;
+ //If we have a fixed element, we must subtract the scroll offset again
+ if(this.element.css('position') == 'fixed') {
+ this.originalPosition.top -= this.offsetParent[0] == document.body ? $(document).scrollTop() : this.offsetParent[0].scrollTop;
+ this.originalPosition.left -= this.offsetParent[0] == document.body ? $(document).scrollLeft() : this.offsetParent[0].scrollLeft;
+ }
- },
- drag: function(that, e) {
-
- var o = this.options;
-
- $.ui.ddmanager.update(this, e);
-
- this.pos = [this.pos[0]-o.cursorAt.left, this.pos[1]-o.cursorAt.top];
-
- $.ui.plugin.call(that, 'drag', [e, that.prepareCallbackObj(this)]);
- var nv = $(this.element).triggerHandler("drag", [e, that.prepareCallbackObj(this)], o.drag);
-
- var nl = (nv && nv.left) ? nv.left : this.pos[0];
- var nt = (nv && nv.top) ? nv.top : this.pos[1];
+ //Generate a flexible offset that will later be subtracted from e.pageX/Y
+ this.offset = {left: e.pageX - this.originalPosition.left, top: e.pageY - this.originalPosition.top };
- $(this.helper).css('left', nl+'px').css('top', nt+'px'); // Stick the helper to the cursor
- return false;
+ //Substract margins
+ if(this.element[0] != this.helper[0]) {
+ this.offset.left += parseInt(this.element.css('marginLeft'),10) || 0;
+ this.offset.top += parseInt(this.element.css('marginTop'),10) || 0;
+ }
- }
- });
+ //Call plugins and callbacks
+ this.propagate("start", e);
- $.ui.plugin.add("draggable", "stop", "effect", function(e,ui) {
- var t = ui.helper;
- if(ui.options.effect[1]) {
- if(t != this) {
- ui.options.beQuietAtEnd = true;
- switch(ui.options.effect[1]) {
- case 'fade':
- $(t).fadeOut(300, function() { $(this).remove(); });
- break;
- default:
- $(t).remove();
- break;
+ this.helperProportions = { width: this.helper.outerWidth(), height: this.helper.outerHeight() };
+ if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);
+
+ //If we have something in cursorAt, we'll use it
+ if(o.cursorAt) {
+ if(o.cursorAt.top != undefined || o.cursorAt.bottom != undefined) {
+ this.offset.top -= this.clickOffset.top - (o.cursorAt.top != undefined ? o.cursorAt.top : (this.helperProportions.height - o.cursorAt.bottom));
+ this.clickOffset.top = (o.cursorAt.top != undefined ? o.cursorAt.top : (this.helperProportions.height - o.cursorAt.bottom));
+ }
+ if(o.cursorAt.left != undefined || o.cursorAt.right != undefined) {
+ this.offset.left -= this.clickOffset.left - (o.cursorAt.left != undefined ? o.cursorAt.left : (this.helperProportions.width - o.cursorAt.right));
+ this.clickOffset.left = (o.cursorAt.left != undefined ? o.cursorAt.left : (this.helperProportions.width - o.cursorAt.right));
}
}
+
+ return false;
+
+ },
+ clear: function() {
+ if($.ui.ddmanager) $.ui.ddmanager.current = null;
+ this.helper = null;
+ },
+ stop: function(e) {
+
+ //If we are using droppables, inform the manager about the drop
+ if ($.ui.ddmanager && !this.options.dropBehaviour)
+ $.ui.ddmanager.drop(this, e);
+
+ //Call plugins and trigger callbacks
+ this.propagate("stop", e);
+
+ if(this.cancelHelperRemoval) return false;
+ if(this.options.helper != 'original') this.helper.remove();
+ this.clear();
+
+ return false;
+ },
+ drag: function(e) {
+
+ //Compute the helpers position
+ this.position = { top: e.pageY - this.offset.top, left: e.pageX - this.offset.left };
+ this.positionAbs = { left: e.pageX - this.clickOffset.left, top: e.pageY - this.clickOffset.top };
+
+ //Call plugins and callbacks
+ this.checkConstrains();
+ this.position = this.propagate("drag", e) || this.position;
+ this.checkConstrains();
+
+ $(this.helper).css({ left: this.position.left+'px', top: this.position.top+'px' }); // Stick the helper to the cursor
+ if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);
+ return false;
}
});
- $.ui.plugin.add("draggable", "start", "effect", function(e,ui) {
- if(ui.options.effect[0]) {
- switch(ui.options.effect[0]) {
- case 'fade':
- $(ui.helper).hide().fadeIn(300);
- break;
- }
+/*
+ * Draggable Extensions
+ */
+
+ $.ui.plugin.add("draggable", "cursor", {
+ start: function(e, ui) {
+ var t = $('body');
+ if (t.css("cursor")) ui.options._cursor = t.css("cursor");
+ t.css("cursor", ui.options.cursor);
+ },
+ stop: function(e, ui) {
+ if (ui.options._cursor) $('body').css("cursor", ui.options._cursor);
}
});
-//----------------------------------------------------------------
-
- $.ui.plugin.add("draggable", "start", "cursor", function(e,ui) {
- var t = $('body');
- if (t.css("cursor")) ui.options.ocursor = t.css("cursor");
- t.css("cursor", ui.options.cursor);
- });
-
- $.ui.plugin.add("draggable", "stop", "cursor", function(e,ui) {
- if (ui.options.ocursor) $('body').css("cursor", ui.options.ocursor);
- });
-
-//----------------------------------------------------------------
-
- $.ui.plugin.add("draggable", "start", "zIndex", function(e,ui) {
- var t = $(ui.helper);
- if(t.css("zIndex")) ui.options.ozIndex = t.css("zIndex");
- t.css('zIndex', ui.options.zIndex);
- });
-
- $.ui.plugin.add("draggable", "stop", "zIndex", function(e,ui) {
- if(ui.options.ozIndex) $(ui.helper).css('zIndex', ui.options.ozIndex);
- });
-
-
-//----------------------------------------------------------------
-
- $.ui.plugin.add("draggable", "start", "opacity", function(e,ui) {
- var t = $(ui.helper);
- if(t.css("opacity")) ui.options.oopacity = t.css("opacity");
- t.css('opacity', ui.options.opacity);
- });
-
- $.ui.plugin.add("draggable", "stop", "opacity", function(e,ui) {
- if(ui.options.oopacity) $(ui.helper).css('opacity', ui.options.oopacity);
- });
-
-//----------------------------------------------------------------
-
- $.ui.plugin.add("draggable", "stop", "revert", function(e,ui) {
-
- var o = ui.options;
- var rpos = { left: 0, top: 0 };
- o.beQuietAtEnd = true;
-
- if(ui.helper != this) {
-
- rpos = $(ui.draggable.sorthelper || this).offset({ border: false });
-
- var nl = rpos.left-o.po.left-o.margins.left;
- var nt = rpos.top-o.po.top-o.margins.top;
-
- } else {
- var nl = o.co.left - (o.po ? o.po.left : 0);
- var nt = o.co.top - (o.po ? o.po.top : 0);
+ $.ui.plugin.add("draggable", "zIndex", {
+ start: function(e, ui) {
+ var t = $(ui.helper);
+ if(t.css("zIndex")) ui.options._zIndex = t.css("zIndex");
+ t.css('zIndex', ui.options.zIndex);
+ },
+ stop: function(e, ui) {
+ if(ui.options._zIndex) $(ui.helper).css('zIndex', ui.options._zIndex);
}
-
- var self = ui.draggable;
-
- $(ui.helper).animate({
- left: nl,
- top: nt
- }, 500, function() {
-
- if(o.wasPositioned) $(self.element).css('position', o.wasPositioned);
- if(o.stop) o.stop.apply(self.element, [self.helper, self.pos, [o.co.left - o.po.left,o.co.top - o.po.top],self]);
-
- if(self.helper != self.element) window.setTimeout(function() { $(self.helper).remove(); }, 0); //Using setTimeout because of strange flickering in Firefox
-
- });
-
});
-//----------------------------------------------------------------
+ $.ui.plugin.add("draggable", "opacity", {
+ start: function(e, ui) {
+ var t = $(ui.helper);
+ if(t.css("opacity")) ui.options._opacity = t.css("opacity");
+ t.css('opacity', ui.options.opacity);
+ },
+ stop: function(e, ui) {
+ if(ui.options._opacity) $(ui.helper).css('opacity', ui.options._opacity);
+ }
+ });
- $.ui.plugin.add("draggable", "start", "iframeFix", function(e,ui) {
- var o = ui.options;
- if(!ui.draggable.slowMode) { // Make clones on top of iframes (only if we are not in slowMode)
+ $.ui.plugin.add("draggable", "revert", {
+ stop: function(e, ui) {
+ var self = ui.instance, helper = $(self.helper);
+ self.cancelHelperRemoval = true;
+
+ $(ui.helper).animate({ left: self.originalPosition.left, top: self.originalPosition.top }, parseInt(ui.options.revert, 10) || 500, function() {
+ if(ui.options.helper != 'original') helper.remove();
+ if (!helper) self.clear();
+ });
+ }
+ });
+
+ $.ui.plugin.add("draggable", "iframeFix", {
+ start: function(e, ui) {
+
+ var o = ui.options;
+ if(ui.instance.slowMode) return; // Make clones on top of iframes (only if we are not in slowMode)
+
if(o.iframeFix.constructor == Array) {
for(var i=0;i
").css("width", $(o.iframeFix[i])[0].offsetWidth+"px").css("height", $(o.iframeFix[i])[0].offsetHeight+"px").css("position", "absolute").css("opacity", "0.001").css("z-index", "1000").css("top", co.top+"px").css("left", co.left+"px").appendTo("body");
+ $('').css("width", $(o.iframeFix[i])[0].offsetWidth+"px").css("height", $(o.iframeFix[i])[0].offsetHeight+"px").css("position", "absolute").css("opacity", "0.001").css("z-index", "1000").css("top", co.top+"px").css("left", co.left+"px").appendTo("body");
}
} else {
$("iframe").each(function() {
var co = $(this).offset({ border: false });
- $("").css("width", this.offsetWidth+"px").css("height", this.offsetHeight+"px").css("position", "absolute").css("opacity", "0.001").css("z-index", "1000").css("top", co.top+"px").css("left", co.left+"px").appendTo("body");
+ $('').css("width", this.offsetWidth+"px").css("height", this.offsetHeight+"px").css("position", "absolute").css("opacity", "0.001").css("z-index", "1000").css("top", co.top+"px").css("left", co.left+"px").appendTo("body");
});
- }
- }
+ }
+ },
+ stop: function(e, ui) {
+ if(ui.options.iframeFix) $("div.DragDropIframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers
+ }
});
- $.ui.plugin.add("draggable","stop", "iframeFix", function(e,ui) {
- if(ui.options.iframeFix) $("div.DragDropIframeFix").each(function() { this.parentNode.removeChild(this); }); //Remove frame helpers
- });
-
-//----------------------------------------------------------------
+ $.ui.plugin.add("draggable", "containment", {
+ start: function(e, ui) {
- $.ui.plugin.add("draggable", "start", "containment", function(e,ui) {
+ var o = ui.options;
+ var self = ui.instance;
+ if((o.containment.left != undefined || o.containment.constructor == Array) && !o._containment) return;
+ if(!o._containment) o._containment = o.containment;
- var o = ui.options;
+ if(o._containment == 'parent') o._containment = this[0].parentNode;
+ if(o._containment == 'document') {
+ o.containment = [
+ 0,
+ 0,
+ $(document).width(),
+ ($(document).height() || document.body.parentNode.scrollHeight)
+ ];
+ } else { //I'm a node, so compute top/left/right/bottom
- if(!o.cursorAtIgnore || o.containment.left != undefined || o.containment.constructor == Array) return;
- if(o.containment == 'parent') o.containment = this.parentNode;
+ var ce = $(o._containment)[0];
+ var co = $(o._containment).offset();
+ o.containment = [
+ co.left + parseInt($(ce).css("borderLeftWidth")),
+ co.top + parseInt($(ce).css("borderTopWidth")),
+ co.left+(ce.offsetWidth || ce.scrollWidth) - parseInt($(ce).css("borderRightWidth")),
+ co.top+(ce.offsetHeight || ce.scrollHeight) - parseInt($(ce).css("borderBottomWidth"))
+ ];
+ }
+
+ var c = o.containment;
+ ui.instance.setContrains(
+ c[0] - (self.offset.left - self.clickOffset.left), //min left
+ c[2] - (self.offset.left - self.clickOffset.left), //max left
+ c[1] - (self.offset.top - self.clickOffset.top), //min top
+ c[3] - (self.offset.top - self.clickOffset.top) //max top
+ );
- if(o.containment == 'document') {
- o.containment = [
- 0-o.margins.left,
- 0-o.margins.top,
- $(document).width()-o.margins.right,
- ($(document).height() || document.body.parentNode.scrollHeight)-o.margins.bottom
- ];
- } else { //I'm a node, so compute top/left/right/bottom
- var ce = $(o.containment)[0];
- var co = $(o.containment).offset({ border: false });
-
- o.containment = [
- co.left-o.margins.left,
- co.top-o.margins.top,
- co.left+(ce.offsetWidth || ce.scrollWidth)-o.margins.right,
- co.top+(ce.offsetHeight || ce.scrollHeight)-o.margins.bottom
- ];
}
+ });
+ $.ui.plugin.add("draggable", "grid", {
+ drag: function(e, ui) {
+ var o = ui.options;
+ var newLeft = ui.instance.originalPosition.left + Math.round((e.pageX - ui.instance._pageX) / o.grid[0]) * o.grid[0];
+ var newTop = ui.instance.originalPosition.top + Math.round((e.pageY - ui.instance._pageY) / o.grid[1]) * o.grid[1];
+
+ ui.instance.position.left = newLeft;
+ ui.instance.position.top = newTop;
+
+ }
+ });
+
+ $.ui.plugin.add("draggable", "axis", {
+ drag: function(e, ui) {
+ var o = ui.options;
+ if(o.constraint) o.axis = o.constraint; //Legacy check
+ switch (o.axis) {
+ case 'x' : ui.instance.position.top = ui.instance.originalPosition.top; break;
+ case 'y' : ui.instance.position.left = ui.instance.originalPosition.left; break;
+ }
+ }
+ });
+
+ $.ui.plugin.add("draggable", "scroll", {
+ start: function(e, ui) {
+ var o = ui.options;
+ o.scrollSensitivity = o.scrollSensitivity || 20;
+ o.scrollSpeed = o.scrollSpeed || 20;
+
+ ui.instance.overflowY = function(el) {
+ do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode);
+ return $(document);
+ }(this);
+ ui.instance.overflowX = function(el) {
+ do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode);
+ return $(document);
+ }(this);
+ },
+ drag: function(e, ui) {
+
+ var o = ui.options;
+ var i = ui.instance;
+
+ if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {
+ if(i.overflowY[0].offsetHeight - (ui.position.top - i.overflowY[0].scrollTop + i.clickOffset.top) < o.scrollSensitivity)
+ i.overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed;
+ if((ui.position.top - i.overflowY[0].scrollTop + i.clickOffset.top) < o.scrollSensitivity)
+ i.overflowY[0].scrollTop = i.overflowY[0].scrollTop - o.scrollSpeed;
+ } else {
+ //$(document.body).append(''+(e.pageY - $(document).scrollTop())+'
');
+ if(e.pageY - $(document).scrollTop() < o.scrollSensitivity)
+ $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
+ if($(window).height() - (e.pageY - $(document).scrollTop()) < o.scrollSensitivity)
+ $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
+ }
+
+ if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {
+ if(i.overflowX[0].offsetWidth - (ui.position.left - i.overflowX[0].scrollLeft + i.clickOffset.left) < o.scrollSensitivity)
+ i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft + o.scrollSpeed;
+ if((ui.position.top - i.overflowX[0].scrollLeft + i.clickOffset.left) < o.scrollSensitivity)
+ i.overflowX[0].scrollLeft = i.overflowX[0].scrollLeft - o.scrollSpeed;
+ } else {
+ if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity)
+ $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
+ if($(window).width() - (e.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
+ $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
+ }
+
+ ui.instance.recallOffset(e);
+
+ }
});
- $.ui.plugin.add("draggable", "drag", "containment", function(e,ui) {
-
- var o = ui.options;
- if(!o.cursorAtIgnore) return;
+ $.ui.plugin.add("draggable", "snap", {
+ start: function(e, ui) {
- var h = $(ui.helper);
- var c = o.containment;
- if(c.constructor == Array) {
+ ui.instance.snapElements = [];
+ $(ui.options.snap === true ? '.ui-draggable' : ui.options.snap).each(function() {
+ var $t = $(this); var $o = $t.offset();
+ if(this != ui.instance.element[0]) ui.instance.snapElements.push({
+ item: this,
+ width: $t.outerWidth(),
+ height: $t.outerHeight(),
+ top: $o.top,
+ left: $o.left
+ });
+ });
- if((ui.draggable.pos[0] < c[0]-o.po.left)) ui.draggable.pos[0] = c[0]-o.po.left;
- if((ui.draggable.pos[1] < c[1]-o.po.top)) ui.draggable.pos[1] = c[1]-o.po.top;
- if(ui.draggable.pos[0]+h[0].offsetWidth > c[2]-o.po.left) ui.draggable.pos[0] = c[2]-o.po.left-h[0].offsetWidth;
- if(ui.draggable.pos[1]+h[0].offsetHeight > c[3]-o.po.top) ui.draggable.pos[1] = c[3]-o.po.top-h[0].offsetHeight;
-
- } else {
+ },
+ drag: function(e, ui) {
- if(c.left && (ui.draggable.pos[0] < c.left)) ui.draggable.pos[0] = c.left;
- if(c.top && (ui.draggable.pos[1] < c.top)) ui.draggable.pos[1] = c.top;
+ var d = ui.options.snapTolerance || 20;
+ var x1 = ui.absolutePosition.left, x2 = x1 + ui.instance.helperProportions.width,
+ y1 = ui.absolutePosition.top, y2 = y1 + ui.instance.helperProportions.height;
- var p = $(o.pp);
- if(c.right && ui.draggable.pos[0]+h[0].offsetWidth > p[0].offsetWidth-c.right) ui.draggable.pos[0] = (p[0].offsetWidth-c.right)-h[0].offsetWidth;
- if(c.bottom && ui.draggable.pos[1]+h[0].offsetHeight > p[0].offsetHeight-c.bottom) ui.draggable.pos[1] = (p[0].offsetHeight-c.bottom)-h[0].offsetHeight;
-
+ for (var i = ui.instance.snapElements.length - 1; i >= 0; i--){
+
+ var l = ui.instance.snapElements[i].left, r = l + ui.instance.snapElements[i].width,
+ t = ui.instance.snapElements[i].top, b = t + ui.instance.snapElements[i].height;
+
+ //Yes, I know, this is insane ;)
+ if(!((l-d < x1 && x1 < r+d && t-d < y1 && y1 < b+d) || (l-d < x1 && x1 < r+d && t-d < y2 && y2 < b+d) || (l-d < x2 && x2 < r+d && t-d < y1 && y1 < b+d) || (l-d < x2 && x2 < r+d && t-d < y2 && y2 < b+d))) continue;
+
+ if(ui.options.snapMode != 'inner') {
+ var ts = Math.abs(t - y2) <= 20;
+ var bs = Math.abs(b - y1) <= 20;
+ var ls = Math.abs(l - x2) <= 20;
+ var rs = Math.abs(r - x1) <= 20;
+ if(ts) ui.position.top = t - ui.instance.offset.top + ui.instance.clickOffset.top - ui.instance.helperProportions.height;
+ if(bs) ui.position.top = b - ui.instance.offset.top + ui.instance.clickOffset.top;
+ if(ls) ui.position.left = l - ui.instance.offset.left + ui.instance.clickOffset.left - ui.instance.helperProportions.width;
+ if(rs) ui.position.left = r - ui.instance.offset.left + ui.instance.clickOffset.left;
+ }
+
+ if(ui.options.snapMode != 'outer') {
+ var ts = Math.abs(t - y1) <= 20;
+ var bs = Math.abs(b - y2) <= 20;
+ var ls = Math.abs(l - x1) <= 20;
+ var rs = Math.abs(r - x2) <= 20;
+ if(ts) ui.position.top = t - ui.instance.offset.top + ui.instance.clickOffset.top;
+ if(bs) ui.position.top = b - ui.instance.offset.top + ui.instance.clickOffset.top - ui.instance.helperProportions.height;
+ if(ls) ui.position.left = l - ui.instance.offset.left + ui.instance.clickOffset.left;
+ if(rs) ui.position.left = r - ui.instance.offset.left + ui.instance.clickOffset.left - ui.instance.helperProportions.width;
+ }
+
+ };
}
-
-
});
-
-//----------------------------------------------------------------
-
- $.ui.plugin.add("draggable", "drag", "grid", function(e,ui) {
- var o = ui.options;
- if(!o.cursorAtIgnore) return;
- ui.draggable.pos[0] = o.co.left + o.margins.left - o.po.left + Math.round((ui.draggable.pos[0] - o.co.left - o.margins.left + o.po.left) / o.grid[0]) * o.grid[0];
- ui.draggable.pos[1] = o.co.top + o.margins.top - o.po.top + Math.round((ui.draggable.pos[1] - o.co.top - o.margins.top + o.po.top) / o.grid[1]) * o.grid[1];
- });
-
-//----------------------------------------------------------------
-
- $.ui.plugin.add("draggable", "drag", "axis", function(e,ui) {
- var o = ui.options;
- if(!o.cursorAtIgnore) return;
- if(o.constraint) o.axis = o.constraint; //Legacy check
- o.axis ? ( o.axis == 'x' ? ui.draggable.pos[1] = o.co.top - o.margins.top - o.po.top : ui.draggable.pos[0] = o.co.left - o.margins.left - o.po.left ) : null;
- });
-
-//----------------------------------------------------------------
-
- $.ui.plugin.add("draggable", "drag", "scroll", function(e,ui) {
-
- var o = ui.options;
- o.scrollSensitivity = o.scrollSensitivity || 20;
- o.scrollSpeed = o.scrollSpeed || 20;
-
- if(o.pp && o.ppOverflow) { // If we have a positioned parent, we only scroll in this one
- // TODO: Extremely strange issues are waiting here..handle with care
- } else {
- if((ui.draggable.rpos[1] - $(window).height()) - $(document).scrollTop() > -o.scrollSensitivity) window.scrollBy(0,o.scrollSpeed);
- if(ui.draggable.rpos[1] - $(document).scrollTop() < o.scrollSensitivity) window.scrollBy(0,-o.scrollSpeed);
- if((ui.draggable.rpos[0] - $(window).width()) - $(document).scrollLeft() > -o.scrollSensitivity) window.scrollBy(o.scrollSpeed,0);
- if(ui.draggable.rpos[0] - $(document).scrollLeft() < o.scrollSensitivity) window.scrollBy(-o.scrollSpeed,0);
- }
-
- });
-
-//----------------------------------------------------------------
-
- $.ui.plugin.add("draggable", "drag", "wrapHelper", function(e,ui) {
-
- var o = ui.options;
- if(o.cursorAtIgnore) return;
- var t = ui.helper;
-
- if(!o.pp || !o.ppOverflow) {
- var wx = $(window).width() - ($.browser.mozilla ? 20 : 0);
- var sx = $(document).scrollLeft();
-
- var wy = $(window).height();
- var sy = $(document).scrollTop();
- } else {
- var wx = o.pp.offsetWidth + o.po.left - 20;
- var sx = o.pp.scrollLeft;
-
- var wy = o.pp.offsetHeight + o.po.top - 20;
- var sy = o.pp.scrollTop;
- }
-
- ui.draggable.pos[0] -= ((ui.draggable.rpos[0]-o.cursorAt.left - wx + t.offsetWidth+o.margins.right) - sx > 0 || (ui.draggable.rpos[0]-o.cursorAt.left+o.margins.left) - sx < 0) ? (t.offsetWidth+o.margins.left+o.margins.right - o.cursorAt.left * 2) : 0;
-
- ui.draggable.pos[1] -= ((ui.draggable.rpos[1]-o.cursorAt.top - wy + t.offsetHeight+o.margins.bottom) - sy > 0 || (ui.draggable.rpos[1]-o.cursorAt.top+o.margins.top) - sy < 0) ? (t.offsetHeight+o.margins.top+o.margins.bottom - o.cursorAt.top * 2) : 0;
-
- });
-
- //Make nodes selectable by expression
- $.extend($.expr[':'], { droppable: "(' '+a.className+' ').indexOf(' ui-droppable ')" });
-
- //Macros for external methods that support chaining
- var methods = "destroy,enable,disable".split(",");
- for(var i=0;i t && y1 < t) || (y1 < b && y2 > b) || (x2 > l && x1 < l) || (x1 < r && x2 > r))) return false;
+
+ if(y2-(draggable.helperProportions.height/2) > t && y1 < t) return 1; //Crosses top edge
+ if(y1 < b && y2 > b) return 2; //Crosses bottom edge
+ if(x2 > l && x1 < l) return 1; //Crosses left edge
+ if(x1 < r && x2 > r) return 2; //Crosses right edge
+
+ //return ( l < x1 && x2 < r
+ // && t < y1 && y2 < b);
break;
case 'intersect':
- return ( l < x1 + (oDrag.helperSize.width / 2) // Right Half
- && x2 - (oDrag.helperSize.width / 2) < r // Left Half
- && t < y1 + (oDrag.helperSize.height / 2) // Bottom Half
- && y2 - (oDrag.helperSize.height / 2) < b ); // Top Half
+ return ( l < x1 + (draggable.helperProportions.width / 2) // Right Half
+ && x2 - (draggable.helperProportions.width / 2) < r // Left Half
+ && t < y1 + (draggable.helperProportions.height / 2) // Bottom Half
+ && y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
break;
case 'pointer':
- return ( l < oDrag.rpos[0] && oDrag.rpos[0] < r
- && t < oDrag.rpos[1] && oDrag.rpos[1] < b);
+ return ( l < ((draggable.positionAbs || draggable.position.absolute).left + draggable.clickOffset.left) && ((draggable.positionAbs || draggable.position.absolute).left + draggable.clickOffset.left) < r
+ && t < ((draggable.positionAbs || draggable.position.absolute).top + draggable.clickOffset.top) && ((draggable.positionAbs || draggable.position.absolute).top + draggable.clickOffset.top) < b);
break;
case 'touch':
- return ( (l < x1 && x1 < r && t < y1 && y1 < b) // Top-Left Corner
- || (l < x1 && x1 < r && t < y2 && y2 < b) // Bottom-Left Corner
- || (l < x2 && x2 < r && t < y1 && y1 < b) // Top-Right Corner
- || (l < x2 && x2 < r && t < y2 && y2 < b) ); // Bottom-Right Corner
+ return ( (y1 >= t && y1 <= b) || // Top edge touching
+ (y2 >= t && y2 <= b) || // Bottom edge touching
+ (y1 < t && y2 > b) // Surrounded vertically
+ ) && (
+ (x1 >= l && x1 <= r) || // Left edge touching
+ (x2 >= l && x2 <= r) || // Right edge touching
+ (x1 < l && x2 > r) // Surrounded horizontally
+ );
break;
default:
return false;
break;
+ }
+
+ };
+
+ /*
+ This manager tracks offsets of draggables and droppables
+ */
+ $.ui.ddmanager = {
+ current: null,
+ droppables: [],
+ prepareOffsets: function(t, e) {
+
+ var m = $.ui.ddmanager.droppables;
+ var type = e ? e.type : null; // workaround for #2317
+ for (var i = 0; i < m.length; i++) {
+
+ if(m[i].options.disabled || (t && !m[i].options.accept.call(m[i].element,(t.currentItem || t.element)))) continue;
+ m[i].visible = m[i].element.is(":visible"); if(!m[i].visible) continue; //If the element is not visible, continue
+ m[i].offset = m[i].element.offset();
+ m[i].proportions = { width: m[i].element.outerWidth(), height: m[i].element.outerHeight() };
+
+ if(type == "dragstart") m[i].activate.call(m[i], e); //Activate the droppable if used directly from draggables
+ }
+
+ },
+ drop: function(draggable, e) {
+
+ var dropped = false;
+ $.each($.ui.ddmanager.droppables, function() {
+
+ if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance))
+ dropped = this.drop.call(this, e);
+
+ if (!this.options.disabled && this.visible && this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
+ this.isout = 1; this.isover = 0;
+ this.deactivate.call(this, e);
+ }
+
+ });
+ return dropped;
+
+ },
+ drag: function(draggable, e) {
+
+ //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
+ if(draggable.options.refreshPositions) $.ui.ddmanager.prepareOffsets(draggable, e);
+
+ //Run through all droppables and check their positions based on specific tolerance options
+ $.each($.ui.ddmanager.droppables, function() {
+
+ if(this.disabled || this.greedyChild || !this.visible) return;
+ var intersects = $.ui.intersect(draggable, this, this.options.tolerance);
+
+ var c = !intersects && this.isover == 1 ? 'isout' : (intersects && this.isover == 0 ? 'isover' : null);
+ if(!c) return;
+
+ var parentInstance;
+ if (this.options.greedy) {
+ var parent = this.element.parents('.ui-droppable:eq(0)');
+ if (parent.length) {
+ parentInstance = $.data(parent[0], 'droppable');
+ parentInstance.greedyChild = (c == 'isover' ? 1 : 0);
+ }
+ }
+
+ // we just moved into a greedy child
+ if (parentInstance && c == 'isover') {
+ parentInstance['isover'] = 0;
+ parentInstance['isout'] = 1;
+ parentInstance.out.call(parentInstance, e);
+ }
+
+ this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
+ this[c == "isover" ? "over" : "out"].call(this, e);
+
+ // we just moved out of a greedy child
+ if (parentInstance && c == 'isout') {
+ parentInstance['isout'] = 0;
+ parentInstance['isover'] = 1;
+ parentInstance.over.call(parentInstance, e);
+ }
+ });
+
}
};
- // options.activeClass
- $.ui.plugin.add("droppable", "activate", "activeClass", function(e,ui) {
- $(this).addClass(ui.options.activeClass);
+/*
+ * Droppable Extensions
+ */
+
+ $.ui.plugin.add("droppable", "activeClass", {
+ activate: function(e, ui) {
+ $(this).addClass(ui.options.activeClass);
+ },
+ deactivate: function(e, ui) {
+ $(this).removeClass(ui.options.activeClass);
+ },
+ drop: function(e, ui) {
+ $(this).removeClass(ui.options.activeClass);
+ }
});
- $.ui.plugin.add("droppable", "deactivate", "activeClass", function(e,ui) {
- $(this).removeClass(ui.options.activeClass);
+
+ $.ui.plugin.add("droppable", "hoverClass", {
+ over: function(e, ui) {
+ $(this).addClass(ui.options.hoverClass);
+ },
+ out: function(e, ui) {
+ $(this).removeClass(ui.options.hoverClass);
+ },
+ drop: function(e, ui) {
+ $(this).removeClass(ui.options.hoverClass);
+ }
});
- $.ui.plugin.add("droppable", "drop", "activeClass", function(e,ui) {
- $(this).removeClass(ui.options.activeClass);
- });
-
- // options.hoverClass
- $.ui.plugin.add("droppable", "over", "hoverClass", function(e,ui) {
- $(this).addClass(ui.options.hoverClass);
- });
- $.ui.plugin.add("droppable", "out", "hoverClass", function(e,ui) {
- $(this).removeClass(ui.options.hoverClass);
- });
- $.ui.plugin.add("droppable", "drop", "hoverClass", function(e,ui) {
- $(this).removeClass(ui.options.hoverClass);
- });
-
+
})(jQuery);
diff --git a/static/scripts/pack_scripts.py b/static/scripts/pack_scripts.py
index 732eda31ee2..0bf5ac4e68b 100755
--- a/static/scripts/pack_scripts.py
+++ b/static/scripts/pack_scripts.py
@@ -1,16 +1,26 @@
#!/usr/bin/env python
+import sys
+
from glob import glob
from subprocess import call
from shutil import copyfile
from os import path
-# Scripts that should not be packed
+# Scripts that should not be packed -- just copied
do_not_pack = set( [ "ie_pngfix.js", "aflax.js" ] )
-cmd = "java -jar ../../scripts/yuicompressor.jar --warn %(fname)s > packed/%(fname)s"
+cmd = "java -jar ../../scripts/yuicompressor.jar --type js -v %(fname)s -o packed/%(fname)s"
-for fname in glob( "*.js" ):
+# If specific scripts specified on command line, just pack them, otherwise pack
+# all.
+
+if len( sys.argv ) > 1:
+ to_pack = sys.argv[1:]
+else:
+ to_pack = glob( "*.js" )
+
+for fname in to_pack:
d = dict( fname=fname )
print "%(fname)s --> packed/%(fname)s" % d
if fname in do_not_pack:
diff --git a/static/scripts/packed/galaxy.panels.js b/static/scripts/packed/galaxy.panels.js
index 6f5da46ac99..dfe7e95e8bb 100644
--- a/static/scripts/packed/galaxy.panels.js
+++ b/static/scripts/packed/galaxy.panels.js
@@ -1 +1 @@
-var hidden_width=7;var border_tweak=jQuery.browser.msie?14:9;var jq=jQuery;function ensure_dd_helper(){if(jq("#DD-helper").length==0){var A=jq("");if(jq.browser.ie){A.css("opacity","0.01")}A.appendTo("body").hide()}}function make_left_panel(E,A,B){var D=false;var C=null;resize=function(F){var G=F;if(F<0){F=0}jq(E).css("width",F);jq(B).css("left",G);jq(A).css("left",F+7)};toggle=function(){if(D){jq(B).removeClass("hover");jq(B).animate({left:C},"fast");jq(E).css("left",-C).show().animate({"left":0},"fast",function(){resize(C);jq(B).removeClass("hidden")});D=false}else{C=jq(B).position().left;jq(A).css("left",hidden_width);jq(B).removeClass("hover");jq(E).animate({left:-C},"fast");jq(B).animate({left:-1},"fast",function(){jq(this).addClass("hidden")});D=true}};jq(B).hover(function(){jq(this).addClass("hover")},function(){jq(this).removeClass("hover")}).draggable({start:function(F,G){jq("#DD-helper").show()},stop:function(F,G){jq("#DD-helper").hide();return false},drag:function(F,G){x=G.position.left;x=Math.min(400,Math.max(100,x));if(D){jq(E).css("left",0);jq(B).removeClass("hidden");D=false}resize(x);G.draggable.pos[0]=x;G.draggable.pos[1]=G.options.co.top},click:function(){toggle()}}).find("div").show()}function make_right_panel(A,E,G){var I=false;var F=false;var C=null;var D=function(J){jq(A).css("width",J);jq(E).css("right",J+9);jq(G).css("right",J).css("left","")};var H=function(){if(I){jq(G).removeClass("hover");jq(G).animate({right:C},"fast");jq(A).css("right",-C).show().animate({"right":0},"fast",function(){D(C);jq(G).removeClass("hidden")});I=false}else{C=jq(document).width()-jq(G).position().left-border_tweak;jq(E).css("right",hidden_width+1);jq(G).removeClass("hover");jq(A).animate({right:-C},"fast");jq(G).animate({right:-1},"fast",function(){jq(this).addClass("hidden")});I=true}F=false};var B=function(J){var K=jq(E).width()-(I?C:0);if(K");if(jq.browser.ie){A.css("opacity","0.01")}A.appendTo("body").hide()}if(jq("#popup-helper").length==0){var A=jq("");if(jq.browser.ie){A.css("opacity","0.01")}A.appendTo("body").hide()}}function make_left_panel(E,A,B){var D=false;var C=null;resize=function(F){var G=F;if(F<0){F=0}jq(E).css("width",F);jq(B).css("left",G);jq(A).css("left",F+7);if(document.recalc){document.recalc()}};toggle=function(){if(D){jq(B).removeClass("hover");jq(B).animate({left:C},"fast");jq(E).css("left",-C).show().animate({left:0},"fast",function(){resize(C);jq(B).removeClass("hidden")});D=false}else{C=jq(B).position().left;jq(A).css("left",hidden_width);if(document.recalc){document.recalc()}jq(B).removeClass("hover");jq(E).animate({left:-C},"fast");jq(B).animate({left:-1},"fast",function(){jq(this).addClass("hidden")});D=true}};jq(B).hover(function(){jq(this).addClass("hover")},function(){jq(this).removeClass("hover")}).draggable({start:function(F,G){jq("#DD-helper").show()},stop:function(F,G){jq("#DD-helper").hide();return false},drag:function(F,G){x=G.position.left;x=Math.min(400,Math.max(100,x));if(D){jq(E).css("left",0);jq(B).removeClass("hidden");D=false}resize(x);G.position.left=x;G.position.top=G.instance.originalPosition.top},click:function(){toggle()}}).find("div").show()}function make_right_panel(A,E,G){var I=false;var F=false;var C=null;var D=function(J){jq(A).css("width",J);jq(E).css("right",J+9);jq(G).css("right",J).css("left","");if(document.recalc){document.recalc()}};var H=function(){if(I){jq(G).removeClass("hover");jq(G).animate({right:C},"fast");jq(A).css("right",-C).show().animate({right:0},"fast",function(){D(C);jq(G).removeClass("hidden")});I=false}else{C=jq(document).width()-jq(G).position().left-border_tweak;jq(E).css("right",hidden_width+1);if(document.recalc){document.recalc()}jq(G).removeClass("hover");jq(A).animate({right:-C},"fast");jq(G).animate({right:-1},"fast",function(){jq(this).addClass("hidden")});I=true}F=false};var B=function(J){var K=jq(E).width()-(I?C:0);if(K