diff options
Diffstat (limited to 'ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop')
12 files changed, 1274 insertions, 0 deletions
diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/jquery.event.drop.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/jquery.event.drop.js new file mode 100644 index 00000000..7599ef91 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/jquery.event.drop.js @@ -0,0 +1,302 @@ +/*! + * jquery.event.drop - v 2.2 + * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com + * Open Source MIT License - http://threedubmedia.com/code/license + */ +// Created: 2008-06-04 +// Updated: 2012-05-21 +// REQUIRES: jquery 1.7.x, event.drag 2.2 + +;(function($){ // secure $ jQuery alias + +// Events: drop, dropstart, dropend + +// add the jquery instance method +$.fn.drop = function( str, arg, opts ){ + // figure out the event type + var type = typeof str == "string" ? str : "", + // figure out the event handler... + fn = $.isFunction( str ) ? str : $.isFunction( arg ) ? arg : null; + // fix the event type + if ( type.indexOf("drop") !== 0 ) + type = "drop"+ type; + // were options passed + opts = ( str == fn ? arg : opts ) || {}; + // trigger or bind event handler + return fn ? this.bind( type, opts, fn ) : this.trigger( type ); +}; + +// DROP MANAGEMENT UTILITY +// returns filtered drop target elements, caches their positions +$.drop = function( opts ){ + opts = opts || {}; + // safely set new options... + drop.multi = opts.multi === true ? Infinity : + opts.multi === false ? 1 : !isNaN( opts.multi ) ? opts.multi : drop.multi; + drop.delay = opts.delay || drop.delay; + drop.tolerance = $.isFunction( opts.tolerance ) ? opts.tolerance : + opts.tolerance === null ? null : drop.tolerance; + drop.mode = opts.mode || drop.mode || 'intersect'; +}; + +// local refs (increase compression) +var $event = $.event, +$special = $event.special, +// configure the drop special event +drop = $.event.special.drop = { + + // these are the default settings + multi: 1, // allow multiple drop winners per dragged element + delay: 20, // async timeout delay + mode: 'overlap', // drop tolerance mode + + // internal cache + targets: [], + + // the key name for stored drop data + datakey: "dropdata", + + // prevent bubbling for better performance + noBubble: true, + + // count bound related events + add: function( obj ){ + // read the interaction data + var data = $.data( this, drop.datakey ); + // count another realted event + data.related += 1; + }, + + // forget unbound related events + remove: function(){ + $.data( this, drop.datakey ).related -= 1; + }, + + // configure the interactions + setup: function(){ + // check for related events + if ( $.data( this, drop.datakey ) ) + return; + // initialize the drop element data + var data = { + related: 0, + active: [], + anyactive: 0, + winner: 0, + location: {} + }; + // store the drop data on the element + $.data( this, drop.datakey, data ); + // store the drop target in internal cache + drop.targets.push( this ); + }, + + // destroy the configure interaction + teardown: function(){ + var data = $.data( this, drop.datakey ) || {}; + // check for related events + if ( data.related ) + return; + // remove the stored data + $.removeData( this, drop.datakey ); + // reference the targeted element + var element = this; + // remove from the internal cache + drop.targets = $.grep( drop.targets, function( target ){ + return ( target !== element ); + }); + }, + + // shared event handler + handler: function( event, dd ){ + // local vars + var results, $targets; + // make sure the right data is available + if ( !dd ) + return; + // handle various events + switch ( event.type ){ + // draginit, from $.event.special.drag + case 'mousedown': // DROPINIT >> + case 'touchstart': // DROPINIT >> + // collect and assign the drop targets + $targets = $( drop.targets ); + if ( typeof dd.drop == "string" ) + $targets = $targets.filter( dd.drop ); + // reset drop data winner properties + $targets.each(function(){ + var data = $.data( this, drop.datakey ); + data.active = []; + data.anyactive = 0; + data.winner = 0; + }); + // set available target elements + dd.droppable = $targets; + // activate drop targets for the initial element being dragged + $special.drag.hijack( event, "dropinit", dd ); + break; + // drag, from $.event.special.drag + case 'mousemove': // TOLERATE >> + case 'touchmove': // TOLERATE >> + drop.event = event; // store the mousemove event + if ( !drop.timer ) + // monitor drop targets + drop.tolerate( dd ); + break; + // dragend, from $.event.special.drag + case 'mouseup': // DROP >> DROPEND >> + case 'touchend': // DROP >> DROPEND >> + drop.timer = clearTimeout( drop.timer ); // delete timer + if ( dd.propagates ){ + $special.drag.hijack( event, "drop", dd ); + $special.drag.hijack( event, "dropend", dd ); + } + break; + + } + }, + + // returns the location positions of an element + locate: function( elem, index ){ + var data = $.data( elem, drop.datakey ), + $elem = $( elem ), + posi = $elem.offset() || {}, + height = $elem.outerHeight(), + width = $elem.outerWidth(), + location = { + elem: elem, + width: width, + height: height, + top: posi.top, + left: posi.left, + right: posi.left + width, + bottom: posi.top + height + }; + // drag elements might not have dropdata + if ( data ){ + data.location = location; + data.index = index; + data.elem = elem; + } + return location; + }, + + // test the location positions of an element against another OR an X,Y coord + contains: function( target, test ){ // target { location } contains test [x,y] or { location } + return ( ( test[0] || test.left ) >= target.left && ( test[0] || test.right ) <= target.right + && ( test[1] || test.top ) >= target.top && ( test[1] || test.bottom ) <= target.bottom ); + }, + + // stored tolerance modes + modes: { // fn scope: "$.event.special.drop" object + // target with mouse wins, else target with most overlap wins + 'intersect': function( event, proxy, target ){ + return this.contains( target, [ event.pageX, event.pageY ] ) ? // check cursor + 1e9 : this.modes.overlap.apply( this, arguments ); // check overlap + }, + // target with most overlap wins + 'overlap': function( event, proxy, target ){ + // calculate the area of overlap... + return Math.max( 0, Math.min( target.bottom, proxy.bottom ) - Math.max( target.top, proxy.top ) ) + * Math.max( 0, Math.min( target.right, proxy.right ) - Math.max( target.left, proxy.left ) ); + }, + // proxy is completely contained within target bounds + 'fit': function( event, proxy, target ){ + return this.contains( target, proxy ) ? 1 : 0; + }, + // center of the proxy is contained within target bounds + 'middle': function( event, proxy, target ){ + return this.contains( target, [ proxy.left + proxy.width * .5, proxy.top + proxy.height * .5 ] ) ? 1 : 0; + } + }, + + // sort drop target cache by by winner (dsc), then index (asc) + sort: function( a, b ){ + return ( b.winner - a.winner ) || ( a.index - b.index ); + }, + + // async, recursive tolerance execution + tolerate: function( dd ){ + // declare local refs + var i, drp, drg, data, arr, len, elem, + // interaction iteration variables + x = 0, ia, end = dd.interactions.length, + // determine the mouse coords + xy = [ drop.event.pageX, drop.event.pageY ], + // custom or stored tolerance fn + tolerance = drop.tolerance || drop.modes[ drop.mode ]; + // go through each passed interaction... + do if ( ia = dd.interactions[x] ){ + // check valid interaction + if ( !ia ) + return; + // initialize or clear the drop data + ia.drop = []; + // holds the drop elements + arr = []; + len = ia.droppable.length; + // determine the proxy location, if needed + if ( tolerance ) + drg = drop.locate( ia.proxy ); + // reset the loop + i = 0; + // loop each stored drop target + do if ( elem = ia.droppable[i] ){ + data = $.data( elem, drop.datakey ); + drp = data.location; + if ( !drp ) continue; + // find a winner: tolerance function is defined, call it + data.winner = tolerance ? tolerance.call( drop, drop.event, drg, drp ) + // mouse position is always the fallback + : drop.contains( drp, xy ) ? 1 : 0; + arr.push( data ); + } while ( ++i < len ); // loop + // sort the drop targets + arr.sort( drop.sort ); + // reset the loop + i = 0; + // loop through all of the targets again + do if ( data = arr[ i ] ){ + // winners... + if ( data.winner && ia.drop.length < drop.multi ){ + // new winner... dropstart + if ( !data.active[x] && !data.anyactive ){ + // check to make sure that this is not prevented + if ( $special.drag.hijack( drop.event, "dropstart", dd, x, data.elem )[0] !== false ){ + data.active[x] = 1; + data.anyactive += 1; + } + // if false, it is not a winner + else + data.winner = 0; + } + // if it is still a winner + if ( data.winner ) + ia.drop.push( data.elem ); + } + // losers... + else if ( data.active[x] && data.anyactive == 1 ){ + // former winner... dropend + $special.drag.hijack( drop.event, "dropend", dd, x, data.elem ); + data.active[x] = 0; + data.anyactive -= 1; + } + } while ( ++i < len ); // loop + } while ( ++x < end ) // loop + // check if the mouse is still moving or is idle + if ( drop.last && xy[0] == drop.last.pageX && xy[1] == drop.last.pageY ) + delete drop.timer; // idle, don't recurse + else // recurse + drop.timer = setTimeout(function(){ + drop.tolerate( dd ); + }, drop.delay ); + // remember event, to compare idleness + drop.last = drop.event; + } + +}; + +// share the same special event configuration with related events... +$special.dropinit = $special.dropstart = $special.dropend = drop; + +})(jQuery); // confine scope
\ No newline at end of file diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/jquery.event.drop.live.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/jquery.event.drop.live.js new file mode 100644 index 00000000..f5911a10 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/jquery.event.drop.live.js @@ -0,0 +1,93 @@ +/*! + * jquery.event.drop.live - v 2.2 + * Copyright (c) 2010 Three Dub Media - http://threedubmedia.com + * Open Source MIT License - http://threedubmedia.com/code/license + */ +// Created: 2010-06-07 +// Updated: 2012-05-21 +// REQUIRES: jquery 1.7.x, event.drag 2.2, event.drop 2.2 + +;(function($){ // secure $ jQuery alias + +// local refs (increase compression) +var $event = $.event, +// ref the drop special event config +drop = $event.special.drop, +// old drop event add method +origadd = drop.add, +// old drop event teradown method +origteardown = drop.teardown; + +// allow events to bubble for delegation +drop.noBubble = false; + +// the namespace for internal live events +drop.livekey = "livedrop"; + +// new drop event add method +drop.add = function( obj ){ + // call the old method + origadd.apply( this, arguments ); + // read the data + var data = $.data( this, drop.datakey ); + // bind the live "dropinit" delegator + if ( !data.live && obj.selector ){ + data.live = true; + $event.add( this, "dropinit."+ drop.livekey, drop.delegate ); + } +}; + +// new drop event teardown method +drop.teardown = function(){ + // call the old method + origteardown.apply( this, arguments ); + // read the data + var data = $.data( this, drop.datakey ) || {}; + // remove the live "dropinit" delegator + if ( data.live ){ + // remove the "live" delegation + $event.remove( this, "dropinit", drop.delegate ); + data.live = false; + } +}; + +// identify potential delegate elements +drop.delegate = function( event, dd ){ + // local refs + var elems = [], $targets, + // element event structure + events = $.data( this, "events" ) || {}; + // query live events + $.each( events || [], function( key, arr ){ + // no event type matches + if ( key.indexOf("drop") !== 0 ) + return; + $.each( arr, function( i, obj ){ + // locate the elements to delegate + $targets = $( event.currentTarget ).find( obj.selector ); + // no element found + if ( !$targets.length ) + return; + // take each target... + $targets.each(function(){ + // add an event handler + $event.add( this, obj.origType +'.'+ drop.livekey, obj.origHandler || obj.handler, obj.data ); + // remember new elements + if ( $.inArray( this, elems ) < 0 ) + elems.push( this ); + }); + }); + }); + // may not exist when artifically triggering dropinit event + if ( dd ) + // clean-up after the interaction ends + $event.add( dd.drag, "dragend."+drop.livekey, function(){ + $.each( elems.concat( this ), function(){ + $event.remove( this, '.'+ drop.livekey ); + }); + }); + //drop.delegates.push( elems ); + return elems.length ? $( elems ) : false; +}; + +})( jQuery ); // confine scope
\ No newline at end of file diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/binding.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/binding.js new file mode 100644 index 00000000..e7541150 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/binding.js @@ -0,0 +1,32 @@ +module("Event Binding"); + +$.each(['dropinit','dropstart','drop','dropend'],function( i, type ){ + + test('"'+ type +'"',function(){ + + expect( 9 ); + + // make sure the event handler gets bound to the element + var $elem = $('<div />'), + elem = $elem[0], + count = 0, + fn = function(){ + count += 1; + }; + + ok( $elem.bind( type, fn )[0] == elem, '.bind("'+ type +'", fn )' ); + ok( $.data( elem, $.event.special.drop.datakey ), "drop data exists" ); + ok( $.data( elem, "events" ), "event data exists" ); + ok( $.data( elem, "events" )[ type ][0], '"'+ type +'" event handler added' ); + + ok( $elem.trigger( type )[0] == elem, '.trigger("'+ type +'")' ); + ok( count == 1, "handler was triggered"); + + ok( $elem.unbind( type )[0] == elem, '.unbind("'+ type +'")' ); + ok( !$.data( elem, "events" ), "event data removed" ); + ok( !$.data( elem, $.event.special.drop.datakey ), "drop data removed" ); + + $elem.remove(); + + }); +});
\ No newline at end of file diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/handlers.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/handlers.js new file mode 100644 index 00000000..f38526ac --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/handlers.js @@ -0,0 +1,130 @@ +;(function(){ + + module("Event Handlers"); + + // a simple re-usable test harness object + var obj = { + init: function( opts ){ + obj.$drag = $('<div class="drag"/>') + .appendTo( document.body ) + .css({ + position: 'absolute', + top: 0, + left: 0, + height: 100, + width: 100 + }) + .bind("dragend",{ drop:'.drop' },function( event, dd ){ + same( dd.drop, obj.dragend, "drop (dragend)" ); + }); + obj.$drop = $('<div class="drop"/><div class="extra"/>') + .appendTo( document.body ) + .css({ + position: 'absolute', + top: 0, + left: 0, + height: 100, + width: 100 + }) + .bind("dropinit dropstart drop dropend",function( event, dd ){ + obj[ event.type ] += 1; + return obj.returned[ event.type ]; + }); + $.extend( obj, { dropinit:0, dropstart:0, drop:0, dropend:0 }); + $.drop({ mode:'overlap', multi:false }); + obj.returned = {}; + obj.dragend = null; + }, + mouse: function(){ + var start = { + pageX: Math.round( Math.random() * 90 ) + 5, + pageY: Math.round( Math.random() * 90 ) + 5 + }, + end = { + pageX: Math.round( Math.random() * 90 ) + start.pageX, + pageY: Math.round( Math.random() * 90 ) + start.pageY + }; + // simulate a complete mouse drag + obj.$drag + .fire("mousedown", start ) + .fire("mousemove", end ) + .fire("mouseup", end ) + .fire("click", end ); + }, + done: function( ms ){ + obj.$drag.remove(); + obj.$drop.remove(); + start(); + } + }; + + asyncTest('"dropinit" return false',function(){ + expect( 5 ); + // test prep + obj.init(); + obj.returned['dropinit'] = false; + obj.dragend = []; + // simulate a partial drag + obj.mouse(); + // check counts + equals( obj.dropinit, 1, "dropinit"); + equals( obj.dropstart, 0, "dropstart"); + equals( obj.drop, 0, "drop"); + equals( obj.dropend, 0, "dropend"); + // continue + obj.done(); + }); + + asyncTest('"dropstart" return false',function(){ + expect( 5 ); + // test prep + obj.init(); + obj.returned['dropstart'] = false; + obj.dragend = []; + // simulate a partial drag + obj.mouse(); + // check counts + equals( obj.dropinit, 1, "dropinit"); + equals( obj.dropstart, 1, "dropstart"); + equals( obj.drop, 0, "drop"); + equals( obj.dropend, 0, "dropend"); + // continue + obj.done(); + }); + + + asyncTest('"drop" return false',function(){ + expect( 5 ); + // test prep + obj.init();// test DROP FALSE + obj.returned['drop'] = false; + obj.dragend = []; + // simulate a partial drag + obj.mouse(); + // check counts + equals( obj.dropinit, 1, "dropinit"); + equals( obj.dropstart, 1, "dropstart"); + equals( obj.drop, 1, "drop"); + equals( obj.dropend, 0, "dropend"); + // continue + obj.done(); + }); + + asyncTest('"dropinit" return elements',function(){ + expect( 5 ); + // test prep + obj.init(); + obj.returned['dropinit'] = obj.$drop.eq(1); + obj.dragend = [ obj.$drop[1] ]; + // simulate a partial drag + obj.mouse(); + // check counts + equals( obj.dropinit, 1, "dropinit"); + equals( obj.dropstart, 1, "dropstart"); + equals( obj.drop, 1, "drop"); + equals( obj.dropend, 1, "dropend"); + // continue + obj.done(); + }); + +})();
\ No newline at end of file diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/index.html b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/index.html new file mode 100644 index 00000000..65928704 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/index.html @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<link href="../../img/favicon.ico" rel="shortcut icon" /> +<link href="../../jquery/qunit.css" rel="stylesheet" /> +<script src="../../jquery/jquery.js"></script> +<script src="../../jquery/qunit.js"></script> +<script src="../../fire/jquery.fire.js"></script> +<script src="../../event.drag/jquery.event.drag.js"></script> +<script src="../../event.drag/jquery.event.drag.live.js"></script> +<script src="../jquery.event.drop.js"></script> +<script src="../jquery.event.drop.live.js"></script> +<script src="./requirements.js"></script> +<script src="./binding.js"></script> +<script src="./method.js"></script> +<script src="./tolerance.js"></script> +<script src="./interaction.js"></script> +<script src="./touch.js"></script> +<script src="./properties.js"></script> +<script src="./handlers.js"></script> +<script src="./live.js"></script> + +<title>ThreeDubMedia · jQuery.event.drop.js</title> +</head> +<body> +<h1 id="qunit-header">jQuery.event.drop.js Unit Tests</h1> +<h2 id="qunit-banner"></h2> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +</body> +</html>
\ No newline at end of file diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/interaction.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/interaction.js new file mode 100644 index 00000000..5b0f4f38 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/interaction.js @@ -0,0 +1,134 @@ +;(function(){ + + module("Mouse Interaction"); + + // a simple re-usable test harness object + var obj = { + init: function( opts ){ + obj.$drag = $('<div />') + .css({ + position: 'absolute', + top: 0, + left: 0, + height: 100, + width: 100 + }) + .appendTo( document.body ) + .bind("draginit dragstart drag dragend click", opts || {}, function( event ){ + obj[ event.type ] += 1; + }); + obj.$drop = $('<div />') + .css({ + position: 'absolute', + top: 0, + left: 0, + height: 100, + width: 100 + }) + .appendTo( document.body ) + .bind("dropinit dropstart drop dropend",function( event ){ + obj[ event.type ] += 1; + }); + $.extend( obj, { + draginit:0, dragstart:0, drag:0, dragend:0, + dropinit:0, dropstart:0, drop:0, dropend:0, + click:0 + }); + }, + mouse: function(){ + var start = { + pageX: Math.round( Math.random() * 90 ) + 5, + pageY: Math.round( Math.random() * 90 ) + 5 + }, + end = { + pageX: Math.round( Math.random() * 90 ) + start.pageX, + pageY: Math.round( Math.random() * 90 ) + start.pageY + }; + // simulate a complete mouse drag + obj.$drag + .fire("mousedown", start ) + .fire("mousemove", end ) + .fire("mouseup", end ) + .fire("click", end ); + }, + done: function(){ + obj.$drag.remove(); + obj.$drop.remove(); + start(); + } + }; + + asyncTest('Drag and Drop defaults',function(){ + // prep DEFAULT interaction + obj.init(); + // simulate DEFAULT interaction + obj.mouse(); + // inspect results + equals( obj.draginit, 1, "draginit"); + equals( obj.dragstart, 1, "dragstart"); + equals( obj.drag, 1, "drag"); + equals( obj.dragend, 1, "dragend"); + equals( obj.dropinit, 1, "dropinit"); + equals( obj.dropstart, 1, "dropstart"); + equals( obj.drop, 1, "drop"); + equals( obj.dropend, 1, "dropend"); + // continue + obj.done(); + }); + + asyncTest('Drag "drop" option (false)',function(){ + // prep interaction + obj.init({ drop:false }); + // simulate drag + obj.mouse(); + // inspect results + equals( obj.draginit, 1, "draginit"); + equals( obj.dragstart, 1, "dragstart"); + equals( obj.drag, 1, "drag"); + equals( obj.dragend, 1, "dragend"); + equals( obj.dropinit, 0, "dropinit"); + equals( obj.dropstart, 0, "dropstart"); + equals( obj.drop, 0, "drop"); + equals( obj.dropend, 0, "dropend"); + // continue + obj.done(); + }); + + asyncTest('Drag "drop" option (unmatched)',function(){ + // prep interaction + obj.init({ drop:'body' }); + // simulate drag + obj.mouse(); + // inspect results + equals( obj.draginit, 1, "draginit"); + equals( obj.dragstart, 1, "dragstart"); + equals( obj.drag, 1, "drag"); + equals( obj.dragend, 1, "dragend"); + equals( obj.dropinit, 0, "dropinit"); + equals( obj.dropstart, 0, "dropstart"); + equals( obj.drop, 0, "drop"); + equals( obj.dropend, 0, "dropend"); + // continue + obj.done(); + }); + + asyncTest('Drag "drop" option (matched)',function(){ + // prep interaction + obj.init({ drop:'div' }); + // simulate drag + obj.mouse(); + // inspect results + equals( obj.draginit, 1, "draginit"); + equals( obj.dragstart, 1, "dragstart"); + equals( obj.drag, 1, "drag"); + equals( obj.dragend, 1, "dragend"); + equals( obj.dropinit, 1, "dropinit"); + equals( obj.dropstart, 1, "dropstart"); + equals( obj.drop, 1, "drop"); + equals( obj.dropend, 1, "dropend"); + // continue + obj.done(); + }); + +})(); + diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/live.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/live.js new file mode 100644 index 00000000..5e30130f --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/live.js @@ -0,0 +1,60 @@ +module("Live Delegation"); + +$.each(["dropinit","dropstart","drop","dropend"],function( i, type ){ + + test('"'+ type+'"',function(){ + + expect( i ? 5 : 1 ); + + if ( !i ){ + ok( true, 'Not supported for this event type.'); + return; + } + + // set up the delegation + $('.drop').live( type, function( event ){ + count += 1; + equals( this, $drop[0], event.type+" target" ); + }); + // local refs + var count = 0, + // add a div to test the delegation + $drop = $('<div class="drop" />') + .css({ + position: 'absolute', + top: 0, left: 0, + height: 100, width: 100 + }) + .appendTo( document.body ), + // add a dragger + $drag = $('<div class="drag" />') + .css({ + position: 'absolute', + top: 0, left: 0, + height: 100, width: 100 + }) + .appendTo( document.body ) + .drag(function(){ }); + + // check triggering of the event handlers + ok( $drop.trigger( type ), '.trigger("'+ type +'")'); + equals( count, 1, "event was triggered"); + + // simulate a complete drag + $drag + .fire("mousedown",{ pageX:50, pageY:50 }) + .fire("mousemove",{ pageX:51, pageY:51 }) + .fire("mouseup",{ pageX:51, pageY:51 }) + .fire("click",{ pageX:51, pageY:51 }); + + // check the event handler counts + equals( count, 2, "event was delegated"); + + // remove delegation + $('.drop').die( type ); + $drag.remove(); + $drop.remove(); + + }); + +});
\ No newline at end of file diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/method.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/method.js new file mode 100644 index 00000000..ea9a05d8 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/method.js @@ -0,0 +1,63 @@ +module("Drop Method"); + +$.each(['init','start','','end'],function( i, type ){ + + test('"drop'+ type +'"',function(){ + + expect( 9 ); + + // make sure the event handler gets bound to the element + var $elem = $('<div />'), + elem = $elem[0], + count = 0, + fn = function(){ + count += 1; + }; + + ok( $elem.drop( type, fn )[0] == elem, ".drop("+( type ? '"'+ type +'",' : "" )+" fn )" ); + ok( $.data( elem, $.event.special.drop.datakey ), "drop data exists" ); + ok( $.data( elem, "events" ), "event data exists" ); + ok( $.data( elem, "events" )[ 'drop'+type ][0], '"drop'+ type +'" event handler added' ); + + ok( $elem.drop( type )[0] == elem, ".drop("+( type ? '"'+ type +'"' : "" )+")" ); + ok( count == 1, "handler was triggered"); + + ok( $elem.unbind( "drop"+ type )[0] == elem, '.unbind("drop'+ type +'")' ); + ok( !$.data( elem, "events" ), "event data removed" ); + ok( !$.data( elem, $.event.special.drag.datakey ), "drag data removed" ); + + $elem.remove(); + + }); + +}); + +test('$.drop()',function(){ + + expect( 4 ); + + // call the static method with settings + var drop = $.event.special.drop, + def = { + multi: drop.multi, + delay: drop.delay, + mode: drop.mode, + tolerance: null + }, + opts = { + multi: 99, + delay: 88, + mode: 77, + tolerance: function(){} + }; + $.drop( opts ); + + ok( drop.multi == opts.multi, "multi option was set" ); + ok( drop.delay == opts.delay, "delay option was set" ); + ok( drop.mode == opts.mode, "mode option was set" ); + ok( drop.tolerance == opts.tolerance, "tolerance option was set" ); + + // restore defaults + $.drop( def ); + +});
\ No newline at end of file diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/properties.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/properties.js new file mode 100644 index 00000000..96185e9e --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/properties.js @@ -0,0 +1,62 @@ +module("Callback Properties"); + +$.each(["init","start","","end"],function( i, type ){ + + test('"drop'+ type +'" callback',function(){ + + expect( i ? 10 : 12 ); + + // create the markup for the test + var $drag = $('<div class="drag"/>') + .appendTo( document.body ) + .css({ + position: 'absolute', + top: 0, + left: 0, + height: 100, + width: 100 + }) + .bind("draginit",function( ev, dd ){ + same( dd.drop, [], 'draginit: "drop"' ); + same( dd.available, [], 'draginit: "available"' ); + }) + .bind("dragstart",function( ev, dd ){ + same( dd.drop, [], 'dragstart: "drop"' ); + same( dd.available, available, 'dragstart: "available"' ); + }) + .bind("drag",function( ev, dd ){ + same( dd.drop, [], 'drag: "drop"' ); + same( dd.available, available, 'drag: "available"' ); + }) + .bind("dragend",function( ev, dd ){ + same( dd.drop, drop, 'dragend: "drop"' ); + same( dd.available, available, 'dragend: "available"' ); + $drag.remove(); + $drop.remove(); + }), + $drop = $('<div class="drop"/><div class="drop"/>') + .appendTo( document.body ) + .css({ + position: 'absolute', + top: 0, + left: 0, + height: 100, + width: 100 + }) + .drop( type, function( ev, dd ){ + same( dd.drop, i < 2 ? [] : drop, 'drop'+ type +': "drop"' ); + same( dd.available, i < 1 ? [] : available, 'drop'+ type +': "available"' ); + }), + available = $drop.toArray(), + drop = $drop.eq(0).toArray(); + + $.drop({ mode:'overlap', multi:false }); + // simulate a complete drag and drop + $drag + .fire("mousedown",{ pageX:50, pageY:50 }) + .fire("mousemove",{ pageX:51, pageY:51 }) + .fire("mouseup",{ pageX:51, pageY:51 }) + .trigger("click"); + }); + +});
\ No newline at end of file diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/requirements.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/requirements.js new file mode 100644 index 00000000..697d2032 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/requirements.js @@ -0,0 +1,37 @@ +module("Requirements"); + +test("jQuery",function(){ + + expect( 2 ); + + // make sure the right jquery is included + ok( window.jQuery, "jQuery exists" ); + ok( parseFloat( jQuery([]).jquery ) >= 1.4, "jQuery version is 1.4 or greater" ); +}); + +test("$.event.special.drag",function(){ + + expect( 5 ); + + // make sure the event interface is complete + ok( jQuery.event.special.draginit, '"draginit" special event is defined' ); + ok( jQuery.event.special.dragstart, '"dragstart" special event is defined' ); + ok( jQuery.event.special.drag, '"drag" special event is defined' ); + ok( jQuery.event.special.dragend, '"dragend" special event is defined' ); + ok( jQuery([]).drag, "$.fn.drag method is defined" ); + +}); + +test("Installation",function(){ + + expect( 6 ); + + // make sure the event interface is complete + ok( jQuery.event.special.dropinit, '"dropinit" special event is defined' ); + ok( jQuery.event.special.dropstart, '"dropstart" special event is defined' ); + ok( jQuery.event.special.drop, '"drop" special event is defined' ); + ok( jQuery.event.special.dropend, '"dropend" special event is defined' ); + ok( jQuery([]).drop, '$.fn.drop method is defined' ); + ok( jQuery.drop, '$.drop method is defined' ); + +});
\ No newline at end of file diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/tolerance.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/tolerance.js new file mode 100644 index 00000000..4bdaf6e5 --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/tolerance.js @@ -0,0 +1,189 @@ +;(function(){ + + module("Tolerance Mode"); + + // re-usable test harness object + var obj = { + init: function( opts ){ + // the drop element + obj.$drop = $('<div />') + .css({ + position: 'absolute', + top: 200, + left: 200, + height: 100, + width: 100 + }) + .appendTo( document.body ) + .bind("dropinit",function( event ){ + if ( obj.multidrop ) + return $( this ) + .clone( true ) + .addClass('clone') + .appendTo( document.body ) + .add( this ); + }) + .bind("drop",function( event ){ + obj.count += 1; + }); + // the drag element + obj.$drag = $('<div />') + .css({ + position: 'absolute', + top: 100, + left: 100, + height: 100, + width: 100 + }) + .appendTo( document.body ) + .bind("draginit", function( event ){ + if ( obj.multidrag ) + return $( this ) + .clone( true ) + .addClass('clone') + .appendTo( document.body ) + .add( this ); + }) + .bind("dragstart",function( ev, dd ){ + if ( obj.proxy ) + return $( this ).clone() + .addClass('clone') + .appendTo( document.body ); + }) + .bind("drag",function( ev, dd ){ + if ( obj.move ) + $( dd.proxy ).css({ + top: dd.offsetY, + left: dd.offsetX + }); + }) + .bind("dragend",function( ev, dd ){ + var $div = $( this ).css({ + top: 100, + left: 100 + }); + $( document.body ).find('.clone').remove(); + }); + // reset test vars + obj.count = 0; + obj.move = obj.proxy = obj.multidrag = obj.multidrop = null; + }, + done: function(){ + obj.$drag.remove(); + obj.$drop.remove(); + start(); + } + }; + + // async iterator + function asyncEach( obj, func, after ){ + // local refs + var arr = [], i = 0, len; + // translate into a secondary array + $.each( obj, function( index, value ){ + len = arr.push({ that:this, index:index, value:value }); + }); + function next(){ + var data = arr[ i++ ], ret; + if ( i <= len ){ + if ( data ) + ret = func.call( data.that, data.index, data.value, next ); + if ( ret === false ) + done(); + } + else done(); + }; + function done(){ + if ( after ) + after(); + }; + next(); + } + + // test each mode... + $.each({ + 'mouse':{ + 'overlap':[0,0,0,0,0], + 'middle':[0,0,0,0,0], + 'fit':[0,0,0,0,0], + 'mouse':[1,1,1,2,4], + 'away':[0,0,0,0,0] + }, + 'overlap':{ + 'overlap':[0,1,1,2,4], + 'middle':[0,1,1,2,4], + 'fit':[0,1,1,2,4], + 'mouse':[0,0,0,0,0], + 'away':[0,0,0,0,0] + }, + 'middle':{ + 'overlap':[0,0,0,0,0], + 'middle':[0,1,1,2,4], + 'fit':[0,1,1,2,4], + 'mouse':[0,0,0,0,0], + 'away':[0,0,0,0,0] + }, + 'fit':{ + 'overlap':[0,0,0,0,0], + 'middle':[0,0,0,0,0], + 'fit':[0,1,1,2,4], + 'mouse':[0,0,0,0,0], + 'away':[0,0,0,0,0] + }, + 'intersect':{ + 'overlap':[0,1,1,2,4], + 'middle':[0,1,1,2,4], + 'fit':[0,1,1,2,4], + 'mouse':[1,1,1,2,4], + 'away':[0,0,0,0,0] + } + }, function( mode, expected ){ + + // test each mode + asyncTest('"'+ mode +'"',function(){ + + expect( 25 ); + + // test prep + obj.init(); + $.drop({ + mode:mode, + multi:true + }); + // drag to each position + asyncEach({ + 'overlap':{ pageX:33, pageY:33 }, + 'middle':{ pageX:66, pageY:66 }, + 'fit':{ pageX:100, pageY:100 }, + 'mouse':{ pageX:250, pageY:250 }, + 'away':{ pageX:-1, pageY:-1 } + }, function( where, coord, next ){ + // execute interaction variants + asyncEach([ + 'dropped '+ where +' (no motion)', + 'dropped '+ where +' (drag motion)', + 'dropped '+ where +' (proxy motion)', + 'dropped '+ where +' (multi drag)', + 'dropped '+ where +' (multi drop)' + ], function( i, msg, next ){ + // set-up + obj.count = 0; + obj.move = ( i > 0 ); + obj.proxy = ( i > 1 ); + obj.multidrag = ( i > 2 ); + obj.multidrop = ( i > 3 ); + // simulate a partial drag + obj.$drag + .fire("mousedown",{ pageX:0, pageY:0 }) + .fire("mousemove", coord ) + .fire("mouseup", coord ) + .fire("click", coord ); + equals( obj.count, expected[where][i], msg ); + next(); + }, next ); + }, obj.done ); + }); + + }); + +})();
\ No newline at end of file diff --git a/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/touch.js b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/touch.js new file mode 100644 index 00000000..b28177fc --- /dev/null +++ b/ecomp-portal-FE/client/bower_components/jquery.event.drag-new/event.drop/test/touch.js @@ -0,0 +1,140 @@ +;(function(){ + + module("Touch Interaction"); + + if ( !document.createEvent ){ + test("Touch Simulation Not Supported",function(){ + ok( true, 'This browser does not support "document.createEvent" and cannot simulate touch events.'); + }); + return; + } + + // a simple re-usable test harness object + var obj = { + init: function( opts ){ + obj.$drag = $('<div />') + .css({ + position: 'absolute', + top: 0, + left: 0, + height: 100, + width: 100 + }) + .appendTo( document.body ) + .bind("draginit dragstart drag dragend click", opts || {}, function( event ){ + obj[ event.type ] += 1; + }); + obj.$drop = $('<div />') + .css({ + position: 'absolute', + top: 0, + left: 0, + height: 100, + width: 100 + }) + .appendTo( document.body ) + .bind("dropinit dropstart drop dropend",function( event ){ + obj[ event.type ] += 1; + }); + $.extend( obj, { + draginit:0, dragstart:0, drag:0, dragend:0, + dropinit:0, dropstart:0, drop:0, dropend:0, + click:0 + }); + }, + touch: function(){ + var start = { + pageX: Math.round( Math.random() * 90 ) + 5, + pageY: Math.round( Math.random() * 90 ) + 5 + }, + end = { + pageX: Math.round( Math.random() * 90 ) + start.pageX, + pageY: Math.round( Math.random() * 90 ) + start.pageY + }; + // simulate a complete mouse drag + obj.$drag + .fire("touchstart", start ) + .fire("touchmove", end ) + .fire("touchend", end ) + .fire("click", end ); + }, + done: function(){ + obj.$drag.remove(); + obj.$drop.remove(); + start(); + } + }; + + asyncTest('Drag and Drop defaults',function(){ + // prep DEFAULT interaction + obj.init(); + // simulate DEFAULT interaction + obj.touch(); + // inspect results + equals( obj.draginit, 1, "draginit"); + equals( obj.dragstart, 1, "dragstart"); + equals( obj.drag, 1, "drag"); + equals( obj.dragend, 1, "dragend"); + equals( obj.dropinit, 1, "dropinit"); + equals( obj.dropstart, 1, "dropstart"); + equals( obj.drop, 1, "drop"); + equals( obj.dropend, 1, "dropend"); + // continue + obj.done(); + }); + + asyncTest('Drag "drop" option (false)',function(){ + // prep interaction + obj.init({ drop:false }); + // simulate drag + obj.touch(); + // inspect results + equals( obj.draginit, 1, "draginit"); + equals( obj.dragstart, 1, "dragstart"); + equals( obj.drag, 1, "drag"); + equals( obj.dragend, 1, "dragend"); + equals( obj.dropinit, 0, "dropinit"); + equals( obj.dropstart, 0, "dropstart"); + equals( obj.drop, 0, "drop"); + equals( obj.dropend, 0, "dropend"); + // continue + obj.done(); + }); + + asyncTest('Drag "drop" option (unmatched)',function(){ + // prep interaction + obj.init({ drop:'body' }); + // simulate drag + obj.touch(); + // inspect results + equals( obj.draginit, 1, "draginit"); + equals( obj.dragstart, 1, "dragstart"); + equals( obj.drag, 1, "drag"); + equals( obj.dragend, 1, "dragend"); + equals( obj.dropinit, 0, "dropinit"); + equals( obj.dropstart, 0, "dropstart"); + equals( obj.drop, 0, "drop"); + equals( obj.dropend, 0, "dropend"); + // continue + obj.done(); + }); + + asyncTest('Drag "drop" option (matched)',function(){ + // prep interaction + obj.init({ drop:'div' }); + // simulate drag + obj.touch(); + // inspect results + equals( obj.draginit, 1, "draginit"); + equals( obj.dragstart, 1, "dragstart"); + equals( obj.drag, 1, "drag"); + equals( obj.dragend, 1, "dragend"); + equals( obj.dropinit, 1, "dropinit"); + equals( obj.dropstart, 1, "dropstart"); + equals( obj.drop, 1, "drop"); + equals( obj.dropend, 1, "dropend"); + // continue + obj.done(); + }); + +})();
\ No newline at end of file |