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.selectable.js



/*
 * jQuery UI Selectable 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/Selectables
 *
 * Depends:
 *    jquery.ui.core.js
 *    jquery.ui.mouse.js
 *    jquery.ui.widget.js
 */
(function( $, undefined ) {
	$.widget("ui.selectable", $.ui.mouse, {
		    options: {
			        appendTo'body',
			        autoRefreshtrue,
			        distance0,
			        filter'*',
			        tolerance'touch'
			    },
		    _create: function() {
			        var self this;
			        this.element.addClass("ui-selectable");
			        this.dragged false;
			        // cache selectee children based on filter
			        var selectees;
			        this.refresh = function() {
				            selectees = $(self.options.filterself.element[0]);
				            selectees.each(function() {
					                var $this = $(this);
					                var pos $this.offset();
					                $.data(this"selectable-item", {
						                    elementthis,
						                    $element$this,
						                    leftpos.left,
						                    toppos.top,
						                    rightpos.left $this.outerWidth(),
						                    bottompos.top $this.outerHeight(),
						                    startselectedfalse,
						                    selected$this.hasClass('ui-selected'),
						                    selecting$this.hasClass('ui-selecting'),
						                    unselecting$this.hasClass('ui-unselecting')
						                });
					            });
				        };
			        this.refresh();
			        this.selectees selectees.addClass("ui-selectee");
			        this._mouseInit();
			        this.helper = $("<div class='ui-selectable-helper'></div>");
			    },
		    destroy: function() {
			        this.selectees
			            .removeClass("ui-selectee")
			            .removeData("selectable-item");
			        this.element
			            .removeClass("ui-selectable ui-selectable-disabled")
			            .removeData("selectable")
			            .unbind(".selectable");
			        this._mouseDestroy();
			        return this;
			    },
		    _mouseStart: function(event) {
			        var self this;
			        this.opos = [event.pageXevent.pageY];
			        if (this.options.disabled)
			            return;
			        var options this.options;
			        this.selectees = $(options.filterthis.element[0]);
			        this._trigger("start"event);
			        $(options.appendTo).append(this.helper);
			        // position helper (lasso)
			        this.helper.css({
				            "left"event.clientX,
				            "top"event.clientY,
				            "width"0,
				            "height"0
				        });
			        if (options.autoRefresh) {
				            this.refresh();
				        }
			        this.selectees.filter('.ui-selected').each(function() {
				            var selectee = $.data(this"selectable-item");
				            selectee.startselected true;
				            if (!event.metaKey) {
					                selectee.$element.removeClass('ui-selected');
					                selectee.selected false;
					                selectee.$element.addClass('ui-unselecting');
					                selectee.unselecting true;
					                // selectable UNSELECTING callback
					                self._trigger("unselecting"event, {
						                    unselectingselectee.element
						                });
					            }
				        });
			        $(event.target).parents().andSelf().each(function() {
				            var selectee = $.data(this"selectable-item");
				            if (selectee) {
					                var doSelect = !event.metaKey || !selectee.$element.hasClass('ui-selected');
					                selectee.$element
					                    .removeClass(doSelect "ui-unselecting" "ui-selected")
					                    .addClass(doSelect "ui-selecting" "ui-unselecting");
					                selectee.unselecting = !doSelect;
					                selectee.selecting doSelect;
					                selectee.selected doSelect;
					                // selectable (UN)SELECTING callback
					                if (doSelect) {
						                    self._trigger("selecting"event, {
							                        selectingselectee.element
							                    });
						                } else {
						                    self._trigger("unselecting"event, {
							                        unselectingselectee.element
							                    });
						                }
					                return false;
					            }
				        });
			    },
		    _mouseDrag: function(event) {
			        var self this;
			        this.dragged true;
			        if (this.options.disabled)
			            return;
			        var options this.options;
			        var x1 this.opos[0], y1 this.opos[1], x2 event.pageXy2 event.pageY;
			        if (x1 x2) {
				var tmp x2;
				 x2 x1;
				 x1 tmp;
				}
			        if (y1 y2) {
				var tmp y2;
				 y2 y1;
				 y1 tmp;
				}
			        this.helper.css({leftx1topy1widthx2-x1heighty2-y1});
			        this.selectees.each(function() {
				            var selectee = $.data(this"selectable-item");
				            //prevent helper from being selected if appendTo: selectable
				            if (!selectee || selectee.element == self.element[0])
				                return;
				            var hit false;
				            if (options.tolerance == 'touch') {
					                hit = ( !(selectee.left x2 || selectee.right x1 || selectee.top y2 || selectee.bottom y1) );
					            } else if (options.tolerance == 'fit') {
					                hit = (selectee.left x1 && selectee.right x2 && selectee.top y1 && selectee.bottom y2);
					            }
				            if (hit) {
					                // SELECT
					                if (selectee.selected) {
						                    selectee.$element.removeClass('ui-selected');
						                    selectee.selected false;
						                }
					                if (selectee.unselecting) {
						                    selectee.$element.removeClass('ui-unselecting');
						                    selectee.unselecting false;
						                }
					                if (!selectee.selecting) {
						                    selectee.$element.addClass('ui-selecting');
						                    selectee.selecting true;
						                    // selectable SELECTING callback
						                    self._trigger("selecting"event, {
							                        selectingselectee.element
							                    });
						                }
					            } else {
					                // UNSELECT
					                if (selectee.selecting) {
						                    if (event.metaKey && selectee.startselected) {
							                        selectee.$element.removeClass('ui-selecting');
							                        selectee.selecting false;
							                        selectee.$element.addClass('ui-selected');
							                        selectee.selected true;
							                    } else {
							                        selectee.$element.removeClass('ui-selecting');
							                        selectee.selecting false;
							                        if (selectee.startselected) {
								                            selectee.$element.addClass('ui-unselecting');
								                            selectee.unselecting true;
								                        }
							                        // selectable UNSELECTING callback
							                        self._trigger("unselecting"event, {
								                            unselectingselectee.element
								                        });
							                    }
						                }
					                if (selectee.selected) {
						                    if (!event.metaKey && !selectee.startselected) {
							                        selectee.$element.removeClass('ui-selected');
							                        selectee.selected false;
							                        selectee.$element.addClass('ui-unselecting');
							                        selectee.unselecting true;
							                        // selectable UNSELECTING callback
							                        self._trigger("unselecting"event, {
								                            unselectingselectee.element
								                        });
							                    }
						                }
					            }
				        });
			        return false;
			    },
		    _mouseStop: function(event) {
			        var self this;
			        this.dragged false;
			        var options this.options;
			        $('.ui-unselecting'this.element[0]).each(function() {
				            var selectee = $.data(this"selectable-item");
				            selectee.$element.removeClass('ui-unselecting');
				            selectee.unselecting false;
				            selectee.startselected false;
				            self._trigger("unselected"event, {
					                unselectedselectee.element
					            });
				        });
			        $('.ui-selecting'this.element[0]).each(function() {
				            var selectee = $.data(this"selectable-item");
				            selectee.$element.removeClass('ui-selecting').addClass('ui-selected');
				            selectee.selecting false;
				            selectee.selected true;
				            selectee.startselected true;
				            self._trigger("selected"event, {
					                selectedselectee.element
					            });
				        });
			        this._trigger("stop"event);
			        this.helper.remove();
			        return false;
			    }
		});
	$.extend($.ui.selectable, {
		    version"1.8.4"
		});
	})(jQuery);





PHP Demo Source Code Index