CLICK HERE TO BUY IT TODAY! OR GET IT FREE VIA TRIALPAY  

PHP Demo Application - Source Code

/Framework/Model/Vendor/jquery-ui/development-bundle/ui/jquery.ui.droppable.js



/*
 * jQuery UI Droppable 1.8.4
 *
 * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Droppables
 *
 * Depends:
 *    jquery.ui.core.js
 *    jquery.ui.widget.js
 *    jquery.ui.mouse.js
 *    jquery.ui.draggable.js
 */
(function( $, undefined ) {
	$.widget("ui.droppable", {
		    widgetEventPrefix"drop",
		    options: {
			        accept'*',
			        activeClassfalse,
			        addClassestrue,
			        greedyfalse,
			        hoverClassfalse,
			        scope'default',
			        tolerance'intersect'
			    },
		    _create: function() {
			        var this.optionsaccept o.accept;
			        this.isover 0;
			 this.isout 1;
			        this.accept = $.isFunction(accept) ? accept : function(d) {
				            return d.is(accept);
				        };
			        //Store the droppable's proportions
			        this.proportions = { widththis.element[0].offsetWidthheightthis.element[0].offsetHeight
				};
			        // Add the reference and positions to the manager
			        $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
			        $.ui.ddmanager.droppables[o.scope].push(this);
			        (o.addClasses && this.element.addClass("ui-droppable"));
			    },
		    destroy: function() {
			        var drop = $.ui.ddmanager.droppables[this.options.scope];
			        for ( var 0;
			 drop.length;
			 i++ )
			            if ( drop[i] == this )
			                drop.splice(i1);
			        this.element
			            .removeClass("ui-droppable ui-droppable-disabled")
			            .removeData("droppable")
			            .unbind(".droppable");
			        return this;
			    },
		    _setOption: function(keyvalue) {
			        if(key == 'accept') {
				            this.accept = $.isFunction(value) ? value : function(d) {
					                return d.is(value);
					            };
				        }
			        $.Widget.prototype._setOption.apply(thisarguments);
			    },
		    _activate: function(event) {
			        var draggable = $.ui.ddmanager.current;
			        if(this.options.activeClassthis.element.addClass(this.options.activeClass);
			        (draggable && this._trigger('activate'eventthis.ui(draggable)));
			    },
		    _deactivate: function(event) {
			        var draggable = $.ui.ddmanager.current;
			        if(this.options.activeClassthis.element.removeClass(this.options.activeClass);
			        (draggable && this._trigger('deactivate'eventthis.ui(draggable)));
			    },
		    _over: function(event) {
			        var draggable = $.ui.ddmanager.current;
			        if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return;
			 // Bail if draggable and droppable are same element
			        if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
				            if(this.options.hoverClassthis.element.addClass(this.options.hoverClass);
				            this._trigger('over'eventthis.ui(draggable));
				        }
			    },
		    _out: function(event) {
			        var draggable = $.ui.ddmanager.current;
			        if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return;
			 // Bail if draggable and droppable are same element
			        if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
				            if(this.options.hoverClassthis.element.removeClass(this.options.hoverClass);
				            this._trigger('out'eventthis.ui(draggable));
				        }
			    },
		    _drop: function(event,custom) {
			        var draggable custom || $.ui.ddmanager.current;
			        if (!draggable || (draggable.currentItem || draggable.element)[0] == this.element[0]) return false;
			 // Bail if draggable and droppable are same element
			        var childrenIntersection false;
			        this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function() {
				            var inst = $.data(this'droppable');
				            if(
				                inst.options.greedy
				                && !inst.options.disabled
				                && inst.options.scope == draggable.options.scope
				                && inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element))
				                && $.ui.intersect(draggable, $.extend(inst, { offsetinst.element.offset()
					}), inst.options.tolerance)
				            ) {
					childrenIntersection true;
					 return false;
					}
				        });
			        if(childrenIntersection) return false;
			        if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
				            if(this.options.activeClassthis.element.removeClass(this.options.activeClass);
				            if(this.options.hoverClassthis.element.removeClass(this.options.hoverClass);
				            this._trigger('drop'eventthis.ui(draggable));
				            return this.element;
				        }
			        return false;
			    },
		    ui: function(c) {
			        return {
				            draggable: (c.currentItem || c.element),
				            helperc.helper,
				            positionc.position,
				            offsetc.positionAbs
				        };
			    }
		});
	$.extend($.ui.droppable, {
		    version"1.8.4"
		});
	$.ui.intersect = function(draggabledroppabletoleranceMode) {
		    if (!droppable.offset) return false;
		    var x1 = (draggable.positionAbs || draggable.position.absolute).leftx2 x1 draggable.helperProportions.width,
		        y1 = (draggable.positionAbs || draggable.position.absolute).topy2 y1 draggable.helperProportions.height;
		    var droppable.offset.leftdroppable.proportions.width,
		        droppable.offset.topdroppable.proportions.height;
		    switch (toleranceMode) {
			        case 'fit':
			            return (<= x1 && x2 <= r
			                && <= y1 && y2 <= b);
			            break;
			        case 'intersect':
			            return (x1 + (draggable.helperProportions.width 2// Right Half
			                && x2 - (draggable.helperProportions.width 2) < // Left Half
			                && y1 + (draggable.helperProportions.height 2// Bottom Half
			                && y2 - (draggable.helperProportions.height 2) < );
			 // Top Half
			            break;
			        case 'pointer':
			            var draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left),
			                draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top),
			                isOver = $.ui.isOver(draggableTopdraggableLefttldroppable.proportions.heightdroppable.proportions.width);
			            return isOver;
			            break;
			        case 'touch':
			            return (
			                    (y1 >= && y1 <= b) ||    // Top edge touching
			                    (y2 >= && y2 <= b) ||    // Bottom edge touching
			                    (y1 && y2 b)        // Surrounded vertically
			                ) && (
			                    (x1 >= && x1 <= r) ||    // Left edge touching
			                    (x2 >= && x2 <= r) ||    // Right edge touching
			                    (x1 && x2 r)        // Surrounded horizontally
			                );
			            break;
			        default:
			            return false;
			            break;
			        }
		};
	/*
	    This manager tracks offsets of draggables and droppables
	*/
	$.ui.ddmanager = {
		    currentnull,
		    droppables: { 'default'[]
			},
		    prepareOffsets: function(tevent) {
			        var = $.ui.ddmanager.droppables[t.options.scope] || [];
			        var type event event.type null;
			 // workaround for #2317
			        var list = (t.currentItem || t.element).find(":data(droppable)").andSelf();
			        droppablesLoop: for (var 0;
			 m.length;
			 i++) {
				            if(m[i].options.disabled || (&& !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) continue;
				    //No disabled and non-accepted
				            for (var j=0;
				 < list.length;
				 j++) {
					if(list[j] == m[i].element[0]) {
						m[i].proportions.height 0;
						 continue droppablesLoop;
						}
					};
				 //Filter out elements in the current dragged item
				            m[i].visible m[i].element.css("display") != "none";
				 if(!m[i].visible) continue;
				                                     //If the element is not visible, continue
				            m[i].offset m[i].element.offset();
				            m[i].proportions = { widthm[i].element[0].offsetWidthheightm[i].element[0].offsetHeight
					};
				            if(type == "mousedown"m[i]._activate.call(m[i], event);
				 //Activate the droppable if used directly from draggables
				        }
			    },
		    drop: function(draggableevent) {
			        var dropped false;
			        $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
				            if(!this.options) return;
				            if (!this.options.disabled && this.visible && $.ui.intersect(draggablethisthis.options.tolerance))
				                dropped dropped || this._drop.call(thisevent);
				            if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
					                this.isout 1;
					 this.isover 0;
					                this._deactivate.call(thisevent);
					            }
				        });
			        return dropped;
			    },
		    drag: function(draggableevent) {
			        //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(draggableevent);
			        //Run through all droppables and check their positions based on specific tolerance options
			        $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
				            if(this.options.disabled || this.greedyChild || !this.visible) return;
				            var intersects = $.ui.intersect(draggablethisthis.options.tolerance);
				            var = !intersects && this.isover == 'isout' : (intersects && this.isover == 'isover' null);
				            if(!c) return;
				            var parentInstance;
				            if (this.options.greedy) {
					                var parent this.element.parents(':data(droppable):eq(0)');
					                if (parent.length) {
						                    parentInstance = $.data(parent[0], 'droppable');
						                    parentInstance.greedyChild = (== 'isover' 0);
						                }
					            }
				            // we just moved into a greedy child
				            if (parentInstance && == 'isover') {
					                parentInstance['isover'] = 0;
					                parentInstance['isout'] = 1;
					                parentInstance._out.call(parentInstanceevent);
					            }
				            this[c] = 1;
				 this[== 'isout' 'isover' 'isout'] = 0;
				            this[== "isover" "_over" "_out"].call(thisevent);
				            // we just moved out of a greedy child
				            if (parentInstance && == 'isout') {
					                parentInstance['isout'] = 0;
					                parentInstance['isover'] = 1;
					                parentInstance._over.call(parentInstanceevent);
					            }
				        });
			    }
		};
	})(jQuery);





PHP Demo Source Code Index