Вход Регистрация
Файл: ui/development-bundle/ui/jquery.ui.mouse.js
Строк: 217
<?php
/*!
 * jQuery UI Mouse 1.10.0
 * http://jqueryui.com
 *
 * Copyright 2013 jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 *
 * http://api.jqueryui.com/mouse/
 *
 * Depends:
 *    jquery.ui.widget.js
 */
(function( $, undefined ) {

var 
mouseHandled false;
$( 
document ).mouseup( function() {
    
mouseHandled false;
});

$.
widget("ui.mouse", {
    
version"1.10.0",
    
options: {
        
cancel"input,textarea,button,select,option",
        
distance1,
        
delay0
    
},
    
_mouseInit: function() {
        var 
that this;

        
this.element
            
.bind("mousedown."+this.widgetName, function(event) {
                return 
that._mouseDown(event);
            })
            .
bind("click."+this.widgetName, function(event) {
                if (
true === $.data(event.targetthat.widgetName ".preventClickEvent")) {
                    $.
removeData(event.targetthat.widgetName ".preventClickEvent");
                    
event.stopImmediatePropagation();
                    return 
false;
                }
            });

        
this.started false;
    },

    
// TODO: make sure destroying one instance of mouse doesn't mess with
    // other instances of mouse
    
_mouseDestroy: function() {
        
this.element.unbind("."+this.widgetName);
        if ( 
this._mouseMoveDelegate ) {
            $(
document)
                .
unbind("mousemove."+this.widgetNamethis._mouseMoveDelegate)
                .
unbind("mouseup."+this.widgetNamethis._mouseUpDelegate);
        }
    },

    
_mouseDown: function(event) {
        
// don't let more than one widget handle mouseStart
        
if( mouseHandled ) { return; }

        
// we may have missed mouseup (out of window)
        
(this._mouseStarted && this._mouseUp(event));

        
this._mouseDownEvent event;

        var 
that this,
            
btnIsLeft = (event.which === 1),
            
// event.target.nodeName works around a bug in IE 8 with
            // disabled inputs (#7620)
            
elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length false);
        if (!
btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
            return 
true;
        }

        
this.mouseDelayMet = !this.options.delay;
        if (!
this.mouseDelayMet) {
            
this._mouseDelayTimer setTimeout(function() {
                
that.mouseDelayMet true;
            }, 
this.options.delay);
        }

        if (
this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
            
this._mouseStarted = (this._mouseStart(event) !== false);
            if (!
this._mouseStarted) {
                
event.preventDefault();
                return 
true;
            }
        }

        
// Click event may never have fired (Gecko & Opera)
        
if (true === $.data(event.targetthis.widgetName ".preventClickEvent")) {
            $.
removeData(event.targetthis.widgetName ".preventClickEvent");
        }

        
// these delegates are required to keep context
        
this._mouseMoveDelegate = function(event) {
            return 
that._mouseMove(event);
        };
        
this._mouseUpDelegate = function(event) {
            return 
that._mouseUp(event);
        };
        $(
document)
            .
bind("mousemove."+this.widgetNamethis._mouseMoveDelegate)
            .
bind("mouseup."+this.widgetNamethis._mouseUpDelegate);

        
event.preventDefault();

        
mouseHandled true;
        return 
true;
    },

    
_mouseMove: function(event) {
        
// IE mouseup check - mouseup happened when mouse was out of window
        
if ($.ui.ie && ( !document.documentMode || document.documentMode ) && !event.button) {
            return 
this._mouseUp(event);
        }

        if (
this._mouseStarted) {
            
this._mouseDrag(event);
            return 
event.preventDefault();
        }

        if (
this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
            
this._mouseStarted =
                (
this._mouseStart(this._mouseDownEventevent) !== false);
            (
this._mouseStarted this._mouseDrag(event) : this._mouseUp(event));
        }

        return !
this._mouseStarted;
    },

    
_mouseUp: function(event) {
        $(
document)
            .
unbind("mousemove."+this.widgetNamethis._mouseMoveDelegate)
            .
unbind("mouseup."+this.widgetNamethis._mouseUpDelegate);

        if (
this._mouseStarted) {
            
this._mouseStarted false;

            if (
event.target === this._mouseDownEvent.target) {
                $.
data(event.targetthis.widgetName ".preventClickEvent"true);
            }

            
this._mouseStop(event);
        }

        return 
false;
    },

    
_mouseDistanceMet: function(event) {
        return (
Math.max(
                
Math.abs(this._mouseDownEvent.pageX event.pageX),
                
Math.abs(this._mouseDownEvent.pageY event.pageY)
            ) >= 
this.options.distance
        
);
    },

    
_mouseDelayMet: function(/* event */) {
        return 
this.mouseDelayMet;
    },

    
// These are placeholder methods, to be overriden by extending plugin
    
_mouseStart: function(/* event */) {},
    
_mouseDrag: function(/* event */) {},
    
_mouseStop: function(/* event */) {},
    
_mouseCapture: function(/* event */) { return true; }
});

})(
jQuery);
?>
Онлайн: 0
Реклама