mirror of
https://github.com/jquery/jquery-ui.git
synced 2026-02-04 15:55:02 -05:00
unindentation
This commit is contained in:
@@ -12,292 +12,291 @@
|
||||
*
|
||||
* Revision: $Id: ui.accordion.js 5656 2008-05-21 19:35:33Z braeker $
|
||||
*/
|
||||
|
||||
;(function($) {
|
||||
|
||||
$.widget("ui.accordion", {
|
||||
init: function() {
|
||||
var options = this.options;
|
||||
|
||||
if ( options.navigation ) {
|
||||
var current = this.element.find("a").filter(options.navigationFilter);
|
||||
if ( current.length ) {
|
||||
if ( current.filter(options.header).length ) {
|
||||
options.active = current;
|
||||
} else {
|
||||
options.active = current.parent().parent().prev();
|
||||
current.addClass("current");
|
||||
}
|
||||
$.widget("ui.accordion", {
|
||||
init: function() {
|
||||
var options = this.options;
|
||||
|
||||
if ( options.navigation ) {
|
||||
var current = this.element.find("a").filter(options.navigationFilter);
|
||||
if ( current.length ) {
|
||||
if ( current.filter(options.header).length ) {
|
||||
options.active = current;
|
||||
} else {
|
||||
options.active = current.parent().parent().prev();
|
||||
current.addClass("current");
|
||||
}
|
||||
}
|
||||
|
||||
// calculate active if not specified, using the first header
|
||||
options.headers = this.element.find(options.header);
|
||||
options.active = findActive(options.headers, options.active);
|
||||
|
||||
// IE7-/Win - Extra vertical space in Lists fixed
|
||||
if ($.browser.msie) {
|
||||
this.element.find('a').css('zoom', '1');
|
||||
}
|
||||
|
||||
if (!this.element.hasClass("ui-accordion")) {
|
||||
this.element.addClass("ui-accordion");
|
||||
$("<span class='ui-accordion-left'/>").insertBefore(options.headers);
|
||||
$("<span class='ui-accordion-right'/>").appendTo(options.headers);
|
||||
options.headers.addClass("ui-accordion-header").attr("tabindex", "0");
|
||||
}
|
||||
|
||||
var maxHeight;
|
||||
if ( options.fillSpace ) {
|
||||
maxHeight = this.element.parent().height();
|
||||
options.headers.each(function() {
|
||||
maxHeight -= $(this).outerHeight();
|
||||
});
|
||||
var maxPadding = 0;
|
||||
options.headers.next().each(function() {
|
||||
maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());
|
||||
}).height(maxHeight - maxPadding);
|
||||
} else if ( options.autoHeight ) {
|
||||
maxHeight = 0;
|
||||
options.headers.next().each(function() {
|
||||
maxHeight = Math.max(maxHeight, $(this).outerHeight());
|
||||
}).height(maxHeight);
|
||||
}
|
||||
|
||||
options.headers
|
||||
.not(options.active || "")
|
||||
.next()
|
||||
.hide();
|
||||
options.active.parent().andSelf().addClass(options.selectedClass);
|
||||
|
||||
if (options.event) {
|
||||
this.element.bind((options.event) + ".accordion", clickHandler);
|
||||
}
|
||||
},
|
||||
activate: function(index) {
|
||||
// call clickHandler with custom event
|
||||
clickHandler.call(this.element[0], {
|
||||
target: findActive( this.options.headers, index )[0]
|
||||
});
|
||||
},
|
||||
destroy: function() {
|
||||
this.options.headers.next().css("display", "");
|
||||
if ( this.options.fillSpace || this.options.autoHeight ) {
|
||||
this.options.headers.next().css("height", "");
|
||||
}
|
||||
$.removeData(this.element[0], "accordion");
|
||||
this.element.removeClass("ui-accordion").unbind(".accordion");
|
||||
}
|
||||
});
|
||||
|
||||
// calculate active if not specified, using the first header
|
||||
options.headers = this.element.find(options.header);
|
||||
options.active = findActive(options.headers, options.active);
|
||||
|
||||
// IE7-/Win - Extra vertical space in Lists fixed
|
||||
if ($.browser.msie) {
|
||||
this.element.find('a').css('zoom', '1');
|
||||
}
|
||||
|
||||
if (!this.element.hasClass("ui-accordion")) {
|
||||
this.element.addClass("ui-accordion");
|
||||
$("<span class='ui-accordion-left'/>").insertBefore(options.headers);
|
||||
$("<span class='ui-accordion-right'/>").appendTo(options.headers);
|
||||
options.headers.addClass("ui-accordion-header").attr("tabindex", "0");
|
||||
}
|
||||
|
||||
var maxHeight;
|
||||
if ( options.fillSpace ) {
|
||||
maxHeight = this.element.parent().height();
|
||||
options.headers.each(function() {
|
||||
maxHeight -= $(this).outerHeight();
|
||||
});
|
||||
var maxPadding = 0;
|
||||
options.headers.next().each(function() {
|
||||
maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height());
|
||||
}).height(maxHeight - maxPadding);
|
||||
} else if ( options.autoHeight ) {
|
||||
maxHeight = 0;
|
||||
options.headers.next().each(function() {
|
||||
maxHeight = Math.max(maxHeight, $(this).outerHeight());
|
||||
}).height(maxHeight);
|
||||
}
|
||||
|
||||
function scopeCallback(callback, scope) {
|
||||
return function() {
|
||||
return callback.apply(scope, arguments);
|
||||
};
|
||||
options.headers
|
||||
.not(options.active || "")
|
||||
.next()
|
||||
.hide();
|
||||
options.active.parent().andSelf().addClass(options.selectedClass);
|
||||
|
||||
if (options.event) {
|
||||
this.element.bind((options.event) + ".accordion", clickHandler);
|
||||
}
|
||||
},
|
||||
activate: function(index) {
|
||||
// call clickHandler with custom event
|
||||
clickHandler.call(this.element[0], {
|
||||
target: findActive( this.options.headers, index )[0]
|
||||
});
|
||||
},
|
||||
destroy: function() {
|
||||
this.options.headers.next().css("display", "");
|
||||
if ( this.options.fillSpace || this.options.autoHeight ) {
|
||||
this.options.headers.next().css("height", "");
|
||||
}
|
||||
$.removeData(this.element[0], "accordion");
|
||||
this.element.removeClass("ui-accordion").unbind(".accordion");
|
||||
}
|
||||
});
|
||||
|
||||
function scopeCallback(callback, scope) {
|
||||
return function() {
|
||||
return callback.apply(scope, arguments);
|
||||
};
|
||||
};
|
||||
|
||||
function completed(cancel) {
|
||||
// if removed while animated data can be empty
|
||||
if (!$.data(this, "accordion")) {
|
||||
return;
|
||||
}
|
||||
|
||||
function completed(cancel) {
|
||||
// if removed while animated data can be empty
|
||||
if (!$.data(this, "accordion")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var instance = $.data(this, "accordion");
|
||||
var options = instance.options;
|
||||
options.running = cancel ? 0 : --options.running;
|
||||
if ( options.running ) {
|
||||
return;
|
||||
}
|
||||
if ( options.clearStyle ) {
|
||||
options.toShow.add(options.toHide).css({
|
||||
height: "",
|
||||
overflow: ""
|
||||
var instance = $.data(this, "accordion");
|
||||
var options = instance.options;
|
||||
options.running = cancel ? 0 : --options.running;
|
||||
if ( options.running ) {
|
||||
return;
|
||||
}
|
||||
if ( options.clearStyle ) {
|
||||
options.toShow.add(options.toHide).css({
|
||||
height: "",
|
||||
overflow: ""
|
||||
});
|
||||
}
|
||||
$(this).triggerHandler("accordionchange", [options.data], options.change);
|
||||
}
|
||||
|
||||
function toggle(toShow, toHide, data, clickedActive, down) {
|
||||
var options = $.data(this, "accordion").options;
|
||||
options.toShow = toShow;
|
||||
options.toHide = toHide;
|
||||
options.data = data;
|
||||
var complete = scopeCallback(completed, this);
|
||||
|
||||
// count elements to animate
|
||||
options.running = toHide.size() === 0 ? toShow.size() : toHide.size();
|
||||
|
||||
if ( options.animated ) {
|
||||
if ( !options.alwaysOpen && clickedActive ) {
|
||||
$.ui.accordion.animations[options.animated]({
|
||||
toShow: jQuery([]),
|
||||
toHide: toHide,
|
||||
complete: complete,
|
||||
down: down,
|
||||
autoHeight: options.autoHeight
|
||||
});
|
||||
} else {
|
||||
$.ui.accordion.animations[options.animated]({
|
||||
toShow: toShow,
|
||||
toHide: toHide,
|
||||
complete: complete,
|
||||
down: down,
|
||||
autoHeight: options.autoHeight
|
||||
});
|
||||
}
|
||||
$(this).triggerHandler("accordionchange", [options.data], options.change);
|
||||
}
|
||||
|
||||
function toggle(toShow, toHide, data, clickedActive, down) {
|
||||
var options = $.data(this, "accordion").options;
|
||||
options.toShow = toShow;
|
||||
options.toHide = toHide;
|
||||
options.data = data;
|
||||
var complete = scopeCallback(completed, this);
|
||||
|
||||
// count elements to animate
|
||||
options.running = toHide.size() === 0 ? toShow.size() : toHide.size();
|
||||
|
||||
if ( options.animated ) {
|
||||
if ( !options.alwaysOpen && clickedActive ) {
|
||||
$.ui.accordion.animations[options.animated]({
|
||||
toShow: jQuery([]),
|
||||
toHide: toHide,
|
||||
complete: complete,
|
||||
down: down,
|
||||
autoHeight: options.autoHeight
|
||||
});
|
||||
} else {
|
||||
$.ui.accordion.animations[options.animated]({
|
||||
toShow: toShow,
|
||||
toHide: toHide,
|
||||
complete: complete,
|
||||
down: down,
|
||||
autoHeight: options.autoHeight
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if ( !options.alwaysOpen && clickedActive ) {
|
||||
toShow.toggle();
|
||||
} else {
|
||||
if ( !options.alwaysOpen && clickedActive ) {
|
||||
toShow.toggle();
|
||||
} else {
|
||||
toHide.hide();
|
||||
toShow.show();
|
||||
}
|
||||
complete(true);
|
||||
toHide.hide();
|
||||
toShow.show();
|
||||
}
|
||||
complete(true);
|
||||
}
|
||||
}
|
||||
|
||||
function clickHandler(event) {
|
||||
var options = $.data(this, "accordion").options;
|
||||
if (options.disabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function clickHandler(event) {
|
||||
var options = $.data(this, "accordion").options;
|
||||
if (options.disabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// called only when using activate(false) to close all parts programmatically
|
||||
if ( !event.target && !options.alwaysOpen ) {
|
||||
options.active.parent().andSelf().toggleClass(options.selectedClass);
|
||||
var toHide = options.active.next(),
|
||||
data = {
|
||||
instance: this,
|
||||
options: options,
|
||||
newHeader: jQuery([]),
|
||||
oldHeader: options.active,
|
||||
newContent: jQuery([]),
|
||||
oldContent: toHide
|
||||
},
|
||||
toShow = (options.active = $([]));
|
||||
toggle.call(this, toShow, toHide, data );
|
||||
return false;
|
||||
}
|
||||
// get the click target
|
||||
var clicked = $(event.target);
|
||||
|
||||
// due to the event delegation model, we have to check if one
|
||||
// of the parent elements is our actual header, and find that
|
||||
if ( clicked.parents(options.header).length ) {
|
||||
while ( !clicked.is(options.header) ) {
|
||||
clicked = clicked.parent();
|
||||
}
|
||||
}
|
||||
|
||||
var clickedActive = clicked[0] == options.active[0];
|
||||
|
||||
// if animations are still active, or the active header is the target, ignore click
|
||||
if (options.running || (options.alwaysOpen && clickedActive)) {
|
||||
return false;
|
||||
}
|
||||
if (!clicked.is(options.header)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// switch classes
|
||||
// called only when using activate(false) to close all parts programmatically
|
||||
if ( !event.target && !options.alwaysOpen ) {
|
||||
options.active.parent().andSelf().toggleClass(options.selectedClass);
|
||||
if ( !clickedActive ) {
|
||||
clicked.parent().andSelf().addClass(options.selectedClass);
|
||||
}
|
||||
|
||||
// find elements to show and hide
|
||||
var toShow = clicked.next(),
|
||||
toHide = options.active.next(),
|
||||
//data = [clicked, options.active, toShow, toHide],
|
||||
var toHide = options.active.next(),
|
||||
data = {
|
||||
instance: this,
|
||||
options: options,
|
||||
newHeader: clicked,
|
||||
newHeader: jQuery([]),
|
||||
oldHeader: options.active,
|
||||
newContent: toShow,
|
||||
newContent: jQuery([]),
|
||||
oldContent: toHide
|
||||
},
|
||||
down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] );
|
||||
|
||||
options.active = clickedActive ? $([]) : clicked;
|
||||
toggle.call(this, toShow, toHide, data, clickedActive, down );
|
||||
|
||||
toShow = (options.active = $([]));
|
||||
toggle.call(this, toShow, toHide, data );
|
||||
return false;
|
||||
};
|
||||
}
|
||||
// get the click target
|
||||
var clicked = $(event.target);
|
||||
|
||||
function findActive(headers, selector) {
|
||||
return selector != undefined
|
||||
? typeof selector == "number"
|
||||
? headers.filter(":eq(" + selector + ")")
|
||||
: headers.not(headers.not(selector))
|
||||
: selector === false
|
||||
? $([])
|
||||
: headers.filter(":eq(0)");
|
||||
// due to the event delegation model, we have to check if one
|
||||
// of the parent elements is our actual header, and find that
|
||||
if ( clicked.parents(options.header).length ) {
|
||||
while ( !clicked.is(options.header) ) {
|
||||
clicked = clicked.parent();
|
||||
}
|
||||
}
|
||||
|
||||
$.extend($.ui.accordion, {
|
||||
defaults: {
|
||||
selectedClass: "selected",
|
||||
alwaysOpen: true,
|
||||
animated: 'slide',
|
||||
event: "click",
|
||||
header: "a",
|
||||
autoHeight: true,
|
||||
running: 0,
|
||||
navigationFilter: function() {
|
||||
return this.href.toLowerCase() == location.href.toLowerCase();
|
||||
}
|
||||
},
|
||||
animations: {
|
||||
slide: function(options, additions) {
|
||||
options = $.extend({
|
||||
easing: "swing",
|
||||
duration: 300
|
||||
}, options, additions);
|
||||
if ( !options.toHide.size() ) {
|
||||
options.toShow.animate({height: "show"}, options);
|
||||
return;
|
||||
}
|
||||
var hideHeight = options.toHide.height(),
|
||||
showHeight = options.toShow.height(),
|
||||
difference = showHeight / hideHeight;
|
||||
options.toShow.css({ height: 0, overflow: 'hidden' }).show();
|
||||
options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{
|
||||
step: function(now) {
|
||||
var current = (hideHeight - now) * difference;
|
||||
if ($.browser.msie || $.browser.opera) {
|
||||
current = Math.ceil(current);
|
||||
}
|
||||
options.toShow.height( current );
|
||||
},
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: function() {
|
||||
if ( !options.autoHeight ) {
|
||||
options.toShow.css("height", "auto");
|
||||
}
|
||||
options.complete();
|
||||
}
|
||||
});
|
||||
},
|
||||
bounceslide: function(options) {
|
||||
this.slide(options, {
|
||||
easing: options.down ? "bounceout" : "swing",
|
||||
duration: options.down ? 1000 : 200
|
||||
});
|
||||
},
|
||||
easeslide: function(options) {
|
||||
this.slide(options, {
|
||||
easing: "easeinout",
|
||||
duration: 700
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
var clickedActive = clicked[0] == options.active[0];
|
||||
|
||||
// deprecated, use accordion("activate", index) instead
|
||||
$.fn.activate = function(index) {
|
||||
return this.accordion("activate", index);
|
||||
};
|
||||
// if animations are still active, or the active header is the target, ignore click
|
||||
if (options.running || (options.alwaysOpen && clickedActive)) {
|
||||
return false;
|
||||
}
|
||||
if (!clicked.is(options.header)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// switch classes
|
||||
options.active.parent().andSelf().toggleClass(options.selectedClass);
|
||||
if ( !clickedActive ) {
|
||||
clicked.parent().andSelf().addClass(options.selectedClass);
|
||||
}
|
||||
|
||||
// find elements to show and hide
|
||||
var toShow = clicked.next(),
|
||||
toHide = options.active.next(),
|
||||
//data = [clicked, options.active, toShow, toHide],
|
||||
data = {
|
||||
instance: this,
|
||||
options: options,
|
||||
newHeader: clicked,
|
||||
oldHeader: options.active,
|
||||
newContent: toShow,
|
||||
oldContent: toHide
|
||||
},
|
||||
down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] );
|
||||
|
||||
options.active = clickedActive ? $([]) : clicked;
|
||||
toggle.call(this, toShow, toHide, data, clickedActive, down );
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
function findActive(headers, selector) {
|
||||
return selector != undefined
|
||||
? typeof selector == "number"
|
||||
? headers.filter(":eq(" + selector + ")")
|
||||
: headers.not(headers.not(selector))
|
||||
: selector === false
|
||||
? $([])
|
||||
: headers.filter(":eq(0)");
|
||||
}
|
||||
|
||||
$.extend($.ui.accordion, {
|
||||
defaults: {
|
||||
selectedClass: "selected",
|
||||
alwaysOpen: true,
|
||||
animated: 'slide',
|
||||
event: "click",
|
||||
header: "a",
|
||||
autoHeight: true,
|
||||
running: 0,
|
||||
navigationFilter: function() {
|
||||
return this.href.toLowerCase() == location.href.toLowerCase();
|
||||
}
|
||||
},
|
||||
animations: {
|
||||
slide: function(options, additions) {
|
||||
options = $.extend({
|
||||
easing: "swing",
|
||||
duration: 300
|
||||
}, options, additions);
|
||||
if ( !options.toHide.size() ) {
|
||||
options.toShow.animate({height: "show"}, options);
|
||||
return;
|
||||
}
|
||||
var hideHeight = options.toHide.height(),
|
||||
showHeight = options.toShow.height(),
|
||||
difference = showHeight / hideHeight;
|
||||
options.toShow.css({ height: 0, overflow: 'hidden' }).show();
|
||||
options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{
|
||||
step: function(now) {
|
||||
var current = (hideHeight - now) * difference;
|
||||
if ($.browser.msie || $.browser.opera) {
|
||||
current = Math.ceil(current);
|
||||
}
|
||||
options.toShow.height( current );
|
||||
},
|
||||
duration: options.duration,
|
||||
easing: options.easing,
|
||||
complete: function() {
|
||||
if ( !options.autoHeight ) {
|
||||
options.toShow.css("height", "auto");
|
||||
}
|
||||
options.complete();
|
||||
}
|
||||
});
|
||||
},
|
||||
bounceslide: function(options) {
|
||||
this.slide(options, {
|
||||
easing: options.down ? "bounceout" : "swing",
|
||||
duration: options.down ? 1000 : 200
|
||||
});
|
||||
},
|
||||
easeslide: function(options) {
|
||||
this.slide(options, {
|
||||
easing: "easeinout",
|
||||
duration: 700
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// deprecated, use accordion("activate", index) instead
|
||||
$.fn.activate = function(index) {
|
||||
return this.accordion("activate", index);
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
@@ -10,267 +10,268 @@
|
||||
* $Id: ui.core.js 5587 2008-05-13 19:56:42Z scott.gonzalez $
|
||||
*/
|
||||
;(function($) {
|
||||
|
||||
$.ui = {
|
||||
plugin: {
|
||||
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 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, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$.ui = {
|
||||
plugin: {
|
||||
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]]);
|
||||
}
|
||||
},
|
||||
cssCache: {},
|
||||
css: function(name) {
|
||||
if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
|
||||
var tmp = $('<div class="ui-resizable-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body');
|
||||
call: function(instance, name, args) {
|
||||
var set = instance.plugins[name];
|
||||
if(!set) { return; }
|
||||
|
||||
//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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** jQuery core modifications and additions **/
|
||||
|
||||
var _remove = $.fn.remove;
|
||||
$.fn.remove = function() {
|
||||
$("*", this).add(this).trigger("remove");
|
||||
return _remove.apply(this, arguments );
|
||||
};
|
||||
|
||||
// $.widget is a factory to create jQuery plugins
|
||||
// taking some boilerplate code out of the plugin code
|
||||
// created by Scott González and Jörn Zaefferer
|
||||
function getter(namespace, plugin, method) {
|
||||
var methods = $[namespace][plugin].getter || [];
|
||||
methods = (typeof methods == "string" ? methods.split(/,?\s+/) : methods);
|
||||
return ($.inArray(method, methods) != -1);
|
||||
for (var i = 0; i < set.length; i++) {
|
||||
if (instance.options[set[i][0]]) {
|
||||
set[i][1].apply(instance.element, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
cssCache: {},
|
||||
css: function(name) {
|
||||
if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; }
|
||||
var tmp = $('<div class="ui-resizable-gen">').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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** jQuery core modifications and additions **/
|
||||
|
||||
var _remove = $.fn.remove;
|
||||
$.fn.remove = function() {
|
||||
$("*", this).add(this).trigger("remove");
|
||||
return _remove.apply(this, arguments );
|
||||
};
|
||||
|
||||
// $.widget is a factory to create jQuery plugins
|
||||
// taking some boilerplate code out of the plugin code
|
||||
// created by Scott González and Jörn Zaefferer
|
||||
function getter(namespace, plugin, method) {
|
||||
var methods = $[namespace][plugin].getter || [];
|
||||
methods = (typeof methods == "string" ? methods.split(/,?\s+/) : methods);
|
||||
return ($.inArray(method, methods) != -1);
|
||||
}
|
||||
|
||||
var widgetPrototype = {
|
||||
init: function() {},
|
||||
destroy: function() {
|
||||
this.element.removeData(this.widgetName);
|
||||
},
|
||||
|
||||
var widgetPrototype = {
|
||||
init: function() {},
|
||||
destroy: function() {
|
||||
this.element.removeData(this.widgetName);
|
||||
},
|
||||
getData: function(key) {
|
||||
return this.options[key];
|
||||
},
|
||||
setData: function(key, value) {
|
||||
this.options[key] = value;
|
||||
},
|
||||
|
||||
enable: function() {
|
||||
this.setData('disabled', false);
|
||||
},
|
||||
disable: function() {
|
||||
this.setData('disabled', true);
|
||||
}
|
||||
};
|
||||
|
||||
$.widget = function(name, prototype) {
|
||||
var namespace = name.split(".")[0];
|
||||
name = name.split(".")[1];
|
||||
// create plugin method
|
||||
$.fn[name] = function(options) {
|
||||
var isMethodCall = (typeof options == 'string'),
|
||||
args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
getData: function(key) {
|
||||
return this.options[key];
|
||||
},
|
||||
setData: function(key, value) {
|
||||
this.options[key] = value;
|
||||
},
|
||||
|
||||
enable: function() {
|
||||
this.setData('disabled', false);
|
||||
},
|
||||
disable: function() {
|
||||
this.setData('disabled', true);
|
||||
if (isMethodCall && getter(namespace, name, options)) {
|
||||
var instance = $.data(this[0], name);
|
||||
return (instance ? instance[options].apply(instance, args)
|
||||
: undefined);
|
||||
}
|
||||
|
||||
return this.each(function() {
|
||||
var instance = $.data(this, name);
|
||||
if (!instance) {
|
||||
$.data(this, name, new $[namespace][name](this, options));
|
||||
} else if (isMethodCall) {
|
||||
instance[options].apply(instance, args);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$.widget = function(name, prototype) {
|
||||
var namespace = name.split(".")[0];
|
||||
name = name.split(".")[1];
|
||||
// create plugin method
|
||||
$.fn[name] = function(options) {
|
||||
var isMethodCall = (typeof options == 'string'),
|
||||
args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
if (isMethodCall && getter(namespace, name, options)) {
|
||||
var instance = $.data(this[0], name);
|
||||
return (instance ? instance[options].apply(instance, args)
|
||||
: undefined);
|
||||
}
|
||||
|
||||
return this.each(function() {
|
||||
var instance = $.data(this, name);
|
||||
if (!instance) {
|
||||
$.data(this, name, new $[namespace][name](this, options));
|
||||
} else if (isMethodCall) {
|
||||
instance[options].apply(instance, args);
|
||||
}
|
||||
// create widget constructor
|
||||
$[namespace][name] = function(element, options) {
|
||||
var self = this;
|
||||
|
||||
this.widgetName = name;
|
||||
|
||||
this.options = $.extend({}, $[namespace][name].defaults, options);
|
||||
this.element = $(element)
|
||||
.bind('setData.' + name, function(e, key, value) {
|
||||
return self.setData(key, value);
|
||||
})
|
||||
.bind('getData.' + name, function(e, key) {
|
||||
return self.getData(key);
|
||||
})
|
||||
.bind('remove', function() {
|
||||
return self.destroy();
|
||||
});
|
||||
this.init();
|
||||
};
|
||||
|
||||
// add widget prototype
|
||||
$[namespace][name].prototype = $.extend({}, widgetPrototype, prototype);
|
||||
};
|
||||
|
||||
|
||||
/** Mouse Interaction Plugin **/
|
||||
|
||||
$.ui.mouse = {
|
||||
mouseInit: function() {
|
||||
var self = this;
|
||||
|
||||
this.element.bind('mousedown.'+this.widgetName, function(e) {
|
||||
return self.mouseDown(e);
|
||||
});
|
||||
|
||||
// Prevent text selection in IE
|
||||
if ($.browser.msie) {
|
||||
this._mouseUnselectable = this.element.attr('unselectable');
|
||||
this.element.attr('unselectable', 'on');
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// Restore text selection in IE
|
||||
($.browser.msie
|
||||
&& this.element.attr('unselectable', this._mouseUnselectable));
|
||||
},
|
||||
|
||||
mouseDown: function(e) {
|
||||
// we may have missed mouseup (out of window)
|
||||
(this._mouseStarted && this.mouseUp(e));
|
||||
|
||||
this._mouseDownEvent = e;
|
||||
|
||||
var self = this,
|
||||
btnIsLeft = (e.which == 1),
|
||||
elIsCancel = ($(e.target).is(this.options.cancel));
|
||||
if (!btnIsLeft || elIsCancel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this._mouseDelayMet = !this.options.delay;
|
||||
if (!this._mouseDelayMet) {
|
||||
this._mouseDelayTimer = setTimeout(function() {
|
||||
self._mouseDelayMet = true;
|
||||
}, this.options.delay);
|
||||
}
|
||||
|
||||
// these delegates are required to keep context
|
||||
this._mouseMoveDelegate = function(e) {
|
||||
return self.mouseMove(e);
|
||||
};
|
||||
|
||||
// create widget constructor
|
||||
$[namespace][name] = function(element, options) {
|
||||
var self = this;
|
||||
|
||||
this.widgetName = name;
|
||||
|
||||
this.options = $.extend({}, $[namespace][name].defaults, options);
|
||||
this.element = $(element)
|
||||
.bind('setData.' + name, function(e, key, value) {
|
||||
return self.setData(key, value);
|
||||
})
|
||||
.bind('getData.' + name, function(e, key) {
|
||||
return self.getData(key);
|
||||
})
|
||||
.bind('remove', function() {
|
||||
return self.destroy();
|
||||
});
|
||||
this.init();
|
||||
this._mouseUpDelegate = function(e) {
|
||||
return self.mouseUp(e);
|
||||
};
|
||||
$(document)
|
||||
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
||||
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
||||
|
||||
// add widget prototype
|
||||
$[namespace][name].prototype = $.extend({}, widgetPrototype, prototype);
|
||||
};
|
||||
return false;
|
||||
},
|
||||
|
||||
|
||||
/** Mouse Interaction Plugin **/
|
||||
|
||||
$.ui.mouse = {
|
||||
mouseInit: function() {
|
||||
var self = this;
|
||||
mouseMove: function(e) {
|
||||
// IE mouseup check - mouseup happened when mouse was out of window
|
||||
if ($.browser.msie && !e.button) {
|
||||
return this.mouseUp(e);
|
||||
}
|
||||
|
||||
this.element.bind('mousedown.'+this.widgetName, function(e) {
|
||||
return self.mouseDown(e);
|
||||
});
|
||||
|
||||
// Prevent text selection in IE
|
||||
if ($.browser.msie) {
|
||||
this._mouseUnselectable = this.element.attr('unselectable');
|
||||
this.element.attr('unselectable', 'on');
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// Restore text selection in IE
|
||||
($.browser.msie
|
||||
&& this.element.attr('unselectable', this._mouseUnselectable));
|
||||
},
|
||||
|
||||
mouseDown: function(e) {
|
||||
// we may have missed mouseup (out of window)
|
||||
(this._mouseStarted && this.mouseUp(e));
|
||||
|
||||
this._mouseDownEvent = e;
|
||||
|
||||
var self = this,
|
||||
btnIsLeft = (e.which == 1),
|
||||
elIsCancel = ($(e.target).is(this.options.cancel));
|
||||
if (!btnIsLeft || elIsCancel) {
|
||||
return true;
|
||||
}
|
||||
|
||||
this._mouseDelayMet = !this.options.delay;
|
||||
if (!this._mouseDelayMet) {
|
||||
this._mouseDelayTimer = setTimeout(function() {
|
||||
self._mouseDelayMet = true;
|
||||
}, this.options.delay);
|
||||
}
|
||||
|
||||
// these delegates are required to keep context
|
||||
this._mouseMoveDelegate = function(e) {
|
||||
return self.mouseMove(e);
|
||||
};
|
||||
this._mouseUpDelegate = function(e) {
|
||||
return self.mouseUp(e);
|
||||
};
|
||||
$(document)
|
||||
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
||||
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
||||
|
||||
if (this._mouseStarted) {
|
||||
this.mouseDrag(e);
|
||||
return false;
|
||||
},
|
||||
}
|
||||
|
||||
mouseMove: function(e) {
|
||||
// IE mouseup check - mouseup happened when mouse was out of window
|
||||
if ($.browser.msie && !e.button) {
|
||||
return this.mouseUp(e);
|
||||
}
|
||||
|
||||
if (this._mouseStarted) {
|
||||
this.mouseDrag(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
|
||||
this._mouseStarted =
|
||||
(this.mouseStart(this._mouseDownEvent, e) !== false);
|
||||
(this._mouseStarted || this.mouseUp(e));
|
||||
}
|
||||
|
||||
return !this._mouseStarted;
|
||||
},
|
||||
if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
|
||||
this._mouseStarted =
|
||||
(this.mouseStart(this._mouseDownEvent, e) !== false);
|
||||
(this._mouseStarted || this.mouseUp(e));
|
||||
}
|
||||
|
||||
mouseUp: function(e) {
|
||||
$(document)
|
||||
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
||||
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
||||
|
||||
if (this._mouseStarted) {
|
||||
this._mouseStarted = false;
|
||||
this.mouseStop(e);
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
mouseDistanceMet: function(e) {
|
||||
return (Math.max(
|
||||
Math.abs(this._mouseDownEvent.pageX - e.pageX),
|
||||
Math.abs(this._mouseDownEvent.pageY - e.pageY)
|
||||
) >= this.options.distance
|
||||
);
|
||||
},
|
||||
|
||||
mouseDelayMet: function(e) {
|
||||
return this._mouseDelayMet;
|
||||
},
|
||||
|
||||
// These are placeholder methods, to be overriden by extending plugin
|
||||
mouseStart: function(e) {},
|
||||
mouseDrag: function(e) {},
|
||||
mouseStop: function(e) {}
|
||||
};
|
||||
return !this._mouseStarted;
|
||||
},
|
||||
|
||||
$.ui.mouse.defaults = {
|
||||
cancel: null,
|
||||
distance: 0,
|
||||
delay: 0
|
||||
};
|
||||
mouseUp: function(e) {
|
||||
$(document)
|
||||
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
||||
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
||||
|
||||
if (this._mouseStarted) {
|
||||
this._mouseStarted = false;
|
||||
this.mouseStop(e);
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
mouseDistanceMet: function(e) {
|
||||
return (Math.max(
|
||||
Math.abs(this._mouseDownEvent.pageX - e.pageX),
|
||||
Math.abs(this._mouseDownEvent.pageY - e.pageY)
|
||||
) >= this.options.distance
|
||||
);
|
||||
},
|
||||
|
||||
mouseDelayMet: function(e) {
|
||||
return this._mouseDelayMet;
|
||||
},
|
||||
|
||||
// These are placeholder methods, to be overriden by extending plugin
|
||||
mouseStart: function(e) {},
|
||||
mouseDrag: function(e) {},
|
||||
mouseStop: function(e) {}
|
||||
};
|
||||
|
||||
$.ui.mouse.defaults = {
|
||||
cancel: null,
|
||||
distance: 0,
|
||||
delay: 0
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
@@ -1443,4 +1443,4 @@ $(document).ready(function() {
|
||||
.mousedown($.datepicker._checkExternalClick);
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
||||
@@ -15,434 +15,434 @@
|
||||
* Revision: $Id: ui.dialog.js 5608 2008-05-15 14:41:12Z scott.gonzalez $
|
||||
*/
|
||||
;(function($) {
|
||||
|
||||
var setDataSwitch = {
|
||||
dragStart: "start.draggable",
|
||||
drag: "drag.draggable",
|
||||
dragStop: "stop.draggable",
|
||||
maxHeight: "maxHeight.resizable",
|
||||
minHeight: "minHeight.resizable",
|
||||
maxWidth: "maxWidth.resizable",
|
||||
minWidth: "minWidth.resizable",
|
||||
resizeStart: "start.resizable",
|
||||
resize: "drag.resizable",
|
||||
resizeStop: "stop.resizable"
|
||||
};
|
||||
|
||||
$.widget("ui.dialog", {
|
||||
init: function() {
|
||||
var self = this;
|
||||
var options = this.options;
|
||||
|
||||
var uiDialogContent = this.element.addClass('ui-dialog-content');
|
||||
|
||||
if (!uiDialogContent.parent().length) {
|
||||
uiDialogContent.appendTo('body');
|
||||
}
|
||||
uiDialogContent
|
||||
.wrap(document.createElement('div'))
|
||||
.wrap(document.createElement('div'));
|
||||
var uiDialogContainer = uiDialogContent.parent().addClass('ui-dialog-container').css({position: 'relative'});
|
||||
var uiDialog = (this.uiDialog = uiDialogContainer.parent()).hide()
|
||||
.addClass('ui-dialog').addClass(options.dialogClass)
|
||||
.css({position: 'absolute', width: options.width, height: options.height, overflow: 'hidden'});
|
||||
|
||||
var classNames = uiDialogContent.attr('className').split(' ');
|
||||
|
||||
// Add content classes to dialog, to inherit theme at top level of element
|
||||
$.each(classNames, function(i, className) {
|
||||
((className != 'ui-dialog-content')
|
||||
&& uiDialog.addClass(className));
|
||||
});
|
||||
|
||||
if ($.fn.resizable) {
|
||||
uiDialog.append('<div class="ui-resizable-n ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-s ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-e ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-w ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-ne ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-se ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-sw ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-nw ui-resizable-handle"></div>');
|
||||
uiDialog.resizable({
|
||||
maxWidth: options.maxWidth,
|
||||
maxHeight: options.maxHeight,
|
||||
minWidth: options.minWidth,
|
||||
minHeight: options.minHeight,
|
||||
start: options.resizeStart,
|
||||
resize: options.resize,
|
||||
stop: function(e, ui) {
|
||||
(options.resizeStop && options.resizeStop.apply(this, arguments));
|
||||
$.ui.dialog.overlay.resize();
|
||||
}
|
||||
});
|
||||
(!options.resizable && uiDialog.resizable('disable'));
|
||||
}
|
||||
|
||||
uiDialogContainer.prepend('<div class="ui-dialog-titlebar"></div>');
|
||||
var uiDialogTitlebar = $('.ui-dialog-titlebar', uiDialogContainer);
|
||||
this.uiDialogTitlebar = uiDialogTitlebar;
|
||||
var title = (options.title) ? options.title : (uiDialogContent.attr('title')) ? uiDialogContent.attr('title') : '';
|
||||
uiDialogTitlebar.append('<span class="ui-dialog-title">' + title + '</span>');
|
||||
uiDialogTitlebar.append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>');
|
||||
this.uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar)
|
||||
.hover(function() { $(this).addClass('ui-dialog-titlebar-close-hover'); },
|
||||
function() { $(this).removeClass('ui-dialog-titlebar-close-hover'); }
|
||||
)
|
||||
.mousedown(function(ev) {
|
||||
ev.stopPropagation();
|
||||
})
|
||||
.click(function() {
|
||||
self.close();
|
||||
return false;
|
||||
});
|
||||
|
||||
// setting tabindex makes the div focusable
|
||||
// setting outline to 0 prevents a border on focus in Mozilla
|
||||
uiDialog.attr('tabindex', -1).css('outline', 0).keydown(function(ev) {
|
||||
if (options.closeOnEscape) {
|
||||
var ESC = 27;
|
||||
(ev.keyCode && ev.keyCode == ESC && self.close());
|
||||
}
|
||||
});
|
||||
|
||||
var hasButtons = false;
|
||||
$.each(options.buttons, function() { return !(hasButtons = true); });
|
||||
if (hasButtons) {
|
||||
var uiDialogButtonPane = $('<div class="ui-dialog-buttonpane"/>')
|
||||
.appendTo(uiDialog);
|
||||
$.each(options.buttons, function(name, fn) {
|
||||
$(document.createElement('button'))
|
||||
.text(name)
|
||||
.click(function() { fn.apply(self.element, arguments); })
|
||||
.appendTo(uiDialogButtonPane);
|
||||
});
|
||||
}
|
||||
|
||||
if ($.fn.draggable) {
|
||||
uiDialog.draggable({
|
||||
handle: '.ui-dialog-titlebar',
|
||||
start: function(e, ui) {
|
||||
self.activate();
|
||||
(options.dragStart && options.dragStart.apply(this, arguments));
|
||||
},
|
||||
drag: options.drag,
|
||||
stop: function(e, ui) {
|
||||
(options.dragStop && options.dragStop.apply(this, arguments));
|
||||
$.ui.dialog.overlay.resize();
|
||||
}
|
||||
});
|
||||
(!options.draggable && uiDialog.draggable('disable'));
|
||||
}
|
||||
|
||||
uiDialog.mousedown(function() {
|
||||
self.activate();
|
||||
});
|
||||
uiDialogTitlebar.click(function() {
|
||||
self.activate();
|
||||
});
|
||||
|
||||
(options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());
|
||||
|
||||
(options.autoOpen && this.open());
|
||||
},
|
||||
|
||||
setData: function(key, value){
|
||||
(setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value));
|
||||
switch (key) {
|
||||
case "draggable":
|
||||
this.uiDialog.draggable(value ? 'enable' : 'disable');
|
||||
break;
|
||||
case "height":
|
||||
this.uiDialog.height(value);
|
||||
break;
|
||||
case "position":
|
||||
this.position(value);
|
||||
break;
|
||||
case "resizable":
|
||||
this.uiDialog.resizable(value ? 'enable' : 'disable');
|
||||
break;
|
||||
case "title":
|
||||
$(".ui-dialog-title", this.uiDialogTitlebar).text(value);
|
||||
break;
|
||||
case "width":
|
||||
this.uiDialog.width(value);
|
||||
break;
|
||||
}
|
||||
this.options[key] = value;
|
||||
},
|
||||
|
||||
position: function(pos) {
|
||||
var wnd = $(window), doc = $(document),
|
||||
pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),
|
||||
minTop = pTop;
|
||||
|
||||
if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) {
|
||||
pos = [
|
||||
pos == 'right' || pos == 'left' ? pos : 'center',
|
||||
pos == 'top' || pos == 'bottom' ? pos : 'middle'
|
||||
];
|
||||
}
|
||||
if (pos.constructor != Array) {
|
||||
pos = ['center', 'middle'];
|
||||
}
|
||||
if (pos[0].constructor == Number) {
|
||||
pLeft += pos[0];
|
||||
} else {
|
||||
switch (pos[0]) {
|
||||
case 'left':
|
||||
pLeft += 0;
|
||||
break;
|
||||
case 'right':
|
||||
pLeft += (wnd.width()) - (this.uiDialog.width());
|
||||
break;
|
||||
default:
|
||||
case 'center':
|
||||
pLeft += (wnd.width() / 2) - (this.uiDialog.width() / 2);
|
||||
}
|
||||
}
|
||||
if (pos[1].constructor == Number) {
|
||||
pTop += pos[1];
|
||||
} else {
|
||||
switch (pos[1]) {
|
||||
case 'top':
|
||||
pTop += 0;
|
||||
break;
|
||||
case 'bottom':
|
||||
pTop += (wnd.height()) - (this.uiDialog.height());
|
||||
break;
|
||||
default:
|
||||
case 'middle':
|
||||
pTop += (wnd.height() / 2) - (this.uiDialog.height() / 2);
|
||||
}
|
||||
}
|
||||
|
||||
// prevent the dialog from being too high (make sure the titlebar
|
||||
// is accessible)
|
||||
pTop = Math.max(pTop, minTop);
|
||||
this.uiDialog.css({top: pTop, left: pLeft});
|
||||
},
|
||||
|
||||
open: function() {
|
||||
this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null;
|
||||
this.uiDialog.appendTo('body');
|
||||
this.position(this.options.position);
|
||||
this.uiDialog.show();
|
||||
this.moveToTop();
|
||||
this.activate();
|
||||
|
||||
// CALLBACK: open
|
||||
var openEV = null;
|
||||
var openUI = {
|
||||
options: this.options
|
||||
};
|
||||
this.uiDialogTitlebarClose.focus();
|
||||
this.element.triggerHandler("dialogopen", [openEV, openUI], this.options.open);
|
||||
},
|
||||
|
||||
activate: function() {
|
||||
// Move modeless dialogs to the top when they're activated. Even
|
||||
// if there is a modal dialog in the window, the modeless dialog
|
||||
// should be on top because it must have been opened after the modal
|
||||
// dialog. Modal dialogs don't get moved to the top because that
|
||||
// would make any modeless dialogs that it spawned unusable until
|
||||
// the modal dialog is closed.
|
||||
(!this.options.modal && this.moveToTop());
|
||||
},
|
||||
|
||||
moveToTop: function() {
|
||||
var maxZ = this.options.zIndex, options = this.options;
|
||||
$('.ui-dialog:visible').each(function() {
|
||||
maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex);
|
||||
});
|
||||
(this.overlay && this.overlay.$el.css('z-index', ++maxZ));
|
||||
this.uiDialog.css('z-index', ++maxZ);
|
||||
},
|
||||
|
||||
close: function() {
|
||||
(this.overlay && this.overlay.destroy());
|
||||
this.uiDialog.hide();
|
||||
|
||||
// CALLBACK: close
|
||||
var closeEV = null;
|
||||
var closeUI = {
|
||||
options: this.options
|
||||
};
|
||||
this.element.triggerHandler("dialogclose", [closeEV, closeUI], this.options.close);
|
||||
$.ui.dialog.overlay.resize();
|
||||
},
|
||||
var setDataSwitch = {
|
||||
dragStart: "start.draggable",
|
||||
drag: "drag.draggable",
|
||||
dragStop: "stop.draggable",
|
||||
maxHeight: "maxHeight.resizable",
|
||||
minHeight: "minHeight.resizable",
|
||||
maxWidth: "maxWidth.resizable",
|
||||
minWidth: "minWidth.resizable",
|
||||
resizeStart: "start.resizable",
|
||||
resize: "drag.resizable",
|
||||
resizeStop: "stop.resizable"
|
||||
};
|
||||
|
||||
$.widget("ui.dialog", {
|
||||
init: function() {
|
||||
var self = this;
|
||||
var options = this.options;
|
||||
|
||||
destroy: function() {
|
||||
(this.overlay && this.overlay.destroy());
|
||||
this.uiDialog.hide();
|
||||
this.element
|
||||
.unbind('.dialog')
|
||||
.removeData('dialog')
|
||||
.removeClass('ui-dialog-content')
|
||||
.hide().appendTo('body');
|
||||
this.uiDialog.remove();
|
||||
}
|
||||
});
|
||||
|
||||
$.extend($.ui.dialog, {
|
||||
defaults: {
|
||||
autoOpen: true,
|
||||
bgiframe: false,
|
||||
buttons: {},
|
||||
closeOnEscape: true,
|
||||
draggable: true,
|
||||
height: 200,
|
||||
minHeight: 100,
|
||||
minWidth: 150,
|
||||
modal: false,
|
||||
overlay: {},
|
||||
position: 'center',
|
||||
resizable: true,
|
||||
width: 300,
|
||||
zIndex: 1000
|
||||
},
|
||||
var uiDialogContent = this.element.addClass('ui-dialog-content');
|
||||
|
||||
overlay: function(dialog) {
|
||||
this.$el = $.ui.dialog.overlay.create(dialog);
|
||||
if (!uiDialogContent.parent().length) {
|
||||
uiDialogContent.appendTo('body');
|
||||
}
|
||||
uiDialogContent
|
||||
.wrap(document.createElement('div'))
|
||||
.wrap(document.createElement('div'));
|
||||
var uiDialogContainer = uiDialogContent.parent().addClass('ui-dialog-container').css({position: 'relative'});
|
||||
var uiDialog = (this.uiDialog = uiDialogContainer.parent()).hide()
|
||||
.addClass('ui-dialog').addClass(options.dialogClass)
|
||||
.css({position: 'absolute', width: options.width, height: options.height, overflow: 'hidden'});
|
||||
|
||||
var classNames = uiDialogContent.attr('className').split(' ');
|
||||
|
||||
// Add content classes to dialog, to inherit theme at top level of element
|
||||
$.each(classNames, function(i, className) {
|
||||
((className != 'ui-dialog-content')
|
||||
&& uiDialog.addClass(className));
|
||||
});
|
||||
|
||||
if ($.fn.resizable) {
|
||||
uiDialog.append('<div class="ui-resizable-n ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-s ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-e ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-w ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-ne ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-se ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-sw ui-resizable-handle"></div>')
|
||||
.append('<div class="ui-resizable-nw ui-resizable-handle"></div>');
|
||||
uiDialog.resizable({
|
||||
maxWidth: options.maxWidth,
|
||||
maxHeight: options.maxHeight,
|
||||
minWidth: options.minWidth,
|
||||
minHeight: options.minHeight,
|
||||
start: options.resizeStart,
|
||||
resize: options.resize,
|
||||
stop: function(e, ui) {
|
||||
(options.resizeStop && options.resizeStop.apply(this, arguments));
|
||||
$.ui.dialog.overlay.resize();
|
||||
}
|
||||
});
|
||||
(!options.resizable && uiDialog.resizable('disable'));
|
||||
}
|
||||
|
||||
uiDialogContainer.prepend('<div class="ui-dialog-titlebar"></div>');
|
||||
var uiDialogTitlebar = $('.ui-dialog-titlebar', uiDialogContainer);
|
||||
this.uiDialogTitlebar = uiDialogTitlebar;
|
||||
var title = (options.title) ? options.title : (uiDialogContent.attr('title')) ? uiDialogContent.attr('title') : '';
|
||||
uiDialogTitlebar.append('<span class="ui-dialog-title">' + title + '</span>');
|
||||
uiDialogTitlebar.append('<a href="#" class="ui-dialog-titlebar-close"><span>X</span></a>');
|
||||
this.uiDialogTitlebarClose = $('.ui-dialog-titlebar-close', uiDialogTitlebar)
|
||||
.hover(function() { $(this).addClass('ui-dialog-titlebar-close-hover'); },
|
||||
function() { $(this).removeClass('ui-dialog-titlebar-close-hover'); }
|
||||
)
|
||||
.mousedown(function(ev) {
|
||||
ev.stopPropagation();
|
||||
})
|
||||
.click(function() {
|
||||
self.close();
|
||||
return false;
|
||||
});
|
||||
|
||||
// setting tabindex makes the div focusable
|
||||
// setting outline to 0 prevents a border on focus in Mozilla
|
||||
uiDialog.attr('tabindex', -1).css('outline', 0).keydown(function(ev) {
|
||||
if (options.closeOnEscape) {
|
||||
var ESC = 27;
|
||||
(ev.keyCode && ev.keyCode == ESC && self.close());
|
||||
}
|
||||
});
|
||||
|
||||
var hasButtons = false;
|
||||
$.each(options.buttons, function() { return !(hasButtons = true); });
|
||||
if (hasButtons) {
|
||||
var uiDialogButtonPane = $('<div class="ui-dialog-buttonpane"/>')
|
||||
.appendTo(uiDialog);
|
||||
$.each(options.buttons, function(name, fn) {
|
||||
$(document.createElement('button'))
|
||||
.text(name)
|
||||
.click(function() { fn.apply(self.element, arguments); })
|
||||
.appendTo(uiDialogButtonPane);
|
||||
});
|
||||
}
|
||||
|
||||
if ($.fn.draggable) {
|
||||
uiDialog.draggable({
|
||||
handle: '.ui-dialog-titlebar',
|
||||
start: function(e, ui) {
|
||||
self.activate();
|
||||
(options.dragStart && options.dragStart.apply(this, arguments));
|
||||
},
|
||||
drag: options.drag,
|
||||
stop: function(e, ui) {
|
||||
(options.dragStop && options.dragStop.apply(this, arguments));
|
||||
$.ui.dialog.overlay.resize();
|
||||
}
|
||||
});
|
||||
(!options.draggable && uiDialog.draggable('disable'));
|
||||
}
|
||||
});
|
||||
|
||||
$.extend($.ui.dialog.overlay, {
|
||||
instances: [],
|
||||
events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
|
||||
function(e) { return e + '.dialog-overlay'; }).join(' '),
|
||||
create: function(dialog) {
|
||||
if (this.instances.length === 0) {
|
||||
// prevent use of anchors and inputs
|
||||
// we use a setTimeout in case the overlay is created from an
|
||||
// event that we're going to be cancelling (see #2804)
|
||||
setTimeout(function() {
|
||||
$('a, :input').bind($.ui.dialog.overlay.events, function() {
|
||||
// allow use of the element if inside a dialog and
|
||||
// - there are no modal dialogs
|
||||
// - there are modal dialogs, but we are in front of the topmost modal
|
||||
var allow = false;
|
||||
var $dialog = $(this).parents('.ui-dialog');
|
||||
if ($dialog.length) {
|
||||
var $overlays = $('.ui-dialog-overlay');
|
||||
if ($overlays.length) {
|
||||
var maxZ = parseInt($overlays.css('z-index'), 10);
|
||||
$overlays.each(function() {
|
||||
maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10));
|
||||
});
|
||||
allow = parseInt($dialog.css('z-index'), 10) > maxZ;
|
||||
} else {
|
||||
allow = true;
|
||||
}
|
||||
uiDialog.mousedown(function() {
|
||||
self.activate();
|
||||
});
|
||||
uiDialogTitlebar.click(function() {
|
||||
self.activate();
|
||||
});
|
||||
|
||||
(options.bgiframe && $.fn.bgiframe && uiDialog.bgiframe());
|
||||
|
||||
(options.autoOpen && this.open());
|
||||
},
|
||||
|
||||
setData: function(key, value){
|
||||
(setDataSwitch[key] && this.uiDialog.data(setDataSwitch[key], value));
|
||||
switch (key) {
|
||||
case "draggable":
|
||||
this.uiDialog.draggable(value ? 'enable' : 'disable');
|
||||
break;
|
||||
case "height":
|
||||
this.uiDialog.height(value);
|
||||
break;
|
||||
case "position":
|
||||
this.position(value);
|
||||
break;
|
||||
case "resizable":
|
||||
this.uiDialog.resizable(value ? 'enable' : 'disable');
|
||||
break;
|
||||
case "title":
|
||||
$(".ui-dialog-title", this.uiDialogTitlebar).text(value);
|
||||
break;
|
||||
case "width":
|
||||
this.uiDialog.width(value);
|
||||
break;
|
||||
}
|
||||
this.options[key] = value;
|
||||
},
|
||||
|
||||
position: function(pos) {
|
||||
var wnd = $(window), doc = $(document),
|
||||
pTop = doc.scrollTop(), pLeft = doc.scrollLeft(),
|
||||
minTop = pTop;
|
||||
|
||||
if ($.inArray(pos, ['center','top','right','bottom','left']) >= 0) {
|
||||
pos = [
|
||||
pos == 'right' || pos == 'left' ? pos : 'center',
|
||||
pos == 'top' || pos == 'bottom' ? pos : 'middle'
|
||||
];
|
||||
}
|
||||
if (pos.constructor != Array) {
|
||||
pos = ['center', 'middle'];
|
||||
}
|
||||
if (pos[0].constructor == Number) {
|
||||
pLeft += pos[0];
|
||||
} else {
|
||||
switch (pos[0]) {
|
||||
case 'left':
|
||||
pLeft += 0;
|
||||
break;
|
||||
case 'right':
|
||||
pLeft += (wnd.width()) - (this.uiDialog.width());
|
||||
break;
|
||||
default:
|
||||
case 'center':
|
||||
pLeft += (wnd.width() / 2) - (this.uiDialog.width() / 2);
|
||||
}
|
||||
}
|
||||
if (pos[1].constructor == Number) {
|
||||
pTop += pos[1];
|
||||
} else {
|
||||
switch (pos[1]) {
|
||||
case 'top':
|
||||
pTop += 0;
|
||||
break;
|
||||
case 'bottom':
|
||||
pTop += (wnd.height()) - (this.uiDialog.height());
|
||||
break;
|
||||
default:
|
||||
case 'middle':
|
||||
pTop += (wnd.height() / 2) - (this.uiDialog.height() / 2);
|
||||
}
|
||||
}
|
||||
|
||||
// prevent the dialog from being too high (make sure the titlebar
|
||||
// is accessible)
|
||||
pTop = Math.max(pTop, minTop);
|
||||
this.uiDialog.css({top: pTop, left: pLeft});
|
||||
},
|
||||
|
||||
open: function() {
|
||||
this.overlay = this.options.modal ? new $.ui.dialog.overlay(this) : null;
|
||||
this.uiDialog.appendTo('body');
|
||||
this.position(this.options.position);
|
||||
this.uiDialog.show();
|
||||
this.moveToTop();
|
||||
this.activate();
|
||||
|
||||
// CALLBACK: open
|
||||
var openEV = null;
|
||||
var openUI = {
|
||||
options: this.options
|
||||
};
|
||||
this.uiDialogTitlebarClose.focus();
|
||||
this.element.triggerHandler("dialogopen", [openEV, openUI], this.options.open);
|
||||
},
|
||||
|
||||
activate: function() {
|
||||
// Move modeless dialogs to the top when they're activated. Even
|
||||
// if there is a modal dialog in the window, the modeless dialog
|
||||
// should be on top because it must have been opened after the modal
|
||||
// dialog. Modal dialogs don't get moved to the top because that
|
||||
// would make any modeless dialogs that it spawned unusable until
|
||||
// the modal dialog is closed.
|
||||
(!this.options.modal && this.moveToTop());
|
||||
},
|
||||
|
||||
moveToTop: function() {
|
||||
var maxZ = this.options.zIndex, options = this.options;
|
||||
$('.ui-dialog:visible').each(function() {
|
||||
maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10) || options.zIndex);
|
||||
});
|
||||
(this.overlay && this.overlay.$el.css('z-index', ++maxZ));
|
||||
this.uiDialog.css('z-index', ++maxZ);
|
||||
},
|
||||
|
||||
close: function() {
|
||||
(this.overlay && this.overlay.destroy());
|
||||
this.uiDialog.hide();
|
||||
|
||||
// CALLBACK: close
|
||||
var closeEV = null;
|
||||
var closeUI = {
|
||||
options: this.options
|
||||
};
|
||||
this.element.triggerHandler("dialogclose", [closeEV, closeUI], this.options.close);
|
||||
$.ui.dialog.overlay.resize();
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
(this.overlay && this.overlay.destroy());
|
||||
this.uiDialog.hide();
|
||||
this.element
|
||||
.unbind('.dialog')
|
||||
.removeData('dialog')
|
||||
.removeClass('ui-dialog-content')
|
||||
.hide().appendTo('body');
|
||||
this.uiDialog.remove();
|
||||
}
|
||||
});
|
||||
|
||||
$.extend($.ui.dialog, {
|
||||
defaults: {
|
||||
autoOpen: true,
|
||||
bgiframe: false,
|
||||
buttons: {},
|
||||
closeOnEscape: true,
|
||||
draggable: true,
|
||||
height: 200,
|
||||
minHeight: 100,
|
||||
minWidth: 150,
|
||||
modal: false,
|
||||
overlay: {},
|
||||
position: 'center',
|
||||
resizable: true,
|
||||
width: 300,
|
||||
zIndex: 1000
|
||||
},
|
||||
|
||||
overlay: function(dialog) {
|
||||
this.$el = $.ui.dialog.overlay.create(dialog);
|
||||
}
|
||||
});
|
||||
|
||||
$.extend($.ui.dialog.overlay, {
|
||||
instances: [],
|
||||
events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
|
||||
function(e) { return e + '.dialog-overlay'; }).join(' '),
|
||||
create: function(dialog) {
|
||||
if (this.instances.length === 0) {
|
||||
// prevent use of anchors and inputs
|
||||
// we use a setTimeout in case the overlay is created from an
|
||||
// event that we're going to be cancelling (see #2804)
|
||||
setTimeout(function() {
|
||||
$('a, :input').bind($.ui.dialog.overlay.events, function() {
|
||||
// allow use of the element if inside a dialog and
|
||||
// - there are no modal dialogs
|
||||
// - there are modal dialogs, but we are in front of the topmost modal
|
||||
var allow = false;
|
||||
var $dialog = $(this).parents('.ui-dialog');
|
||||
if ($dialog.length) {
|
||||
var $overlays = $('.ui-dialog-overlay');
|
||||
if ($overlays.length) {
|
||||
var maxZ = parseInt($overlays.css('z-index'), 10);
|
||||
$overlays.each(function() {
|
||||
maxZ = Math.max(maxZ, parseInt($(this).css('z-index'), 10));
|
||||
});
|
||||
allow = parseInt($dialog.css('z-index'), 10) > maxZ;
|
||||
} else {
|
||||
allow = true;
|
||||
}
|
||||
return allow;
|
||||
});
|
||||
}, 1);
|
||||
|
||||
// allow closing by pressing the escape key
|
||||
$(document).bind('keydown.dialog-overlay', function(e) {
|
||||
var ESC = 27;
|
||||
(e.keyCode && e.keyCode == ESC && dialog.close());
|
||||
}
|
||||
return allow;
|
||||
});
|
||||
|
||||
// handle window resize
|
||||
$(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
|
||||
}
|
||||
}, 1);
|
||||
|
||||
var $el = $('<div/>').appendTo(document.body)
|
||||
.addClass('ui-dialog-overlay').css($.extend({
|
||||
borderWidth: 0, margin: 0, padding: 0,
|
||||
position: 'absolute', top: 0, left: 0,
|
||||
width: this.width(),
|
||||
height: this.height()
|
||||
}, dialog.options.overlay));
|
||||
|
||||
(dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());
|
||||
|
||||
this.instances.push($el);
|
||||
return $el;
|
||||
},
|
||||
|
||||
destroy: function($el) {
|
||||
this.instances.splice($.inArray(this.instances, $el), 1);
|
||||
|
||||
if (this.instances.length === 0) {
|
||||
$('a, :input').add([document, window]).unbind('.dialog-overlay');
|
||||
}
|
||||
|
||||
$el.remove();
|
||||
},
|
||||
|
||||
height: function() {
|
||||
if ($.browser.msie && $.browser.version < 7) {
|
||||
var scrollHeight = Math.max(
|
||||
document.documentElement.scrollHeight,
|
||||
document.body.scrollHeight
|
||||
);
|
||||
var offsetHeight = Math.max(
|
||||
document.documentElement.offsetHeight,
|
||||
document.body.offsetHeight
|
||||
);
|
||||
|
||||
if (scrollHeight < offsetHeight) {
|
||||
return $(window).height() + 'px';
|
||||
} else {
|
||||
return scrollHeight + 'px';
|
||||
}
|
||||
} else {
|
||||
return $(document).height() + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
width: function() {
|
||||
if ($.browser.msie && $.browser.version < 7) {
|
||||
var scrollWidth = Math.max(
|
||||
document.documentElement.scrollWidth,
|
||||
document.body.scrollWidth
|
||||
);
|
||||
var offsetWidth = Math.max(
|
||||
document.documentElement.offsetWidth,
|
||||
document.body.offsetWidth
|
||||
);
|
||||
|
||||
if (scrollWidth < offsetWidth) {
|
||||
return $(window).width() + 'px';
|
||||
} else {
|
||||
return scrollWidth + 'px';
|
||||
}
|
||||
} else {
|
||||
return $(document).width() + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
resize: function() {
|
||||
/* If the dialog is draggable and the user drags it past the
|
||||
* right edge of the window, the document becomes wider so we
|
||||
* need to stretch the overlay. If the user then drags the
|
||||
* dialog back to the left, the document will become narrower,
|
||||
* so we need to shrink the overlay to the appropriate size.
|
||||
* This is handled by shrinking the overlay before setting it
|
||||
* to the full document size.
|
||||
*/
|
||||
var $overlays = $([]);
|
||||
$.each($.ui.dialog.overlay.instances, function() {
|
||||
$overlays = $overlays.add(this);
|
||||
// allow closing by pressing the escape key
|
||||
$(document).bind('keydown.dialog-overlay', function(e) {
|
||||
var ESC = 27;
|
||||
(e.keyCode && e.keyCode == ESC && dialog.close());
|
||||
});
|
||||
|
||||
$overlays.css({
|
||||
width: 0,
|
||||
height: 0
|
||||
}).css({
|
||||
width: $.ui.dialog.overlay.width(),
|
||||
height: $.ui.dialog.overlay.height()
|
||||
});
|
||||
// handle window resize
|
||||
$(window).bind('resize.dialog-overlay', $.ui.dialog.overlay.resize);
|
||||
}
|
||||
});
|
||||
|
||||
var $el = $('<div/>').appendTo(document.body)
|
||||
.addClass('ui-dialog-overlay').css($.extend({
|
||||
borderWidth: 0, margin: 0, padding: 0,
|
||||
position: 'absolute', top: 0, left: 0,
|
||||
width: this.width(),
|
||||
height: this.height()
|
||||
}, dialog.options.overlay));
|
||||
|
||||
(dialog.options.bgiframe && $.fn.bgiframe && $el.bgiframe());
|
||||
|
||||
this.instances.push($el);
|
||||
return $el;
|
||||
},
|
||||
|
||||
$.extend($.ui.dialog.overlay.prototype, {
|
||||
destroy: function() {
|
||||
$.ui.dialog.overlay.destroy(this.$el);
|
||||
destroy: function($el) {
|
||||
this.instances.splice($.inArray(this.instances, $el), 1);
|
||||
|
||||
if (this.instances.length === 0) {
|
||||
$('a, :input').add([document, window]).unbind('.dialog-overlay');
|
||||
}
|
||||
});
|
||||
|
||||
$el.remove();
|
||||
},
|
||||
|
||||
height: function() {
|
||||
if ($.browser.msie && $.browser.version < 7) {
|
||||
var scrollHeight = Math.max(
|
||||
document.documentElement.scrollHeight,
|
||||
document.body.scrollHeight
|
||||
);
|
||||
var offsetHeight = Math.max(
|
||||
document.documentElement.offsetHeight,
|
||||
document.body.offsetHeight
|
||||
);
|
||||
|
||||
if (scrollHeight < offsetHeight) {
|
||||
return $(window).height() + 'px';
|
||||
} else {
|
||||
return scrollHeight + 'px';
|
||||
}
|
||||
} else {
|
||||
return $(document).height() + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
width: function() {
|
||||
if ($.browser.msie && $.browser.version < 7) {
|
||||
var scrollWidth = Math.max(
|
||||
document.documentElement.scrollWidth,
|
||||
document.body.scrollWidth
|
||||
);
|
||||
var offsetWidth = Math.max(
|
||||
document.documentElement.offsetWidth,
|
||||
document.body.offsetWidth
|
||||
);
|
||||
|
||||
if (scrollWidth < offsetWidth) {
|
||||
return $(window).width() + 'px';
|
||||
} else {
|
||||
return scrollWidth + 'px';
|
||||
}
|
||||
} else {
|
||||
return $(document).width() + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
resize: function() {
|
||||
/* If the dialog is draggable and the user drags it past the
|
||||
* right edge of the window, the document becomes wider so we
|
||||
* need to stretch the overlay. If the user then drags the
|
||||
* dialog back to the left, the document will become narrower,
|
||||
* so we need to shrink the overlay to the appropriate size.
|
||||
* This is handled by shrinking the overlay before setting it
|
||||
* to the full document size.
|
||||
*/
|
||||
var $overlays = $([]);
|
||||
$.each($.ui.dialog.overlay.instances, function() {
|
||||
$overlays = $overlays.add(this);
|
||||
});
|
||||
|
||||
$overlays.css({
|
||||
width: 0,
|
||||
height: 0
|
||||
}).css({
|
||||
width: $.ui.dialog.overlay.width(),
|
||||
height: $.ui.dialog.overlay.height()
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$.extend($.ui.dialog.overlay.prototype, {
|
||||
destroy: function() {
|
||||
$.ui.dialog.overlay.destroy(this.$el);
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,280 +13,279 @@
|
||||
*
|
||||
* Revision: $Id: ui.droppable.js 5568 2008-05-12 15:07:16Z paul.bakaus $
|
||||
*/
|
||||
|
||||
;(function($) {
|
||||
|
||||
$.widget("ui.droppable", {
|
||||
init: function() {
|
||||
$.widget("ui.droppable", {
|
||||
init: function() {
|
||||
|
||||
this.element.addClass("ui-droppable");
|
||||
this.isover = 0; this.isout = 1;
|
||||
|
||||
//Prepare the passed options
|
||||
var o = this.options, accept = o.accept;
|
||||
o = $.extend(o, {
|
||||
accept: o.accept && o.accept.constructor == Function ? o.accept : function(d) {
|
||||
return $(d).is(accept);
|
||||
}
|
||||
});
|
||||
|
||||
//Store the droppable's proportions
|
||||
this.proportions = { width: this.element.outerWidth(), height: this.element.outerHeight() };
|
||||
|
||||
// Add the reference and positions to the manager
|
||||
$.ui.ddmanager.droppables.push(this);
|
||||
|
||||
},
|
||||
plugins: {},
|
||||
ui: function(c) {
|
||||
return {
|
||||
instance: this,
|
||||
draggable: (c.currentItem || c.element),
|
||||
helper: c.helper,
|
||||
position: c.position,
|
||||
absolutePosition: c.positionAbs,
|
||||
options: this.options,
|
||||
element: this.element
|
||||
};
|
||||
},
|
||||
destroy: function() {
|
||||
var drop = $.ui.ddmanager.droppables;
|
||||
for ( var i = 0; i < drop.length; i++ )
|
||||
if ( drop[i] == this )
|
||||
drop.splice(i, 1);
|
||||
|
||||
this.element
|
||||
.removeClass("ui-droppable ui-droppable-disabled")
|
||||
.removeData("droppable")
|
||||
.unbind(".droppable");
|
||||
},
|
||||
enable: function() {
|
||||
this.element.removeClass("ui-droppable-disabled");
|
||||
this.options.disabled = false;
|
||||
},
|
||||
disable: function() {
|
||||
this.element.addClass("ui-droppable-disabled");
|
||||
this.options.disabled = true;
|
||||
},
|
||||
over: function(e) {
|
||||
|
||||
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.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
|
||||
$.ui.plugin.call(this, 'over', [e, this.ui(draggable)]);
|
||||
this.element.triggerHandler("dropover", [e, this.ui(draggable)], this.options.over);
|
||||
}
|
||||
|
||||
},
|
||||
out: function(e) {
|
||||
|
||||
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.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
|
||||
$.ui.plugin.call(this, 'out', [e, this.ui(draggable)]);
|
||||
this.element.triggerHandler("dropout", [e, this.ui(draggable)], this.options.out);
|
||||
}
|
||||
|
||||
},
|
||||
drop: function(e,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(".ui-droppable").not(".ui-draggable-dragging").each(function() {
|
||||
var inst = $.data(this, 'droppable');
|
||||
if(inst.options.greedy && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)) {
|
||||
childrenIntersection = true; return false;
|
||||
}
|
||||
});
|
||||
if(childrenIntersection) return false;
|
||||
|
||||
if(this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
|
||||
$.ui.plugin.call(this, 'drop', [e, this.ui(draggable)]);
|
||||
this.element.triggerHandler("drop", [e, this.ui(draggable)], this.options.drop);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
},
|
||||
activate: function(e) {
|
||||
|
||||
var draggable = $.ui.ddmanager.current;
|
||||
$.ui.plugin.call(this, 'activate', [e, this.ui(draggable)]);
|
||||
if(draggable) this.element.triggerHandler("dropactivate", [e, this.ui(draggable)], this.options.activate);
|
||||
|
||||
},
|
||||
deactivate: function(e) {
|
||||
|
||||
var draggable = $.ui.ddmanager.current;
|
||||
$.ui.plugin.call(this, 'deactivate', [e, this.ui(draggable)]);
|
||||
if(draggable) this.element.triggerHandler("dropdeactivate", [e, this.ui(draggable)], this.options.deactivate);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$.extend($.ui.droppable, {
|
||||
defaults: {
|
||||
disabled: false,
|
||||
tolerance: 'intersect'
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.intersect = function(draggable, droppable, toleranceMode) {
|
||||
|
||||
this.element.addClass("ui-droppable");
|
||||
this.isover = 0; this.isout = 1;
|
||||
|
||||
//Prepare the passed options
|
||||
var o = this.options, accept = o.accept;
|
||||
o = $.extend(o, {
|
||||
accept: o.accept && o.accept.constructor == Function ? o.accept : function(d) {
|
||||
return $(d).is(accept);
|
||||
}
|
||||
});
|
||||
|
||||
//Store the droppable's proportions
|
||||
this.proportions = { width: this.element.outerWidth(), height: this.element.outerHeight() };
|
||||
|
||||
// Add the reference and positions to the manager
|
||||
$.ui.ddmanager.droppables.push(this);
|
||||
|
||||
},
|
||||
plugins: {},
|
||||
ui: function(c) {
|
||||
return {
|
||||
instance: this,
|
||||
draggable: (c.currentItem || c.element),
|
||||
helper: c.helper,
|
||||
position: c.position,
|
||||
absolutePosition: c.positionAbs,
|
||||
options: this.options,
|
||||
element: this.element
|
||||
};
|
||||
},
|
||||
destroy: function() {
|
||||
var drop = $.ui.ddmanager.droppables;
|
||||
for ( var i = 0; i < drop.length; i++ )
|
||||
if ( drop[i] == this )
|
||||
drop.splice(i, 1);
|
||||
|
||||
this.element
|
||||
.removeClass("ui-droppable ui-droppable-disabled")
|
||||
.removeData("droppable")
|
||||
.unbind(".droppable");
|
||||
},
|
||||
enable: function() {
|
||||
this.element.removeClass("ui-droppable-disabled");
|
||||
this.options.disabled = false;
|
||||
},
|
||||
disable: function() {
|
||||
this.element.addClass("ui-droppable-disabled");
|
||||
this.options.disabled = true;
|
||||
},
|
||||
over: function(e) {
|
||||
|
||||
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.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
|
||||
$.ui.plugin.call(this, 'over', [e, this.ui(draggable)]);
|
||||
this.element.triggerHandler("dropover", [e, this.ui(draggable)], this.options.over);
|
||||
}
|
||||
|
||||
},
|
||||
out: function(e) {
|
||||
|
||||
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.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
|
||||
$.ui.plugin.call(this, 'out', [e, this.ui(draggable)]);
|
||||
this.element.triggerHandler("dropout", [e, this.ui(draggable)], this.options.out);
|
||||
}
|
||||
|
||||
},
|
||||
drop: function(e,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(".ui-droppable").not(".ui-draggable-dragging").each(function() {
|
||||
var inst = $.data(this, 'droppable');
|
||||
if(inst.options.greedy && $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)) {
|
||||
childrenIntersection = true; return false;
|
||||
}
|
||||
});
|
||||
if(childrenIntersection) return false;
|
||||
|
||||
if(this.options.accept.call(this.element,(draggable.currentItem || draggable.element))) {
|
||||
$.ui.plugin.call(this, 'drop', [e, this.ui(draggable)]);
|
||||
this.element.triggerHandler("drop", [e, this.ui(draggable)], this.options.drop);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!droppable.offset) return false;
|
||||
|
||||
var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
|
||||
y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
|
||||
var l = droppable.offset.left, r = l + droppable.proportions.width,
|
||||
t = droppable.offset.top, b = t + droppable.proportions.height;
|
||||
|
||||
switch (toleranceMode) {
|
||||
case 'fit':
|
||||
return (l < x1 && x2 < r
|
||||
&& t < y1 && y2 < b);
|
||||
break;
|
||||
case 'intersect':
|
||||
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 < ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) && ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) < r
|
||||
&& t < ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) && ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) < b);
|
||||
break;
|
||||
case 'touch':
|
||||
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;
|
||||
|
||||
},
|
||||
activate: function(e) {
|
||||
|
||||
var draggable = $.ui.ddmanager.current;
|
||||
$.ui.plugin.call(this, 'activate', [e, this.ui(draggable)]);
|
||||
if(draggable) this.element.triggerHandler("dropactivate", [e, this.ui(draggable)], this.options.activate);
|
||||
|
||||
},
|
||||
deactivate: function(e) {
|
||||
|
||||
var draggable = $.ui.ddmanager.current;
|
||||
$.ui.plugin.call(this, 'deactivate', [e, this.ui(draggable)]);
|
||||
if(draggable) this.element.triggerHandler("dropdeactivate", [e, this.ui(draggable)], this.options.deactivate);
|
||||
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$.extend($.ui.droppable, {
|
||||
defaults: {
|
||||
disabled: false,
|
||||
tolerance: 'intersect'
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.intersect = function(draggable, droppable, toleranceMode) {
|
||||
};
|
||||
|
||||
/*
|
||||
This manager tracks offsets of draggables and droppables
|
||||
*/
|
||||
$.ui.ddmanager = {
|
||||
current: null,
|
||||
droppables: [],
|
||||
prepareOffsets: function(t, e) {
|
||||
|
||||
if (!droppable.offset) return false;
|
||||
|
||||
var x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
|
||||
y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height;
|
||||
var l = droppable.offset.left, r = l + droppable.proportions.width,
|
||||
t = droppable.offset.top, b = t + droppable.proportions.height;
|
||||
|
||||
switch (toleranceMode) {
|
||||
case 'fit':
|
||||
return (l < x1 && x2 < r
|
||||
&& t < y1 && y2 < b);
|
||||
break;
|
||||
case 'intersect':
|
||||
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 < ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) && ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left) < r
|
||||
&& t < ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) && ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top) < b);
|
||||
break;
|
||||
case 'touch':
|
||||
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++) {
|
||||
|
||||
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" || type == "sortactivate") m[i].activate.call(m[i], e); //Activate the droppable if used directly from draggables
|
||||
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" || type == "sortactivate") 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) return;
|
||||
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);
|
||||
}
|
||||
|
||||
},
|
||||
drop: function(draggable, 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() {
|
||||
|
||||
var dropped = false;
|
||||
$.each($.ui.ddmanager.droppables, function() {
|
||||
|
||||
if(!this.options) return;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
});
|
||||
return dropped;
|
||||
}
|
||||
|
||||
},
|
||||
drag: function(draggable, e) {
|
||||
// we just moved into a greedy child
|
||||
if (parentInstance && c == 'isover') {
|
||||
parentInstance['isover'] = 0;
|
||||
parentInstance['isout'] = 1;
|
||||
parentInstance.out.call(parentInstance, 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);
|
||||
this[c] = 1; this[c == 'isout' ? 'isover' : 'isout'] = 0;
|
||||
this[c == "isover" ? "over" : "out"].call(this, 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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// we just moved out of a greedy child
|
||||
if (parentInstance && c == 'isout') {
|
||||
parentInstance['isout'] = 0;
|
||||
parentInstance['isover'] = 1;
|
||||
parentInstance.over.call(parentInstance, e);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* 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", "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", "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", "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);
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,261 +14,261 @@
|
||||
*/
|
||||
;(function($) {
|
||||
|
||||
$.widget("ui.selectable", $.extend($.ui.mouse, {
|
||||
init: 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.filter, self.element[0]);
|
||||
selectees.each(function() {
|
||||
var $this = $(this);
|
||||
var pos = $this.offset();
|
||||
$.data(this, "selectable-item", {
|
||||
element: this,
|
||||
$element: $this,
|
||||
left: pos.left,
|
||||
top: pos.top,
|
||||
right: pos.left + $this.width(),
|
||||
bottom: pos.top + $this.height(),
|
||||
startselected: false,
|
||||
selected: $this.hasClass('ui-selected'),
|
||||
selecting: $this.hasClass('ui-selecting'),
|
||||
unselecting: $this.hasClass('ui-unselecting')
|
||||
});
|
||||
$.widget("ui.selectable", $.extend($.ui.mouse, {
|
||||
init: 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.filter, self.element[0]);
|
||||
selectees.each(function() {
|
||||
var $this = $(this);
|
||||
var pos = $this.offset();
|
||||
$.data(this, "selectable-item", {
|
||||
element: this,
|
||||
$element: $this,
|
||||
left: pos.left,
|
||||
top: pos.top,
|
||||
right: pos.left + $this.width(),
|
||||
bottom: pos.top + $this.height(),
|
||||
startselected: false,
|
||||
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 = $(document.createElement('div')).css({border:'1px dotted black'});
|
||||
},
|
||||
toggle: function() {
|
||||
if(this.options.disabled){
|
||||
this.enable();
|
||||
} else {
|
||||
this.disable();
|
||||
}
|
||||
},
|
||||
destroy: function() {
|
||||
this.element
|
||||
.removeClass("ui-selectable ui-selectable-disabled")
|
||||
.removeData("selectable")
|
||||
.unbind(".selectable");
|
||||
this.mouseDestroy();
|
||||
},
|
||||
enable: function() {
|
||||
this.element.removeClass("ui-selectable-disabled");
|
||||
this.options.disabled = false;
|
||||
},
|
||||
disable: function() {
|
||||
this.element.addClass("ui-selectable-disabled");
|
||||
this.options.disabled = true;
|
||||
},
|
||||
mouseStart: function(e) {
|
||||
var self = this;
|
||||
|
||||
this.opos = [e.pageX, e.pageY];
|
||||
|
||||
if (this.options.disabled)
|
||||
return;
|
||||
|
||||
var options = this.options;
|
||||
|
||||
this.selectees = $(options.filter, this.element[0]);
|
||||
|
||||
// selectable START callback
|
||||
this.element.triggerHandler("selectablestart", [e, {
|
||||
"selectable": this.element[0],
|
||||
"options": options
|
||||
}], options.start);
|
||||
|
||||
$('body').append(this.helper);
|
||||
// position helper (lasso)
|
||||
this.helper.css({
|
||||
"z-index": 100,
|
||||
"position": "absolute",
|
||||
"left": e.clientX,
|
||||
"top": e.clientY,
|
||||
"width": 0,
|
||||
"height": 0
|
||||
});
|
||||
};
|
||||
this.refresh();
|
||||
|
||||
if (options.autoRefresh) {
|
||||
this.refresh();
|
||||
this.selectees = selectees.addClass("ui-selectee");
|
||||
|
||||
this.mouseInit();
|
||||
|
||||
this.helper = $(document.createElement('div')).css({border:'1px dotted black'});
|
||||
},
|
||||
toggle: function() {
|
||||
if(this.options.disabled){
|
||||
this.enable();
|
||||
} else {
|
||||
this.disable();
|
||||
}
|
||||
},
|
||||
destroy: function() {
|
||||
this.element
|
||||
.removeClass("ui-selectable ui-selectable-disabled")
|
||||
.removeData("selectable")
|
||||
.unbind(".selectable");
|
||||
this.mouseDestroy();
|
||||
},
|
||||
enable: function() {
|
||||
this.element.removeClass("ui-selectable-disabled");
|
||||
this.options.disabled = false;
|
||||
},
|
||||
disable: function() {
|
||||
this.element.addClass("ui-selectable-disabled");
|
||||
this.options.disabled = true;
|
||||
},
|
||||
mouseStart: function(e) {
|
||||
var self = this;
|
||||
|
||||
this.opos = [e.pageX, e.pageY];
|
||||
|
||||
if (this.options.disabled)
|
||||
return;
|
||||
|
||||
var options = this.options;
|
||||
|
||||
this.selectees = $(options.filter, this.element[0]);
|
||||
|
||||
// selectable START callback
|
||||
this.element.triggerHandler("selectablestart", [e, {
|
||||
"selectable": this.element[0],
|
||||
"options": options
|
||||
}], options.start);
|
||||
|
||||
$('body').append(this.helper);
|
||||
// position helper (lasso)
|
||||
this.helper.css({
|
||||
"z-index": 100,
|
||||
"position": "absolute",
|
||||
"left": e.clientX,
|
||||
"top": e.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 (!e.ctrlKey) {
|
||||
selectee.$element.removeClass('ui-selected');
|
||||
selectee.selected = false;
|
||||
selectee.$element.addClass('ui-unselecting');
|
||||
selectee.unselecting = true;
|
||||
// selectable UNSELECTING callback
|
||||
self.element.triggerHandler("selectableunselecting", [e, {
|
||||
selectable: self.element[0],
|
||||
unselecting: selectee.element,
|
||||
options: options
|
||||
}], options.unselecting);
|
||||
}
|
||||
});
|
||||
|
||||
var isSelectee = false;
|
||||
$(e.target).parents().andSelf().each(function() {
|
||||
if($.data(this, "selectable-item")) isSelectee = true;
|
||||
});
|
||||
return this.options.keyboard ? !isSelectee : true;
|
||||
},
|
||||
mouseDrag: function(e) {
|
||||
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 = e.pageX, y2 = e.pageY;
|
||||
if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
|
||||
if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
|
||||
this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-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);
|
||||
}
|
||||
|
||||
this.selectees.filter('.ui-selected').each(function() {
|
||||
var selectee = $.data(this, "selectable-item");
|
||||
selectee.startselected = true;
|
||||
if (!e.ctrlKey) {
|
||||
if (hit) {
|
||||
// SELECT
|
||||
if (selectee.selected) {
|
||||
selectee.$element.removeClass('ui-selected');
|
||||
selectee.selected = false;
|
||||
selectee.$element.addClass('ui-unselecting');
|
||||
selectee.unselecting = true;
|
||||
// selectable UNSELECTING callback
|
||||
self.element.triggerHandler("selectableunselecting", [e, {
|
||||
}
|
||||
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.element.triggerHandler("selectableselecting", [e, {
|
||||
selectable: self.element[0],
|
||||
unselecting: selectee.element,
|
||||
selecting: selectee.element,
|
||||
options: options
|
||||
}], options.unselecting);
|
||||
}], options.selecting);
|
||||
}
|
||||
});
|
||||
|
||||
var isSelectee = false;
|
||||
$(e.target).parents().andSelf().each(function() {
|
||||
if($.data(this, "selectable-item")) isSelectee = true;
|
||||
});
|
||||
return this.options.keyboard ? !isSelectee : true;
|
||||
},
|
||||
mouseDrag: function(e) {
|
||||
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 = e.pageX, y2 = e.pageY;
|
||||
if (x1 > x2) { var tmp = x2; x2 = x1; x1 = tmp; }
|
||||
if (y1 > y2) { var tmp = y2; y2 = y1; y1 = tmp; }
|
||||
this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-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.element.triggerHandler("selectableselecting", [e, {
|
||||
selectable: self.element[0],
|
||||
selecting: selectee.element,
|
||||
options: options
|
||||
}], options.selecting);
|
||||
}
|
||||
} else {
|
||||
// UNSELECT
|
||||
if (selectee.selecting) {
|
||||
if (e.ctrlKey && 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.element.triggerHandler("selectableunselecting", [e, {
|
||||
selectable: self.element[0],
|
||||
unselecting: selectee.element,
|
||||
options: options
|
||||
}], options.unselecting);
|
||||
}
|
||||
}
|
||||
if (selectee.selected) {
|
||||
if (!e.ctrlKey && !selectee.startselected) {
|
||||
selectee.$element.removeClass('ui-selected');
|
||||
selectee.selected = false;
|
||||
|
||||
} else {
|
||||
// UNSELECT
|
||||
if (selectee.selecting) {
|
||||
if (e.ctrlKey && 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.element.triggerHandler("selectableunselecting", [e, {
|
||||
selectable: self.element[0],
|
||||
unselecting: selectee.element,
|
||||
options: options
|
||||
}], options.unselecting);
|
||||
}
|
||||
// selectable UNSELECTING callback
|
||||
self.element.triggerHandler("selectableunselecting", [e, {
|
||||
selectable: self.element[0],
|
||||
unselecting: selectee.element,
|
||||
options: options
|
||||
}], options.unselecting);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
mouseStop: function(e) {
|
||||
var self = this;
|
||||
|
||||
this.dragged = false;
|
||||
|
||||
var options = this.options;
|
||||
if (selectee.selected) {
|
||||
if (!e.ctrlKey && !selectee.startselected) {
|
||||
selectee.$element.removeClass('ui-selected');
|
||||
selectee.selected = false;
|
||||
|
||||
$('.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.element.triggerHandler("selectableunselected", [e, {
|
||||
selectable: self.element[0],
|
||||
unselected: selectee.element,
|
||||
options: options
|
||||
}], options.unselected);
|
||||
});
|
||||
$('.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.element.triggerHandler("selectableselected", [e, {
|
||||
selectable: self.element[0],
|
||||
selected: selectee.element,
|
||||
options: options
|
||||
}], options.selected);
|
||||
});
|
||||
this.element.triggerHandler("selectablestop", [e, {
|
||||
selectee.$element.addClass('ui-unselecting');
|
||||
selectee.unselecting = true;
|
||||
// selectable UNSELECTING callback
|
||||
self.element.triggerHandler("selectableunselecting", [e, {
|
||||
selectable: self.element[0],
|
||||
unselecting: selectee.element,
|
||||
options: options
|
||||
}], options.unselecting);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
mouseStop: function(e) {
|
||||
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.element.triggerHandler("selectableunselected", [e, {
|
||||
selectable: self.element[0],
|
||||
options: this.options
|
||||
}], this.options.stop);
|
||||
|
||||
this.helper.remove();
|
||||
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
|
||||
$.extend($.ui.selectable, {
|
||||
defaults: {
|
||||
distance: 0,
|
||||
delay: 0,
|
||||
cancel: ":input,button",
|
||||
appendTo: 'body',
|
||||
autoRefresh: true,
|
||||
filter: '*',
|
||||
tolerance: 'touch'
|
||||
}
|
||||
});
|
||||
|
||||
unselected: selectee.element,
|
||||
options: options
|
||||
}], options.unselected);
|
||||
});
|
||||
$('.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.element.triggerHandler("selectableselected", [e, {
|
||||
selectable: self.element[0],
|
||||
selected: selectee.element,
|
||||
options: options
|
||||
}], options.selected);
|
||||
});
|
||||
this.element.triggerHandler("selectablestop", [e, {
|
||||
selectable: self.element[0],
|
||||
options: this.options
|
||||
}], this.options.stop);
|
||||
|
||||
this.helper.remove();
|
||||
|
||||
return false;
|
||||
}
|
||||
}));
|
||||
|
||||
$.extend($.ui.selectable, {
|
||||
defaults: {
|
||||
distance: 0,
|
||||
delay: 0,
|
||||
cancel: ":input,button",
|
||||
appendTo: 'body',
|
||||
autoRefresh: true,
|
||||
filter: '*',
|
||||
tolerance: 'touch'
|
||||
}
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
|
||||
@@ -14,417 +14,417 @@
|
||||
*/
|
||||
;(function($) {
|
||||
|
||||
$.fn.unwrap = $.fn.unwrap || function(expr) {
|
||||
return this.each(function(){
|
||||
$(this).parents(expr).eq(0).after(this).remove();
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.unwrap = $.fn.unwrap || function(expr) {
|
||||
return this.each(function(){
|
||||
$(this).parents(expr).eq(0).after(this).remove();
|
||||
});
|
||||
};
|
||||
|
||||
$.widget("ui.slider", {
|
||||
plugins: {},
|
||||
ui: function(e) {
|
||||
return {
|
||||
instance: this,
|
||||
options: this.options,
|
||||
handle: this.currentHandle,
|
||||
value: this.options.axis != "both" || !this.options.axis ? Math.round(this.value(null,this.options.axis == "vertical" ? "y" : "x")) : {
|
||||
x: Math.round(this.value(null,"x")),
|
||||
y: Math.round(this.value(null,"y"))
|
||||
},
|
||||
range: this.getRange()
|
||||
};
|
||||
},
|
||||
propagate: function(n,e) {
|
||||
$.ui.plugin.call(this, n, [e, this.ui()]);
|
||||
this.element.triggerHandler(n == "slide" ? n : "slide"+n, [e, this.ui()], this.options[n]);
|
||||
},
|
||||
destroy: function() {
|
||||
this.element
|
||||
.removeClass("ui-slider ui-slider-disabled")
|
||||
.removeData("slider")
|
||||
.unbind(".slider");
|
||||
this.handle
|
||||
.unwrap("a")
|
||||
.mouse("destroy");
|
||||
this.generated && this.generated.remove();
|
||||
},
|
||||
enable: function() {
|
||||
this.element.removeClass("ui-slider-disabled");
|
||||
this.disabled = false;
|
||||
},
|
||||
disable: function() {
|
||||
this.element.addClass("ui-slider-disabled");
|
||||
this.disabled = true;
|
||||
},
|
||||
setData: function(key, value) {
|
||||
this.options[key] = value;
|
||||
if (/min|max|steps/.test(key)) {
|
||||
this.initBoundaries();
|
||||
}
|
||||
},
|
||||
|
||||
init: function() {
|
||||
|
||||
var self = this;
|
||||
this.element.addClass("ui-slider");
|
||||
$.widget("ui.slider", {
|
||||
plugins: {},
|
||||
ui: function(e) {
|
||||
return {
|
||||
instance: this,
|
||||
options: this.options,
|
||||
handle: this.currentHandle,
|
||||
value: this.options.axis != "both" || !this.options.axis ? Math.round(this.value(null,this.options.axis == "vertical" ? "y" : "x")) : {
|
||||
x: Math.round(this.value(null,"x")),
|
||||
y: Math.round(this.value(null,"y"))
|
||||
},
|
||||
range: this.getRange()
|
||||
};
|
||||
},
|
||||
propagate: function(n,e) {
|
||||
$.ui.plugin.call(this, n, [e, this.ui()]);
|
||||
this.element.triggerHandler(n == "slide" ? n : "slide"+n, [e, this.ui()], this.options[n]);
|
||||
},
|
||||
destroy: function() {
|
||||
this.element
|
||||
.removeClass("ui-slider ui-slider-disabled")
|
||||
.removeData("slider")
|
||||
.unbind(".slider");
|
||||
this.handle
|
||||
.unwrap("a")
|
||||
.mouse("destroy");
|
||||
this.generated && this.generated.remove();
|
||||
},
|
||||
enable: function() {
|
||||
this.element.removeClass("ui-slider-disabled");
|
||||
this.disabled = false;
|
||||
},
|
||||
disable: function() {
|
||||
this.element.addClass("ui-slider-disabled");
|
||||
this.disabled = true;
|
||||
},
|
||||
setData: function(key, value) {
|
||||
this.options[key] = value;
|
||||
if (/min|max|steps/.test(key)) {
|
||||
this.initBoundaries();
|
||||
|
||||
// Initialize mouse and key events for interaction
|
||||
this.handle = $(this.options.handle, this.element);
|
||||
if (!this.handle.length) {
|
||||
self.handle = self.generated = $(self.options.handles || [0]).map(function() {
|
||||
var handle = $("<div/>").addClass("ui-slider-handle").appendTo(self.element);
|
||||
if (this.id)
|
||||
handle.attr("id", this.id);
|
||||
return handle[0];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var handleclass = function(el) {
|
||||
this.element = $(el);
|
||||
this.element.data("mouse", this);
|
||||
this.options = self.options;
|
||||
|
||||
this.element.bind("mousedown", function() {
|
||||
if(self.currentHandle) this.blur(self.currentHandle);
|
||||
self.focus(this,1);
|
||||
});
|
||||
|
||||
this.mouseInit();
|
||||
};
|
||||
|
||||
$.extend(handleclass.prototype, $.ui.mouse, {
|
||||
mouseStart: function(e) { return self.start.call(self, e, this.element[0]); },
|
||||
mouseStop: function(e) { return self.stop.call(self, e, this.element[0]); },
|
||||
mouseDrag: function(e) { return self.drag.call(self, e, this.element[0]); },
|
||||
trigger: function(e) { this.mouseDown(e); }
|
||||
});
|
||||
|
||||
|
||||
$(this.handle)
|
||||
.each(function() {
|
||||
new handleclass(this);
|
||||
})
|
||||
.wrap('<a href="javascript:void(0)" style="cursor:default;"></a>')
|
||||
.parent()
|
||||
.bind('focus', function(e) { self.focus(this.firstChild); })
|
||||
.bind('blur', function(e) { self.blur(this.firstChild); })
|
||||
.bind('keydown', function(e) { if(!self.options.noKeyboard) self.keydown(e.keyCode, this.firstChild); })
|
||||
;
|
||||
|
||||
// Bind the click to the slider itself
|
||||
this.element.bind('mousedown.slider', function(e) {
|
||||
self.click.apply(self, [e]);
|
||||
self.currentHandle.data("mouse").trigger(e);
|
||||
self.firstValue = self.firstValue + 1; //This is for always triggering the change event
|
||||
});
|
||||
|
||||
// Move the first handle to the startValue
|
||||
$.each(this.options.handles || [], function(index, handle) {
|
||||
self.moveTo(handle.start, index, true);
|
||||
});
|
||||
if (!isNaN(this.options.startValue))
|
||||
this.moveTo(this.options.startValue, 0, true);
|
||||
|
||||
this.previousHandle = $(this.handle[0]); //set the previous handle to the first to allow clicking before selecting the handle
|
||||
if(this.handle.length == 2 && this.options.range) this.createRange();
|
||||
},
|
||||
initBoundaries: function() {
|
||||
|
||||
var element = this.element[0], o = this.options;
|
||||
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
|
||||
|
||||
$.extend(o, {
|
||||
axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'),
|
||||
max: !isNaN(parseInt(o.max,10)) ? { x: parseInt(o.max, 10), y: parseInt(o.max, 10) } : ({ x: o.max && o.max.x || 100, y: o.max && o.max.y || 100 }),
|
||||
min: !isNaN(parseInt(o.min,10)) ? { x: parseInt(o.min, 10), y: parseInt(o.min, 10) } : ({ x: o.min && o.min.x || 0, y: o.min && o.min.y || 0 })
|
||||
});
|
||||
//Prepare the real maxValue
|
||||
o.realMax = {
|
||||
x: o.max.x - o.min.x,
|
||||
y: o.max.y - o.min.y
|
||||
};
|
||||
//Calculate stepping based on steps
|
||||
o.stepping = {
|
||||
x: o.stepping && o.stepping.x || parseInt(o.stepping, 10) || (o.steps ? o.realMax.x/(o.steps.x || parseInt(o.steps, 10) || o.realMax.x) : 0),
|
||||
y: o.stepping && o.stepping.y || parseInt(o.stepping, 10) || (o.steps ? o.realMax.y/(o.steps.y || parseInt(o.steps, 10) || o.realMax.y) : 0)
|
||||
};
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
init: function() {
|
||||
|
||||
keydown: function(keyCode, handle) {
|
||||
if(/(37|38|39|40)/.test(keyCode)) {
|
||||
this.moveTo({
|
||||
x: /(37|39)/.test(keyCode) ? (keyCode == 37 ? '-' : '+') + '=' + this.oneStep("x") : 0,
|
||||
y: /(38|40)/.test(keyCode) ? (keyCode == 38 ? '-' : '+') + '=' + this.oneStep("y") : 0
|
||||
}, handle);
|
||||
}
|
||||
},
|
||||
focus: function(handle,hard) {
|
||||
this.currentHandle = $(handle).addClass('ui-slider-handle-active');
|
||||
if (hard)
|
||||
this.currentHandle.parent()[0].focus();
|
||||
},
|
||||
blur: function(handle) {
|
||||
$(handle).removeClass('ui-slider-handle-active');
|
||||
if(this.currentHandle && this.currentHandle[0] == handle) { this.previousHandle = this.currentHandle; this.currentHandle = null; };
|
||||
},
|
||||
click: function(e) {
|
||||
// This method is only used if:
|
||||
// - The user didn't click a handle
|
||||
// - The Slider is not disabled
|
||||
// - There is a current, or previous selected handle (otherwise we wouldn't know which one to move)
|
||||
|
||||
var pointer = [e.pageX,e.pageY];
|
||||
|
||||
var clickedHandle = false;
|
||||
this.handle.each(function() {
|
||||
if(this == e.target)
|
||||
clickedHandle = true;
|
||||
});
|
||||
if (clickedHandle || this.disabled || !(this.currentHandle || this.previousHandle))
|
||||
return;
|
||||
|
||||
// If a previous handle was focussed, focus it again
|
||||
if (!this.currentHandle && this.previousHandle)
|
||||
this.focus(this.previousHandle, true);
|
||||
|
||||
// propagate only for distance > 0, otherwise propagation is done my drag
|
||||
this.offset = this.element.offset();
|
||||
|
||||
this.moveTo({
|
||||
y: this.convertValue(e.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"),
|
||||
x: this.convertValue(e.pageX - this.offset.left - this.currentHandle[0].offsetWidth/2, "x")
|
||||
}, null, !this.options.distance);
|
||||
},
|
||||
var self = this;
|
||||
this.element.addClass("ui-slider");
|
||||
this.initBoundaries();
|
||||
|
||||
// Initialize mouse and key events for interaction
|
||||
this.handle = $(this.options.handle, this.element);
|
||||
if (!this.handle.length) {
|
||||
self.handle = self.generated = $(self.options.handles || [0]).map(function() {
|
||||
var handle = $("<div/>").addClass("ui-slider-handle").appendTo(self.element);
|
||||
if (this.id)
|
||||
handle.attr("id", this.id);
|
||||
return handle[0];
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var handleclass = function(el) {
|
||||
this.element = $(el);
|
||||
this.element.data("mouse", this);
|
||||
this.options = self.options;
|
||||
|
||||
this.element.bind("mousedown", function() {
|
||||
if(self.currentHandle) this.blur(self.currentHandle);
|
||||
self.focus(this,1);
|
||||
});
|
||||
|
||||
this.mouseInit();
|
||||
};
|
||||
|
||||
$.extend(handleclass.prototype, $.ui.mouse, {
|
||||
mouseStart: function(e) { return self.start.call(self, e, this.element[0]); },
|
||||
mouseStop: function(e) { return self.stop.call(self, e, this.element[0]); },
|
||||
mouseDrag: function(e) { return self.drag.call(self, e, this.element[0]); },
|
||||
trigger: function(e) { this.mouseDown(e); }
|
||||
});
|
||||
|
||||
|
||||
$(this.handle)
|
||||
.each(function() {
|
||||
new handleclass(this);
|
||||
})
|
||||
.wrap('<a href="javascript:void(0)" style="cursor:default;"></a>')
|
||||
.parent()
|
||||
.bind('focus', function(e) { self.focus(this.firstChild); })
|
||||
.bind('blur', function(e) { self.blur(this.firstChild); })
|
||||
.bind('keydown', function(e) { if(!self.options.noKeyboard) self.keydown(e.keyCode, this.firstChild); })
|
||||
;
|
||||
|
||||
// Bind the click to the slider itself
|
||||
this.element.bind('mousedown.slider', function(e) {
|
||||
self.click.apply(self, [e]);
|
||||
self.currentHandle.data("mouse").trigger(e);
|
||||
self.firstValue = self.firstValue + 1; //This is for always triggering the change event
|
||||
});
|
||||
|
||||
// Move the first handle to the startValue
|
||||
$.each(this.options.handles || [], function(index, handle) {
|
||||
self.moveTo(handle.start, index, true);
|
||||
});
|
||||
if (!isNaN(this.options.startValue))
|
||||
this.moveTo(this.options.startValue, 0, true);
|
||||
|
||||
this.previousHandle = $(this.handle[0]); //set the previous handle to the first to allow clicking before selecting the handle
|
||||
if(this.handle.length == 2 && this.options.range) this.createRange();
|
||||
},
|
||||
initBoundaries: function() {
|
||||
|
||||
var element = this.element[0], o = this.options;
|
||||
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
|
||||
|
||||
$.extend(o, {
|
||||
axis: o.axis || (element.offsetWidth < element.offsetHeight ? 'vertical' : 'horizontal'),
|
||||
max: !isNaN(parseInt(o.max,10)) ? { x: parseInt(o.max, 10), y: parseInt(o.max, 10) } : ({ x: o.max && o.max.x || 100, y: o.max && o.max.y || 100 }),
|
||||
min: !isNaN(parseInt(o.min,10)) ? { x: parseInt(o.min, 10), y: parseInt(o.min, 10) } : ({ x: o.min && o.min.x || 0, y: o.min && o.min.y || 0 })
|
||||
});
|
||||
//Prepare the real maxValue
|
||||
o.realMax = {
|
||||
x: o.max.x - o.min.x,
|
||||
y: o.max.y - o.min.y
|
||||
};
|
||||
//Calculate stepping based on steps
|
||||
o.stepping = {
|
||||
x: o.stepping && o.stepping.x || parseInt(o.stepping, 10) || (o.steps ? o.realMax.x/(o.steps.x || parseInt(o.steps, 10) || o.realMax.x) : 0),
|
||||
y: o.stepping && o.stepping.y || parseInt(o.stepping, 10) || (o.steps ? o.realMax.y/(o.steps.y || parseInt(o.steps, 10) || o.realMax.y) : 0)
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
createRange: function() {
|
||||
this.rangeElement = $('<div></div>')
|
||||
.addClass('ui-slider-range')
|
||||
.css({ position: 'absolute' })
|
||||
.appendTo(this.element);
|
||||
this.updateRange();
|
||||
},
|
||||
updateRange: function() {
|
||||
var prop = this.options.axis == "vertical" ? "top" : "left";
|
||||
var size = this.options.axis == "vertical" ? "height" : "width";
|
||||
this.rangeElement.css(prop, parseInt($(this.handle[0]).css(prop),10) + this.handleSize(0, this.options.axis == "vertical" ? "y" : "x")/2);
|
||||
this.rangeElement.css(size, parseInt($(this.handle[1]).css(prop),10) - parseInt($(this.handle[0]).css(prop),10));
|
||||
},
|
||||
getRange: function() {
|
||||
return this.rangeElement ? this.convertValue(parseInt(this.rangeElement.css(this.options.axis == "vertical" ? "height" : "width"),10), this.options.axis == "vertical" ? "y" : "x") : null;
|
||||
},
|
||||
|
||||
handleIndex: function() {
|
||||
return this.handle.index(this.currentHandle[0]);
|
||||
},
|
||||
value: function(handle, axis) {
|
||||
if(this.handle.length == 1) this.currentHandle = this.handle;
|
||||
if(!axis) axis = this.options.axis == "vertical" ? "y" : "x";
|
||||
|
||||
var curHandle = $(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle);
|
||||
|
||||
if(curHandle.data("mouse").sliderValue) {
|
||||
return parseInt(curHandle.data("mouse").sliderValue[axis],10);
|
||||
} else {
|
||||
return parseInt(((parseInt(curHandle.css(axis == "x" ? "left" : "top"),10) / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(handle,axis))) * this.options.realMax[axis]) + this.options.min[axis],10);
|
||||
}
|
||||
|
||||
},
|
||||
convertValue: function(value,axis) {
|
||||
return this.options.min[axis] + (value / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis))) * this.options.realMax[axis];
|
||||
},
|
||||
keydown: function(keyCode, handle) {
|
||||
if(/(37|38|39|40)/.test(keyCode)) {
|
||||
this.moveTo({
|
||||
x: /(37|39)/.test(keyCode) ? (keyCode == 37 ? '-' : '+') + '=' + this.oneStep("x") : 0,
|
||||
y: /(38|40)/.test(keyCode) ? (keyCode == 38 ? '-' : '+') + '=' + this.oneStep("y") : 0
|
||||
}, handle);
|
||||
}
|
||||
},
|
||||
focus: function(handle,hard) {
|
||||
this.currentHandle = $(handle).addClass('ui-slider-handle-active');
|
||||
if (hard)
|
||||
this.currentHandle.parent()[0].focus();
|
||||
},
|
||||
blur: function(handle) {
|
||||
$(handle).removeClass('ui-slider-handle-active');
|
||||
if(this.currentHandle && this.currentHandle[0] == handle) { this.previousHandle = this.currentHandle; this.currentHandle = null; };
|
||||
},
|
||||
click: function(e) {
|
||||
// This method is only used if:
|
||||
// - The user didn't click a handle
|
||||
// - The Slider is not disabled
|
||||
// - There is a current, or previous selected handle (otherwise we wouldn't know which one to move)
|
||||
|
||||
translateValue: function(value,axis) {
|
||||
return ((value - this.options.min[axis]) / this.options.realMax[axis]) * (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis));
|
||||
},
|
||||
translateRange: function(value,axis) {
|
||||
if (this.rangeElement) {
|
||||
if (this.currentHandle[0] == this.handle[0] && value >= this.translateValue(this.value(1),axis))
|
||||
value = this.translateValue(this.value(1,axis) - this.oneStep(axis), axis);
|
||||
if (this.currentHandle[0] == this.handle[1] && value <= this.translateValue(this.value(0),axis))
|
||||
value = this.translateValue(this.value(0,axis) + this.oneStep(axis), axis);
|
||||
}
|
||||
if (this.options.handles) {
|
||||
var handle = this.options.handles[this.handleIndex()];
|
||||
if (value < this.translateValue(handle.min,axis)) {
|
||||
value = this.translateValue(handle.min,axis);
|
||||
} else if (value > this.translateValue(handle.max,axis)) {
|
||||
value = this.translateValue(handle.max,axis);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
},
|
||||
translateLimits: function(value,axis) {
|
||||
if (value >= this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis))
|
||||
value = this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis);
|
||||
if (value <= 0)
|
||||
value = 0;
|
||||
return value;
|
||||
},
|
||||
handleSize: function(handle,axis) {
|
||||
return $(handle != undefined && handle !== null ? this.handle[handle] : this.currentHandle)[0]["offset"+(axis == "x" ? "Width" : "Height")];
|
||||
},
|
||||
oneStep: function(axis) {
|
||||
return this.options.stepping[axis] || 1;
|
||||
},
|
||||
|
||||
|
||||
start: function(e, handle) {
|
||||
var pointer = [e.pageX,e.pageY];
|
||||
|
||||
var o = this.options;
|
||||
if(this.disabled) return false;
|
||||
var clickedHandle = false;
|
||||
this.handle.each(function() {
|
||||
if(this == e.target)
|
||||
clickedHandle = true;
|
||||
});
|
||||
if (clickedHandle || this.disabled || !(this.currentHandle || this.previousHandle))
|
||||
return;
|
||||
|
||||
// Prepare the outer size
|
||||
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
|
||||
// If a previous handle was focussed, focus it again
|
||||
if (!this.currentHandle && this.previousHandle)
|
||||
this.focus(this.previousHandle, true);
|
||||
|
||||
// This is a especially ugly fix for strange blur events happening on mousemove events
|
||||
if (!this.currentHandle)
|
||||
this.focus(this.previousHandle, true);
|
||||
// propagate only for distance > 0, otherwise propagation is done my drag
|
||||
this.offset = this.element.offset();
|
||||
|
||||
this.offset = this.element.offset();
|
||||
|
||||
this.handleOffset = this.currentHandle.offset();
|
||||
this.clickOffset = { top: e.pageY - this.handleOffset.top, left: e.pageX - this.handleOffset.left };
|
||||
|
||||
this.firstValue = this.value();
|
||||
|
||||
this.propagate('start', e);
|
||||
return true;
|
||||
|
||||
},
|
||||
stop: function(e) {
|
||||
this.propagate('stop', e);
|
||||
if (this.firstValue != this.value())
|
||||
this.propagate('change', e);
|
||||
// This is a especially ugly fix for strange blur events happening on mousemove events
|
||||
this.focus(this.currentHandle, true);
|
||||
return false;
|
||||
},
|
||||
drag: function(e, handle) {
|
||||
this.moveTo({
|
||||
y: this.convertValue(e.pageY - this.offset.top - this.currentHandle[0].offsetHeight/2, "y"),
|
||||
x: this.convertValue(e.pageX - this.offset.left - this.currentHandle[0].offsetWidth/2, "x")
|
||||
}, null, !this.options.distance);
|
||||
},
|
||||
|
||||
|
||||
var o = this.options;
|
||||
var position = { top: e.pageY - this.offset.top - this.clickOffset.top, left: e.pageX - this.offset.left - this.clickOffset.left};
|
||||
if(!this.currentHandle) this.focus(this.previousHandle, true); //This is a especially ugly fix for strange blur events happening on mousemove events
|
||||
|
||||
position.left = this.translateLimits(position.left, "x");
|
||||
position.top = this.translateLimits(position.top, "y");
|
||||
|
||||
if (o.stepping.x) {
|
||||
var value = this.convertValue(position.left, "x");
|
||||
value = Math.round(value / o.stepping.x) * o.stepping.x;
|
||||
position.left = this.translateValue(value, "x");
|
||||
}
|
||||
if (o.stepping.y) {
|
||||
var value = this.convertValue(position.top, "y");
|
||||
value = Math.round(value / o.stepping.y) * o.stepping.y;
|
||||
position.top = this.translateValue(value, "y");
|
||||
}
|
||||
|
||||
position.left = this.translateRange(position.left, "x");
|
||||
position.top = this.translateRange(position.top, "y");
|
||||
createRange: function() {
|
||||
this.rangeElement = $('<div></div>')
|
||||
.addClass('ui-slider-range')
|
||||
.css({ position: 'absolute' })
|
||||
.appendTo(this.element);
|
||||
this.updateRange();
|
||||
},
|
||||
updateRange: function() {
|
||||
var prop = this.options.axis == "vertical" ? "top" : "left";
|
||||
var size = this.options.axis == "vertical" ? "height" : "width";
|
||||
this.rangeElement.css(prop, parseInt($(this.handle[0]).css(prop),10) + this.handleSize(0, this.options.axis == "vertical" ? "y" : "x")/2);
|
||||
this.rangeElement.css(size, parseInt($(this.handle[1]).css(prop),10) - parseInt($(this.handle[0]).css(prop),10));
|
||||
},
|
||||
getRange: function() {
|
||||
return this.rangeElement ? this.convertValue(parseInt(this.rangeElement.css(this.options.axis == "vertical" ? "height" : "width"),10), this.options.axis == "vertical" ? "y" : "x") : null;
|
||||
},
|
||||
|
||||
if(o.axis != "vertical") this.currentHandle.css({ left: position.left });
|
||||
if(o.axis != "horizontal") this.currentHandle.css({ top: position.top });
|
||||
|
||||
//Store the slider's value
|
||||
this.currentHandle.data("mouse").sliderValue = {
|
||||
x: Math.round(this.convertValue(position.left, "x")) || 0,
|
||||
y: Math.round(this.convertValue(position.top, "y")) || 0
|
||||
};
|
||||
|
||||
if (this.rangeElement)
|
||||
this.updateRange();
|
||||
this.propagate('slide', e);
|
||||
return false;
|
||||
},
|
||||
handleIndex: function() {
|
||||
return this.handle.index(this.currentHandle[0]);
|
||||
},
|
||||
value: function(handle, axis) {
|
||||
if(this.handle.length == 1) this.currentHandle = this.handle;
|
||||
if(!axis) axis = this.options.axis == "vertical" ? "y" : "x";
|
||||
|
||||
var curHandle = $(handle != undefined && handle !== null ? this.handle[handle] || handle : this.currentHandle);
|
||||
|
||||
moveTo: function(value, handle, noPropagation) {
|
||||
if(curHandle.data("mouse").sliderValue) {
|
||||
return parseInt(curHandle.data("mouse").sliderValue[axis],10);
|
||||
} else {
|
||||
return parseInt(((parseInt(curHandle.css(axis == "x" ? "left" : "top"),10) / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(handle,axis))) * this.options.realMax[axis]) + this.options.min[axis],10);
|
||||
}
|
||||
|
||||
var o = this.options;
|
||||
|
||||
// Prepare the outer size
|
||||
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
|
||||
|
||||
//If no handle has been passed, no current handle is available and we have multiple handles, return false
|
||||
if (handle == undefined && !this.currentHandle && this.handle.length != 1)
|
||||
return false;
|
||||
|
||||
//If only one handle is available, use it
|
||||
if (handle == undefined && !this.currentHandle)
|
||||
handle = 0;
|
||||
|
||||
if (handle != undefined)
|
||||
this.currentHandle = this.previousHandle = $(this.handle[handle] || handle);
|
||||
|
||||
|
||||
if(value.x !== undefined && value.y !== undefined) {
|
||||
var x = value.x, y = value.y;
|
||||
} else {
|
||||
var x = value, y = value;
|
||||
}
|
||||
|
||||
if(x !== undefined && x.constructor != Number) {
|
||||
var me = /^\-\=/.test(x), pe = /^\+\=/.test(x);
|
||||
if(me || pe) {
|
||||
x = this.value(null, "x") + parseInt(x.replace(me ? '=' : '+=', ''), 10);
|
||||
} else {
|
||||
x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10);
|
||||
}
|
||||
}
|
||||
|
||||
if(y !== undefined && y.constructor != Number) {
|
||||
var me = /^\-\=/.test(y), pe = /^\+\=/.test(y);
|
||||
if(me || pe) {
|
||||
y = this.value(null, "y") + parseInt(y.replace(me ? '=' : '+=', ''), 10);
|
||||
} else {
|
||||
y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10);
|
||||
}
|
||||
}
|
||||
|
||||
if(o.axis != "vertical" && x !== undefined) {
|
||||
if(o.stepping.x) x = Math.round(x / o.stepping.x) * o.stepping.x;
|
||||
x = this.translateValue(x, "x");
|
||||
x = this.translateLimits(x, "x");
|
||||
x = this.translateRange(x, "x");
|
||||
this.currentHandle.css({ left: x });
|
||||
}
|
||||
|
||||
if(o.axis != "horizontal" && y !== undefined) {
|
||||
if(o.stepping.y) y = Math.round(y / o.stepping.y) * o.stepping.y;
|
||||
y = this.translateValue(y, "y");
|
||||
y = this.translateLimits(y, "y");
|
||||
y = this.translateRange(y, "y");
|
||||
this.currentHandle.css({ top: y });
|
||||
}
|
||||
|
||||
if (this.rangeElement)
|
||||
this.updateRange();
|
||||
|
||||
//Store the slider's value
|
||||
this.currentHandle.data("mouse").sliderValue = {
|
||||
x: Math.round(this.convertValue(x, "x")) || 0,
|
||||
y: Math.round(this.convertValue(y, "y")) || 0
|
||||
};
|
||||
|
||||
if (!noPropagation) {
|
||||
this.propagate('start', null);
|
||||
this.propagate('stop', null);
|
||||
this.propagate('change', null);
|
||||
this.propagate("slide", null);
|
||||
},
|
||||
convertValue: function(value,axis) {
|
||||
return this.options.min[axis] + (value / (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis))) * this.options.realMax[axis];
|
||||
},
|
||||
|
||||
translateValue: function(value,axis) {
|
||||
return ((value - this.options.min[axis]) / this.options.realMax[axis]) * (this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis));
|
||||
},
|
||||
translateRange: function(value,axis) {
|
||||
if (this.rangeElement) {
|
||||
if (this.currentHandle[0] == this.handle[0] && value >= this.translateValue(this.value(1),axis))
|
||||
value = this.translateValue(this.value(1,axis) - this.oneStep(axis), axis);
|
||||
if (this.currentHandle[0] == this.handle[1] && value <= this.translateValue(this.value(0),axis))
|
||||
value = this.translateValue(this.value(0,axis) + this.oneStep(axis), axis);
|
||||
}
|
||||
if (this.options.handles) {
|
||||
var handle = this.options.handles[this.handleIndex()];
|
||||
if (value < this.translateValue(handle.min,axis)) {
|
||||
value = this.translateValue(handle.min,axis);
|
||||
} else if (value > this.translateValue(handle.max,axis)) {
|
||||
value = this.translateValue(handle.max,axis);
|
||||
}
|
||||
}
|
||||
});
|
||||
return value;
|
||||
},
|
||||
translateLimits: function(value,axis) {
|
||||
if (value >= this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis))
|
||||
value = this.actualSize[axis == "x" ? "width" : "height"] - this.handleSize(null,axis);
|
||||
if (value <= 0)
|
||||
value = 0;
|
||||
return value;
|
||||
},
|
||||
handleSize: function(handle,axis) {
|
||||
return $(handle != undefined && handle !== null ? this.handle[handle] : this.currentHandle)[0]["offset"+(axis == "x" ? "Width" : "Height")];
|
||||
},
|
||||
oneStep: function(axis) {
|
||||
return this.options.stepping[axis] || 1;
|
||||
},
|
||||
|
||||
$.ui.slider.getter = "value";
|
||||
|
||||
start: function(e, handle) {
|
||||
|
||||
$.ui.slider.defaults = {
|
||||
handle: ".ui-slider-handle",
|
||||
distance: 1
|
||||
};
|
||||
var o = this.options;
|
||||
if(this.disabled) return false;
|
||||
|
||||
// Prepare the outer size
|
||||
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
|
||||
|
||||
// This is a especially ugly fix for strange blur events happening on mousemove events
|
||||
if (!this.currentHandle)
|
||||
this.focus(this.previousHandle, true);
|
||||
|
||||
this.offset = this.element.offset();
|
||||
|
||||
this.handleOffset = this.currentHandle.offset();
|
||||
this.clickOffset = { top: e.pageY - this.handleOffset.top, left: e.pageX - this.handleOffset.left };
|
||||
|
||||
this.firstValue = this.value();
|
||||
|
||||
this.propagate('start', e);
|
||||
return true;
|
||||
|
||||
},
|
||||
stop: function(e) {
|
||||
this.propagate('stop', e);
|
||||
if (this.firstValue != this.value())
|
||||
this.propagate('change', e);
|
||||
// This is a especially ugly fix for strange blur events happening on mousemove events
|
||||
this.focus(this.currentHandle, true);
|
||||
return false;
|
||||
},
|
||||
drag: function(e, handle) {
|
||||
|
||||
var o = this.options;
|
||||
var position = { top: e.pageY - this.offset.top - this.clickOffset.top, left: e.pageX - this.offset.left - this.clickOffset.left};
|
||||
if(!this.currentHandle) this.focus(this.previousHandle, true); //This is a especially ugly fix for strange blur events happening on mousemove events
|
||||
|
||||
position.left = this.translateLimits(position.left, "x");
|
||||
position.top = this.translateLimits(position.top, "y");
|
||||
|
||||
if (o.stepping.x) {
|
||||
var value = this.convertValue(position.left, "x");
|
||||
value = Math.round(value / o.stepping.x) * o.stepping.x;
|
||||
position.left = this.translateValue(value, "x");
|
||||
}
|
||||
if (o.stepping.y) {
|
||||
var value = this.convertValue(position.top, "y");
|
||||
value = Math.round(value / o.stepping.y) * o.stepping.y;
|
||||
position.top = this.translateValue(value, "y");
|
||||
}
|
||||
|
||||
position.left = this.translateRange(position.left, "x");
|
||||
position.top = this.translateRange(position.top, "y");
|
||||
|
||||
if(o.axis != "vertical") this.currentHandle.css({ left: position.left });
|
||||
if(o.axis != "horizontal") this.currentHandle.css({ top: position.top });
|
||||
|
||||
//Store the slider's value
|
||||
this.currentHandle.data("mouse").sliderValue = {
|
||||
x: Math.round(this.convertValue(position.left, "x")) || 0,
|
||||
y: Math.round(this.convertValue(position.top, "y")) || 0
|
||||
};
|
||||
|
||||
if (this.rangeElement)
|
||||
this.updateRange();
|
||||
this.propagate('slide', e);
|
||||
return false;
|
||||
},
|
||||
|
||||
moveTo: function(value, handle, noPropagation) {
|
||||
|
||||
var o = this.options;
|
||||
|
||||
// Prepare the outer size
|
||||
this.actualSize = { width: this.element.outerWidth() , height: this.element.outerHeight() };
|
||||
|
||||
//If no handle has been passed, no current handle is available and we have multiple handles, return false
|
||||
if (handle == undefined && !this.currentHandle && this.handle.length != 1)
|
||||
return false;
|
||||
|
||||
//If only one handle is available, use it
|
||||
if (handle == undefined && !this.currentHandle)
|
||||
handle = 0;
|
||||
|
||||
if (handle != undefined)
|
||||
this.currentHandle = this.previousHandle = $(this.handle[handle] || handle);
|
||||
|
||||
|
||||
if(value.x !== undefined && value.y !== undefined) {
|
||||
var x = value.x, y = value.y;
|
||||
} else {
|
||||
var x = value, y = value;
|
||||
}
|
||||
|
||||
if(x !== undefined && x.constructor != Number) {
|
||||
var me = /^\-\=/.test(x), pe = /^\+\=/.test(x);
|
||||
if(me || pe) {
|
||||
x = this.value(null, "x") + parseInt(x.replace(me ? '=' : '+=', ''), 10);
|
||||
} else {
|
||||
x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10);
|
||||
}
|
||||
}
|
||||
|
||||
if(y !== undefined && y.constructor != Number) {
|
||||
var me = /^\-\=/.test(y), pe = /^\+\=/.test(y);
|
||||
if(me || pe) {
|
||||
y = this.value(null, "y") + parseInt(y.replace(me ? '=' : '+=', ''), 10);
|
||||
} else {
|
||||
y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10);
|
||||
}
|
||||
}
|
||||
|
||||
if(o.axis != "vertical" && x !== undefined) {
|
||||
if(o.stepping.x) x = Math.round(x / o.stepping.x) * o.stepping.x;
|
||||
x = this.translateValue(x, "x");
|
||||
x = this.translateLimits(x, "x");
|
||||
x = this.translateRange(x, "x");
|
||||
this.currentHandle.css({ left: x });
|
||||
}
|
||||
|
||||
if(o.axis != "horizontal" && y !== undefined) {
|
||||
if(o.stepping.y) y = Math.round(y / o.stepping.y) * o.stepping.y;
|
||||
y = this.translateValue(y, "y");
|
||||
y = this.translateLimits(y, "y");
|
||||
y = this.translateRange(y, "y");
|
||||
this.currentHandle.css({ top: y });
|
||||
}
|
||||
|
||||
if (this.rangeElement)
|
||||
this.updateRange();
|
||||
|
||||
//Store the slider's value
|
||||
this.currentHandle.data("mouse").sliderValue = {
|
||||
x: Math.round(this.convertValue(x, "x")) || 0,
|
||||
y: Math.round(this.convertValue(y, "y")) || 0
|
||||
};
|
||||
|
||||
if (!noPropagation) {
|
||||
this.propagate('start', null);
|
||||
this.propagate('stop', null);
|
||||
this.propagate('change', null);
|
||||
this.propagate("slide", null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.ui.slider.getter = "value";
|
||||
|
||||
$.ui.slider.defaults = {
|
||||
handle: ".ui-slider-handle",
|
||||
distance: 1
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1068
ui/source/ui.tabs.js
1068
ui/source/ui.tabs.js
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user